This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/166] New: strcasestr.c with local support (partial solution shown)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]