public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/166] New: strcasestr.c with local support (partial solution shown)
@ 2004-05-16  8:46 Digital at JoesCat dot com
  2004-05-17 19:45 ` [Bug libc/166] " pere at hungry dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Digital at JoesCat dot com @ 2004-05-16  8:46 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-05 22:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-16  8:46 [Bug libc/166] New: strcasestr.c with local support (partial solution shown) Digital at JoesCat dot com
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

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).