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

* [Bug libc/166] strcasestr.c with local support (partial solution shown)
  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 ` pere at hungry dot com
  2004-05-18  1:28 ` Digital at JoesCat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pere at hungry dot com @ 2004-05-17 19:45 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From pere at hungry dot com  2004-05-17 19:45 -------
Can you explain how this patch is supposed to change the behavoiur
of strcasestr()?  It would be easier to evaluate it if the intention
was explicitly stated.

-- 


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

* [Bug libc/166] strcasestr.c with local support (partial solution shown)
  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
  3 siblings, 0 replies; 5+ messages in thread
From: Digital at JoesCat dot com @ 2004-05-18  1:28 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Subject: Re:  strcasestr.c with local support (partial solution shown)

On Monday 17 May 2004 12:45, pere at hungry dot com wrote:
>------- Additional Comments From pere at hungry dot com  2004-05-17 19:45
> ------- Can you explain how this patch is supposed to change the
> behavoiur of strcasestr()?  It would be easier to evaluate it if the
> intention was explicitly stated.

Sorry, I haven't really figured out bugzilla to have included the details 
as attachments, plus I've run into these enter boxes where there is a 
limit of 4000 characters or something like that, therefore clipping-out 
further important information (I did not want it to clip info, therefore 
that is why the brief diff solution).

Thank you for replying as you have more experience dealing with and 
inserting attachments into bugzilla (I hope).

Looking at glib, I notice that there is localized equivalents to strcase 
functions (note the added _l to examples below):
glibc-2.3.2/sysdeps/generic/strcasecmp.c
glibc-2.3.2/sysdeps/generic/strcasecmp_l.c

glibc-2.3.2/sysdeps/generic/strncase.c
glibc-2.3.2/sysdeps/generic/strncase_l.c

It appears that strcasestr.c is the only exception without an _l 
equivalent, so I was suggesting also adding an _l version for strcasestr.c 
because it also is a strcase type function.

so:
glibc-2.3.2/sysdeps/generic/strcasestr.c

becomes:
glibc-2.3.2/sysdeps/generic/strcasestr.c
glibc-2.3.2/sysdeps/generic/strcasestr_l.c

If I use strncase.c and strncase_l.c as a template example, then this is 
the expected results (I hope, but think I may be missing information):

diff.txt
version 2.3.2 -> improved version shown in bug126

diff_.txt
improvement version shown in bug126 -> "_l" version

strcasestr.c
this includes bug126 improvement plus _l changes I hope gets inserted
(I used strncase.c as template example for this)
(I am not sure about the undef __strcasestr since I do not know how to 
compile the glib libraries yet)

strcasestr_l.c
(new file required if I follow strncase.c as example)

diff_.txt
here is the diff_.txt between the previous improvement suggested in bug 126 
and the new improved strcasestr.c with _l added
(no longer important since you see accumilated changes in strcasestr.c 
attached).

I believe the string.h files need to be updated as well to include 
recognition for strcasestr_l but was unsure where to put it since you may 
have some sort of "order' which you would prever to keep it in.

Then there needs to be some way to include the new strcasestr_l when 
compiling the entire library, but since i'm not sure where to look yet, 
I'm hoping that you have more experience in knowing where to activate it.

Sorry about an incomplete solution, but I hope my bug166 allows you to be 
aware that maybe strcasestr could be improved for local functionality :-)

question:
BTW did bug 126 get included?
I don't know where to look for the upgraded libraries - that is if it 
actually got included  ???.

Thanks,
I hope this helps, but if you need more info, please reply.

------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Created an attachment (id=84)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=84&action=view)

------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Created an attachment (id=85)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=85&action=view)

------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Created an attachment (id=86)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=86&action=view)

------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Created an attachment (id=87)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=87&action=view)

------- Additional Comments From Digital at JoesCat dot com  2004-05-18 01:28 -------
Created an attachment (id=88)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=88&action=view)


-- 


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

* [Bug libc/166] strcasestr.c with local support (partial solution shown)
  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
  3 siblings, 0 replies; 5+ messages in thread
From: Digital at JoesCat dot com @ 2004-06-05  3:51 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From Digital at JoesCat dot com  2004-06-05 03:51 -------
On further looking, found that the TOLOWER locales support has already been 
implemented, so this bug report is no longer valid. 
Requesting to close this bug report. 
 
thanks. 
 
See: sources.redhat.com 
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/generic/strcasestr.c?cvsroot=glibc 
 
You will note where version 1.7 already has improvments done. 
 
Bug 126 (speed improvement) will be sent with improvements according to updates 
as seen on URL pointed to above. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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

* [Bug libc/166] strcasestr.c with local support (partial solution shown)
  2004-05-16  8:46 [Bug libc/166] New: strcasestr.c with local support (partial solution shown) Digital at JoesCat dot com
                   ` (2 preceding siblings ...)
  2004-06-05  3:51 ` Digital at JoesCat dot com
@ 2006-02-05 22:49 ` roland at gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: roland at gnu dot org @ 2006-02-05 22:49 UTC (permalink / raw)
  To: glibc-bugs



-- 
Bug 166 depends on bug 126, which changed state.

Bug 126 Summary: speed improvement for strcasestr.c (included code if you request)
http://sourceware.org/bugzilla/show_bug.cgi?id=126

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
             Status|WAITING                     |RESOLVED
         Resolution|                            |WONTFIX

http://sourceware.org/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).