From 64e480b07851a56a65d391fa930b295e5c9a944b Mon Sep 17 00:00:00 2001 From: Raja R Harinath Date: Wed, 18 Feb 1998 21:37:52 +0000 Subject: Include `libsupport.a'. * Makefile.am (gncal_LDADD): Include `libsupport.a'. * calcs.c (month_atoi): Replace buggy explicit loop string compare with strcasecmp. (day_atoi): Likewise. - Hari svn path=/trunk/; revision=40 --- calendar/calcs.c | 52 ++++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 36 deletions(-) (limited to 'calendar/calcs.c') diff --git a/calendar/calcs.c b/calendar/calcs.c index 002ffbf28b..2797a31d6c 100644 --- a/calendar/calcs.c +++ b/calendar/calcs.c @@ -11,6 +11,12 @@ #include #include "calcs.h" +#include + +#ifndef HAVE_STRCASECMP +int strcasecmp(const char * /*s1*/, const char * /*s2*/); +#endif + /* Number of days in a month */ static const int dvec[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /* Number of past days of a month */ @@ -117,47 +123,21 @@ void get_system_date(int *day, int *month, int *year) */ int month_atoi(const char *string) { - int i, j; - int len; - char *ptr; - - len = strlen(string); - - for(i= MONTH_MIN; i <= MONTH_MAX; i++) { - ptr = (char*)month_name(i); - j = 0; - while ( *(ptr + j) && string[j]) - if (tolower((ptr+j)) == tolower(string[j])) - j++; - else - break; - if (j == len || !*(ptr + j)) - return(i); - } + int i; + for (i = MONTH_MIN; i <= MONTH_MAX; i++) + if (strcasecmp(string, (char *)month_name(i)) == 0) + return i; return 0; -} /* month_atoi */ +} int day_atoi(const char *string) { - int i, j; - int len; - char *ptr; - - len = strlen(string); - - for(i= DAY_MIN; i <= DAY_MAX; i++) { - ptr = (char*)day_name(i); - j = 0; - while ( *(ptr + j) && string[j]) - if (tolower((ptr+j)) == tolower(string[j])) - j++; - else - break; - if (j == len || !*(ptr + j)) - return(i); - } + int i; + for (i = DAY_MIN; i <= DAY_MAX; i++) + if (strcasecmp(string, (char *)day_name(i)) == 0) + return i; return 0; -} /* day_atoi */ +} /* * Returns ordinal suffix (st, nd, rd, th) for a day -- cgit v1.2.3