Re: One more corner case in `ls -lga` parsing and big minors in Solaris



Sorry, missed patch and sample lslR file.

-- 
Regards,
Andrew V. Samoilov.
vfs/ChangeLog:

	* utilvfs.c (vfs_parse_ls_lga): Handle device without comma
	between major and minor.  Use "%s" pattern in message().

--- vfs/utilvfs.c	Fri Dec 26 15:55:10 2003
+++ vfs/utilvfs.c	Fri Dec 26 16:29:04 2003
@@ -748,12 +748,17 @@ vfs_parse_ls_lga (const char *p, struct 
     if (S_ISCHR (s->st_mode) || S_ISBLK (s->st_mode)) {
 	int maj, min;
 
-	if (!is_num (idx2) || sscanf (columns[idx2], " %d,", &maj) != 1)
-	    goto error;
-
-	if (!is_num (++idx2) || sscanf (columns[idx2], " %d", &min) != 1)
-	    goto error;
+	/* Corner case: there is no comma between maj & min */
+	if (!is_num (idx2) && idx2 == 2) {
+	    if (!is_num (++idx2) || sscanf (columns[idx2], " %d,%d", &min, &min) != 2)
+		goto error;
+	} else {
+	    if (!is_num (idx2) || sscanf (columns[idx2], " %d,", &maj) != 1)
+		goto error;
 
+	    if (!is_num (++idx2) || sscanf (columns[idx2], " %d", &min) != 1)
+		goto error;
+	}
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
 	s->st_rdev = ((maj & 0xff) << 8) | (min & 0xffff00ff);
 #endif
@@ -833,10 +838,10 @@ vfs_parse_ls_lga (const char *p, struct 
 	static int errorcount = 0;
 
 	if (++errorcount < 5) {
-	    message (1, _("Cannot parse:"),
+	    message (1, _("Cannot parse:"), "%s",
 		     (p_copy && *p_copy) ? p_copy : line);
 	} else if (errorcount == 5)
-	    message (1, _("Error"),
+	    message (1, MSG_ERROR,
 		     _("More parsing errors will be ignored."));
     }
 

Attachment: lslR
Description: Binary data



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