Replace some loops with string.h functions

* src/init.c: Replace loop with strspn
* src/url.c: Replace loop with strrchr

Copyright-paperwork-exempt: Yes
This commit is contained in:
Kapus, Timotej 2018-10-26 13:33:58 +00:00 committed by Tim Rühsen
parent 7903dbc9d8
commit 6d7cd9313c
2 changed files with 5 additions and 5 deletions

View File

@ -885,8 +885,10 @@ parse_line (const char *line, char **com, char **val, int *comind)
#if defined(WINDOWS) || defined(MSDOS)
# define ISSEP(c) ((c) == '/' || (c) == '\\')
# define SEPSTRING "/\\"
#else
# define ISSEP(c) ((c) == '/')
# define SEPSTRING "/"
#endif
/* Run commands[comind].action. */
@ -927,8 +929,7 @@ setval_internal_tilde (int comind, const char *com, const char *val)
xfree (*pstring);
/* Skip the leading "~/". */
for (++val; ISSEP (*val); val++)
;
val += strspn(val + 1, SEPSTRING) + 1;
*pstring = concat_strings (home, "/", val, (char *)0);
xfree (home);
}

View File

@ -1248,9 +1248,8 @@ mkalldirs (const char *path)
struct stat st;
int res;
p = path + strlen (path);
for (; *p != '/' && p != path; p--)
;
p = strrchr(path, '/');
p = p == NULL ? path : p;
/* Don't create if it's just a file. */
if ((p == path) && (*p != '/'))