]> sourceware.org Git - newlib-cygwin.git/commitdiff
* cygpath.cc (doit): Detect and warn about an empty path. Detect and warn
authorChristopher Faylor <me@cgf.cx>
Wed, 26 Dec 2001 17:46:12 +0000 (17:46 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 26 Dec 2001 17:46:12 +0000 (17:46 +0000)
about errors converting a path.
(main): Set prog_name correctly -- don't leave an extra slash or backslash at
the beginning of it.

winsup/utils/ChangeLog
winsup/utils/cygpath.cc

index 186a98dc4700fa617e98b04a477c0b5150c07f00..0bfbce07ebc42accd7559c024b93303b1af48770 100644 (file)
@@ -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
index bac8b42db8c1aaba19bda3483287fc6655413046..2ba54a18536afbc0f24e9ebe9ddb10d2a1ff59e3 100644 (file)
@@ -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;
This page took 0.035144 seconds and 5 git commands to generate.