]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* string/Makefile (tst-strxfrm2-ENV): Define.
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Jan 2007 18:02:24 +0000 (18:02 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 12 Jan 2007 18:02:24 +0000 (18:02 +0000)
* string/strxfrm_l.c (STRXFRM): Fix trailing \1 optimization
if N is one bigger than return value.
* string/tst-strxfrm2.c (do_test): Also test strxfrm with l1 + 1
and l1 last arguments, if buf is defined, verify the return value
equals to strlen (buf) and verify no byte beyond passed length
is modified.

* string/Makefile (tests): Add tst-strxfrm2.
* string/tst-strxfrm2.c: New file.

* string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal
optimization even if needed > n.

ChangeLog
string/Makefile
string/strxfrm_l.c

index 0afd09566b38791a0a751518bf0c899dd9508b66..6697b048b2550c979583c360b1f29293036a9049 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2007-01-03  Ulrich Drepper  <drepper@redhat.com>
+
+       * string/Makefile (tst-strxfrm2-ENV): Define.
+
+2006-11-10  Jakub Jelinek  <jakub@redhat.com>
+
+       * string/strxfrm_l.c (STRXFRM): Fix trailing \1 optimization
+       if N is one bigger than return value.
+       * string/tst-strxfrm2.c (do_test): Also test strxfrm with l1 + 1
+       and l1 last arguments, if buf is defined, verify the return value
+       equals to strlen (buf) and verify no byte beyond passed length
+       is modified.
+
+2006-11-09  Ulrich Drepper  <drepper@redhat.com>
+
+       * string/Makefile (tests): Add tst-strxfrm2.
+       * string/tst-strxfrm2.c: New file.
+
+2006-11-08  Jakub Jelinek  <jakub@redhat.com>
+
+       * string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal
+       optimization even if needed > n.
+
 2006-12-22  Gavin Romig-Koch  <gavin@redhat.com>
 
        * nis/nss_compat/compat-grp.c (internal_getgrgid_r): Don't
index a84ebebcaa8544d65423ef14eb3e317d1f36e463..f087022b3c0946f6217ec9c0caa09cccac0450f2 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002, 2005, 2006, 2007 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -54,7 +54,7 @@ tests         := tester inl-tester noinl-tester testcopy test-ffs     \
                   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap      \
                   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry       \
                   bug-strtok1 $(addprefix test-,$(strop-tests))        \
-                  bug-envz1
+                  bug-envz1 tst-strxfrm2
 distribute     := memcopy.h pagecopy.h tst-svc.expect test-string.h
 
 
@@ -64,6 +64,7 @@ tester-ENV = LANGUAGE=C
 inl-tester-ENV = LANGUAGE=C
 noinl-tester-ENV = LANGUAGE=C
 tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata
+tst-strxfrm2-ENV = LOCPATH=$(common-objpfx)localedata
 bug-strcoll1-ENV = LOCPATH=$(common-objpfx)localedata
 CFLAGS-inl-tester.c = -fno-builtin
 CFLAGS-noinl-tester.c = -fno-builtin
index 533560191919173ddc30b0c92da4d22a528c921e..20f2f149bdea97134b6db5360aa4c74564847247 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995,96,97,2002, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 2002, 2004, 2005, 2006
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -96,6 +97,7 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
   const int32_t *indirect;
   uint_fast32_t pass;
   size_t needed;
+  size_t last_needed;
   const USTRING_TYPE *usrc;
   size_t srclen = STRLEN (src);
   int32_t *idxarr;
@@ -197,6 +199,7 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
         this is true for all of them.  */
       int position = rule & sort_position;
 
+      last_needed = needed;
       if (position == 0)
        {
          for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
@@ -426,11 +429,11 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
      a `position' rule at the end and if no non-ignored character
      is found the last \1 byte is immediately followed by a \0 byte
      signalling this.  We can avoid the \1 byte(s).  */
-  if (needed <= n && needed > 2 && dest[needed - 2] == L('\1'))
+  if (needed > 2 && needed == last_needed + 1)
     {
       /* Remove the \1 byte.  */
-      --needed;
-      dest[needed - 1] = L('\0');
+      if (--needed <= n)
+       dest[needed - 1] = L('\0');
     }
 
   /* Free the memory if needed.  */