summaryrefslogtreecommitdiffstats
path: root/usr.sbin/zic
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-02-10 03:07:17 +0000
committertedu <tedu@openbsd.org>2015-02-10 03:07:17 +0000
commit4bef7063268f7f785ebac81f107e5f7acf09265e (patch)
tree58bd93f7f4b311926a9107e10a6384a16a7fb5d2 /usr.sbin/zic
parentIn rt_if_track skip rtables that are not in the rdomain of the ifp. (diff)
downloadwireguard-openbsd-4bef7063268f7f785ebac81f107e5f7acf09265e.tar.xz
wireguard-openbsd-4bef7063268f7f785ebac81f107e5f7acf09265e.zip
lowerit -> tolower
ciequal -> strcasecmp itsabbr -> strncasecmp ok krw
Diffstat (limited to 'usr.sbin/zic')
-rw-r--r--usr.sbin/zic/zic.c51
1 files changed, 7 insertions, 44 deletions
diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c
index ff23205027b..03481345519 100644
--- a/usr.sbin/zic/zic.c
+++ b/usr.sbin/zic/zic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zic.c,v 1.11 2015/02/09 23:34:46 tedu Exp $ */
+/* $OpenBSD: zic.c,v 1.12 2015/02/10 03:07:17 tedu Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -94,7 +94,6 @@ static int addtype(long gmtoff, const char * abbr, int isdst,
static void leapadd(zic_t t, int positive, int rolling, int count);
static void adjleap(void);
static void associate(void);
-static int ciequal(const char * ap, const char * bp);
static void convert(long val, char * buf);
static void convert64(zic_t val, char * buf);
static void dolink(const char * fromfield, const char * tofield);
@@ -116,9 +115,7 @@ static int inzcont(char ** fields, int nfields);
static int inzone(char ** fields, int nfields);
static int inzsub(char ** fields, int nfields, int iscont);
static int is32(zic_t x);
-static int itsabbr(const char * abbr, const char * word);
static int itsdir(const char * name);
-static int lowerit(int c);
static int mkdirs(char * filename);
static void newabbr(const char * abbr);
static long oadd(long t1, long t2);
@@ -1175,7 +1172,7 @@ const char * const timep;
dp = ecpyalloc(timep);
if (*dp != '\0') {
ep = dp + strlen(dp) - 1;
- switch (lowerit(*ep)) {
+ switch (tolower((unsigned char)*ep)) {
case 's': /* Standard */
rp->r_todisstd = TRUE;
rp->r_todisgmt = FALSE;
@@ -2325,41 +2322,6 @@ const char * const type;
errx(1, "command was '%s', result was %d", buf, result);
}
-static int
-lowerit(a)
-int a;
-{
- a = (unsigned char) a;
- return (isascii(a) && isupper(a)) ? tolower(a) : a;
-}
-
-static int
-ciequal(ap, bp) /* case-insensitive equality */
-const char * ap;
-const char * bp;
-{
- while (lowerit(*ap) == lowerit(*bp++))
- if (*ap++ == '\0')
- return TRUE;
- return FALSE;
-}
-
-static int
-itsabbr(abbr, word)
-const char * abbr;
-const char * word;
-{
- if (lowerit(*abbr) != lowerit(*word))
- return FALSE;
- ++word;
- while (*++abbr != '\0')
- do {
- if (*word == '\0')
- return FALSE;
- } while (lowerit(*word++) != lowerit(*abbr));
- return TRUE;
-}
-
static const struct lookup *
byword(word, table)
const char * const word;
@@ -2368,23 +2330,24 @@ const struct lookup * const table;
const struct lookup * foundlp;
const struct lookup * lp;
- if (word == NULL || table == NULL)
+ if (word == NULL || *word == '\0' || table == NULL)
return NULL;
/*
** Look for exact match.
*/
for (lp = table; lp->l_word != NULL; ++lp)
- if (ciequal(word, lp->l_word))
+ if (strcasecmp(word, lp->l_word) == 0)
return lp;
/*
** Look for inexact match.
*/
foundlp = NULL;
for (lp = table; lp->l_word != NULL; ++lp)
- if (itsabbr(word, lp->l_word)) {
+ if (strncasecmp(word, lp->l_word, strlen(word)) == 0) {
if (foundlp == NULL)
foundlp = lp;
- else return NULL; /* multiple inexact matches */
+ else
+ return NULL; /* multiple inexact matches */
}
return foundlp;
}