From patchwork Wed Jan 11 15:52:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 18852 Received: (qmail 18639 invoked by alias); 11 Jan 2017 15:52:50 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18619 invoked by uid 89); 11 Jan 2017 15:52:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_40, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 spammy=__THROW, __destlen, __throw, __dest X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: Joseph Myers CC: "libc-alpha@sourceware.org" , nd Subject: Re: [PATCH v2] Remove index defines Date: Wed, 11 Jan 2017 15:52:35 +0000 Message-ID: References: , , In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-office365-filtering-correlation-id: 94d74017-ce39-4d37-e5e8-08d43a39dcc4 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0802MB2611; x-microsoft-exchange-diagnostics: 1; AM5PR0802MB2611; 7:o+MUt4kpipXqLanECoQGXqNrw5R22DgQK5/I0+I5vUV/09R5R6Cc1M4n/8Q7seg64YfXorcRnKEs7dIRiL4xy6qWRk2T61G8uPhvrLtIkffTriKTsyZBYV5cbU8PrkSTMgnLsrr+/q9qr+0eIm3hWOgBf9hDk9EzVb25pkrVn109AAahTIgPbC/pnsOQUBkkVNBqP68bNyM41fkDHT0/etLTNL+QmrUu7mZXjzEUepIEqtPF3BL1KTsW6l6RXTFZWsgpLGMFpv45wWaT3Gu7LjTCswgPpyh2oaA+9gjjgb+u9HSM5by+gznVAzQLa+7zsBjtRMIeqdkmfq9ZYKQAKEewIZAFtfq2evgrzjRBQSiW9mDdj8sCaohBNi9AJQrK6aTFoEpZzXVCPvljboNQMHSSSL3OtPrUIDSAB3j91yYLRK5o7ztTY//MPs5A3BW35aoE5iRacLvZmnzh8iBN9w== nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:AM5PR0802MB2611; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2611; x-forefront-prvs: 01842C458A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39410400002)(39840400002)(39850400002)(39450400003)(39860400002)(377424004)(199003)(54534003)(189002)(38730400001)(6506006)(6116002)(102836003)(3846002)(101416001)(76176999)(54356999)(66066001)(33656002)(3280700002)(50986999)(77096006)(93886004)(7736002)(305945005)(97736004)(229853002)(99286003)(4326007)(5660300001)(92566002)(7696004)(9686003)(189998001)(2900100001)(110136003)(55016002)(74316002)(3660700001)(25786008)(86362001)(81166006)(68736007)(8936002)(8676002)(81156014)(106356001)(106116001)(6436002)(122556002)(575784001)(54906002)(6916009)(2950100002)(2906002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2611; H:AM5PR0802MB2610.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2017 15:52:35.5138 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2611 OK here is a new version that also removes index from hurd and sunrpc: As a minor cleanup remove the (r)index defines from include/string.h as they are only used internally in a few places. Rename all uses that occur in GLIBC to str(r)chr. ChangeLog: 2017-01-11 Wilco Dijkstra * hurd/path-lookup.c (file_name_path_scan): Rename index to strchr. * include/string.h (index): Remove define. (rindex): Likewise. * misc/getttyent.c (__getttyent): Rename index to strchr. * misc/ttyslot.c (ttyslot): Rename rindex to strrchr. * sunrpc/rpc_main.c (mkfile_output): Likewise. diff --git a/hurd/path-lookup.c b/hurd/path-lookup.c index d79a482e834d15895f64efd2858899eb9aaf48cd..f2061b0bff1a1babced48e98f6592a5c15e177b2 100644 --- a/hurd/path-lookup.c +++ b/hurd/path-lookup.c @@ -33,7 +33,7 @@ file_name_path_scan (const char *file_name, const char *path, error_t (*fun)(const char *name), char **prefixed_name) { - if (path == NULL || index (file_name, '/')) + if (path == NULL || strchr (file_name, '/')) { if (prefixed_name) *prefixed_name = 0; @@ -47,7 +47,7 @@ file_name_path_scan (const char *file_name, const char *path, for (;;) { error_t err; - const char *next = index (path, ':') ?: path + strlen (path); + const char *next = strchr (path, ':') ?: path + strlen (path); size_t pfx_len = next - path; char pfxed_name[pfx_len + 2 + file_name_len + 1]; diff --git a/include/string.h b/include/string.h index 300a2e2faa7d4000431329e2c7848db7bb9a6258..07389f327886bccc3ba30a0056c25a309c72079c 100644 --- a/include/string.h +++ b/include/string.h @@ -160,15 +160,6 @@ extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy"); #endif -# ifndef _ISOMAC -# ifndef index -# define index(s, c) (strchr ((s), (c))) -# endif -# ifndef rindex -# define rindex(s, c) (strrchr ((s), (c))) -# endif -# endif - extern void *__memcpy_chk (void *__restrict __dest, const void *__restrict __src, size_t __len, size_t __destlen) __THROW; diff --git a/misc/getttyent.c b/misc/getttyent.c index d2af87012343b0596d50dfdecff14ecf55c16732..73002f52d10dc30af95d3163bc5f7a1992fe9dce 100644 --- a/misc/getttyent.c +++ b/misc/getttyent.c @@ -78,7 +78,7 @@ __getttyent (void) return (NULL); } /* skip lines that are too big */ - if (!index(p, '\n')) { + if (!strchr (p, '\n')) { while ((c = getc_unlocked(tf)) != '\n' && c != EOF) ; continue; @@ -127,7 +127,7 @@ __getttyent (void) tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; - if ((p = index(p, '\n'))) + if ((p = strchr (p, '\n'))) *p = '\0'; return (&tty); } @@ -179,7 +179,7 @@ internal_function value (char *p) { - return ((p = index(p, '=')) ? ++p : NULL); + return ((p = strchr (p, '=')) ? ++p : NULL); } int diff --git a/misc/ttyslot.c b/misc/ttyslot.c index 0ed14d73ea53e7ed09c58717316fea20fa0177eb..2f3c7953d75c8522f3b6447c43a9e33aa19e8f72 100644 --- a/misc/ttyslot.c +++ b/misc/ttyslot.c @@ -56,7 +56,7 @@ ttyslot (void) __setttyent(); for (cnt = 0; cnt < 3; ++cnt) if (__ttyname_r (cnt, name, buflen) == 0) { - if ((p = rindex(name, '/'))) + if ((p = strrchr (name, '/'))) ++p; else p = name; diff --git a/sunrpc/rpc_main.c b/sunrpc/rpc_main.c index 0a51e2cfa233570eeee15705da19c1af7ad3147e..f94bc91546ffe58881374ab9363d73bf4e8a11d2 100644 --- a/sunrpc/rpc_main.c +++ b/sunrpc/rpc_main.c @@ -956,7 +956,7 @@ mkfile_output (struct commandline *cmd) mkfilename = alloc (strlen ("Makefile.") + strlen (cmd->infile) + 1); if (mkfilename == NULL) abort (); - temp = rindex (cmd->infile, '.'); + temp = strrchr (cmd->infile, '.'); cp = stpcpy (mkfilename, "Makefile."); if (temp != NULL) *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';