use __strchrnul instead of strchr and strlen in execvpe

The result is the same but takes less code.
Note that __execvpe calls getenv which calls __strchrnul so even
using static output the size of the executable won't grow.
This commit is contained in:
Frediano Ziglio 2019-03-26 09:36:47 +00:00 committed by Rich Felker
parent 086a12b920
commit 7fe51ea85b

View File

@ -28,8 +28,7 @@ int __execvpe(const char *file, char *const argv[], char *const envp[])
for(p=path; ; p=z) { for(p=path; ; p=z) {
char b[l+k+1]; char b[l+k+1];
z = strchr(p, ':'); z = __strchrnul(p, ':');
if (!z) z = p+strlen(p);
if (z-p >= l) { if (z-p >= l) {
if (!*z++) break; if (!*z++) break;
continue; continue;