Quellcode durchsuchen

libgis: sync G_chop() to trunk

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64071 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz vor 10 Jahren
Ursprung
Commit
d478d2cb7c
1 geänderte Dateien mit 7 neuen und 5 gelöschten Zeilen
  1. 7 5
      lib/gis/strings.c

+ 7 - 5
lib/gis/strings.c

@@ -295,15 +295,17 @@ char *G_chop(char *line)
 	return (line);
     }
 
-    for (t = line; *t; t++)	/* go to end */
+    for (t = f; *t; t++)	/* go from first non white-space char to end */
 	;
     while (isspace(*--t)) ;
     *++t = '\0';		/* remove trailing white-spaces */
 
-    t = line;
-    while (*f)			/* copy */
-	*t++ = *f++;
-    *t = '\0';
+    if (f != line) {
+	t = line;
+	while (*f)		/* leading white spaces, shift */
+	    *t++ = *f++;
+	*t = '\0';
+    }
 
     return (line);
 }