svn commit: r268920 - head/bin/sh
Jilles Tjoelker
jilles at FreeBSD.org
Sun Jul 20 12:06:53 UTC 2014
Author: jilles
Date: Sun Jul 20 12:06:52 2014
New Revision: 268920
URL: http://svnweb.freebsd.org/changeset/base/268920
Log:
sh: Remove prefix() function. Use strncmp() instead.
Modified:
head/bin/sh/exec.c
head/bin/sh/jobs.c
head/bin/sh/mystring.c
head/bin/sh/mystring.h
Modified: head/bin/sh/exec.c
==============================================================================
--- head/bin/sh/exec.c Sun Jul 20 11:00:51 2014 (r268919)
+++ head/bin/sh/exec.c Sun Jul 20 12:06:52 2014 (r268920)
@@ -365,7 +365,7 @@ find_command(const char *name, struct cm
for (;(fullname = padvance(&path, name)) != NULL; stunalloc(fullname)) {
idx++;
if (pathopt) {
- if (prefix("func", pathopt)) {
+ if (strncmp(pathopt, "func", 4) == 0) {
/* handled below */
} else {
continue; /* ignore unimplemented options */
Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c Sun Jul 20 11:00:51 2014 (r268919)
+++ head/bin/sh/jobs.c Sun Jul 20 12:06:52 2014 (r268920)
@@ -562,6 +562,7 @@ getjob_nonotfound(const char *name)
{
int jobno;
struct job *found, *jp;
+ size_t namelen;
pid_t pid;
int i;
@@ -603,10 +604,12 @@ currentjob: if ((jp = getcurjob(NULL)) =
if (found != NULL)
return (found);
} else {
+ namelen = strlen(name);
found = NULL;
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
if (jp->used && jp->nprocs > 0
- && prefix(name + 1, jp->ps[0].cmd)) {
+ && strncmp(jp->ps[0].cmd, name + 1,
+ namelen - 1) == 0) {
if (found)
error("%s: ambiguous", name);
found = jp;
Modified: head/bin/sh/mystring.c
==============================================================================
--- head/bin/sh/mystring.c Sun Jul 20 11:00:51 2014 (r268919)
+++ head/bin/sh/mystring.c Sun Jul 20 12:06:52 2014 (r268920)
@@ -61,21 +61,6 @@ char nullstr[1]; /* zero length string
/*
- * prefix -- see if pfx is a prefix of string.
- */
-
-int
-prefix(const char *pfx, const char *string)
-{
- while (*pfx) {
- if (*pfx++ != *string++)
- return 0;
- }
- return 1;
-}
-
-
-/*
* Convert a string of digits to an integer, printing an error message on
* failure.
*/
Modified: head/bin/sh/mystring.h
==============================================================================
--- head/bin/sh/mystring.h Sun Jul 20 11:00:51 2014 (r268919)
+++ head/bin/sh/mystring.h Sun Jul 20 12:06:52 2014 (r268920)
@@ -35,7 +35,6 @@
#include <string.h>
-int prefix(const char *, const char *);
int number(const char *);
int is_number(const char *);
More information about the svn-src-all
mailing list