pike.git / lib / modules / Getopt.pmod

version» Context lines:

pike.git/lib/modules/Getopt.pmod:1:   // startpid = (int)find_arg(argv, "s", ({ "start-script-pid" }),   // ({ "ROXEN_START_SCRIPT_PID"}));      // configuration_dir = find_arg(argv, "d", ({ "config-dir",   // "configurations",   // "configuration-directory" }),   // ({ "ROXEN_CONFIGDIR", "CONFIGURATIONS" }),   // "../configurations");       - string|int find_option(array argv, -  array|string shortform, -  array|string|void longform, -  array|string|void envvars, -  mixed|void def, + string|int find_option(array(string) argv, +  array(string)|string shortform, +  array(string)|string|void longform, +  array(string)|string|void envvars, +  string|int|void def,    int|void throw_errors)   { -  mixed value; +  string|int value;    int i,hasarg;       hasarg=query_num_arg() > 4; -  if(!arrayp(longform)) longform=({longform}); -  if(!arrayp(shortform)) shortform=({shortform}); -  if(!arrayp(envvars)) envvars=({envvars}); +  if(!arrayp(longform)) longform=({[string]longform}); +  if(!arrayp(shortform)) shortform=({[string]shortform}); +  if(!arrayp(envvars)) envvars=({[string]envvars});       for(i=1; i<sizeof(argv); i++)    {    if(argv[i] && strlen(argv[i]) > 1)    {    if(argv[i][0] == '-')    {    if(argv[i][1] == '-')    {    string tmp;
pike.git/lib/modules/Getopt.pmod:103:    if(argv[i]=="-") argv[i]=0;    return value;    }    }    }    }    }    }       if(arrayp(envvars)) -  foreach(envvars, value) -  if(value && (value=getenv(value))) +  foreach([array(string)]envvars, value) +  if(value && (value=[string]getenv([string]value)))    return value;       return def;   }      /*    * ({ "name", type, ({aliases}), env_var, default })    */      constant HAS_ARG=1;   constant NO_ARG=2;   constant MAY_HAVE_ARG=3;      #define NAME 0   #define TYPE 1   #define ALIASES 2   #define ENV 3   #define DEF 4    - array find_all_options(array(string) argv, array options, + array find_all_options(array(string) argv, +  array(array(array(string)|string)) options,    void|int posix_me_harder, void|int throw_errors)   { -  mapping quick=([]); -  foreach(options, mixed opt) +  mapping(string:array(string|array(string))) quick=([]); +  foreach(options, array(array(string)|string) opt)    { -  mixed aliases=opt[ALIASES]; -  if(!arrayp(aliases)) aliases=({aliases}); -  foreach(aliases, mixed optname) +  array(string)|string aliases=[array(string)|string]opt[ALIASES]; +  if(!arrayp(aliases)) aliases=({[string]aliases}); +  foreach([array(string)]aliases, string optname)    {    if(optname[0..1]=="--")    {    quick[optname]=opt;    }else{    foreach(optname[1..]/"",string optletter)    {    quick["-"+optletter]=opt;    }    }
pike.git/lib/modules/Getopt.pmod:226:    if(argv[e]=="-") argv[e]=0;    }    }else{    if(posix_me_harder != -1)    if(posix_me_harder || getenv("POSIX_ME_HARDER"))    break;    }    }       multiset done=mkmultiset(column(ret, 0)); -  foreach(options, array(string) option) +  foreach(options, array(string|array(string)) option)    { -  string name=option[NAME]; +  string name=[string]option[NAME];    if(done[name]) continue;    if(sizeof(option) > ENV)    { -  mixed foo=option[ENV]; +  array(string)|string foo=option[ENV];    if(!foo) continue; -  if(stringp(foo)) foo=({foo}); -  foreach(foo, foo) +  if(stringp(foo)) foo=({[string]foo}); +  foreach([array(string)]foo, foo)    { -  if(foo=getenv(foo)) +  if(foo=[string]getenv([string]foo))    {    ret+=({ ({name, foo}) });    done[name]=1;    break;    }    }       if(!done && sizeof(option)>3 && option[3])    {    ret+=({ ({name, option[3]}) });