mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
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;
|
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).
|
* 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_type = type;
|
||||||
*ret_skipped = 1;
|
|
||||||
|
|
||||||
|
if (ret_skipped != NULL)
|
||||||
|
*ret_skipped = 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +399,8 @@ vfs_parse_fileperms (const char *s, size_t * ret_skipped, mode_t * ret_perms)
|
|||||||
/* ACLs on Solaris, HP-UX and others */
|
/* ACLs on Solaris, HP-UX and others */
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
*ret_skipped = p - s;
|
if (ret_skipped != NULL)
|
||||||
|
*ret_skipped = p - s;
|
||||||
*ret_perms = perms;
|
*ret_perms = perms;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -509,6 +490,27 @@ vfs_parse_raw_filemode (const char *s, size_t * ret_skipped, mode_t * ret_mode)
|
|||||||
return TRUE;
|
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 */
|
/** This function parses from idx in the columns[] array */
|
||||||
|
|
||||||
@ -568,7 +570,7 @@ vfs_parse_filedate (int idx, time_t * t)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Month name */
|
/* Month name */
|
||||||
if (is_month (p, &tim))
|
if (vfs_parse_month (p, &tim))
|
||||||
{
|
{
|
||||||
/* And we expect, it followed by day number */
|
/* And we expect, it followed by day number */
|
||||||
if (!is_num (idx))
|
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 */
|
/* Mhm, the ls -lg did not produce a group field */
|
||||||
for (idx = 3; idx <= 5; idx++)
|
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]))
|
|| is_dos_date (columns[idx]) || is_localized_month (columns[idx]))
|
||||||
break;
|
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,
|
gboolean vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linkname,
|
||||||
size_t * filename_pos);
|
size_t * filename_pos);
|
||||||
size_t vfs_parse_ls_lga_get_final_spaces (void);
|
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);
|
int vfs_parse_filedate (int idx, time_t * t);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user