Ilya Zakharevich on Fri, 9 Feb 2001 00:39:45 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PATCH] DOSHISH paths with \r etc


\r name would not allow : or \ in name.

Enjoy,
Ilya

Index: src/gp/gp.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/gp/gp.c,v
retrieving revision 1.67
diff -p -u -r1.67 gp.c
--- src/gp/gp.c	2001/02/08 18:02:39	1.67
+++ src/gp/gp.c	2001/02/09 05:24:02
@@ -177,12 +177,16 @@ gp_preinit(int force)
   for (i=0; i<c_LAST; i++) gp_colors[i] = c_NONE;
 }
 
-#define GET_SEP_SIZE 128
+#ifdef MAXPATHLEN
+#  define GET_SEP_SIZE MAXPATHLEN
+#else
+#  define GET_SEP_SIZE 128
+#endif
 #define separe(c)  ((c)==';' || (c)==':')
 
 /* Return all chars, up to next separator */
 static char*
-get_sep(char *t)
+get_sep0(char *t, int colon)
 {
   static char buf[GET_SEP_SIZE], *lim = buf + GET_SEP_SIZE-1;
   char *s = buf;
@@ -193,17 +197,32 @@ get_sep(char *t)
     switch(*s++ = *t++)
     {
       case '"':
-        if (outer || s[-2] != '\\') outer = !outer;
+        if (outer || (s >= buf+2 && s[-2] != '\\')) outer = !outer;
         break;
       case '\0':
         return buf;
-      default:
-        if (outer && separe(*t)) { *s=0; return buf; }
+      case ';':
+	if (outer) { s[-1]=0; return buf; } break;
+      case ':':
+        if (outer && colon) { s[-1]=0; return buf; } break;
     }
     if (s == lim) err(talker,"buffer overflow in get_sep");
   }
 }
 
+static char*
+get_sep(char *t)
+{
+    return get_sep0(t,1);
+}
+
+static char*
+get_sep_colon_ok(char *t)
+{
+    return get_sep0(t,0);
+}
+
+
 /* as above, t must be writeable, return 1 if we modified t */
 static int
 get_sep2(char *t)
@@ -1746,7 +1765,7 @@ escape(char *tch)
         case 'w':
 	{
 	  GEN g[2]; g[0] = x; g[1] = NULL;
-	  s = get_sep(s); if (!*s) s = current_logfile;
+	  s = get_sep_colon_ok(s); if (!*s) s = current_logfile;
 	  write0(s, g, f_RAW); return;
 	}
       }
@@ -1769,7 +1788,7 @@ escape(char *tch)
       break;
     case 'h': print_hash_list(s); break;
     case 'l':
-      s = get_sep(s);
+      s = get_sep_colon_ok(s);
       if (*s)
       {
         sd_logfile(s,d_ACKNOWLEDGE);
@@ -1786,7 +1805,7 @@ escape(char *tch)
       }
       break;
     case 'q': gp_quit(); break;
-    case 'r': switchin(get_sep(s)); break;
+    case 'r': switchin(get_sep_colon_ok(s)); break;
     case 's': etatpile(0); break;
     case 't': gentypes(); break;
     case 'u':
Index: src/language/es.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/language/es.c,v
retrieving revision 1.46
diff -p -u -r1.46 es.c
--- src/language/es.c	2001/02/06 14:56:52	1.46
+++ src/language/es.c	2001/02/09 05:24:15
@@ -2445,7 +2445,7 @@ switchin(char *name0)
     name = pari_strdup(name0);
   }
   /* if name contains '/',  don't use dir_list */
-  s=name; while (*s && *s != '/') s++;
+  s=name; while (*s && *s != '/' && *s != '\\') s++;
   if (*s) { if (try_name(name)) return; }
   else
   {