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.363 2004/10/09 11:50:49 per Exp $ + // $Id: master.pike.in,v 1.364 2004/10/30 11:41:47 mast Exp $      #pike __REAL_VERSION__   //#pragma strict_types      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "ยค/" != "\244/"   #error "master.pike.in is corrupted."   #endif   
pike.git/lib/master.pike.in:110:   #define GET_RESOLV_MSG_DEPTH resolv_msg_depth   #define INC_RESOLV_MSG_DEPTH() (++resolv_msg_depth)   #define DEC_RESOLV_MSG_DEPTH() (--resolv_msg_depth)   #endif      void resolv_debug (string fmt, mixed... args)   {    string pad = " " * GET_RESOLV_MSG_DEPTH;    if (sizeof (args)) fmt = sprintf (fmt, @args);    if (fmt[-1] == '\n') -  fmt = pad + replace (fmt[..sizeof (fmt) - 2], "\n", "\n" + pad) + "\n"; +  fmt = pad + replace (fmt[..<1], "\n", "\n" + pad) + "\n";    else    fmt = pad + replace (fmt, "\n", "\n" + pad);    werror (fmt);   }      #else // !RESOLV_DEBUG   #define INC_RESOLV_MSG_DEPTH() 0   #define DEC_RESOLV_MSG_DEPTH() 0   #define resolv_debug(X...) do {} while (0)   #endif // !RESOLV_DEBUG      //! @appears error   //! Throws an error. A more readable version of the code   //! @expr{throw( ({ sprintf(f, @@args), backtrace() }) )@}.   void error(string f, mixed ... args) { -  array b = backtrace(); +     if (sizeof(args)) f = sprintf(f, @args); -  throw( ({ f, b[..sizeof(b)-2] }) ); +  throw( ({ f, backtrace()[..<1] }) );   }      // FIXME: Should the pikeroot-things be private?   #ifdef PIKE_FAKEROOT   object o;   string fakeroot(string s)   {    string tmp1=combine_path_with_cwd(s);   #ifdef PIKE_FAKEROOT_OMIT    foreach(PIKE_FAKEROOT_OMIT/PATH_SEPARATOR, string x)
pike.git/lib/master.pike.in:235:   //! This function divides a path into its components. This might seem like   //! it could be done by dividing the string on <tt>"/"</tt>, but that will   //! not work on some operating systems. To turn the components back into   //! a path again, use @[combine_path()].   //!   array(string) explode_path(string p)   {   #ifdef __amigaos__    int colon = search(reverse(p), ":");    if(colon >= 0) -  return ({ p[..sizeof(p)-colon-1] }) + explode_path(p[sizeof(p)-colon..]); +  return ({ p[..<colon] }) + explode_path(p[<colon+1..]);    array(string) r = p/"/"; -  return replace(r[..sizeof(r)-2], "", "/")+r[sizeof(r)-1..]; +  return replace(r[..<1], "", "/")+r[<0..];   #else    array(string) r = EXPLODE_PATH(p);    if(r[0] == "" && sizeof(p))    r[0] = "/";    return r;   #endif   }      //! @appears dirname   //! Returns all but the last segment of a path. Some example inputs and
pike.git/lib/master.pike.in:267:   //! </matrix>@}   //!   //! @seealso   //! @[basename()], @[explode_path()]   string dirname(string x)   {    if(x=="") return "";   #ifdef __amigaos__    array(string) tmp=x/":";    array(string) tmp2=tmp[-1]/"/"; -  tmp[-1]=tmp2[..sizeof(tmp2)-2]*"/"; +  tmp[-1]=tmp2[..<1]*"/";    if(sizeof(tmp2) >= 2 && tmp2[-2]=="") tmp[-1]+="/";    return tmp*":";   #else    array(string) tmp=EXPLODE_PATH(x);    if(x[0]=='/' && sizeof(tmp)<3) return "/"; -  return tmp[..sizeof(tmp)-2]*"/"; +  return tmp[..<1]*"/";   #endif   }      //! @appears basename   //! Returns the last segment of a path.   //!   //! @seealso   //! @[dirname()], @[explode_path()]   string basename(string x)   {
pike.git/lib/master.pike.in:675:    constant is_generic_error = 1;    constant is_compile_callback_error = 1;   }      static void compile_cb_error (string msg, mixed ... args)   // Use this to throw errors that should be converted to plain compile   // error messages, without backtraces being reported by   // compile_exception.   {    if (sizeof (args)) msg = sprintf (msg, @args); -  array bt = backtrace(); -  bt = bt[..sizeof (bt) - 2]; -  throw (CompileCallbackError (msg, bt)); +  throw (CompileCallbackError (msg, backtrace()[..<1]));   }      static void compile_cb_rethrow (object|array err)   // Use this to rethrow errors that should be converted to plain   // compile error messages, without backtraces being reported by   // compile_exception.   {    array bt;    if (array|object e = catch (bt = get_backtrace (err)))    handle_error (e);
pike.git/lib/master.pike.in:954:   {    string ext;    string nname;       // werror("low_cast_to_program(%O, %O, %O, %O)\n",    // pname, current_file, handler, mkobj);       if(sscanf(reverse(BASENAME(pname)),"%s.%s",ext, nname))    {    ext="."+reverse(ext); -  pname=pname[..sizeof(pname)-sizeof(ext)-1]; +  pname=pname[..<sizeof(ext)];    }    else {    ext="";    }       if(IS_ABSOLUTE_PATH(pname))    {    program|NoValue prog = programs[pname];    if (programp (prog)) return prog;    pname=combine_path("",pname);
pike.git/lib/master.pike.in:1210:   #else   #define FIX_CASE(X) (X)   #endif /* __NT__ */       static string base_from_filename(string fname)    {    string low_name = FIX_CASE(fname);    if (has_prefix(low_name, ".#")) return 0;    if (has_suffix(low_name, ".pike") ||    has_suffix(low_name, ".pmod")) { -  return fname[..sizeof(fname)-6]; +  return fname[..<5];    }    if (has_suffix(low_name, ".so")) { -  return fname[..sizeof(fname)-4]; +  return fname[..<3];    }    return 0;    }       static int prio_from_filename(string fname)    {    fname = FIX_CASE(fname);    if (has_suffix(fname, ".pmod")) return 3;    if (has_suffix(fname, ".so")) return 2;    if (has_suffix(fname, ".pike")) return 1;
pike.git/lib/master.pike.in:1236:    return 0;    }       static void create(string d, object|void h)    {    resolv_debug ("dirnode(%O,%O) created\n",d,h);    dirname=d;    compilation_handler=h;    fc[dirname]=this;    if(has_suffix(FIX_CASE(dirname),".pmod")) { -  fc[dirname[..sizeof(dirname)-6]]=this; +  fc[dirname[..<5]]=this;    }    array(string) files = sort(get_dir(d)||({}));    if (!sizeof(d)) return;    array(string) bases = map(files, base_from_filename);    files = filter(files, bases);    bases = filter(bases, bases);    resolv_debug("dirnode(%O,%O) got %d files.\n",    d, h, sizeof(bases));    if (!sizeof(files)) return;   
pike.git/lib/master.pike.in:2922:    int identcount = 0;       void identify_parts (mixed stuff)    {    // Use an array as stack here instead of recursing directly; we    // might be pressed for stack space if the backtrace being    // described is a stack overflow.    array identify_stack = ({stuff});    while (sizeof (identify_stack)) {    stuff = identify_stack[-1]; -  identify_stack = identify_stack[..sizeof (identify_stack) - 2]; +  identify_stack = identify_stack[..<1];    if (objectp (stuff) || functionp (stuff) || programp (stuff))    ident[stuff]++;    else if (arrayp (stuff)) {    if (!ident[stuff]++)    identify_stack += stuff;    }    else if (multisetp (stuff)) {    if (!ident[stuff]++)    identify_stack += indices([multiset]stuff);    }
pike.git/lib/master.pike.in:3161:    // 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 (module_prefix || "") + path[..sizeof(path)-13] + (module_suffix || ""); +  return (module_prefix || "") + path[..<12] + (module_suffix || "");    }    if (has_suffix(path, ".pmod")) { -  return (module_prefix || "") + path[..sizeof(path)-6] + (module_suffix || ""); +  return (module_prefix || "") + path[..<5] + (module_suffix || "");    }    if (has_suffix(path, ".so")) { -  return (module_prefix || "") + path[..sizeof(path)-4] + (module_suffix || ""); +  return (module_prefix || "") + path[..<3] + (module_suffix || "");    }    if (has_suffix(path, ".pike")) { -  return path[..sizeof(path)-6] + (object_suffix || ""); +  return path[..<5] + (object_suffix || "");    }    return path + (object_suffix || "");   }         //! Describe the path to the module @[mod].   //!   //! @param mod   //! If @[mod] is a program, attempt to describe the path   //! to a clone of @[mod].
pike.git/lib/master.pike.in:3346:   //!   string describe_function (function f)   {    if (!f) return 0;       string name;       if(string s = programs_reverse_lookup (f))    {    if(has_suffix(s, ".pmod")) -  name = BASENAME(s[..sizeof(s)-6]); +  name = BASENAME(s[..<5]);    else    name = trim_file_name(s);    }    else    if (catch (name = function_name (f))) name = "function";       object o = function_object([function(mixed...:void|mixed)]f);    if(object_program (o)) { // Check if it's an object in a way that    // (hopefully) doesn't call any functions    // in it (neither `== nor `!).