Fixed -m command line option (only numerical form is supported)

This commit is contained in:
Pierre Pronchery 2005-07-14 16:58:16 +00:00
parent 027c167084
commit eb41fcfaad

View File

@ -36,21 +36,21 @@ int main(int argc, char * argv[])
mode_t mode = 0777; mode_t mode = 0777;
int errcode = 0; int errcode = 0;
int o; int o;
char * p;
int i; int i;
while((o = getopt(argc, argv, "m:")) != -1) while((o = getopt(argc, argv, "m:")) != -1)
{
switch(o) switch(o)
{ {
case 'm': case 'm':
/* FIXME */ /* FIXME mode may be an expression */
if((mode = strtol(optarg, NULL, 8)) > 0777) mode = strtol(optarg, &p, 8);
if(*optarg == '\0' || *p != '\0' || mode > 0777)
return _usage(); return _usage();
break; break;
case '?': default:
return _usage(); return _usage();
} }
}
if(argc == optind) if(argc == optind)
return _usage(); return _usage();
for(i = optind; i < argc; i++) for(i = optind; i < argc; i++)