pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:178:    extern string current_path;    int cd(string s);    string getcwd();   #endif    string combine_path_with_cwd(string path);   #ifdef FILE_STAT_CACHE    extern int invalidate_time;    extern mapping(string:multiset(string)) dir_cache;   #endif    -  //! @decl mapping(string:array(string)) environment -  //! -  //! Mapping containing the environment variables. -  //! -  //! The mapping currently has the following structure: -  //! @mapping -  //! @member array(string) index -  //! Note that the index is @[lower_case()]'d on NT. -  //! @array -  //! @elem string varname -  //! Variable name with case intact. -  //! @elem string value -  //! Variable value. -  //! @endarray -  //! @endmapping -  //! -  //! @note -  //! This mapping should not be accessed directly; use @[getenv()] -  //! and @[putenv()] instead. This mapping is not publicly -  //! accessible in pikes newer than 7.6. -  //! -  //! @note -  //! This mapping is not compatible with @[Process.create_process()]; -  //! use the mapping returned from calling @[getenv()] without arguments -  //! instead. -  //! -  //! @bugs -  //! This mapping is not the real environment; it is just a copy of -  //! the environment made at startup. Pike does attempt to keep -  //! track of changes in the mapping and to reflect them in the -  //! real environment, but avoid accessing this mapping if at all -  //! possible. -  +     string|mapping(string:string) getenv(string|void s);    void putenv(string|void varname, string|void value);    -  // compat_environment is the mapping returned by `environment -  // (if any). -  // compat_environment_copy is used to keep track of any changes -  // performed destructively on the compat_environment mapping. -  // Both should be zero if not in use. -  // Removed in Pike 7.8. -  protected mapping(string:array(string)) compat_environment; -  protected mapping(string:array(string)) compat_environment_copy; -  - #pragma no_deprecation_warnings -  local __deprecated__(mapping(string:array(string))) `environment() -  { -  if (compat_environment) return compat_environment; -  compat_environment_copy = ([]); - #ifdef __NT__ -  // Can't use the cached environment returned by getenv(), since -  // variable names have been lowercased there. -  foreach((array(array(string)))Builtin._getenv(), array(string) pair) { -  compat_environment_copy[lower_case(pair[0])] = pair; -  } - #else -  foreach((array(array(string)))getenv(), array(string) pair) { -  compat_environment_copy[pair[0]] = pair; -  } - #endif -  return compat_environment = copy_value(compat_environment_copy); -  } -  -  local void `environment=(__deprecated__(mapping(string:array(string))) -  new_env) -  { -  compat_environment = new_env; -  if (!new_env) -  compat_environment_copy = 0; -  else if (!compat_environment_copy) -  compat_environment_copy = ([]); -  } - #pragma deprecation_warnings -  +     void add_include_path(string tmp);    void remove_include_path(string tmp);    void add_module_path(string tmp);    void remove_module_path(string tmp);    void add_program_path(string tmp);    void remove_program_path(string tmp);    mapping(string:program|NoValue) programs;       extern mapping(program:object) objects;    object cast_to_object(string oname, string current_file);
pike.git/lib/master.pike.in:880:   {    mapping(string:string) res;       if (force_update) {    res = Builtin._getenv();   #ifdef __NT__    set_lc_env (res);   #else    environment = res + ([]);   #endif -  // Kill the compat environment if forced. -  compat_environment = compat_environment_copy = 0; +     } -  +     else { -  if (compat_environment && -  !equal(compat_environment, compat_environment_copy)) { -  foreach(compat_environment; string varname; array(string) pair) { -  if (!equal(pair, compat_environment_copy[varname])) { -  putenv(pair[0], pair[1]); -  } -  } -  foreach(compat_environment_copy; string varname; array(string) pair) { -  if (!compat_environment[varname]) { -  putenv(pair[0]); -  } -  } -  } +    #ifdef __NT__    // Can't use the cached environment since variable names have been    // lowercased there.    res = Builtin._getenv();    if (!environment) set_lc_env (res);   #else    if (!environment) environment = Builtin._getenv();    res = environment + ([]);   #endif    }
pike.git/lib/master.pike.in:947:   //! @seealso   //! @[putenv()]   variant string getenv (string varname, void|int force_update)   {    if (!environment || force_update) {   #ifdef __NT__    set_lc_env (Builtin._getenv());   #else    environment = Builtin._getenv();   #endif -  // Kill the compat environment if forced. -  compat_environment = compat_environment_copy = 0; +     }      #ifdef __NT__    varname = lower_case(varname);   #endif    -  if (compat_environment) { -  array(string) res; -  if (!equal(res = compat_environment[varname], -  compat_environment_copy[varname])) { -  // Something has messed with the compat environment mapping. -  putenv(varname, res[?1]); -  } -  } -  +     return environment[varname];   }      void putenv (string varname, void|string value)   //! Sets the environment variable @[varname] to @[value].   //!   //! If @[value] is omitted or zero, the environment variable   //! @[varname] is removed.   //!   //! @[varname] and @[value] cannot be wide strings nor contain
pike.git/lib/master.pike.in:985:   //! @expr{'='@} characters.   //!   //! @note   //! On NT the environment variable name is case insensitive.   //!   //! @seealso   //! @[getenv()]   //!   {    Builtin._putenv (varname, value); -  if (compat_environment) { -  string lvarname = varname; - #ifdef __NT__ -  lvarname = lower_case(varname); - #endif -  if (value) { -  compat_environment[lvarname] = -  (compat_environment_copy[lvarname] = ({ varname, value })) + ({}); -  } else { -  m_delete(compat_environment, lvarname); -  m_delete(compat_environment_copy, lvarname); -  } -  } +     if (environment) {   #ifdef __NT__    varname = lower_case (varname);   #endif    if (value) environment[varname] = value;    else m_delete (environment, varname);    }   }      
pike.git/lib/master.pike.in:3313:    if (cur_compat_ver < lowestcompat)    {    werror("This Pike only supports compatibility down to %s.\n",    (string)lowestcompat);    cur_compat_ver = lowestcompat;    compat_major = lowestcompat->major;    compat_minor = lowestcompat->minor;    }    if (compat_major != -1) {    object compat_master = get_compat_master (compat_major, compat_minor); -  -  if (cur_compat_ver <= Version (7, 6)) { -  mapping(string:array(string)) compat_env = ([]); -  foreach (Builtin._getenv(); string var; string val) { - #ifdef __NT__ -  compat_env[lower_case (var)] = ({var, val}); - #else -  compat_env[var] = ({var, val}); - #endif +     } -  compat_master->environment = compat_env; -  } -  } +        foreach(q, array opts)    {    switch(opts[0])    {    case "dumpversion":    write("%d.%d.%d\n", __REAL_MAJOR__, __REAL_MINOR__, __REAL_BUILD__);    exit(0);       case "version":
pike.git/lib/master.pike.in:3388:       exit(0, format_paths());       case "execute":    main_resolv( "Gmp.bignum" );    random_seed((time() ^ (getpid()<<8)));    argv = tmp->get_args(argv,1);       program prog;    mixed compile_err = catch {; -  if(cur_compat_ver <= Version(7,4)) -  prog = compile_string( -  "mixed create(int argc, array(string) argv,array(string) env){"+ -  opts[1]+";}"); -  else if (intp (opts[1])) +  if (intp (opts[1]))    prog = compile_string ("mixed run() {}");    else {    string code = opts[1];    while(sscanf(code, "%sCHAR(%1s)%s", code, string c, string rest)==3)    code += c[0] + rest; -  if (cur_compat_ver <= Version (7, 6)) +     prog = compile_string(    "#define NOT(X) !(X)\n" -  "mixed run(int argc, array(string) argv," -  "mapping(string:string) env){"+ -  code+";}"); -  else -  prog = compile_string( -  "#define NOT(X) !(X)\n" +     "mixed run(int argc, array(string) argv){" + code + ";}");    }    };       if (compile_err) {    if (compile_err->is_cpp_or_compilation_error) {    // Don't clutter the output with the backtrace for    // compilation errors.    exit (20, call_describe_error (compile_err));    }
pike.git/lib/master.pike.in:3430:   #if constant(_debug)    if(debug) _debug(debug);   #endif    if(trace) trace = predef::trace(trace);    mixed ret;    mixed err = catch {    // One reason for this catch is to get a new call to    // eval_instruction in interpret.c so that the debug and    // trace levels set above take effect in the bytecode    // evaluator. -  if(cur_compat_ver <= Version(7,4)) -  prog (sizeof(argv),argv,getenv()); -  else if (cur_compat_ver <= Version (7, 6)) -  ret = prog()->run(sizeof(argv),argv,getenv()); -  else +     ret = prog()->run(sizeof(argv),argv);    };    predef::trace(trace);    if (err) {    handle_error (err);    ret = 10;    }    if(stringp(ret)) {    write(ret);    if(ret[-1]!='\n') write("\n");
pike.git/lib/master.pike.in:3580:   #endif    if(trace) trace = predef::trace(trace);    mixed ret;    mixed err = catch {    // The main reason for this catch is actually to get a new call    // to eval_instruction in interpret.c so that the debug and    // trace levels set above take effect in the bytecode evaluator.    // Note that it won't work if there's another catch surrounding    // this one.    object script; -  if(cur_compat_ver <= Version(7,4)) { -  script=prog(); -  } -  else { +     script=prog(argv); -  } +     if(!script->main)    error("Error: %s has no main().\n", argv[0]); -  if (cur_compat_ver <= Version (7, 6)) -  ret=script->main(sizeof(argv),argv,getenv()); -  else if (cur_compat_ver <= Version (8, 0)) +  if (cur_compat_ver <= Version (8, 0))    ret = script->main(sizeof(argv),argv);    else    {    mixed first_arg = __get_first_arg_type(_typeof(script->main));    // NB: first_arg may be zero eg in case main() ignores all args.    if( first_arg && (typeof(argv) <= first_arg) ) {    // argv accepted as first argument.    ret=script->main(argv);    } else    ret=script->main(sizeof(argv),argv);