Am Montag, den 17.10.2005, 16:18 +0200 schrieb Alexander Larsson: > On Fri, 2005-10-14 at 22:51 +0200, Christian Neumair wrote: > > OK, the GnomeVFS ls -lga parser is seriously hosed by only handling one > > filename at a time, but that's a different topic. > > The attached patch fixes bug 163671 [1]. It makes GnomeVFS pass all > > "test-parse-ls-lga" tests, and even display files named like a time or > > like a year correctly in FTP directories, which was a bit tricky, since > > the FTP module didn't split the string at '\n' characters before passing > > it to the parser. However, since the API suggests that > > gnome_vfs_parse_ls_lga can parse multiple lines ([2]), I've preferred to > > add multiline detection semantics to the latter. > > > > [1] http://bugzilla.gnome.org/show_bug.cgi?id=163671 > > [2] which is - I repeat - NOT true as of writing, it only sets the first > > member of the passed-in filename array > > I'm not sure why you think the filename argument is an array. Its just a > normal out-parameter. Ouch, sorry. Please ignore my stupid comment. > Furthermore, it looks like this is not a full patch. vfs_parse_filedate > adds more arguments, but the calls to it are not changed. That was removed by accident. -- Christian Neumair <chris gnome-de org>
Index: libgnomevfs/gnome-vfs-parse-ls.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-parse-ls.c,v
retrieving revision 1.13
diff -u -p -r1.13 gnome-vfs-parse-ls.c
--- libgnomevfs/gnome-vfs-parse-ls.c 8 May 2005 13:04:05 -0000 1.13
+++ libgnomevfs/gnome-vfs-parse-ls.c 17 Oct 2005 17:21:34 -0000
@@ -360,16 +360,35 @@ vfs_parse_filemode (const char *p)
return res;
}
+static gboolean
+is_last_column (int idx,
+ int num_cols,
+ const char *carbon,
+ int column_ptr[])
+{
+ const char *p;
+
+ if (idx + 1 == num_cols) {
+ return TRUE;
+ }
+
+ p = carbon + column_ptr[idx + 1] - 1;
+ return *p == '\r' || *p == '\n';
+}
+
static int
vfs_parse_filedate (int idx,
char *columns[],
+ int num_cols,
+ const char *carbon,
+ int column_ptr[],
time_t *t)
{ /* This thing parses from idx in columns[] array */
char *p;
struct tm tim;
int d[3];
- int got_year = 0;
+ int got_year = 0, got_time = 0;
int current_mon;
time_t now;
@@ -439,14 +458,20 @@ vfs_parse_filedate (int idx,
}
/* Here we expect to find time and/or year */
-
+
if (is_num (columns[idx])) {
- if (is_time (columns[idx], &tim) || (got_year = is_year (columns[idx], &tim))) {
+ if ((got_time = is_time (columns[idx], &tim)) ||
+ (got_year = is_year (columns[idx], &tim))) {
idx++;
/* This is a special case for ctime () or Mon DD YYYY hh:mm */
if (is_num (columns[idx]) &&
- ((got_year = is_year (columns[idx], &tim)) || is_time (columns[idx], &tim)))
+ !is_last_column (idx, num_cols, carbon, column_ptr) && /* ensure that we don't eat two lines at once,
+ where the first line provides a year-like
+ filename but no year, or a time-like filename
+ but no time */
+ ((!got_year && (got_year = is_year (columns[idx], &tim))) ||
+ (!got_time && (got_time = is_time (columns[idx], &tim)))))
idx++; /* time & year or reverse */
} /* only time or date */
}
@@ -489,6 +514,7 @@ gnome_vfs_parse_ls_lga (const char *p,
return 0;
p_copy = g_strdup (p);
+
if ((i = vfs_parse_filetype (*(p++))) == -1)
goto error;
@@ -592,7 +618,7 @@ gnome_vfs_parse_ls_lga (const char *p,
#endif
}
- idx = vfs_parse_filedate (idx, columns, &s->st_mtime);
+ idx = vfs_parse_filedate (idx, columns, num_cols, p, column_ptr, &s->st_mtime);
if (!idx)
goto error;
/* Use resulting time value */
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil