mirror of https://github.com/MidnightCommander/mc
* vfs.c (is_localized_month): New function for locale's
abbreviated month name as any 3 bytes long string without digits and control characters. (vfs_parse_filedate): Fallback to is_localized_month() if is_month() and is_dos_date() fail and set date to Jan 1 1970. (vfs_parse_ls_lga): Use is_localized_month().
This commit is contained in:
parent
30aeb24388
commit
004ae18d9e
|
@ -1,3 +1,12 @@
|
|||
2003-02-19 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* vfs.c (is_localized_month): New function for locale's
|
||||
abbreviated month name as any 3 bytes long string without digits
|
||||
and control characters.
|
||||
(vfs_parse_filedate): Fallback to is_localized_month() if
|
||||
is_month() and is_dos_date() fail and set date to Jan 1 1970.
|
||||
(vfs_parse_ls_lga): Use is_localized_month().
|
||||
|
||||
2003-01-24 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* smbfs.c (smbfs_nothingisopen): Warning fix for 64-bit systems.
|
||||
|
|
38
vfs/vfs.c
38
vfs/vfs.c
|
@ -1359,7 +1359,7 @@ is_dos_date (const char *str)
|
|||
}
|
||||
|
||||
static int
|
||||
is_week (char *str, struct tm *tim)
|
||||
is_week (const char *str, struct tm *tim)
|
||||
{
|
||||
static const char *week = "SunMonTueWedThuFriSat";
|
||||
char *pos;
|
||||
|
@ -1376,7 +1376,7 @@ is_week (char *str, struct tm *tim)
|
|||
}
|
||||
|
||||
static int
|
||||
is_month (char *str, struct tm *tim)
|
||||
is_month (const char *str, struct tm *tim)
|
||||
{
|
||||
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
char *pos;
|
||||
|
@ -1392,8 +1392,27 @@ is_month (char *str, struct tm *tim)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for possible locale's abbreviated month name (Jan..Dec).
|
||||
* Any 3 bytes long string without digit and control characters.
|
||||
* isalpha() is locale specific, so it cannot be used if current
|
||||
* locale is "C" and ftp server use Cyrillic.
|
||||
* TODO: Punctuation characters also cannot be part of month name.
|
||||
* NB: It is assumed there are no whitespaces in month.
|
||||
*/
|
||||
static int
|
||||
is_time (char *str, struct tm *tim)
|
||||
is_localized_month (const unsigned char *month)
|
||||
{
|
||||
int i = 0;
|
||||
while ((i < 3) && *month && !isdigit (*month) && !iscntrl (*month)) {
|
||||
i++;
|
||||
month++;
|
||||
}
|
||||
return ((i == 3) && (*month == 0));
|
||||
}
|
||||
|
||||
static int
|
||||
is_time (const char *str, struct tm *tim)
|
||||
{
|
||||
char *p, *p2;
|
||||
|
||||
|
@ -1540,6 +1559,7 @@ vfs_parse_filedate (int idx, time_t *t)
|
|||
struct tm tim;
|
||||
int d[3];
|
||||
int got_year = 0;
|
||||
int l10n = 0; /* Locale's abbreviated month name */
|
||||
|
||||
/* Let's setup default time values */
|
||||
tim.tm_year = current_year;
|
||||
|
@ -1599,9 +1619,14 @@ vfs_parse_filedate (int idx, time_t *t)
|
|||
got_year = 1;
|
||||
} else
|
||||
return 0; /* sscanf failed */
|
||||
} else
|
||||
} else {
|
||||
/* Locale's abbreviated month name followed by day number */
|
||||
if (is_localized_month (p) && (is_num (idx++)))
|
||||
l10n = 1;
|
||||
else
|
||||
return 0; /* unsupported format */
|
||||
}
|
||||
}
|
||||
|
||||
/* Here we expect to find time and/or year */
|
||||
|
||||
|
@ -1635,7 +1660,7 @@ vfs_parse_filedate (int idx, time_t *t)
|
|||
|
||||
tim.tm_year--;
|
||||
|
||||
if ((*t = mktime (&tim)) < 0)
|
||||
if (l10n || (*t = mktime (&tim)) < 0)
|
||||
*t = 0;
|
||||
return idx;
|
||||
}
|
||||
|
@ -1692,7 +1717,8 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linknam
|
|||
|
||||
/* Mhm, the ls -lg did not produce a group field */
|
||||
for (idx = 3; idx <= 5; idx++)
|
||||
if (is_month(columns [idx], NULL) || is_week(columns [idx], NULL) || is_dos_date(columns[idx]))
|
||||
if (is_month (columns[idx], NULL) || is_week (columns[idx], NULL)
|
||||
|| is_dos_date (columns[idx]) || is_localized_month (columns[idx]))
|
||||
break;
|
||||
|
||||
if (idx == 6 || (idx == 5 && !S_ISCHR (s->st_mode) && !S_ISBLK (s->st_mode)))
|
||||
|
|
Loading…
Reference in New Issue