From 9706e89a8885812fd7fdd1ab4485afac92f7691d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 17 Mar 2000 21:33:15 +0000 Subject: 2000-03-17 Roland McGrath * hashexec.c (check_hashbang): Use strpbrk directly instead of strsep. Fix up INTERP_LEN properly in the no-argument case. --- exec/hashexec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'exec') 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; -- cgit v1.2.3