YACP
Joshua Daniel Franklin
joshuadfranklin@yahoo.com
Thu Jun 20 16:18:00 GMT 2002
YACP (Yet Another Cygpath Patch)
The major change that this make is setting the UNIXy output to be the
default. This was already true for the -ADHPSW options. If this is a
bad idea for some reason unknown to me, there were only 3 lines changed
to do it. (Everything still works with --unix, of course.)
Also, thinking about this new --type TYPE option, I was wondering what
exactly the 'dos' type did. So I look at the code:
- if (strcasecmp (windows_format_arg, "mixed") == 0)
- mixed_flag = 1;
- else if (strcasecmp (windows_format_arg, "dos") == 0)
- /* nothing */;
- else
- usage (stderr, 1);
- break;
Ah! It does /* nothing */, I see. So also this patch REMOVES the
-t, --type option and changes it to -m, --mixed instead. This is hopefully
easier to understand.
Also there is gratuitous alphabetizing of the longopts and options, and
various cleanup in usage().
ChangeLog:
2002-06-18 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* cygpath.cc (usage): Clean up usage output (more).
(main): Change --type option to --mixed; remove '/* nothing */'.
Make UNIXy output default.
-------------- next part --------------
--- cygpath.cc-orig Thu Jun 20 17:28:00 2002
+++ cygpath.cc Thu Jun 20 18:06:23 2002
@@ -30,28 +30,27 @@ static int path_flag, unix_flag, windows
static int shortname_flag, longname_flag;
static int ignore_flag, allusers_flag, output_flag;
static int mixed_flag;
-static const char *windows_format_arg;
static struct option long_options[] = {
- {(char *) "help", no_argument, NULL, 'h'},
{(char *) "absolute", no_argument, NULL, 'a'},
+ {(char *) "close", required_argument, (int *) &close_arg, 'c'},
+ {(char *) "file", required_argument, (int *) &file_arg, 'f'},
+ {(char *) "help", no_argument, NULL, 'h'},
+ {(char *) "ignore", no_argument, NULL, 'i'},
+ {(char *) "long-name", no_argument, NULL, 'l'},
+ {(char *) "mixed", no_argument, NULL, 'm'},
{(char *) "option", no_argument, NULL, 'o'},
{(char *) "path", no_argument, NULL, 'p'},
- {(char *) "close", required_argument, (int *) &close_arg, 'c'},
+ {(char *) "short-name", no_argument, NULL, 's'},
{(char *) "unix", no_argument, NULL, 'u'},
- {(char *) "file", required_argument, (int *) &file_arg, 'f'},
{(char *) "version", no_argument, NULL, 'v'},
{(char *) "windows", no_argument, NULL, 'w'},
- {(char *) "short-name", no_argument, NULL, 's'},
- {(char *) "long-name", no_argument, NULL, 'l'},
- {(char *) "windir", no_argument, NULL, 'W'},
- {(char *) "sysdir", no_argument, NULL, 'S'},
- {(char *) "ignore", no_argument, NULL, 'i'},
{(char *) "allusers", no_argument, NULL, 'A'},
{(char *) "desktop", no_argument, NULL, 'D'},
- {(char *) "smprograms", no_argument, NULL, 'P'},
- {(char *) "type", required_argument, (int *) &windows_format_arg, 't'},
{(char *) "homeroot", no_argument, NULL, 'H'},
+ {(char *) "smprograms", no_argument, NULL, 'P'},
+ {(char *) "sysdir", no_argument, NULL, 'S'},
+ {(char *) "windir", no_argument, NULL, 'W'},
{0, no_argument, 0, 0}
};
@@ -60,32 +59,31 @@ usage (FILE * stream, int status)
{
if (!ignore_flag || !status)
fprintf (stream, "\
-Usage: %s (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME\n\n\
- %s [-ADHPSW] \n\n\
-Output type options (required):\n\
- -u|--unix print Unix form of NAME (default)\n\
- -w|--windows print Windows form of NAME \n\n\
- -t|--type print Windows form of NAME with TYPE one of\n\
- dos drive letter with backslashes (C:\\WINNT)\n\
- mixed drive letter with regular slashes (C:/WINNT)\n\
+Usage: %s (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME\n\
+ %s [-ADHPSW] \n\
+Output type options:\n\
+ -u, --unix (default) print Unix form of NAME (/cygdrive/c/winnt)\n\
+ -w, --windows print Windows form of NAME (C:\\WINNT)\n\
+ -m, --mixed like --windows, but with regular slashes (C:/WINNT)\n\
Path conversion options:\n\
- -a|--absolute output absolute path\n\
- -c|--close HANDLE close HANDLE (for use in captured process)\n\
- -f|--file FILE read FILE for input; use - to read from STDIN\n\
- -i|--ignore ignore missing argument\n\
- -l|--long-name print Windows long form of NAME (with -w only)\n\
- -p|--path NAME is a PATH list (i.e., '/bin:/usr/bin')\n\
- -s|--short-name print Windows short form of NAME (with -w only)\n\
+ -a, --absolute output absolute path\n\
+ -l, --long-name print Windows long form of NAME (with -w only)\n\
+ -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin')\n\
+ -s, --short-name print Windows short form of NAME (with -w only)\n\
System information output:\n\
- -A|--allusers use `All Users' instead of current user for -D, -P\n\
- -D|--desktop output `Desktop' directory and exit\n\
- -H|--homeroot output `Profiles' directory (home root) and exit\n\
- -P|--smprograms output Start Menu `Programs' directory and exit\n\
- -S|--sysdir output system directory and exit\n\
- -W|--windir output `Windows' directory and exit\n\n\
+ -A, --allusers use `All Users' instead of current user for -D, -P\n\
+ -D, --desktop output `Desktop' directory and exit\n\
+ -H, --homeroot output `Profiles' directory (home root) and exit\n\
+ -P, --smprograms output Start Menu `Programs' directory and exit\n\
+ -S, --sysdir output system directory and exit\n\
+ -W, --windir output `Windows' directory and exit\n\
Other options:\n\
- -h|--help output usage information and exit\n\
- -v|--version output version information and exit\n\
+ -f, --file FILE read FILE for input; use - to read from STDIN\n\
+ -o, --option read options from FILE as well (for use with --file)\n\
+ -c, --close HANDLE close HANDLE (for use in captured process)\n\
+ -i, --ignore ignore missing argument\n\
+ -h, --help output usage information and exit\n\
+ -v, --version output version information and exit\
", prog_name, prog_name);
exit (ignore_flag ? 0 : status);
}
@@ -543,7 +541,7 @@ main (int argc, char **argv)
prog_name++;
path_flag = 0;
- unix_flag = 0;
+ unix_flag = 1;
windows_flag = 0;
shortname_flag = 0;
longname_flag = 0;
@@ -552,7 +550,7 @@ main (int argc, char **argv)
options_from_file_flag = 0;
allusers_flag = 0;
output_flag = 0;
- while ((c = getopt_long (argc, argv, (char *) "hac:f:opslSuvwt:WiDPAH",
+ while ((c = getopt_long (argc, argv, (char *) "ac:f:hilmopsuvwADHPSW",
long_options, (int *) NULL)) != EOF)
{
switch (c)
@@ -578,15 +576,24 @@ main (int argc, char **argv)
break;
case 'u':
- if (unix_flag || windows_flag)
+ if (windows_flag || mixed_flag)
usage (stderr, 1);
unix_flag = 1;
break;
case 'w':
- if (unix_flag || windows_flag)
+ if (windows_flag || mixed_flag)
+ usage (stderr, 1);
+ unix_flag = 0;
+ windows_flag = 1;
+ break;
+
+ case 'm':
+ if (windows_flag)
usage (stderr, 1);
+ unix_flag = 0;
windows_flag = 1;
+ mixed_flag = 1;
break;
case 'l':
@@ -601,21 +608,6 @@ main (int argc, char **argv)
shortname_flag = 1;
break;
- case 't':
- if (unix_flag || (optarg == NULL))
- usage (stderr, 1);
-
- windows_flag = 1;
- windows_format_arg = (*optarg == '=') ? (optarg + 1) : (optarg);
-
- if (strcasecmp (windows_format_arg, "mixed") == 0)
- mixed_flag = 1;
- else if (strcasecmp (windows_format_arg, "dos") == 0)
- /* nothing */;
- else
- usage (stderr, 1);
- break;
-
case 'A':
allusers_flag = 1;
break;
@@ -652,7 +644,7 @@ main (int argc, char **argv)
if (options_from_file_flag && !file_arg)
usage (stderr, 1);
- if (!output_flag && !unix_flag && !windows_flag && !options_from_file_flag)
+ if (!unix_flag && !windows_flag && !mixed_flag && !options_from_file_flag)
usage (stderr, 1);
if (!file_arg)
@@ -714,6 +706,10 @@ main (int argc, char **argv)
shortname_flag = 0;
longname_flag = 1;
break;
+ case 'm':
+ unix_flag = 0;
+ windows_flag = 1;
+ mixed_flag = 1;
case 'w':
unix_flag = 0;
windows_flag = 1;
More information about the Cygwin-patches
mailing list