public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Digital at JoesCat dot com" <sourceware-bugzilla@sources.redhat.com>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/166] New: strcasestr.c with local support (partial solution shown)
Date: Sun, 16 May 2004 08:46:00 -0000	[thread overview]
Message-ID: <20040516084644.166.Digital@JoesCat.com> (raw)

This is a suggestion for local support as I see it being used with some of the 
other str functions. 
I am no expert, but here is the beginning of a locals support for strcasestr.c 
I know there is more involved, but I am not at that level of expertise yet. 
this update builts on the improvement shown in bug 126. 
 
I called it strcasestr_.c just to differentiate it, but in reality, I believe 
it would be an improvement to strcasestr.c 
Hopefully this is a start  ;-) 
 
--- strcasestr.c        2004-04-20 17:38:13.000000000 -0700 
+++ strcasestr_.c       2004-05-16 01:31:21.591192424 -0700 
@@ -41,13 +41,34 @@ 
 
 typedef unsigned chartype; 
 
-#undef strcasestr 
-#undef __strcasestr 
+#ifndef weak_alias 
+# define __strcasestr strcasestr 
+# define TOLOWER(Ch) tolower (Ch) 
+# define TOUPPER(Ch) toupper (Ch) 
+#else 
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL 
+#  define __strcasestr __strcasestr_l 
+#  define TOLOWER(Ch) __tolower_l ((Ch), loc) 
+#  define TOUPPER(Ch) __toupper_l ((Ch), loc) 
+# else 
+#  define TOLOWER(Ch) tolower (Ch) 
+#  define TOUPPER(Ch) toupper (Ch) 
+# endif 
+#endif 
+ 
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL 
+# define LOCALE_PARAM , loc 
+# define LOCALE_PARAM_DECL __locale_t loc; 
+#else 
+# define LOCALE_PARAM 
+# define LOCALE_PARAM_DECL 
+#endif 
 
 char * 
-__strcasestr (phaystack, pneedle) 
+__strcasestr (phaystack, pneedle LOCAL_PARAM) 
      const char *phaystack; 
      const char *pneedle; 
+     LOCALE_PARAM_DECL 
 { 
   register const unsigned char *haystack, *needle; 
   register chartype bl, bu, cl, cu; 
@@ -55,10 +76,10 @@ 
   haystack = (const unsigned char *) phaystack; 
   needle = (const unsigned char *) pneedle; 
 
-  bl = _tolower (*needle); 
+  bl = TOLOWER (*needle); 
   if (bl != '\0') 
     { 
-      bu = _toupper (bl); 
+      bu = TOUPPER (bl); 
       haystack--;                              /* possible ANSI violation */ 
       do 
        { 
@@ -68,10 +89,10 @@ 
        } 
       while ((cl != bl) && (cl != bu)); 
 
-      cl = _tolower (*++needle); 
+      cl = TOLOWER (*++needle); 
       if (cl == '\0') 
        goto foundneedle; 
-      cu = _toupper (cl); 
+      cu = TOUPPER (cl); 
       ++needle; 
       goto jin; 
 
@@ -104,23 +125,23 @@ 
 
          rhaystack = haystack-- + 1; 
          rneedle = needle; 
-         a = _tolower (*rneedle); 
+         a = TOLOWER (*rneedle); 
 
-         if (_tolower (*rhaystack) == (int) a) 
+         if (TOLOWER (*rhaystack) == (int) a) 
            do 
              { 
                if (a == '\0') 
                  goto foundneedle; 
                ++rhaystack; 
-               a = _tolower (*++needle); 
-               if (_tolower (*rhaystack) != (int) a) 
+               a = TOLOWER (*++needle); 
+               if (TOLOWER (*rhaystack) != (int) a) 
                  break; 
                if (a == '\0') 
                  goto foundneedle; 
                ++rhaystack; 
-               a = _tolower (*++needle); 
+               a = TOLOWER (*++needle); 
              } 
-           while (_tolower (*rhaystack) == (int) a); 
+           while (TOLOWER (*rhaystack) == (int) a); 
 
          needle = rneedle;             /* took the register-poor approach */ 
 
@@ -133,5 +154,6 @@ 
 ret0: 
   return 0; 
 } 
- 
+#ifndef __strcasestr 
 weak_alias (__strcasestr, strcasestr) 
+#endif

-- 
           Summary: strcasestr.c with local support (partial solution shown)
           Product: glibc
           Version: 2.3.2
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: Digital at JoesCat dot com
                CC: glibc-bugs at sources dot redhat dot com
 BugsThisDependsOn: 126


http://sources.redhat.com/bugzilla/show_bug.cgi?id=166

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2004-05-16  8:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-16  8:46 Digital at JoesCat dot com [this message]
2004-05-17 19:45 ` [Bug libc/166] " pere at hungry dot com
2004-05-18  1:28 ` Digital at JoesCat dot com
2004-06-05  3:51 ` Digital at JoesCat dot com
2006-02-05 22:49 ` roland at gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040516084644.166.Digital@JoesCat.com \
    --to=sourceware-bugzilla@sources.redhat.com \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).