pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   // -*- Pike -*-   //   // Master Control Program for Pike.   //   // This file is part of Pike. For copyright information see COPYRIGHT.   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.284 2003/05/31 11:05:35 mast Exp $ + // $Id: master.pike.in,v 1.285 2003/05/31 12:47:29 mast Exp $      #pike __REAL_VERSION__      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "ยค/" != "\244/"   #error "master.pike.in is corrupted."   #endif      // --- Some configurable parameters
pike.git/lib/master.pike.in:2287:    if (_trim_file_name_cb) return _trim_file_name_cb(s);       /* getcwd() can fail, but since this is called from handle_error(),    * we don't want to fail, so we don't care about that.    */    catch {    string cwd=getcwd();    if (sizeof(cwd) && (cwd[-1] != '/')) {    cwd += "/";    } -  if(s[..sizeof(cwd)-1]==cwd) return s[sizeof(cwd)..]; +  if(has_prefix (s, cwd)) return s[sizeof(cwd)..];    };    return s;   }      function(string:string) set_trim_file_name_callback(function(string:string) s)   {    function(string:string) f=_trim_file_name_cb;    _trim_file_name_cb=s;    return f;   }
pike.git/lib/master.pike.in:2641:    break;    }    }    }       return ret;    }   }       - static string get_clean_program_path ( program p, string pref1, -  string suff1, string suff2 ) + string program_path_to_name ( string path, +  void|string module_prefix, void|string module_suffix, +  void|string object_suffix ) + //! Converts a module path on the form @expr{"Foo.pmod/Bar.pmod"@} or + //! @expr{"/path/to/pike/lib/modules/Foo.pmod/Bar.pmod"@} to a module + //! identifier on the form @expr{"Foo.Bar"@}. + //! + //! If @[module_prefix] or @[module_suffix] are given, they are + //! prepended and appended, respectively, to the returned string if + //! it's a module file (i.e. ends with @expr{".pmod"@} or + //! @expr{".so"@}). If @[object_suffix] is given, it's appended to the + //! returned string if it's an object file (i.e. ends with + //! @expr{".pike"@}).   {    array(string) sort_paths_by_length(array(string) paths)    {    sort(map(paths, sizeof), paths);    return reverse(paths);    }; -  string path = programs_reverse_lookup (p); -  if (path) { -  if (path == "/master") return "master"+suff2; +  +  if (path == "/master") return "master" + (object_suffix || ""); +     foreach(sort_paths_by_length(map(pike_module_path - ({""}),    lambda(string s) {    if (s[-1] == '/') return s;    return s+"/";    })),    string prefix) {    if (has_prefix(path, prefix)) {    path = path[sizeof(prefix)..];    break;    }    } -  +  + #if 0 +  // This seems broken. Why should the current directory or the +  // setting of SHORT_PIKE_ERRORS etc affect the module identifiers? +  // /mast    path = trim_file_name(path); -  + #endif +     string modname = replace(path, ".pmod/", ".");    if(search(modname, "/")<0) path=modname; -  +     if (has_suffix(path, ".module.pmod")) { -  return pref1+path[..sizeof(path)-13]+suff1; +  return (module_prefix || "") + path[..sizeof(path)-13] + (module_suffix || "");    }    if (has_suffix(path, ".pmod")) { -  return pref1+path[..sizeof(path)-6]+suff1; +  return (module_prefix || "") + path[..sizeof(path)-6] + (module_suffix || "");    }    if (has_suffix(path, ".so")) { -  return pref1+path[..sizeof(path)-4]+suff1; +  return (module_prefix || "") + path[..sizeof(path)-4] + (module_suffix || "");    }    if (has_suffix(path, ".pike")) { -  return path[..sizeof(path)-6]+suff2; +  return path[..sizeof(path)-6] + (object_suffix || "");    } -  return path + suff2; +  return path + (object_suffix || "");   } -  return 0; - } +          //! Describe the path to the module @[mod].   //!   //! @param mod   //! If @[mod] is a program, attempt to describe the path   //! to a clone of @[mod].   //!   //! @param ret_obj   //! If an instance of @[mod] is found, it will be returned
pike.git/lib/master.pike.in:2726:    if (mod) {    catch {    string res = sprintf("%O", mod);    if (res != "object" && res != "")    return (objectp (objects[parent_fun]) && programs["/master"] != parent_fun?    res+".":res+"->");    };    }    if (!object_program(parent_fun)) {    // We might be a top-level entity. -  string path = get_clean_program_path(parent_fun, "", ".", "()->"); -  if(path) return path; +  if (string path = programs_reverse_lookup (parent_fun)) +  return program_path_to_name(path, "", ".", "()->");    }    // Begin by describing our parent.    array(object) parent_obj = ({ 0 });    string res = describe_module(function_object(parent_fun)||    function_program(parent_fun)||    object_program(parent_fun),    parent_obj);    // werror("So far: %O parent_obj:%O\n", res, parent_obj);    object|program parent =    objectp (parent_obj[0]) ? parent_obj[0] : object_program(parent_fun);
pike.git/lib/master.pike.in:2812:    return 0;    }), o);    }    if (i >= 0) {    s = [string]indices(parent_obj)[i];    return describe_module(parent_obj) + s;    }    }    };    if(objectp (objects[parent_fun])) -  if(s=get_clean_program_path(parent_fun, "", "", "()")) +  if ((s = programs_reverse_lookup (parent_fun)) && +  (s=program_path_to_name(s, "", "", "()")))    return s;    /* Try identifying the program. */    if(( s=describe_program(parent_fun) ))    return s+"()";       return 0;   }      //!   string describe_program(program|function p)   {    string s;    if(!p) return 0;       if (p == object_program (_static_modules))    return "object_program(_static_modules)";       if(programp(p) && -  (s=get_clean_program_path([program]p, "object_program(", ")", ""))) +  (s = programs_reverse_lookup ([program] p)) && +  (s=program_path_to_name(s, "object_program(", ")", "")))    return s;       if(object|program tmp=(function_object(p) || function_program(p))) {    if(s = function_name(p))    {    return describe_module(tmp) + s;    }    }       if(s=_static_modules.Builtin()->program_defined(p))