pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.159 2001/07/02 17:07:18 grubba Exp $ +  * $Id: master.pike.in,v 1.160 2001/07/27 14:42:19 nilsson Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD
pike.git/lib/master.pike.in:43:    if(glob(x,tmp1))    return s;   #endif    return PIKE_FAKEROOT+tmp1;   }   #else   #define fakeroot(X) X   #endif       - //! @global + //! @appears is_absolute_path   //! Check if a path @[p] is fully qualified (ie not relative).   //!   //! @returns   //! Returns 1 if the path is absolute, 0 otherwise.   int is_absolute_path(string p)   {   #ifdef __NT__    p=replace(p,"\\","/");    if(sscanf(p,"%[a-zA-Z]:%*c",string s)==2 && sizeof(s)==1)    return 1;   #define IS_ABSOLUTE_PATH is_absolute_path   #else   #define IS_ABSOLUTE_PATH(X) ((X)[0]=='/')   #endif    return p[0]=='/';   }    - //! @global + //! @appears explode_path   //! Split a path @[p] into its components.   //!   //! 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.   //!   array(string) explode_path(string p)   {   #ifdef __NT__    p=replace(p,"\\","/");   #define EXPLODE_PATH(X) (replace((X),"\\","/")/"/")   #else   #define EXPLODE_PATH(X) ((X)/"/")   #endif    return p/"/";   }    - //! @global + //! @appears dirname   //! Returns all but the last segment of a path.   //!   //! @seealso   //! @[basename()], @[explode_path()]   string dirname(string x)   {    array(string) tmp=EXPLODE_PATH(x);    return tmp[..sizeof(tmp)-2]*"/";   }    - //! @global + //! @appears basename   //! Returns the last segment of a path.   //!   //! @seealso   //! @[dirname()], @[explode_path()]   string basename(string x)   {    array(string) tmp=EXPLODE_PATH(x);    return tmp[-1];   }   #define DIRNAME dirname
pike.git/lib/master.pike.in:146:      #define AUTORELOAD_CHECK_FILE(X)   #define AUTORELOAD_BEGIN()   #define AUTORELOAD_FINISH(VAR,CACHE,FILE)      #endif      int compat_major=-1;   int compat_minor=-1;    - //! @global + //! @appears compile_string   //! Compile the Pike code in the string @[data] into a program.   //! If @[filename] is not specified, it will default to @tt{"-"@}.   //!   //! Functionally equal to @code{@[compile](@[cpp](@[source], @[filename]))@}.   //!   //! @seealso   //! @[compile()], @[cpp()], @[compile_file()]   //!   program compile_string(string source, void|string filename,    object|void handler)
pike.git/lib/master.pike.in:242:    return predef::file_stat(x);   }   #else   #define master_file_stat file_stat   #endif      mapping (string:string) environment=([]);          - //! @global +    //! @decl string getenv(string varname)   //! @decl mapping(string:string) getenv() -  + //! @appears getenv   //!   //! When called with no arguments, a mapping with all current envrionment   //! 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.   //!   string|mapping(string:string) getenv(string|void s)   {    if(!s) return environment + ([]);    return environment[s];   }       - //! @global + //! @appears compile_file   //! Compile the Pike code contained in the file @[filename] into a program.   //!   //! This function will compile the file @[filename] to a Pike program that can   //! later be instantiated. It is the same as doing   //! @code{@[compile_string](@[Stdio.read_file](@[filename]), @[filename])@}.   //!   //! @seealso   //! @[compile()], @[compile_string()], @[cpp()]   //!   program compile_file(string filename,
pike.git/lib/master.pike.in:308:   {    return environment[s];   }      function(:mapping(string:string))|function(string:string) getenv(s)   {    if(!s) return environment + ([]);    return environment[s];   }    - mapping(string:string) getenv() | + // mapping(string:string) getenv() |   string getenv(string s)   {    if(!s) return environment + ([]);    return environment[s];   }   #endif /* 0 */    - //! @global + //! @appears putenv   //! Sets the environment variable @[varname] to @[value].   //!   //! @seealso   //! @[getenv()]   //!   void putenv(string varname, string value)   {    environment[varname] = value;   }    - //! @global + //! @appears normalize_path   string normalize_path( string X )   {   #ifndef __NT__    return X;   #else    return replace(X,"\\","/");   #endif   }      mapping (string:program) programs=(["/master":object_program(this_object())]);
pike.git/lib/master.pike.in:586:    }    };    werror("Original error:\n"    "%O\n", trace);    }) {    werror("sprintf() failed to write error.\n");    }    }   }    - //! @global +    //! @decl object new(string|program prog, mixed ... args) - //! @decl object clone(string|program prog, mixed ... args) + //! @appears new   //!   //! Instantiate a program.   //!   //! A new instance of the class @[prog] will be created.   //! All global variables in the new object be initialized, and   //! then @[create()] will be called with @[args] as arguments.   //!   //! @note   //! These two functions are considered obsolete, use   //! @code{((program)@[prog])(@@@[args])@}
pike.git/lib/master.pike.in:616:    if(stringp(prog))    {    if(program p=cast_to_program(prog,backtrace()[-2][0]))    return p(@args);    else    error(sprintf("new: failed to find program %s.\n",prog));    }    return prog(@args);   }    + //! @decl object clone(string|program prog, mixed ... args) + //! @appears clone + //! + //! @seealso + //! @[new()] +    function clone = new;      /* This array contains the names of the functions    * that a replacing master-object may want to override.    */   constant master_efuns = ({    "basename",    "dirname",    "is_absolute_path",    "explode_path",
pike.git/lib/master.pike.in:1011:    }    if (handler) {    return dirnode(path, handler);    }    return fc[path]=dirnode(path);   }            multiset no_resolv = (<>); +  + //!   class CompatResolver   {    array(string) pike_include_path=({});    array(string) pike_module_path=({});    array(string) pike_program_path=({});    int want_warnings = PIKE_WARNINGS;    string ver;       void create(mixed v)    {    ver=(string)v;    }    -  //! @global +  //! @appears add_include_path    //! Add a directory to search for include files.    //!    //! This is the same as the command line option @tt{-I@}.    //!    //! @note    //! Note that the added directory will only be searched when using    //! < > to quote the included file.    //!    //! @seealso    //! @[remove_include_path()]    //!    void add_include_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));    pike_include_path-=({tmp});    pike_include_path=({tmp})+pike_include_path;    }    -  //! @global +  //! @appears remove_include_path    //! Remove a directory to search for include files.    //!    //! This function performs the reverse operation of @[add_include_path()].    //!    //! @seealso    //! @[add_include_path()]    //!    void remove_include_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));    pike_include_path-=({tmp});    }    -  //! @global +  //! @appears add_module_path    //! Add a directory to search for modules.    //!    //! This is the same as the command line option @tt{-M@}.    //!    //! @seealso    //! @[remove_module_path()]    //!    void add_module_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));    pike_module_path-=({tmp});    pike_module_path=({tmp})+pike_module_path;    }       -  //! @global +  //! @appears remove_module_path    //! Remove a directory to search for modules.    //!    //! This function performs the reverse operation of @[add_module_path()].    //!    //! @seealso    //! @[add_module_path()]    //!    void remove_module_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));    pike_module_path-=({tmp});    }       -  //! @global +  //! @appears add_program_path    //! Add a directory to search for programs.    //!    //! This is the same as the command line option @tt{-P@}.    //!    //! @seealso    //! @[remove_program_path()]    //!    void add_program_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));    pike_program_path-=({tmp});    pike_program_path=({tmp})+pike_program_path;    }       -  //! @global +  //! @appears remove_program_path    //! Remove a directory to search for programs.    //!    //! This function performs the reverse operation of @[add_program_path()].    //!    //! @seealso    //! @[add_program_path()]    //!    void remove_program_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp));
pike.git/lib/master.pike.in:2093:    return s+"->"+name;    }    return name;   }      /* It is possible that this should be a real efun,    * it is currently used by handle_error to convert a backtrace to a    * readable message.    */    - //! @global + //! @appears describe_backtrace   //! Returns a string containing a readable message that describes where   //! the backtrace was made.   //!   //! The argument @[trace] should normally be the return value from a call   //! to @[backtrace()], or a caught error.   //!   //! @seealso   //! @[backtrace()], @[describe_error()], @[catch()], @[throw()]   //!   string describe_backtrace(mixed trace, void|int linewidth)
pike.git/lib/master.pike.in:2277:    -loop_start, loops)});    frames += tail;    }       ret += frames * "";    }       return ret || "No backtrace!\n";;   }    - //! @global + //! @appears describe_error   //! Returns only the error message from a backtrace.   //!   //! If there is no error message in the backtrace, a fallback message   //! will be returned.   //!   //! @seealso   //! @[backtrace()], @[describe_backtrace()]   //!   string describe_error (mixed trace)   {