diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-01-07 12:08:11 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-01-07 12:08:11 +0000 |
commit | 6004370ba19f3191c69fd5b514b079791a7751e1 (patch) | |
tree | dc04fb70fad9da66e6497f3884beff0411d5f508 /winsup/utils | |
parent | 8c7d5f45eefe091659592f4f754cd6a7b9db3246 (diff) | |
download | cygnal-6004370ba19f3191c69fd5b514b079791a7751e1.tar.gz cygnal-6004370ba19f3191c69fd5b514b079791a7751e1.tar.bz2 cygnal-6004370ba19f3191c69fd5b514b079791a7751e1.zip |
* cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale.
Revert usage of argz functions when reading input from file and
simplify option usage. Allow only one option argument and use
the rest as filename argument to allow spaces in filenames. Restrict
processing special folder type options to one line.
Diffstat (limited to 'winsup/utils')
-rw-r--r-- | winsup/utils/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/utils/cygpath.cc | 46 |
2 files changed, 28 insertions, 26 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 727817b3b..e3bab28ab 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,11 @@ +2010-01-07 Corinna Vinschen <corinna@vinschen.de> + + * cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale. + Revert usage of argz functions when reading input from file and + simplify option usage. Allow only one option argument and use + the rest as filename argument to allow spaces in filenames. Restrict + processing special folder type options to one line. + 2009-12-17 Christopher Faylor <me+cygwin@cgf.cx> * ps.cc (main): Return 0 if pid found. diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc index 83d4e3fd3..3f6e5a9cc 100644 --- a/winsup/utils/cygpath.cc +++ b/winsup/utils/cygpath.cc @@ -1,6 +1,6 @@ /* cygpath.cc -- convert pathnames between Windows and Unix format Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. + 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. This file is part of Cygwin. @@ -16,7 +16,6 @@ details. */ #include <wchar.h> #include <locale.h> #include <stdlib.h> -#include <argz.h> #include <limits.h> #include <getopt.h> #include <windows.h> @@ -1029,10 +1028,7 @@ main (int argc, char **argv) { int o; - /* Use locale from environment. If not set or set to "C", use UTF-8. */ setlocale (LC_CTYPE, ""); - if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) - setlocale (LC_CTYPE, "en_US.UTF-8"); prog_name = strrchr (argv[0], '/'); if (!prog_name) prog_name = strrchr (argv[0], '\\'); @@ -1070,35 +1066,33 @@ main (int argc, char **argv) while (fgets (buf, sizeof (buf), fp)) { - size_t azl = 0; - int ac; - char *az, **av; + int ac = 0; + char *av[4] = { NULL, NULL, NULL, NULL }; char *p = strchr (buf, '\n'); if (p) *p = '\0'; - if (argz_create_sep (buf, ' ', &az, &azl)) + p = buf; + av[ac++] = prog_name; + av[ac++] = p; + if (options_from_file_flag && *p == '-') { - perror ("cygpath"); - exit (1); + while (*p && !isspace (*p)) + ++p; + if (*p) + { + *p++ = '\0'; + while (*p && isspace (*p)) + ++p; + av[ac++] = p; + } + o = do_options (ac, av, 1); } - if (!az) - continue; - ac = argz_count (az, azl) + 1; - av = (char **) malloc ((ac + 1) * sizeof (char *)); - if (!av) + else { - perror ("cygpath"); - exit (1); + output_flag = 0; + optind = 1; } - av[0] = prog_name; - argz_extract (az, azl, av + 1); - if (options_from_file_flag) - o = do_options (ac, av, 1); - else - optind = 1; action (ac, av, o); - free (az); - free (av); } } exit (0); |