X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fparse-duration.c;h=0a8c4ada8408e187952e636b4441409cd36f4669;hb=5ea8bedd0c6a7a8f29dcff301d126b58cc123ea8;hp=8952a8fae393e1db92a119615b55b7d2cb0dbd21;hpb=aeb898d88cddc17cefc7738940b4917e9ee27933;p=gnulib.git diff --git a/lib/parse-duration.c b/lib/parse-duration.c index 8952a8fae..0a8c4ada8 100644 --- a/lib/parse-duration.c +++ b/lib/parse-duration.c @@ -1,5 +1,5 @@ /* Parse a time duration and return a seconds count - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. Written by Bruce Korb , 2008. This program is free software: you can redistribute it and/or modify @@ -26,7 +26,6 @@ #include #include #include -#include "xalloc.h" #ifndef NUL #define NUL '\0' @@ -381,7 +380,7 @@ parse_time (cch_t * pz) } /* Returns a substring of the given string, with spaces at the beginning and at - the end destructively removed. */ + the end destructively removed, per SNOBOL. */ static char * trim (char * pz) { @@ -406,13 +405,20 @@ trim (char * pz) static time_t parse_period (cch_t * in_pz) { - char * pz = xstrdup (in_pz); - char * pT = strchr (pz, 'T'); + char * pT; char * ps; + char * pz = strdup (in_pz); void * fptr = pz; time_t res = 0; - if (pT != NUL) + if (pz == NULL) + { + errno = ENOMEM; + return BAD_TIME; + } + + pT = strchr (pz, 'T'); + if (pT != NULL) { *(pT++) = NUL; pz = trim (pz);