diff options
author | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
commit | e7e5b53bf16ab3b35646f0580b36fa7d7afa9678 (patch) | |
tree | b751618c7a82d9c00cab91ea9f611585dbf14d84 /usr.sbin/sade | |
parent | d106f2fd7cf6be7617b1756d893b5b6fba5310f4 (diff) | |
download | FreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.zip FreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.tar.gz |
Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.
This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/variable.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c index 911eb02..ae3a6e0 100644 --- a/usr.sbin/sade/variable.c +++ b/usr.sbin/sade/variable.c @@ -83,7 +83,7 @@ variable_set(char *var, int dirty) else if (!*var) msgDebug("Warning: Zero length name & value passed to variable_set()\n"); SAFE_STRCPY(tmp, var); - if ((cp = index(tmp, '=')) == NULL) + if ((cp = strchr(tmp, '=')) == NULL) msgFatal("Invalid variable format: %s", var); *(cp++) = '\0'; make_variable(tmp, string_skipwhite(cp), dirty); @@ -123,7 +123,7 @@ variable_unset(char *var) Variable *vp; char name[512], *cp; - if ((cp = index(var, '=')) != NULL) + if ((cp = strchr(var, '=')) != NULL) sstrncpy(name, var, cp - var); else SAFE_STRCPY(name, var); @@ -189,14 +189,14 @@ variable_check2(char *data) if (data == NULL) return -1; SAFE_STRCPY(tmp, data); - if ((cp = index(tmp, '=')) != NULL) { + if ((cp = strchr(tmp, '=')) != NULL) { *(cp++) = '\0'; if (*cp == '"') { /* smash quotes if present */ ++cp; - if ((cp3 = index(cp, '"')) != NULL) + if ((cp3 = strchr(cp, '"')) != NULL) *cp3 = '\0'; } - else if ((cp3 = index(cp, ',')) != NULL) + else if ((cp3 = strchr(cp, ',')) != NULL) *cp3 = '\0'; cp2 = variable_get(tmp); if (cp2 != NULL) { @@ -305,7 +305,7 @@ pvariable_set(char *var) msgDebug("Warning: Zero length name & value passed to variable_set()\n"); /* Add a trivial namespace to whatever name the caller chooses. */ SAFE_STRCPY(tmp, "SYSINSTALL_PVAR"); - if (index(var, '=') == NULL) + if (strchr(var, '=') == NULL) msgFatal("Invalid variable format: %s", var); strlcat(tmp, var, 1024); p = strchr(tmp, '='); |