* vfs.c (vfs_parse_filemode): Fix parsing for filenames that

begin with a number.
From Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
This commit is contained in:
Pavel Roskin 2002-09-25 05:09:08 +00:00
parent a3f9820755
commit d2417f2096
2 changed files with 70 additions and 58 deletions

View File

@ -1,3 +1,9 @@
2002-09-25 Pavel Roskin <proski@gnu.org>
* vfs.c (vfs_parse_filemode): Fix parsing for filenames that
begin with a number.
From Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
2002-09-24 Andrew V. Samoilov <sav@bcs.zp.ua>
* smbfs.c: Undef USE_NCURSES - no needs to include *curces.h.

View File

@ -1573,9 +1573,10 @@ int vfs_parse_filemode (const char *p)
return res;
}
int vfs_parse_filedate(int idx, time_t *t)
{ /* This thing parses from idx in columns[] array */
/* This function parses from idx in the columns[] array */
int
vfs_parse_filedate (int idx, time_t *t)
{
char *p;
struct tm tim;
int d[3];
@ -1648,16 +1649,22 @@ int vfs_parse_filedate(int idx, time_t *t)
/* Here we expect to find time and/or year */
if (is_num (idx)) {
if(is_time(columns[idx], &tim) || (got_year = is_year(columns[idx], &tim))) {
if (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 (idx) && (columns[idx+1][0]) &&
((got_year |= is_year(columns[idx], &tim)) || is_time(columns[idx], &tim)))
idx++; /* time & year or reverse */
} /* only time or date */
if (is_num (idx) && (columns[idx + 1][0])) {
if (got_year) {
if (is_time (columns[idx], &tim))
idx++; /* time also */
} else {
if ((got_year = is_year (columns[idx], &tim)))
idx++; /* year also */
}
else
}
} /* only time or date */
} else
return 0; /* Nor time or date */
/*
@ -1666,9 +1673,8 @@ int vfs_parse_filedate(int idx, time_t *t)
* This does not check for years before 1900 ... I don't know, how
* to represent them at all
*/
if (!got_year &&
current_mon < 6 && current_mon < tim.tm_mon &&
tim.tm_mon - current_mon >= 6)
if (!got_year && current_mon < 6 && current_mon < tim.tm_mon
&& tim.tm_mon - current_mon >= 6)
tim.tm_year--;