X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0a032eea07f6d77ac6ea4d5a39c9491c34358058..394a751fd883d2bbfc769fed7e254e008a2ef45e:/sbr/context_find.c diff --git a/sbr/context_find.c b/sbr/context_find.c index 09fcde0c..48ab8d0a 100644 --- a/sbr/context_find.c +++ b/sbr/context_find.c @@ -1,12 +1,13 @@ -/* - * context_find.c -- find an entry in the context/profile list +/* context_find.c -- find an entry in the context/profile list * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ -#include +#include "h/mh.h" +#include "concat.h" +#include "context_find.h" char * @@ -14,9 +15,10 @@ context_find (const char *str) { struct node *np; + str = FENDNULL(str); for (np = m_defs; np; np = np->n_next) - if (!strcasecmp (np->n_name ? np->n_name : "", str ? str : "")) - return (np->n_field); + if (!strcasecmp(FENDNULL(np->n_name), str)) + return np->n_field; return NULL; } @@ -30,7 +32,8 @@ context_find (const char *str) */ char * context_find_by_type (const char *string, const char *type, - const char *subtype) { + const char *subtype) +{ char *value = NULL; if (subtype) { @@ -58,11 +61,14 @@ context_find_by_type (const char *string, const char *type, * The search is case insensitive. */ int -context_find_prefix (const char *prefix) { +context_find_prefix (const char *prefix) +{ struct node *np; + size_t len; + len = strlen(prefix); for (np = m_defs; np; np = np->n_next) { - if (np->n_name && ! strncasecmp (np->n_name, prefix, strlen(prefix))) { + if (np->n_name && ! strncasecmp (np->n_name, prefix, len)) { return 1; } }