]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/psdate.c
Let the afterinstall target ignore failures from running chflags. This
[pw-darwin.git] / pw / psdate.c
index f8b1fce894b455565fece97d1594213961aadfaa..3f4c0105b75b91a20f1d4071d985b893eea63612 100644 (file)
@@ -43,9 +43,9 @@ a2i(char const ** str)
        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;
        }
@@ -55,10 +55,10 @@ a2i(char const ** str)
 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;
 }
@@ -72,15 +72,15 @@ aindex(char const * arr[], char const ** str, int len)
        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;
@@ -143,7 +143,7 @@ parse_datesub(char const * str, int *day, int *mon, int *year)
 
        while (*str && strchr(nchrs + 10, *str) != NULL)
                ++str;
-       if (isdigit(*str)) {
+       if (isdigit((unsigned char)*str)) {
                *year = atoi(str);
                if (*year > 1900)
                        *year -= 1900;
@@ -176,7 +176,7 @@ parse_date(time_t dt, char const * str)
        if (dt == 0)
                dt = time(NULL);
 
-       while (*str && isspace(*str))
+       while (*str && isspace((unsigned char)*str))
                ++str;
 
        if (numerics(str)) {
@@ -234,8 +234,8 @@ parse_date(time_t dt, char const * 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);
 
                /*
@@ -247,7 +247,7 @@ parse_date(time_t dt, char const * str)
                        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';
@@ -275,19 +275,15 @@ parse_date(time_t dt, char const * str)
                        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);