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.211 2002/07/28 23:54:31 nilsson Exp $ + // $Id: master.pike.in,v 1.212 2002/07/29 14:34:04 nilsson 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:143:    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]=='/';   }    + #ifdef __NT__ + #define EXPLODE_PATH(X) (replace((X),"\\","/")/"/") + #else + #define EXPLODE_PATH(X) ((X)/"/") + #endif +    //! @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/"/"; +  return EXPLODE_PATH(p);   }      //! @appears dirname   //! Returns all but the last segment of a path. Some example inputs and   //! outputs:   //!   //! @xml{<matrix>   //! <r><c><b>Expression</b></c><c><b>Value</b></c></r>   //! <r><c>dirname("/a/b")</c><c>"/a/"</c></r>   //! <r><c>dirname("/a/")</c><c>"/a/"</c></r>
pike.git/lib/master.pike.in:1252:      //!   class CompatResolver   {    array(string) pike_include_path=({});    array(string) pike_module_path=({});    array(string) pike_program_path=({});    mapping(string:string) predefines = ([]);    string ver;    -  //! The ComparResolver is initialized with a value that can be +  //! The CompatResolver is initialized with a value that can be    //! casted into a "%d.%d" string, e.g. a version object.    void create(mixed version)    {    ver=(string)version;    }       //! Add a directory to search for include files.    //!    //! This is the same as the command line option @tt{-I@}.    //!
pike.git/lib/master.pike.in:1451:       // FIXME: Support having the cache in the handler?    if( no_resolv[ identifier ] ) {   #ifdef RESOLV_DEBUG    werror("Resolv(%O, %O) => excluded\n",identifier, current_file);   #endif /* RESOLV_DEBUG */    return UNDEFINED;    }       if (current_file && !stringp(current_file)) { -  throw(({sprintf("resolv(%O, %O, %O): current_file is not a string!\n", -  identifier, current_file, current_handler), -  backtrace()})); +  error( "resolv(%O, %O, %O): current_file is not a string!\n", +  identifier, current_file, current_handler, +  backtrace() );    }       mixed ret;    string id=identifier+":"+(current_file ? dirname(current_file) : "-");    if( zero_type (ret = resolv_cache[id]) != 1 )    {   // werror("Resolv cached(%O) => %O (%d)\n",id,resolv_cache[id],zero_type(resolv_cache[id]));   #ifdef RESOLV_DEBUG    if (ret == ZERO_TYPE)    werror("Resolv(%O, %O) => not found (cached)\n",identifier, current_file);
pike.git/lib/master.pike.in:1593:    {    sscanf(b,"%s=%s",a,b);    a="="+a;    }    putenv(a, b);    }else{    werror("Broken environment var %s\n",a);    }    }    +  void _error(string a, mixed ... args) { +  werror(a, @b); +  exit(1); +  };    -  +    #ifndef NOT_INSTALLED    q=(getenv("PIKE_INCLUDE_PATH")||"")/":"-({""});    for(i=sizeof(q)-1;i>=0;i--) add_include_path(q[i]);       q=(getenv("PIKE_PROGRAM_PATH")||"")/":"-({""});    for(i=sizeof(q)-1;i>=0;i--) add_program_path(q[i]);       q=(getenv("PIKE_MODULE_PATH")||"")/":"-({""});    for(i=sizeof(q)-1;i>=0;i--) add_module_path(q[i]);   #endif    -  +  string format_paths() { +  return ("master.pike..." + (_master_file_name || __FILE__) + "\n" +  "Module path..." + pike_module_path*"\n" +  " " + "\n" +  "Include path.." + pike_include_path*"\n" +  " " + "\n" +  "Program path.." + pike_program_path*"\n" +  " " + "\n"); +  }; +     if(sizeof(argv)>1 && sizeof(argv[1]) && argv[1][0]=='-')    {    tmp=resolv("Getopt");    -  if (!tmp) { -  werror("master.pike: Couldn't resolv Getopt module.\n" +  if (!tmp) +  _error("master.pike: Couldn't resolv Getopt module.\n"    "Is your PIKE_MODULE_PATH environment variable set correctly?\n"); -  exit(1); -  } +        q=tmp->find_all_options(argv,({    ({"compat_version",tmp->HAS_ARG,({"-V","--compat"})}),    ({"version",tmp->NO_ARG,({"-v","--version"})}),    ({"help",tmp->NO_ARG,({"-h","--help"})}),    ({"features",tmp->NO_ARG,({"--features"})}),    ({"info",tmp->NO_ARG,({"--info"})}),    ({"execute",tmp->HAS_ARG,({"-e","--execute"})}),    ({"debug_without",tmp->HAS_ARG,({"--debug-without"})}),    ({"preprocess",tmp->HAS_ARG,({"-E","--preprocess"})}),
pike.git/lib/master.pike.in:1739:    _master_file_name = q[i][1];    break;    }    }       foreach(q, array opts)    {    switch(opts[0])    {    case "version": -  werror(version() + " Copyright © 1994-2002 Roxen Internet Software\n" +  werror(version() + " Copyright © 1994-2002 Linköping University\n"    "Pike comes with ABSOLUTELY NO WARRANTY; This is free software and you are\n"    "welcome to redistribute it under certain conditions; Read the files\n"    "COPYING and COPYRIGHT in the Pike distribution for more details.\n");    exit(0);       case "help":    werror("Usage: pike [-driver options] script [script arguments]\n"    "Driver options include:\n"    " -I --include-path=<p>: Add <p> to the include path\n"    " -M --module-path=<p> : Add <p> to the module path\n"
pike.git/lib/master.pike.in:1773:       case "features":    postparseaction="features";    break;       case "info":    postparseaction="info";    break;       case "showpaths": -  werror("Include path : " + pike_include_path*"\n" -  " " + "\n" -  "Module path : " + pike_module_path*"\n" -  " " + "\n" -  "Program path : " + pike_program_path*"\n" -  " " + "\n" -  "Master file : " + (_master_file_name || __FILE__) + "\n"); +  werror(format_paths());    exit(0);       case "execute":    random_seed(time() ^ (getpid()<<8));    argv = tmp->get_args(argv,1);    if(trace) predef::trace(trace);    compile_string("mixed create(int argc, array(string) argv,array(string) env){"+    opts[1]+";}")(sizeof(argv),argv,env);    exit(0);       case "preprocess":    _static_modules.files()->_stdout->write(cpp(master_read_file(opts[1]),    opts[1]));    exit(0);    }    }       argv = tmp->get_args(argv,1);    }    -  +  mixed main_resolv(array syms) { +  mixed v = resolv(syms[0]); +  foreach(syms[1..], string sym) +  if(v) v = v[sym]; +  if(!v) +  _error("Could not resolv %s\n", syms*"."); +  return v; +  }; +     switch (postparseaction)    {    case "features": -  v = resolv("Tools"); -  if (v) v = v["Install"]; -  if (v) v = v["features"]; -  if (!v) -  { -  werror("Could not resolv Tools.Install.features\n"); -  exit(1); -  } -  -  _static_modules.files()->_stdout->write(v()*"\n"+"\n"); +  _static_modules.files()->_stdout-> +  write( main_resolv( "Tools.Install.features"/"." )()*"\n"+"\n" );    exit(0);       case "info":    function w=_static_modules.files()->_stdout->write;    w("Software......Pike\n"    "Version......."+version()+"\n"    "WWW...........http://pike.ida.liu.se/\n"    "\n");       w("pike binary..."+_pike_file_name+"\n"); -  w("master.pike..."+__FILE__+"\n"); +  w( format_paths() + "\n");    -  w("Module path..." + pike_module_path*"\n" -  " " + "\n" -  "Include path.." + pike_include_path*"\n" -  " " + "\n" -  "Program path.." + pike_program_path*"\n" -  " " + "\n" +  w("Features......"+ +  main_resolv( "Tools.Install.features"/"." )()*"\n "+    "\n"); -  -  v = resolv("Tools"); -  if (v) v = v["Install"]; -  if (v) v = v["features"]; -  if (!v) -  { -  werror("Could not resolv Tools.Install.features\n"); -  exit(1); -  } -  -  w("Features......"+v()*"\n "+"\n"); -  -  +     exit(0);    }       random_seed(time() ^ (getpid()<<8));       if(sizeof(argv)==1)    { -  /* Attempt to resolv Tools.Hilfe.StdinHilfe */ -  tmp = resolv("Tools"); -  if (!tmp) { -  werror("Couldn't find Tools.\n"); -  exit(1); -  } -  tmp = tmp["Hilfe"]; -  if (!tmp) { -  werror("Couldn't find Hilfe.\n"); -  exit(1); -  } -  tmp->StdinHilfe(); +  main_resolv( ({ "Tools", "Hilfe" }) )->StdinHilfe();    exit(0); -  } else { -  argv=argv[1..]; +     } -  +  else +  argv=argv[1..];       argv[0]=combine_path_with_cwd(argv[0]);       program prog; -  +     mixed err = catch {    prog=(program)argv[0];    };    -  if (err) { -  werror( "Pike: Failed to compile script:\n" +  if (err) +  _error( "Pike: Failed to compile script:\n"    "%s\n", stringp(err[0])?err[0]:describe_backtrace(err) ); -  exit(1); -  } +     -  // FIXME: Isn't the following code dead? +     if(!prog) -  { -  werror("Pike: Couldn't find script to execute\n(%O)\n",argv[0]); -  exit(1); -  } +  _error("Pike: Couldn't find script to execute\n(%O)\n", argv[0]);       object script=prog();      #if constant(_debug)    if(debug) _debug(debug);   #endif -  +     if(!script->main) -  { -  werror("Error: "+argv[0]+" has no main().\n"); -  exit(1); -  } +  _error("Error: "+argv[0]+" has no main().\n");       if(trace) predef::trace(trace);    i=script->main(sizeof(argv),argv,env);    if(i >=0) exit(i);    _async=1;       while(1)    {    mixed err=catch    {