diff --git a/configure b/configure index c2094f93..7955b56f 100755 --- a/configure +++ b/configure @@ -4322,24 +4322,6 @@ if test "$ac_cv_header_wctype_h" != "yes" ; then exit 1 fi -ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = xyes -then : - printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes -then : - printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp" -if test "x$ac_cv_func_strncasecmp" = xyes -then : - printf "%s\n" "#define HAVE_STRNCASECMP 1" >>confdefs.h - -fi ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv" if test "x$ac_cv_func_setenv" = xyes then : diff --git a/configure.ac b/configure.ac index 418413a3..21d1819c 100644 --- a/configure.ac +++ b/configure.ac @@ -109,7 +109,7 @@ if test "$ac_cv_header_wctype_h" != "yes" ; then exit 1 fi -AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1 readline) +AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1 readline) if test "$ac_cv_func_mbstowcs" != "yes"; then echo "*** Remind requires the mbstowcs function" diff --git a/src/calendar.c b/src/calendar.c index edd060d3..126137e6 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -2117,7 +2117,7 @@ static int DoCalRem(ParsePtr p, int col) } } if (trig.typ == PASSTHRU_TYPE) { - if (!PsCal && !StrCmpi(trig.passthru, "SHADE")) { + if (!PsCal && !strcasecmp(trig.passthru, "SHADE")) { if (dse == DSEToday) { DBufInit(&obuf); r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); @@ -2130,7 +2130,7 @@ static int DoCalRem(ParsePtr p, int col) DBufFree(&obuf); } } - if (!PsCal && !StrCmpi(trig.passthru, "WEEK")) { + if (!PsCal && !strcasecmp(trig.passthru, "WEEK")) { if (dse == DSEToday) { DBufInit(&obuf); r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); @@ -2143,11 +2143,11 @@ static int DoCalRem(ParsePtr p, int col) DBufFree(&obuf); } } - if (!PsCal && StrCmpi(trig.passthru, "COLOR") && StrCmpi(trig.passthru, "COLOUR") && StrCmpi(trig.passthru, "MOON")) { + if (!PsCal && strcasecmp(trig.passthru, "COLOR") && strcasecmp(trig.passthru, "COLOUR") && strcasecmp(trig.passthru, "MOON")) { FreeTrig(&trig); return OK; } - if (!PsCal && !StrCmpi(trig.passthru, "MOON")) { + if (!PsCal && !strcasecmp(trig.passthru, "MOON")) { if (dse == DSEToday) { DBufInit(&obuf); r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); @@ -2160,8 +2160,8 @@ static int DoCalRem(ParsePtr p, int col) DBufFree(&obuf); } } - if (!StrCmpi(trig.passthru, "COLOR") || - !StrCmpi(trig.passthru, "COLOUR")) { + if (!strcasecmp(trig.passthru, "COLOR") || + !strcasecmp(trig.passthru, "COLOUR")) { is_color = 1; /* Strip off the three color numbers */ DBufFree(&buf); @@ -2225,8 +2225,8 @@ static int DoCalRem(ParsePtr p, int col) /* Suppress time if it's not today or if it's a non-COLOR special */ if (dse != DSEToday || (trig.typ == PASSTHRU_TYPE && - StrCmpi(trig.passthru, "COLOUR") && - StrCmpi(trig.passthru, "COLOR"))) { + strcasecmp(trig.passthru, "COLOUR") && + strcasecmp(trig.passthru, "COLOR"))) { if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) { DBufFree(&obuf); DBufFree(&raw_buf); @@ -2335,7 +2335,7 @@ static int DoCalRem(ParsePtr p, int col) e->if_depth = get_if_pointer() - get_base_if_pointer(); e->trig = trig; if (e->trig.tz) { - e->trig.tz = StrDup(e->trig.tz); + e->trig.tz = strdup(e->trig.tz); } e->tt = tim; e->wc_pos = NULL; @@ -2344,8 +2344,8 @@ static int DoCalRem(ParsePtr p, int col) e->r = col_r; e->g = col_g; e->b = col_b; - e->text = StrDup(s); - e->raw_text = StrDup(DBufValue(&raw_buf)); + e->text = strdup(s); + e->raw_text = strdup(DBufValue(&raw_buf)); DBufFree(&raw_buf); DBufFree(&obuf); DBufFree(&pre_buf); @@ -2661,7 +2661,7 @@ static void WriteSimpleEntryProtocol2(CalEntry *e) PrintJSONKeyPairInt("r", e->r); PrintJSONKeyPairInt("g", e->g); PrintJSONKeyPairInt("b", e->b); - } else if (!StrCmpi(e->passthru, "SHADE")) { + } else if (!strcasecmp(e->passthru, "SHADE")) { int r, g, b, n; n = sscanf(e->text, "%d %d %d", &r, &g, &b); if (n < 3) { diff --git a/src/config.h.in b/src/config.h.in index 7aea6589..81963f14 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -45,21 +45,12 @@ /* Define to 1 if you have the `readline' function. */ #undef HAVE_READLINE -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H -/* Define to 1 if you have the `strncasecmp' function. */ -#undef HAVE_STRNCASECMP - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_INOTIFY_H diff --git a/src/dedupe.c b/src/dedupe.c index 9129350a..fd582c02 100644 --- a/src/dedupe.c +++ b/src/dedupe.c @@ -101,7 +101,7 @@ InsertDedupeEntry(int trigger_date, int trigger_time, char const *body) } e->trigger_date = trigger_date; e->trigger_time = trigger_time; - e->body = StrDup(body); + e->body = strdup(body); if (!e->body) { free(e); return; diff --git a/src/dorem.c b/src/dorem.c index a40ab77e..6285d0b8 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -306,11 +306,11 @@ ensure_satnode_mentions_trigdate_aux(expr_node *node, int *mentioned) } else { name = node->u.value.v.str; } - if (!StrCmpi(name, "T") || - !StrCmpi(name, "Td") || - !StrCmpi(name, "Tm") || - !StrCmpi(name, "Tw") || - !StrCmpi(name, "Ty")) { + if (!strcasecmp(name, "T") || + !strcasecmp(name, "Td") || + !strcasecmp(name, "Tm") || + !strcasecmp(name, "Tw") || + !strcasecmp(name, "Ty")) { *mentioned = 1; return; } @@ -1120,7 +1120,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim) if (r != OK) { return r; } - trig->tz = StrDup(DBufValue(&buf)); + trig->tz = strdup(DBufValue(&buf)); if (!trig->tz) { return E_NO_MEM; } @@ -1576,14 +1576,14 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig const *tim, int dse, int is DBufInit(&calRow); DBufInit(&pre_buf); if (t->typ == RUN_TYPE && RunDisabled) return E_RUN_DISABLED; - if ((t->typ == PASSTHRU_TYPE && StrCmpi(t->passthru, "COLOR") && StrCmpi(t->passthru, "COLOUR")) || + if ((t->typ == PASSTHRU_TYPE && strcasecmp(t->passthru, "COLOR") && strcasecmp(t->passthru, "COLOUR")) || t->typ == CAL_TYPE || t->typ == PS_TYPE || t->typ == PSF_TYPE) return OK; /* Handle COLOR types */ - if (t->typ == PASSTHRU_TYPE && (!StrCmpi(t->passthru, "COLOR") || !StrCmpi(t->passthru, "COLOUR"))) { + if (t->typ == PASSTHRU_TYPE && (!strcasecmp(t->passthru, "COLOR") || !strcasecmp(t->passthru, "COLOUR"))) { /* Strip off three tokens */ r = ParseToken(p, &buf); sscanf(DBufValue(&buf), "%d", &red); @@ -2291,17 +2291,17 @@ void FixSpecialType(Trigger *t) } /* Convert SPECIAL MSG / MSF / RUN / CAL to just plain MSG / MSF / etc */ - if (!StrCmpi(t->passthru, "MSG")) { + if (!strcasecmp(t->passthru, "MSG")) { t->typ = MSG_TYPE; - } else if (!StrCmpi(t->passthru, "MSF")) { + } else if (!strcasecmp(t->passthru, "MSF")) { t->typ = MSF_TYPE; - } else if (!StrCmpi(t->passthru, "RUN")) { + } else if (!strcasecmp(t->passthru, "RUN")) { t->typ = RUN_TYPE; - } else if (!StrCmpi(t->passthru, "CAL")) { + } else if (!strcasecmp(t->passthru, "CAL")) { t->typ = CAL_TYPE; - } else if (!StrCmpi(t->passthru, "PS")) { + } else if (!strcasecmp(t->passthru, "PS")) { t->typ = PS_TYPE; - } else if (!StrCmpi(t->passthru, "PSFILE")) { + } else if (!strcasecmp(t->passthru, "PSFILE")) { t->typ = PSF_TYPE; } } diff --git a/src/expr.c b/src/expr.c index ae2775f2..b2ea828b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2256,7 +2256,7 @@ static int make_atom(expr_node *atom, Var *locals) /* Variable */ if (isalpha(*s) || *s == '_') { while(v) { - if (! StrinCmp(s, v->name, VAR_NAME_LEN)) { + if (! strncasecmp(s, v->name, VAR_NAME_LEN)) { atom->type = N_LOCAL_VAR; atom->u.arg = i; return OK; @@ -3139,7 +3139,7 @@ int CopyValue(Value *dest, const Value *src) { dest->type = ERR_TYPE; if (src->type == STR_TYPE) { - dest->v.str = StrDup(src->v.str); + dest->v.str = strdup(src->v.str); if (!dest->v.str) return E_NO_MEM; } else { dest->v.val = src->v.val; @@ -3312,7 +3312,7 @@ int DoCoerce(char type, Value *v) default: return E_CANT_COERCE; } v->type = STR_TYPE; - v->v.str = StrDup(coerce_buf); + v->v.str = strdup(coerce_buf); if (!v->v.str) { v->type = ERR_TYPE; return E_NO_MEM; diff --git a/src/files.c b/src/files.c index 7dca63e5..884680ca 100644 --- a/src/files.c +++ b/src/files.c @@ -159,7 +159,7 @@ void SetCurrentFilename(char const *fname) fprintf(ErrFp, "Out of Memory!\n"); exit(1); } - e->fname = StrDup(fname); + e->fname = strdup(fname); if (!e->fname) { fprintf(ErrFp, "Out of Memory!\n"); exit(1); @@ -559,7 +559,7 @@ static int CacheFile(char const *fname, int use_pclose) return E_NO_MEM; } cf->cache = NULL; - cf->filename = StrDup(fname); + cf->filename = strdup(fname); if (!cf->filename) { ShouldCache = 0; if (use_pclose) { @@ -627,7 +627,7 @@ static int CacheFile(char const *fname, int use_pclose) cl->next = NULL; cl->LineNo = LineNo; cl->LineNoStart = LineNoStart; - cl->text = StrDup(s); + cl->text = strdup(s); DBufFree(&LineBuffer); if (!cl->text) { DestroyCache(cf); @@ -874,7 +874,7 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i) i->chain = NULL; if (!*dirname) return E_CANT_OPEN; - dir = StrDup(dirname); + dir = strdup(dirname); if (!dir) return E_NO_MEM; /* Strip trailing slashes off directory */ @@ -916,7 +916,7 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i) if (ShouldCache) { dc = malloc(sizeof(DirectoryFilenameChain)); if (dc) { - dc->dirname = StrDup(dir); + dc->dirname = strdup(dir); if (!dc->dirname) { free(dc); dc = NULL; @@ -972,7 +972,7 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i) return E_NO_MEM; } - ch->filename = StrDup(glob_buf.gl_pathv[r]); + ch->filename = strdup(glob_buf.gl_pathv[r]); if (!ch->filename) { globfree(&glob_buf); FreeChain(i->chain); diff --git a/src/funcs.c b/src/funcs.c index e8076e83..961160d1 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -448,7 +448,7 @@ static int RetStrVal(char const *s, func_info *info) RetVal.v.str = malloc(1); if (RetVal.v.str) *RetVal.v.str = 0; } else { - RetVal.v.str = StrDup(s); + RetVal.v.str = strdup(s); } if (!RetVal.v.str) { @@ -652,11 +652,11 @@ static int FCoerce(func_info *info) it won't be destroyed */ DCOPYVAL(RetVal, ARG(1)); - if (! StrCmpi(s, "int")) r = DoCoerce(INT_TYPE, &RetVal); - else if (! StrCmpi(s, "date")) r = DoCoerce(DATE_TYPE, &RetVal); - else if (! StrCmpi(s, "time")) r = DoCoerce(TIME_TYPE, &RetVal); - else if (! StrCmpi(s, "string")) r = DoCoerce(STR_TYPE, &RetVal); - else if (! StrCmpi(s, "datetime")) r = DoCoerce(DATETIME_TYPE, &RetVal); + if (! strcasecmp(s, "int")) r = DoCoerce(INT_TYPE, &RetVal); + else if (! strcasecmp(s, "date")) r = DoCoerce(DATE_TYPE, &RetVal); + else if (! strcasecmp(s, "time")) r = DoCoerce(TIME_TYPE, &RetVal); + else if (! strcasecmp(s, "string")) r = DoCoerce(STR_TYPE, &RetVal); + else if (! strcasecmp(s, "datetime")) r = DoCoerce(DATETIME_TYPE, &RetVal); else { Eprint("coerce(): Invalid type `%s'", s); return E_CANT_COERCE; @@ -3537,7 +3537,7 @@ static int UTCToLocalHelper(int datetime, int *ret) old_tz = getenv("TZ"); if (old_tz) { - old_tz = StrDup(old_tz); + old_tz = strdup(old_tz); if (!old_tz) return E_NO_MEM; } @@ -4281,7 +4281,7 @@ int tz_convert(int year, int month, int day, /* backup old TZ env var */ old_tz = getenv("TZ"); if (old_tz) { - old_tz = StrDup(old_tz); + old_tz = strdup(old_tz); if (!old_tz) return E_NO_MEM; } if (tgt_tz == NULL || !*tgt_tz) { diff --git a/src/hbcal.c b/src/hbcal.c index d5ff6473..e81cf7a5 100644 --- a/src/hbcal.c +++ b/src/hbcal.c @@ -262,14 +262,14 @@ int HebNameToNum(char const *mname) int m=-1; for (i=0; i<14; i++) { - if (!StrCmpi(mname, HebMonthNames[i])) { + if (!strcasecmp(mname, HebMonthNames[i])) { m = i; break; } } if (m == -1) { for (i=0; i<14; i++) { - if (!StrCmpi(mname, IvritMonthNames[i])) { + if (!strcasecmp(mname, IvritMonthNames[i])) { m = i; break; } diff --git a/src/init.c b/src/init.c index 6773ba5e..f330020b 100644 --- a/src/init.c +++ b/src/init.c @@ -196,7 +196,7 @@ void InitRemind(int argc, char const *argv[]) /* Initialize local time zone */ LocalTimeZone = getenv("TZ"); if (LocalTimeZone) { - LocalTimeZone = StrDup(LocalTimeZone); + LocalTimeZone = strdup(LocalTimeZone); if (!LocalTimeZone) { fprintf(stderr, "Out of memory!\n"); exit(1); diff --git a/src/main.c b/src/main.c index ec75e140..7b2fc9eb 100644 --- a/src/main.c +++ b/src/main.c @@ -1516,11 +1516,11 @@ int DoRun(ParsePtr p) if ( (r=ParseToken(p, &buf)) ) return r; /* Only allow RUN ON in top-level script */ - if (! StrCmpi(DBufValue(&buf), "ON")) { + if (! strcasecmp(DBufValue(&buf), "ON")) { if (TopLevel()) RunDisabled &= ~RUN_SCRIPT; } /* But allow RUN OFF anywhere */ - else if (! StrCmpi(DBufValue(&buf), "OFF")) + else if (! strcasecmp(DBufValue(&buf), "OFF")) RunDisabled |= RUN_SCRIPT; else { DBufFree(&buf); @@ -1548,11 +1548,11 @@ int DoExpr(ParsePtr p) if ( (r=ParseToken(p, &buf)) ) return r; /* Only allow EXPR ON in top-level script */ - if (! StrCmpi(DBufValue(&buf), "ON")) { + if (! strcasecmp(DBufValue(&buf), "ON")) { if (TopLevel()) ExpressionEvaluationDisabled = 0; } /* But allow EXPR OFF anywhere */ - else if (! StrCmpi(DBufValue(&buf), "OFF")) + else if (! strcasecmp(DBufValue(&buf), "OFF")) ExpressionEvaluationDisabled = 1; else { DBufFree(&buf); @@ -2117,7 +2117,7 @@ SaveLastTrigger(Trigger const *t) DBufInit(&(LastTrigger.tags)); if (LastTrigger.tz) { - LastTrigger.tz = StrDup(LastTrigger.tz); + LastTrigger.tz = strdup(LastTrigger.tz); } DBufPuts(&(LastTrigger.tags), DBufValue(&(t->tags))); TrigInfo *cur = t->infos; diff --git a/src/protos.h b/src/protos.h index cfd6d621..62fe9a9c 100644 --- a/src/protos.h +++ b/src/protos.h @@ -13,20 +13,8 @@ /* Suppress unused variable warnings */ #define UNUSED(x) (void) x -#ifdef HAVE_STRDUP -#define StrDup strdup -#endif - -#ifdef HAVE_STRNCASECMP -#define StrinCmp strncasecmp -#endif - -#ifdef HAVE_STRCASECMP -#define StrCmpi strcasecmp -#endif - /* Define a string assignment macro - be careful!!! */ -#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); } +#define STRSET(x, str) { if (x) free(x); (x) = strdup(str); } /* Define a general malloc routine for creating pointers to objects */ #define NEW(type) (malloc(sizeof(type))) @@ -131,18 +119,6 @@ int ComputeTriggerNoAdjustDuration (int today, Trigger *trig, TimeTrig const *ti int AdjustTriggerForDuration(int today, int r, Trigger *trig, TimeTrig *tim, int save_in_globals); char *StrnCpy (char *dest, char const *source, int n); -#ifndef HAVE_STRNCASECMP -int StrinCmp (char const *s1, char const *s2, int n); -#endif - -#ifndef HAVE_STRDUP -char *StrDup (char const *s); -#endif - -#ifndef HAVE_STRCASECMP -int StrCmpi (char const *s1, char const *s2); -#endif - void strtolower(char *s); Var *FindVar (char const *str, int create); diff --git a/src/queue.c b/src/queue.c index 996ad486..31546ec1 100644 --- a/src/queue.c +++ b/src/queue.c @@ -155,7 +155,7 @@ int QueueReminder(ParsePtr p, Trigger *trig, qelem->red = DefaultColorR; qelem->green = DefaultColorG; qelem->blue = DefaultColorB; - qelem->text = StrDup(p->pos); /* Guaranteed that parser is not nested. */ + qelem->text = strdup(p->pos); /* Guaranteed that parser is not nested. */ if (!qelem->text) { free(qelem); return E_NO_MEM; diff --git a/src/rem2ps.c b/src/rem2ps.c index 41d81f82..e368c28c 100644 --- a/src/rem2ps.c +++ b/src/rem2ps.c @@ -154,24 +154,6 @@ put_escaped_string(char const *s) } } -/***************************************************************/ -/* */ -/* StrCmpi */ -/* */ -/* Compare strings, case insensitive. */ -/* */ -/***************************************************************/ -static int StrCmpi(char const *s1, char const *s2) -{ - int r; - while (*s1 && *s2) { - r = toupper(*s1) - toupper(*s2); - if (r) return r; - s1++; - s2++; - } - return toupper(*s1) - toupper(*s2); -} /***************************************************************/ /* */ /* Parse the new-style JSON intermediate format */ @@ -229,18 +211,18 @@ JSONToCalEntry(DynamicBuffer const *buf) } else if (!strcmp(nm, "passthru")) { if (v->type == json_string) { s = v->u.string.ptr; - if (!StrCmpi(s, "PostScript")) { + if (!strcasecmp(s, "PostScript")) { c->special = SPECIAL_POSTSCRIPT; - } else if (!StrCmpi(s, "SHADE")) { + } else if (!strcasecmp(s, "SHADE")) { c->special = SPECIAL_SHADE; - } else if (!StrCmpi(s, "MOON")) { + } else if (!strcasecmp(s, "MOON")) { c->special = SPECIAL_MOON; - } else if (!StrCmpi(s, "WEEK")) { + } else if (!strcasecmp(s, "WEEK")) { c->special = SPECIAL_WEEK; - } else if (!StrCmpi(s, "PSFile")) { + } else if (!strcasecmp(s, "PSFile")) { c->special = SPECIAL_PSFILE; - } else if (!StrCmpi(s, "COLOUR") || - !StrCmpi(s, "COLOR")) { + } else if (!strcasecmp(s, "COLOUR") || + !strcasecmp(s, "COLOR")) { c->special = SPECIAL_COLOR; } else { c->special = SPECIAL_UNKNOWN; @@ -301,20 +283,20 @@ TextToCalEntry(DynamicBuffer *buf) strcpy(c->entry, startOfBody); /* Save the type of SPECIAL */ - if (!StrCmpi(passthru, "PostScript")) { + if (!strcasecmp(passthru, "PostScript")) { c->special = SPECIAL_POSTSCRIPT; - } else if (!StrCmpi(passthru, "SHADE")) { + } else if (!strcasecmp(passthru, "SHADE")) { c->special = SPECIAL_SHADE; - } else if (!StrCmpi(passthru, "MOON")) { + } else if (!strcasecmp(passthru, "MOON")) { c->special = SPECIAL_MOON; - } else if (!StrCmpi(passthru, "WEEK")) { + } else if (!strcasecmp(passthru, "WEEK")) { c->special = SPECIAL_WEEK; - } else if (!StrCmpi(passthru, "PSFile")) { + } else if (!strcasecmp(passthru, "PSFile")) { c->special = SPECIAL_PSFILE; - } else if (!StrCmpi(passthru, "COLOUR") || - !StrCmpi(passthru, "COLOR")) { + } else if (!strcasecmp(passthru, "COLOUR") || + !strcasecmp(passthru, "COLOR")) { c->special = SPECIAL_COLOR; - } else if (StrCmpi(passthru, "*")) { + } else if (strcasecmp(passthru, "*")) { c->special = SPECIAL_UNKNOWN; } return c; diff --git a/src/sort.c b/src/sort.c index 4bccc454..7fc4b650 100644 --- a/src/sort.c +++ b/src/sort.c @@ -49,7 +49,7 @@ static Sortrem *MakeSortRem(int dse, int tim, char const *body, int typ, int pri Sortrem *new = NEW(Sortrem); if (!new) return NULL; - new->text = StrDup(body); + new->text = strdup(body); if (!new->text) { free(new); return NULL; diff --git a/src/trans.c b/src/trans.c index 3e2c1bcb..761e22dc 100644 --- a/src/trans.c +++ b/src/trans.c @@ -443,19 +443,19 @@ DoTranslate(ParsePtr p) r = ParseToken(p, &orig); if (r) return r; r = VerifyEoln(p); - if (!StrCmpi(DBufValue(&orig), "dump")) { + if (!strcasecmp(DBufValue(&orig), "dump")) { DBufFree(&orig); if (r) return r; DumpTranslationTable(stdout, 0); return OK; } - if (!StrCmpi(DBufValue(&orig), "clear")) { + if (!strcasecmp(DBufValue(&orig), "clear")) { DBufFree(&orig); if (r) return r; ClearTranslationTable(); return OK; } - if (!StrCmpi(DBufValue(&orig), "generate")) { + if (!strcasecmp(DBufValue(&orig), "generate")) { DBufFree(&orig); if (r) return r; GenerateTranslationTemplate(); diff --git a/src/trigger.c b/src/trigger.c index 36de4e3d..b305b299 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -738,7 +738,7 @@ NewTrigInfo(char const *i) return NULL; } ti->next = NULL; - ti->info = StrDup(i); + ti->info = strdup(i); if (!ti->info) { free(ti); return NULL; diff --git a/src/userfns.c b/src/userfns.c index 5800601e..b11d0bf1 100644 --- a/src/userfns.c +++ b/src/userfns.c @@ -318,7 +318,7 @@ int DoFset(ParsePtr p) } /* If we've already seen this local variable, error */ for (i=0; inargs; i++) { - if (!StrinCmp(DBufValue(&buf), local_array[i].name, VAR_NAME_LEN)) { + if (!strncasecmp(DBufValue(&buf), local_array[i].name, VAR_NAME_LEN)) { DBufFree(&buf); DestroyUserFunc(func); return E_REPEATED_ARG; @@ -393,7 +393,7 @@ int DoFset(ParsePtr p) return E_NO_MEM; } for (i=0; inargs; i++) { - func->args[i] = StrDup(local_array[i].name); + func->args[i] = strdup(local_array[i].name); if (!func->args[i]) { DestroyUserFunc(func); return E_NO_MEM; @@ -619,7 +619,7 @@ static UserFunc *clone_userfunc(char const *name, int *r) return NULL; } for (i=0; inargs; i++) { - dest->args[i] = StrDup(src->args[i]); + dest->args[i] = strdup(src->args[i]); if (!dest->args[i]) { DestroyUserFunc(dest); return NULL; diff --git a/src/utils.c b/src/utils.c index 016129ec..1d241bd1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -140,67 +140,6 @@ char *StrnCpy(char *dest, char const *source, int n) return odest; } -#ifndef HAVE_STRNCASECMP -/***************************************************************/ -/* */ -/* StrinCmp - compare strings, case-insensitive */ -/* */ -/***************************************************************/ -int StrinCmp(char const *s1, char const *s2, int n) -{ - register int r; - while (n && *s1 && *s2) { - n--; - r = toupper(*s1) - toupper(*s2); - if (r) return r; - s1++; - s2++; - } - if (n) return (toupper(*s1) - toupper(*s2)); else return 0; -} - -#endif - -#ifndef HAVE_STRDUP -/***************************************************************/ -/* */ -/* StrDup */ -/* */ -/* Like ANSI strdup */ -/* */ -/***************************************************************/ -char *StrDup(char const *s) -{ - char *ret = malloc(strlen(s)+1); - if (!ret) return NULL; - strcpy(ret, s); - return ret; -} - -#endif - -#ifndef HAVE_STRCASECMP -/***************************************************************/ -/* */ -/* StrCmpi */ -/* */ -/* Compare strings, case insensitive. */ -/* */ -/***************************************************************/ -int StrCmpi(char const *s1, char const *s2) -{ - int r; - while (*s1 && *s2) { - r = toupper(*s1) - toupper(*s2); - if (r) return r; - s1++; - s2++; - } - return toupper(*s1) - toupper(*s2); -} - -#endif - /***************************************************************/ /* */ /* DateOK */ diff --git a/src/var.c b/src/var.c index 98bf7948..f5b0ee54 100644 --- a/src/var.c +++ b/src/var.c @@ -52,7 +52,7 @@ static int VarCompareFunc(void const *a, void const *b) { Var *x = (Var *) a; Var *y = (Var *) b; - return StrCmpi(x->name, y->name); + return strcasecmp(x->name, y->name); } void @@ -220,15 +220,15 @@ static int warning_level_func(int do_set, Value *val) if (!strcmp(val->v.str, VERSION)) { WarningLevel = NULL; } else { - WarningLevel = StrDup(val->v.str); + WarningLevel = strdup(val->v.str); if (!WarningLevel) return E_NO_MEM; } return OK; } if (!WarningLevel) { - val->v.str = StrDup(VERSION); + val->v.str = strdup(VERSION); } else { - val->v.str = StrDup(WarningLevel); + val->v.str = strdup(WarningLevel); } if (!val->v.str) { return E_NO_MEM; @@ -257,14 +257,14 @@ static int oncefile_func(int do_set, Value *val) if (OnceFile) { free( (void *) OnceFile); } - OnceFile = StrDup(val->v.str); + OnceFile = strdup(val->v.str); if (!OnceFile) return E_NO_MEM; return OK; } if (!OnceFile) { - val->v.str = StrDup(""); + val->v.str = strdup(""); } else { - val->v.str = StrDup(OnceFile); + val->v.str = strdup(OnceFile); } if (!val->v.str) return E_NO_MEM; val->type = STR_TYPE; @@ -1397,9 +1397,9 @@ static int GetTranslatableVariable(SysVar const *v, Value *value) { char const *translated = tr((char const *) v->value); if (translated) { - value->v.str = StrDup(translated); + value->v.str = strdup(translated); } else { - value->v.str = StrDup(""); + value->v.str = strdup(""); } if (!value->v.str) return E_NO_MEM; value->type = STR_TYPE; @@ -1491,9 +1491,9 @@ int GetSysVar(char const *name, Value *val) return f(0, val); } else if (v->type == STR_TYPE) { if (! * (char **) v->value) { - val->v.str = StrDup(""); + val->v.str = strdup(""); } else { - val->v.str = StrDup(*((char **) v->value)); + val->v.str = strdup(*((char **) v->value)); } if (!val->v.str) return E_NO_MEM; } else { @@ -1524,7 +1524,7 @@ SysVar *FindSysVar(char const *name) int r; while (top >= bottom) { - r = StrCmpi(name, SysVarArr[mid].name); + r = strcasecmp(name, SysVarArr[mid].name); if (!r) return &SysVarArr[mid]; else if (r>0) bottom = mid+1; else top = mid-1;