Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-12-26 20:46:12 +0300
committerChristopher Faylor <me@cgf.cx>2001-12-26 20:46:12 +0300
commitc02e32c9bd099994f6042d079051d1aa574f619e (patch)
tree2600dd3e1e88f0f4d320162434bf47d78133e4f9
parent028ee5466b3dcefe5bc15d6a3d66fe89a3d91aa0 (diff)
* cygpath.cc (doit): Detect and warn about an empty path. Detect and warn
about errors converting a path. (main): Set prog_name correctly -- don't leave an extra slash or backslash at the beginning of it.
-rw-r--r--winsup/utils/ChangeLog7
-rw-r--r--winsup/utils/cygpath.cc32
2 files changed, 32 insertions, 7 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 186a98dc4..0bfbce07e 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,10 @@
+2001-12-26 Jonathan Kamens <jik@curl.com>
+
+ * cygpath.cc (doit): Detect and warn about an empty path. Detect and
+ warn about errors converting a path.
+ (main): Set prog_name correctly -- don't leave an extra slash or
+ backslash at the beginning of it.
+
Fri Dec 14 14:04:37 2001 Jason Tishler <jason@tishler.net>
* mkpasswd.c (enum_users): Change to unconditionally use
diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc
index bac8b42db..2ba54a185 100644
--- a/winsup/utils/cygpath.cc
+++ b/winsup/utils/cygpath.cc
@@ -141,6 +141,8 @@ doit (char *filename)
{
char *buf;
size_t len;
+ int retval;
+ int (*conv_func)(const char *, char *);
if (path_flag)
{
@@ -155,7 +157,14 @@ doit (char *filename)
}
if (! path_flag)
- len = strlen (filename) + 100;
+ {
+ len = strlen (filename) + 100;
+ if (len == 100)
+ {
+ fprintf(stderr, "%s: can't convert empty path\n", prog_name);
+ exit (1);
+ }
+ }
else
{
if (unix_flag)
@@ -188,13 +197,20 @@ doit (char *filename)
else
{
if (unix_flag)
- (absolute_flag ? cygwin_conv_to_full_posix_path : cygwin_conv_to_posix_path) (filename, buf);
+ conv_func = (absolute_flag ? cygwin_conv_to_full_posix_path :
+ cygwin_conv_to_posix_path);
else
- {
- (absolute_flag ? cygwin_conv_to_full_win32_path : cygwin_conv_to_win32_path) (filename, buf);
- if (shortname_flag)
- buf = get_short_name (buf);
- }
+ conv_func = (absolute_flag ? cygwin_conv_to_full_win32_path :
+ cygwin_conv_to_win32_path);
+ retval = conv_func (filename, buf);
+ if (retval < 0)
+ {
+ fprintf (stderr, "%s: error converting \"%s\"\n",
+ prog_name, filename);
+ exit (1);
+ }
+ if (!unix_flag && shortname_flag)
+ buf = get_short_name (buf);
}
puts (buf);
@@ -214,6 +230,8 @@ main (int argc, char **argv)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
+ else
+ prog_name++;
path_flag = 0;
unix_flag = 0;