mirror of https://github.com/MidnightCommander/mc
Ticket #2841: ftpfs: new filelist parser.
Initial step: minor refactoring: * (vfs_parse_month): rename from is_month() and make global. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
32c28026f8
commit
02989d4d84
|
@ -114,27 +114,6 @@ is_week (const char *str, struct tm *tim)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
is_month (const char *str, struct tm *tim)
|
||||
{
|
||||
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
const char *pos;
|
||||
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
pos = strstr (month, str);
|
||||
if (pos == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (tim != NULL)
|
||||
tim->tm_mon = (pos - month) / 3;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Check for possible locale's abbreviated month name (Jan..Dec).
|
||||
|
@ -282,8 +261,9 @@ vfs_parse_filetype (const char *s, size_t * ret_skipped, mode_t * ret_type)
|
|||
}
|
||||
|
||||
*ret_type = type;
|
||||
*ret_skipped = 1;
|
||||
|
||||
if (ret_skipped != NULL)
|
||||
*ret_skipped = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -419,6 +399,7 @@ vfs_parse_fileperms (const char *s, size_t * ret_skipped, mode_t * ret_perms)
|
|||
/* ACLs on Solaris, HP-UX and others */
|
||||
p++;
|
||||
|
||||
if (ret_skipped != NULL)
|
||||
*ret_skipped = p - s;
|
||||
*ret_perms = perms;
|
||||
|
||||
|
@ -509,6 +490,27 @@ vfs_parse_raw_filemode (const char *s, size_t * ret_skipped, mode_t * ret_mode)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
vfs_parse_month (const char *str, struct tm * tim)
|
||||
{
|
||||
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
const char *pos;
|
||||
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
pos = strstr (month, str);
|
||||
if (pos == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (tim != NULL)
|
||||
tim->tm_mon = (pos - month) / 3;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** This function parses from idx in the columns[] array */
|
||||
|
||||
|
@ -568,7 +570,7 @@ vfs_parse_filedate (int idx, time_t * t)
|
|||
*/
|
||||
|
||||
/* Month name */
|
||||
if (is_month (p, &tim))
|
||||
if (vfs_parse_month (p, &tim))
|
||||
{
|
||||
/* And we expect, it followed by day number */
|
||||
if (!is_num (idx))
|
||||
|
@ -732,7 +734,7 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna
|
|||
|
||||
/* 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)
|
||||
if (vfs_parse_month (columns[idx], NULL) || is_week (columns[idx], NULL)
|
||||
|| is_dos_date (columns[idx]) || is_localized_month (columns[idx]))
|
||||
break;
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ void vfs_parse_ls_lga_init (void);
|
|||
gboolean vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linkname,
|
||||
size_t * filename_pos);
|
||||
size_t vfs_parse_ls_lga_get_final_spaces (void);
|
||||
gboolean vfs_parse_month (const char *str, struct tm *tim);
|
||||
int vfs_parse_filedate (int idx, time_t * t);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue