diff --git a/lib/modules/Array.pmod b/lib/modules/Array.pmod index b5f2d111f9a2ded220cf38758dcf1832589b87e4..964bfdaa16a39c1b9a60725f7405d2ed0137ba90 100644 --- a/lib/modules/Array.pmod +++ b/lib/modules/Array.pmod @@ -101,7 +101,7 @@ mixed reduce(function fun, array arr, mixed|void zero) if(sizeof(arr)) zero = arr[0]; for(int i=1; i<sizeof(arr); i++) - zero = fun(zero, arr[i]); + zero = ([function(mixed,mixed:mixed)]fun)(zero, arr[i]); return zero; } @@ -110,7 +110,7 @@ mixed rreduce(function fun, array arr, mixed|void zero) if(sizeof(arr)) zero = arr[-1]; for(int i=sizeof(arr)-2; i>=0; --i) - zero = fun(arr[i], zero); + zero = ([function(mixed,mixed:mixed)]fun)(arr[i], zero); return zero; } @@ -154,21 +154,21 @@ int search_array(array arr, mixed fun, mixed ... args) if(stringp(fun)) { for(e=0;e<sizeof(arr);e++) - if(([array(object)]arr)[e][fun](@args)) + if(([function(mixed...:mixed)]([array(object)]arr)[e][fun])(@args)) return e; return -1; } else if(functionp(fun)) { for(e=0;e<sizeof(arr);e++) - if(([function]fun)(arr[e],@args)) + if(([function(mixed,mixed...:mixed)]fun)(arr[e],@args)) return e; return -1; } else if(intp(fun)) { for(e=0;e<sizeof(arr);e++) - if(([array(function)]arr)[e](@args)) + if(([array(function(mixed...:mixed))]arr)[e](@args)) return e; return -1; } @@ -184,7 +184,7 @@ array sum_arrays(function foo, array(mixed) ... args) int e,d; ret=allocate(sizeof(args[0])); for(e=0;e<sizeof(args[0]);e++) - ret[e]=foo(@ column(args, e)); + ret[e]=([function(mixed...:mixed)]foo)(@ column(args, e)); return ret; } @@ -227,7 +227,8 @@ array sort_array(array foo,function|void cmp, mixed ... args) while(1) { - if(cmp(foo[foop],foo[barp],@args) <= 0) + if(([function(mixed,mixed,mixed...:int)]cmp)(foo[foop],foo[barp],@args) + <= 0) { bar[start++]=foo[foop++]; if(foop == fooend) @@ -262,11 +263,11 @@ array columns(array x, array ind) return ret; } -array transpose_old(array x) +array transpose_old(array(array|string) x) { if (!sizeof(x)) return x; - array ret=allocate(sizeof(x[0])); - for(int e=0;e<sizeof(x[0]);e++) ret[e]=column(x,e); + array ret=allocate(sizeof([array|string]x[0])); + for(int e=0;e<sizeof([array|string]x[0]);e++) ret[e]=column(x,e); return ret; } @@ -550,6 +551,6 @@ int lyskom_sort_func(string a,string b) array flatten(array a) { array ret=({}); - foreach(a, a) ret+=arrayp(a)?flatten(a):({a}); + foreach(a, mixed b) ret+=arrayp(b)?flatten([array]b):({b}); return ret; } diff --git a/lib/modules/Getopt.pmod b/lib/modules/Getopt.pmod index e8f62c176c54bf882724d3dce8c377e8191da519..5695d5249d7853d6d7fe2226d18f2fc9150a457b 100644 --- a/lib/modules/Getopt.pmod +++ b/lib/modules/Getopt.pmod @@ -8,20 +8,20 @@ // "../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++) { @@ -110,8 +110,8 @@ string|int find_option(array argv, } 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; @@ -131,15 +131,16 @@ constant MAY_HAVE_ARG=3; #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]=="--") { @@ -233,18 +234,18 @@ array find_all_options(array(string) argv, array options, } 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; diff --git a/lib/modules/String.pmod b/lib/modules/String.pmod index e1bdd0ff6e89bd5f3b1d4f9b30a111abdf3cf69f..808f5edd9762943be99deaa0f82e5d6f6ccd66e9 100644 --- a/lib/modules/String.pmod +++ b/lib/modules/String.pmod @@ -5,7 +5,7 @@ constant width=__builtin.string_width; /* * Implode an array of strings to an english 'list' - * ie. ({"foo","bar","gazonk"}) beomces "foo, bar and gazonk" + * ie. ({"foo","bar","gazonk"}) becomes "foo, bar and gazonk" */ string implode_nicely(array(string|int|float) foo, string|void and) { @@ -14,7 +14,7 @@ string implode_nicely(array(string|int|float) foo, string|void and) switch(sizeof(foo)) { case 0: return ""; - case 1: return foo[0]; + case 1: return ([array(string)]foo)[0]; default: return foo[0..sizeof(foo)-2]*", "+" "+and+" "+foo[-1]; } }