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 as GPL (General Public License)   // See the files COPYING and DISCLAIMER for more information.   // - // $Id: master.pike.in,v 1.203 2002/05/23 23:27:16 mast Exp $ + // $Id: master.pike.in,v 1.204 2002/05/24 21:46:03 nilsson Exp $      #pike __REAL_VERSION__      // --- Some configurable parameters      #define PIKE_AUTORELOAD   #define GETCWD_CACHE   #define FILE_STAT_CACHE      // This define is search and replaced by bin/install.pike.
pike.git/lib/master.pike.in:61:      // --- Functions begin here.      #define Stat _static_modules.files.Stat   #define capitalize(X) (upper_case((X)[..0])+(X)[1..])      //! @appears error   //! Throws an error. A more readable version of the code   //! @tt{throw( ({ sprintf(f, @@args), backtrace() }) )@}.   void error(string f, mixed ... args) { -  array(array) b = backtrace(); +  array b = backtrace();    if (sizeof(args)) f = sprintf(f, @args);    throw( ({ f, b[..sizeof(b)-2] }) );   }      // FIXME: Should the pikeroot-things be private?   #ifdef PIKE_FAKEROOT   object o;   string fakeroot(string s)   {    string tmp1=combine_path_with_cwd(s);
pike.git/lib/master.pike.in:184:    return tmp[-1];   }   #define BASENAME(X) (EXPLODE_PATH(X)[-1])      #ifdef PIKE_AUTORELOAD      int autoreload_on;   int newest;      #define AUTORELOAD_CHECK_FILE(X) \ -  if(autoreload_on) if(mixed fnord=master_file_stat(X)) if(fnord[3]>newest) newest=fnord[3]; +  if(autoreload_on) if(Stat s=master_file_stat(X)) if(s->mtime>newest) newest=[int]s->mtime;      #define AUTORELOAD_BEGIN() \    int ___newest=newest; \    newest=0         #define AUTORELOAD_FINISH(VAR, CACHE, FILE) \    if(autoreload_on) { \    if(CACHE [ FILE ] && newest <= load_time[FILE]) { \    VAR = CACHE [ FILE ]; \
pike.git/lib/master.pike.in:233:    compat_major, compat_minor),    handler,    compat_major,    compat_minor);   }      //!   string master_read_file(string file)   {    object o=_static_modules.files()->Fd(); -  if(o->open(fakeroot(file),"r")) -  return o->read(); +  if( ([function(string, string : int)]o->open)(fakeroot(file),"r") ) +  return ([function(void : string)]o->read)();    return 0;   }      #ifdef GETCWD_CACHE   string current_path;   int cd(string s)   {    current_path=0;    return predef::cd(s);   }
pike.git/lib/master.pike.in:266:      #ifdef FILE_STAT_CACHE      #define FILE_STAT_CACHE_TIME 20      int invalidate_time;   mapping(string:multiset(string)) dir_cache = ([]);      Stat master_file_stat(string x)   { -  string file, dir=combine_path_with_cwd(x); +  string dir = combine_path_with_cwd(x); +  string file = BASENAME(dir); +  dir = dirname(dir);    -  file=BASENAME(dir); -  dir=dirname(dir); -  -  multiset(string) d; +     if(time() > invalidate_time)    { -  dir_cache=([]); -  invalidate_time=time()+FILE_STAT_CACHE_TIME; +  dir_cache = ([]); +  invalidate_time = time()+FILE_STAT_CACHE_TIME;    } -  if(zero_type(d=dir_cache[dir])) +  +  multiset(string) d = dir_cache[dir]; +  if( zero_type(d) )    { -  if(array(string) tmp=get_dir(dir)) +  array(string) tmp = get_dir(dir); +  if(tmp)    {   #ifdef __NT__ -  tmp=map(tmp, lower_case); +  tmp = map(tmp, lower_case);   #endif -  d=dir_cache[dir]=aggregate_multiset(@tmp); -  }else{ +  d = dir_cache[dir] = aggregate_multiset(@tmp); +  } +  else    dir_cache[dir]=0;    } -  } +       #ifdef __NT__ -  file=lower_case(file); +  file = lower_case(file);   #endif    if(d && !d[file]) return 0;       return predef::file_stat(x);   }   #else   #define master_file_stat file_stat   #endif // FILE_STAT_CACHE      mapping (string:array(string)) environment=([]);
pike.git/lib/master.pike.in:319:   //! variables will be returned.   //!   //! If the @[varname] argument has been given, the value of the environment   //! variable with the name @[varname] will be returned. If no such   //! environment variable exists, @tt{0@} (zero) will be returned.   //!   //! On NT the environment variable name is case insensitive.   //!   string|mapping(string:string) getenv(string|void s)   { -  if(!s) return aggregate_mapping( @(values(environment)*({}) ) ); +  if(!s) return [mapping(string:string)]aggregate_mapping( @(values(environment)*({}) ) );   #ifdef __NT__    s = lower_case(s);   #endif    return environment[s] && environment[s][1];   }         //! @appears compile_file   //! Compile the Pike code contained in the file @[filename] into a program.   //!
pike.git/lib/master.pike.in:435:    // module relocation stuff.    foreach (pike_module_path, string path)    if (has_prefix (fname, path))    return map (pike_module_path, `+, "/", fname[sizeof (path)..], ".o");   #endif    return ({ fname + ".o" });   }      #if constant(_static_modules.Builtin.mutex)   #define THREADED - object compilation_mutex = _static_modules.Builtin()->mutex(); + _static_modules.Builtin.mutex compilation_mutex = _static_modules.Builtin()->mutex();   #endif      static program low_findprog(string pname,    string ext,    object|void handler,    void|int mkobj)   {    program ret;    Stat s;    string fname=pname+ext;
pike.git/lib/master.pike.in:509:    case ".pike":    foreach(query_precompiled_names(fname), string oname) {    if(Stat s2=master_file_stat(fakeroot(oname)))    {    if(s2[1]>=0 && s2[3]>=s[3])    {    mixed err=catch {    AUTORELOAD_CHECK_FILE(oname);    return programs[fname] =    decode_value(master_read_file(oname), -  Codec(fname,mkobj)); +  Codec(fname, mkobj));    };    m_delete(programs, fname);    if (handler && handler->compile_warning) {    handler->compile_warning(oname, 0,    sprintf("Decode failed:\n"    "\t%s", describe_error(err)));    } else {    compile_warning(oname, 0,    sprintf("Decode failed:\n"    "\t%s", describe_error(err)));
pike.git/lib/master.pike.in:575:   // to the program so that it can be freed.   //   void unregister(program p)   {    if(string fname=search(programs,p)) {    m_delete(programs, fname);    // FIXME: The following assumes that programs are always stored    // with '/' as path separators, even on NT. Haven't checked if    // that always is the case.    fname = dirname (fname); -  if (object n = fname != "" && fc[fname]) +  object n; +  if ( fname!="" && (n = fc[fname]) )    if (n->is_resolv_dirnode || n->is_resolv_joinnode)    n->delete_value (p);    }    if (zero_type(objects[p]) != 1)    m_delete(objects, p);    foreach (fc; string name; mixed mod)    if (objectp(mod) && object_program(mod) == p)    m_delete(fc, name);   }   
pike.git/lib/master.pike.in:683:    if(mixed x=catch {    werror(describe_backtrace(trace));    }) {    // One reason for this might be too little stack space, which    // easily can occur for "out of stack" errors. It should help to    // tune up the STACK_MARGIN values in interpret.c then.    werror("Error in handle_error in master object:\n");    if(catch {    catch {    if (catch { -  string msg = x[0]; -  array bt = x[1]; +  string msg = [string]x[0]; +  array bt = [array]x[1];    werror("%s%O\n", msg, bt);    }) {    werror("%O\n", x);    }    };    werror("Original error:\n"    "%O\n", trace);    }) {    werror("sprintf() failed to write error.\n");    }
pike.git/lib/master.pike.in:719:   //! @code{((program)@[prog])(@@@[args])@}   //! instead.   //!   //! @seealso   //! @[destruct()], @[compile_string()], @[compile_file()]   //!   object new(string|program prog, mixed ... args)   {    if(stringp(prog))    { -  if(program p=cast_to_program(prog,backtrace()[-2][0])) +  if(program p=cast_to_program(prog, backtrace()[-2][0]))    return p(@args);    else    error("Failed to find program %s.\n", prog);    }    return prog(@args);   }      //! @decl object clone(string|program prog, mixed ... args)   //! @appears clone   //!
pike.git/lib/master.pike.in:2595:    if (catch {    return trace[0] || "No error message.\n";    }) {    return "Error indexing backtrace!\n";    }    }    return sprintf ("Backtrace is of unknown type %t!\n", trace);   }       - class Codec + class Codec (void|string fname, void|int mkobj)   { -  string fname; -  int mkobj; +     program prog_to_mkobj; -  void create(void|string f,void|int m) -  { -  fname=f; -  mkobj=m; -  } +        object __register_new_program(program p)    {    if(fname)    {    programs[fname]=prog_to_mkobj=p;    fname=0;    if (mkobj)    return objects[p] || (objects[p]=__null_program());    }