diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-07 20:35:43 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-01-07 20:55:05 -0600 |
commit | 4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c (patch) | |
tree | 164ca843d1450f9b3534760fb670adc39cfe8e08 /lib/libalpm/be_local.c | |
parent | d288240426551e9d58a708e28fe0217e56d017d6 (diff) | |
download | pacman-4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c.tar.xz |
Refactor old date parsing into single method
We've managed to duplicate this four times at this point, so make it a
method in util.c instead.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r-- | lib/libalpm/be_local.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 4c8e0e9c..109edf49 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -28,7 +28,6 @@ #include <stdint.h> /* intmax_t */ #include <sys/stat.h> #include <dirent.h> -#include <ctype.h> #include <time.h> #include <limits.h> /* PATH_MAX */ #include <locale.h> /* setlocale */ @@ -570,33 +569,13 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) goto error; } _alpm_strtrim(line); - - char first = tolower((unsigned char)line[0]); - if(first > 'a' && first < 'z') { - struct tm tmp_tm = {0}; /* initialize to null in case of failure */ - setlocale(LC_TIME, "C"); - strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); - info->builddate = mktime(&tmp_tm); - setlocale(LC_TIME, ""); - } else { - info->builddate = atol(line); - } + info->builddate = _alpm_parsedate(line); } else if(strcmp(line, "%INSTALLDATE%") == 0) { if(fgets(line, sizeof(line), fp) == NULL) { goto error; } _alpm_strtrim(line); - - char first = tolower((unsigned char)line[0]); - if(first > 'a' && first < 'z') { - struct tm tmp_tm = {0}; /* initialize to null in case of failure */ - setlocale(LC_TIME, "C"); - strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); - info->installdate = mktime(&tmp_tm); - setlocale(LC_TIME, ""); - } else { - info->installdate = atol(line); - } + info->installdate = _alpm_parsedate(line); } else if(strcmp(line, "%PACKAGER%") == 0) { if(fgets(line, sizeof(line), fp) == NULL) { goto error; |