X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=psi.d%2Fgetopt.psi;fp=psi.d%2Fgetopt.psi;h=42b5ee5763d32564e4b016fe0a08665caf6a2332;hb=b78637d9020222f1032349f231c0dc84a69797bc;hp=ac7fd738c098d2c11bd208a89b4d9108caae985b;hpb=440ff658995f1378fd74c0101ff6c2b4951ffdf9;p=m6w6%2Fext-psi diff --git a/psi.d/getopt.psi b/psi.d/getopt.psi index ac7fd73..42b5ee5 100644 --- a/psi.d/getopt.psi +++ b/psi.d/getopt.psi @@ -1,33 +1,37 @@ +#include + function psi\opterr(int $value) : void { let opterr = intval($value); - return void(opterr_set); + 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 optind = intval($v); - return void(optind_set); + return optind_set(optind) as void(optind_set); } function psi\optopt() : int { - return to_int(optopt); + return optopt() as to_int(optopt); } function psi\optarg() : string { - return to_string(optarg); + return optarg() as to_string(optarg); } -/* 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,