From owner-svn-src-all@FreeBSD.ORG Sun Jul 20 12:06:53 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 55E58A92; Sun, 20 Jul 2014 12:06:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AAAB2E01; Sun, 20 Jul 2014 12:06:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6KC6rtf013339; Sun, 20 Jul 2014 12:06:53 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6KC6q37013335; Sun, 20 Jul 2014 12:06:52 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201407201206.s6KC6q37013335@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 20 Jul 2014 12:06:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268920 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Jul 2014 12:06:53 -0000 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 -int prefix(const char *, const char *); int number(const char *); int is_number(const char *);