int i = 0;
char const *s = *str;
- if (isdigit(*s)) {
+ if (isdigit((unsigned char)*s)) {
i = atoi(s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
++s;
*str = s;
}
static int
numerics(char const * str)
{
- int rc = isdigit(*str);
+ int rc = isdigit((unsigned char)*str);
if (rc)
- while (isdigit(*str) || *str == 'x')
+ while (isdigit((unsigned char)*str) || *str == 'x')
++str;
return rc && !*str;
}
mystr[len] = '\0';
l = strlen(strncpy(mystr, *str, len));
for (i = 0; i < l; i++)
- mystr[i] = (char) tolower(mystr[i]);
+ mystr[i] = (char) tolower((unsigned char)mystr[i]);
for (i = 0; arr[i] && strcmp(mystr, arr[i]) != 0; i++);
if (arr[i] == NULL)
i = -1;
else { /* Skip past it */
- while (**str && isalpha(**str))
+ while (**str && isalpha((unsigned char)**str))
++(*str);
/* And any following whitespace */
- while (**str && (**str == ',' || isspace(**str)))
+ while (**str && (**str == ',' || isspace((unsigned char)**str)))
++(*str);
} /* Return index */
return i;
while (*str && strchr(nchrs + 10, *str) != NULL)
++str;
- if (isdigit(*str)) {
+ if (isdigit((unsigned char)*str)) {
*year = atoi(str);
if (*year > 1900)
*year -= 1900;
if (dt == 0)
dt = time(NULL);
- while (*str && isspace(*str))
+ while (*str && isspace((unsigned char)*str))
++str;
if (numerics(str)) {
* Skip past any weekday prefix
*/
weekday(&str);
- str = strncpy(tmp, str, sizeof tmp - 1);
- tmp[sizeof tmp - 1] = '\0';
+ strlcpy(tmp, str, sizeof(tmp));
+ str = tmp;
T = localtime(&dt);
/*
else {
int j = 1;
- while (q[j] && isupper(q[j]))
+ while (q[j] && isupper((unsigned char)q[j]))
++j;
if (q[j] == '\0')
*q = '\0';
if ((q = strpbrk(p, " \t")) != NULL) { /* Time first? */
int l = q - str;
- strncpy(timestr, str, l);
- timestr[l] = '\0';
- strncpy(datestr, q + 1, sizeof datestr);
- datestr[sizeof datestr - 1] = '\0';
+ strlcpy(timestr, str, l + 1);
+ strlcpy(datestr, q + 1, sizeof(datestr));
parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec);
parse_datesub(datestr, &T->tm_mday, &T->tm_mon, &T->tm_year);
} else if ((q = strrchr(tmp, ' ')) != NULL) { /* Time last */
int l = q - tmp;
- strncpy(timestr, q + 1, sizeof timestr);
- timestr[sizeof timestr - 1] = '\0';
- strncpy(datestr, tmp, l);
- datestr[l] = '\0';
+ strlcpy(timestr, q + 1, sizeof(timestr));
+ strlcpy(datestr, tmp, l + 1);
} else /* Bail out */
return dt;
parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec);