X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=psi.d%2Fgetopt.psi;h=fcf1db7c348523bd6a21f02eeb67bdcd8c4ce1fd;hb=de4f7cc512bbffb5e71290ac48e659dae5e9601d;hp=5e1e427ce50cec30c22d678b954bb9815c4e131b;hpb=5e240548ba570610ce0dbc248a2b7654a0e080fa;p=m6w6%2Fext-psi diff --git a/psi.d/getopt.psi b/psi.d/getopt.psi index 5e1e427..fcf1db7 100644 --- a/psi.d/getopt.psi +++ b/psi.d/getopt.psi @@ -2,8 +2,12 @@ function psi\opterr(int $value) : void { let _v = intval($value); return void(opterr_set); } -function psi\optind() : int { - return to_int(optind); +function psi\optind\get() : int { + return to_int(optind_get); +} +function psi\optind\set(int $v) : void { + let _v = intval($v); + return void(optind_set); } function psi\optopt() : int { return to_int(optopt); @@ -11,15 +15,22 @@ function psi\optopt() : int { function psi\optarg() : string { return to_string(optarg); } - -function psi\getopt(array &$argv, string $options) : int { +/* OSX +function psi\optreset() : void { + let _v = 1; + return void(optreset_set); +} +*/ +static function psi\getopt(array &$argv, string $options) : int { let argc = count($argv); let argv = &arrval($argv, *argv = strval($argv) ); let optstring = strval($options); - return to_int(getopt); - set $argv = to_array(argv, - to_string(argv) + return to_int(getopt); + set $argv = to_array( + *argv, + argc, + to_string(*argv) ); }