lib/, src/: Use strrspn() instead of its pattern
This requires changing isspace(3) calls to an explicit accept string, and I chose " \t\n" for it (as is done in other parts of this project), which isn't exactly the same, but we probably don't want other isspace(3) characters in those files, so it should work. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
7c9da42db0
commit
c6018240f8
+4
-5
@@ -14,7 +14,10 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
|
||||
|
||||
/*
|
||||
* valid_field - insure that a field contains all legal characters
|
||||
@@ -89,11 +92,7 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
|
||||
* makes it possible to change the field to empty, by
|
||||
* entering a space. --marekm
|
||||
*/
|
||||
|
||||
while (newf < cp && isspace (cp[-1])) {
|
||||
cp--;
|
||||
}
|
||||
*cp = '\0';
|
||||
*strrspn(newf, " \t\n") = '\0';
|
||||
|
||||
cp = newf;
|
||||
while (isspace (*cp)) {
|
||||
|
||||
+2
-8
@@ -31,6 +31,7 @@
|
||||
#include "string/sprintf/xasprintf.h"
|
||||
#include "string/strchr/stpcspn.h"
|
||||
#include "string/strchr/stpspn.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -528,7 +529,6 @@ static void def_load (void)
|
||||
#else /* USE_ECONF */
|
||||
static void def_load (void)
|
||||
{
|
||||
int i;
|
||||
FILE *fp;
|
||||
char buf[1024], *name, *value, *s;
|
||||
|
||||
@@ -560,13 +560,7 @@ static void def_load (void)
|
||||
/*
|
||||
* Trim trailing whitespace.
|
||||
*/
|
||||
for (i = (ptrdiff_t) strlen (buf) - 1; i >= 0; --i) {
|
||||
if (!isspace (buf[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
buf[i] = '\0';
|
||||
*strrspn(buf, " \t\n") = '\0';
|
||||
|
||||
/*
|
||||
* Break the line into two fields.
|
||||
|
||||
+2
-4
@@ -57,6 +57,7 @@
|
||||
#include <arpa/inet.h> /* for inet_ntoa() */
|
||||
|
||||
#include "sizeof.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
|
||||
#if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64)
|
||||
#undef MAXHOSTNAMELEN
|
||||
@@ -110,10 +111,7 @@ int login_access (const char *user, const char *from)
|
||||
if (line[0] == '#') {
|
||||
continue; /* comment line */
|
||||
}
|
||||
while (end > 0 && isspace (line[end - 1])) {
|
||||
end--;
|
||||
}
|
||||
line[end] = '\0'; /* strip trailing whitespace */
|
||||
*strrspn(line, " \t\n") = '\0';
|
||||
if (line[0] == '\0') { /* skip blank lines */
|
||||
continue;
|
||||
}
|
||||
|
||||
+5
-5
@@ -8,13 +8,17 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
|
||||
|
||||
#ifndef SUAUTHFILE
|
||||
#define SUAUTHFILE "/etc/suauth"
|
||||
@@ -77,11 +81,7 @@ int check_su_auth (const char *actual_id,
|
||||
continue;
|
||||
}
|
||||
|
||||
while (endline > 0 && (temp[endline - 1] == ' '
|
||||
|| temp[endline - 1] == '\t'
|
||||
|| temp[endline - 1] == '\n'))
|
||||
endline--;
|
||||
temp[endline] = '\0';
|
||||
*strrspn(temp, " \t\n") = '\0';
|
||||
|
||||
posn = 0;
|
||||
while (temp[posn] == ' ' || temp[posn] == '\t')
|
||||
|
||||
Reference in New Issue
Block a user