X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=psi.d%2Fgetopt.psi;h=962ac970fb74ae66f126d2a78c554fec1ccb3c0d;hp=fcf1db7c348523bd6a21f02eeb67bdcd8c4ce1fd;hb=b029005e56a8913fbb3d17ab497b4a37a00a211c;hpb=9bcb1df0786a8193d65949c857baaba2f4296e84 diff --git a/psi.d/getopt.psi b/psi.d/getopt.psi index fcf1db7..962ac97 100644 --- a/psi.d/getopt.psi +++ b/psi.d/getopt.psi @@ -1,33 +1,37 @@ +#include + function psi\opterr(int $value) : void { - let _v = intval($value); - return void(opterr_set); + let opterr = intval($value); + return opterr_set(opterr) as void(opterr_set); } function psi\optind\get() : int { - return to_int(optind_get); + return optind_get() as to_int(optind_get); } function psi\optind\set(int $v) : void { - let _v = intval($v); - return void(optind_set); + let optind = intval($v); + return optind_set(optind) as void(optind_set); } function psi\optopt() : int { - return to_int(optopt); + return optopt_get() as to_int(optopt_get); } function psi\optarg() : string { - return to_string(optarg); + return optarg_get() as to_string(optarg_get); } -/* OSX + +#ifdef _OPTRESET function psi\optreset() : void { let _v = 1; - return void(optreset_set); + return optreset_set(_v) as void(optreset_set); } -*/ +#endif + 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); + return getopt(argc, argv, optstring) as to_int(getopt); set $argv = to_array( *argv, argc,