diff options
author | Roland McGrath <roland@gnu.org> | 2000-03-17 21:33:15 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2000-03-17 21:33:15 +0000 |
commit | 9706e89a8885812fd7fdd1ab4485afac92f7691d (patch) | |
tree | 523d8632269351c86b431574fb100389b63ea670 | |
parent | 5dddcaa84f298553d84ad4d1f101fda555e37efc (diff) |
2000-03-17 Roland McGrath <roland@baalperazim.frob.com>
* hashexec.c (check_hashbang): Use strpbrk directly instead of strsep.
Fix up INTERP_LEN properly in the no-argument case.
-rw-r--r-- | exec/hashexec.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/exec/hashexec.c b/exec/hashexec.c index b6bc4f32..4b4ff47e 100644 --- a/exec/hashexec.c +++ b/exec/hashexec.c @@ -166,17 +166,19 @@ check_hashbang (struct execdata *e, /* Find the name of the interpreter. */ - p = interp_buf; - p += strspn (p, " \t"); - interp = strsep (&p, " \t"); + interp = interp_buf + strspn (interp_buf, " \t"); + p = strpbrk (interp, " \t"); if (p) { + /* Terminate the interpreter name. */ + *p++ = '\0'; + /* Skip remaining blanks, and the rest of the line is the argument. */ arg = p + strspn (p, " \t"); - arg_len = interp_len - 1 - (arg - interp_buf); /* without null */ - interp_len = p - interp; + arg_len = interp_len - 1 - (arg - interp_buf); /* without null here */ + interp_len = p + 1 - interp; /* This one includes the null. */ if (arg_len == 0) arg = NULL; @@ -194,6 +196,7 @@ check_hashbang (struct execdata *e, /* There is no argument. */ arg = NULL; arg_len = 0; + interp_len -= interp - interp_buf; /* Account for blanks skipped. */ } user_crdir = user_cwdir = MACH_PORT_NULL; |