Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > f0a7db5ce43a3864df69d9148b858895 > files > 4

coreutils-8.25-3.1.mga6.src.rpm

--- coreutils-8.2/src/df.c.space	2009-09-29 15:27:54.000000000 +0200
+++ coreutils-8.2/src/df.c	2010-01-03 06:56:41.000000000 +0100
@@ -298,6 +298,35 @@
     *dest = -*dest;
 }
 
+/* Since the values in a line are separated by spaces, a name cannot
+ * contain a space.  Therefore some programs encode spaces in names
+ * by the strings "\040".  We undo the encoding when reading an entry.
+ * The decoding happens in place.  */
+static char * decode_name (char *buf)
+{
+    char *rp = buf;
+    char *wp = buf;
+
+    do
+	if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '4' && rp[3] == '0') {
+	    /* \040 is a SPACE.  */
+	    *wp++ = ' ';
+	    rp += 3;
+	} else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2') {
+	    /* \012 is a TAB.  */
+	    *wp++ = '\t';
+	    rp += 3;
+	} else if (rp[0] == '\\' && rp[1] == '\\') {
+	    /* We have to escape \\ to be able to represent all characters.  */
+	    *wp++ = '\\';
+	    rp += 1;
+	} else
+	    *wp++ = *rp;
+    while (*rp++ != '\0');
+
+    return buf;
+}
+
 /* Display a space listing for the disk device with absolute file name DISK.
    If MOUNT_POINT is non-NULL, it is the name of the root of the
    file system on DISK.
@@ -346,7 +375,7 @@
      It would be better to report on the unmounted file system,
      but statfs doesn't do that on most systems.  */
   if (!stat_file)
-    stat_file = mount_point ? mount_point : disk;
+    stat_file = mount_point ? decode_name((char *) mount_point) : disk;
 
   if (force_fsu)
     fsu = *force_fsu;
@@ -509,6 +538,7 @@
       else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0)
         mount_point += 8;
 #endif
+      /* at this point mount_point should ba already decoded */
       printf (" %s", mount_point);
     }
   putchar ('\n');