* cygpath.cc (do_options): Allow outputflag combined with other

basic flags.  Only check options_from_file_flag if reading options
	from command line.
	(main): Check for NULL argz vector.  Don't free argz vector prematurely.
	Don't force flag combination in !options_from_file_flag case.
This commit is contained in:
Corinna Vinschen 2007-05-29 07:54:45 +00:00
parent 76a2ee78b6
commit df1841c310
2 changed files with 15 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2007-05-29 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (do_options): Allow outputflag combined with other
basic flags. Only check options_from_file_flag if reading options
from command line.
(main): Check for NULL argz vector. Don't free argz vector prematurely.
Don't force flag combination in !options_from_file_flag case.
2007-05-23 Corinna Vinschen <corinna@vinschen.de> 2007-05-23 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc: Include argz.h. * cygpath.cc: Include argz.h.

View File

@ -894,12 +894,12 @@ do_options (int argc, char **argv, int from_file)
} }
/* If none of the "important" flags are set, -u is default. */ /* If none of the "important" flags are set, -u is default. */
if (!unix_flag && !windows_flag && !options_from_file_flag && !output_flag if (!unix_flag && !windows_flag && !mode_flag
&& !mode_flag) && (!from_file ? !options_from_file_flag : 1))
unix_flag = 1; unix_flag = 1;
/* Only one of ... */ /* Only one of ... */
if (unix_flag + windows_flag + output_flag + mode_flag > 1 if (unix_flag + windows_flag + mode_flag > 1
+ (!from_file ? options_from_file_flag : 0)) + (!from_file ? options_from_file_flag : 0))
usage (stderr, 1); usage (stderr, 1);
@ -994,6 +994,8 @@ main (int argc, char **argv)
perror ("cygpath"); perror ("cygpath");
exit (1); exit (1);
} }
if (!az)
continue;
ac = argz_count (az, azl) + 1; ac = argz_count (az, azl) + 1;
av = (char **) malloc ((ac + 1) * sizeof (char *)); av = (char **) malloc ((ac + 1) * sizeof (char *));
if (!av) if (!av)
@ -1003,16 +1005,12 @@ main (int argc, char **argv)
} }
av[0] = prog_name; av[0] = prog_name;
argz_extract (az, azl, av + 1); argz_extract (az, azl, av + 1);
free (az);
if (options_from_file_flag) if (options_from_file_flag)
o = do_options (ac, av, 1); o = do_options (ac, av, 1);
else else
{ optind = 1;
optind = 1;
unix_flag = 1;
output_flag = mode_flag = windows_flag = 0;
}
action (ac, av, o); action (ac, av, o);
free (az);
free (av); free (av);
} }
} }