From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78623 invoked by alias); 13 Aug 2019 00:00:26 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 78133 invoked by uid 89); 13 Aug 2019 00:00:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=needle, H*F:D*it X-HELO: mail-ot1-f50.google.com Received: from mail-ot1-f50.google.com (HELO mail-ot1-f50.google.com) (209.85.210.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Aug 2019 00:00:14 +0000 Received: by mail-ot1-f50.google.com with SMTP id o101so12896962ota.8 for ; Mon, 12 Aug 2019 17:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesio-it.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=UZzXiFbMbraxDjx1RmYhPMEAzVhxC8pSlP0ygRhfv+E=; b=GnwmZsToZbQ88fgxwryBWZMC3H0EDGRkBi1bDX1CD1qWQw7CadasFlY8nZRTFOQud9 JmA4I23zavKFEeIQphluyT4gsZ7RD/xy5Pmx+NM9wJAiyf+jzyf+TtbuDtoTpLLN48SI 9iMkwNO/s9jKG6i1Q77SBKy9XJe+aZyWLgdizYEKmte0mEf5scU/0NBtmgDEVBnUlRK3 JjCxVMXFt3P5ZrQwlDvYzGtqqBdguJaJizcHrl9ti2SLAWkItDeqXmTLn/1pdoAw6uIc hbGdA5S6CVSxgx5tIh8uus2ne9QjJ45t5TOmoLvbdM7wc5HZ/3/7LqLiewGo2wQAuhCC +d5g== MIME-Version: 1.0 Received: by 2002:a4f:705:0:0:0:0:0 with HTTP; Mon, 12 Aug 2019 17:00:07 -0700 (PDT) From: Giacomo Tesio Date: Tue, 13 Aug 2019 00:00:00 -0000 Message-ID: Subject: [PATCH] memmem.c and strstr.c: do not require -std=c99 To: newlib@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019/txt/msg00469.txt.bz2 --- newlib/libc/string/memmem.c | 3 ++- newlib/libc/string/strstr.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/newlib/libc/string/memmem.c b/newlib/libc/string/memmem.c index 55d2459aa..65267b9c5 100644 --- a/newlib/libc/string/memmem.c +++ b/newlib/libc/string/memmem.c @@ -143,10 +143,11 @@ memmem (const void *haystack, size_t hs_len, const void *needle, size_t ne_len) size_t tmp, shift1; size_t m1 = ne_len - 1; size_t offset = 0; + int i; /* Initialize bad character shift hash table. */ memset (shift, 0, sizeof (shift)); - for (int i = 1; i < m1; i++) + for (i = 1; i < m1; i++) shift[hash2 (ne + i)] = i; shift1 = m1 - shift[hash2 (ne + m1)]; shift[hash2 (ne + m1)] = m1; diff --git a/newlib/libc/string/strstr.c b/newlib/libc/string/strstr.c index 0256c1aa6..00fe060e9 100644 --- a/newlib/libc/string/strstr.c +++ b/newlib/libc/string/strstr.c @@ -102,7 +102,8 @@ strstr2 (const unsigned char *hs, const unsigned char *ne) { uint32_t h1 = (ne[0] << 16) | ne[1]; uint32_t h2 = 0; - for (int c = hs[0]; h1 != h2 && c != 0; c = *++hs) + int c; + for (c = hs[0]; h1 != h2 && c != 0; c = *++hs) h2 = (h2 << 16) | c; return h1 == h2 ? (char *)hs - 2 : NULL; } @@ -112,7 +113,8 @@ strstr3 (const unsigned char *hs, const unsigned char *ne) { uint32_t h1 = (ne[0] << 24) | (ne[1] << 16) | (ne[2] << 8); uint32_t h2 = 0; - for (int c = hs[0]; h1 != h2 && c != 0; c = *++hs) + int c; + for (c = hs[0]; h1 != h2 && c != 0; c = *++hs) h2 = (h2 | c) << 8; return h1 == h2 ? (char *)hs - 3 : NULL; } @@ -122,7 +124,8 @@ strstr4 (const unsigned char *hs, const unsigned char *ne) { uint32_t h1 = (ne[0] << 24) | (ne[1] << 16) | (ne[2] << 8) | ne[3]; uint32_t h2 = 0; - for (int c = hs[0]; c != 0 && h1 != h2; c = *++hs) + int c; + for (c = hs[0]; c != 0 && h1 != h2; c = *++hs) h2 = (h2 << 8) | c; return h1 == h2 ? (char *)hs - 4 : NULL; } @@ -142,6 +145,7 @@ strstr (const char *haystack, const char *needle) { const unsigned char *hs = (const unsigned char *) haystack; const unsigned char *ne = (const unsigned char *) needle; + int i; /* Handle short needle special cases first. */ if (ne[0] == '\0') @@ -170,7 +174,7 @@ strstr (const char *haystack, const char *needle) /* Initialize bad character shift hash table. */ memset (shift, ne_len + 1, sizeof (shift)); - for (int i = 0; i < ne_len; i++) + for (i = 0; i < ne_len; i++) shift[ne[i] % sizeof (shift)] = ne_len - i; do -- 2.11.0