]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 5 Sep 2001 00:26:04 +0000 (00:26 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 5 Sep 2001 00:26:04 +0000 (00:26 +0000)
2001-09-04  Jakub Jelinek  <jakub@redhat.com>

* iconv/strtab.c (strtabinit): Initialize null Strent.
(newstring): Move len == 0 handling...
(strtabadd): ...here.
If len == 1, return null Strent.
When inserting a suffix of an existing string, check if
it is not equal to some suffix already recorded.
Copy left and right members over if adding longer string.

2001-09-04  Jakub Jelinek  <jakub@redhat.com>

* sunrpc/rpc_cout.c (upcase): Account for trailing '\0'.

* sysdeps/unix/sysv/linux/alpha/gethostname.c: Include <errno.h>.
(__syscall_gethostname): Add prototype.

ChangeLog
iconv/strtab.c
sunrpc/rpc_cout.c
sysdeps/unix/sysv/linux/alpha/gethostname.c

index 9f4379d2b42819d391baf5d5f2b00ee1da321976..0f6f2862b0d96dd2a7b61646374342852789e015 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-09-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * iconv/strtab.c (strtabinit): Initialize null Strent.
+       (newstring): Move len == 0 handling...
+       (strtabadd): ...here.
+       If len == 1, return null Strent.
+       When inserting a suffix of an existing string, check if
+       it is not equal to some suffix already recorded.
+       Copy left and right members over if adding longer string.
+
+2001-09-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * sunrpc/rpc_cout.c (upcase): Account for trailing '\0'.
+
+       * sysdeps/unix/sysv/linux/alpha/gethostname.c: Include <errno.h>.
+       (__syscall_gethostname): Add prototype.
+
 2001-09-04  Ulrich Drepper  <drepper@redhat.com>
 
        * elf/dl-object.c (_dl_new_object): Remove unnecessary if.
index 4189f97281a6774e209ed5be54c89b5f5d4eeda6..e6feb2cf24a79803198e746370c1e63ef4e0c080 100644 (file)
@@ -90,13 +90,21 @@ extern size_t strtaboffset (struct Strent *se);
 struct Strtab *
 strtabinit (void)
 {
+  struct Strtab *ret;
+
   if (ps == 0)
     {
       ps = sysconf (_SC_PAGESIZE) - 2 * sizeof (void *);
       assert (sizeof (struct memoryblock) < ps);
     }
 
-  return (struct Strtab *) calloc (1, sizeof (struct Strtab));
+  ret = (struct Strtab *) calloc (1, sizeof (struct Strtab));
+  if (ret != NULL)
+    {
+      ret->null.len = 1;
+      ret->null.string = "";
+    }
+  return ret;
 }
 
 
@@ -141,10 +149,6 @@ newstring (struct Strtab *st, const char *str, size_t len)
   size_t align;
   int i;
 
-  /* Compute the string length if the caller doesn't know it.  */
-  if (len == 0)
-    len = strlen (str) + 1;
-
   /* Compute the amount of padding needed to make the structure aligned.  */
   align = ((__alignof__ (struct Strent)
            - (((uintptr_t) st->backp)
@@ -211,6 +215,14 @@ strtabadd (struct Strtab *st, const char *str, size_t len)
   struct Strent *newstr;
   struct Strent **sep;
 
+  /* Compute the string length if the caller doesn't know it.  */
+  if (len == 0)
+    len = strlen (str) + 1;
+
+  /* Make sure all "" strings get offset 0.  */
+  if (len == 1)
+    return &st->null;
+
   /* Allocate memory for the new string and its associated information.  */
   newstr = newstring (st, str, len);
 
@@ -223,6 +235,19 @@ strtabadd (struct Strtab *st, const char *str, size_t len)
       /* This is not the same entry.  This means we have a prefix match.  */
       if ((*sep)->len > newstr->len)
        {
+         struct Strent *subs;
+
+         for (subs = (*sep)->next; subs; subs = subs->next)
+           if (subs->len == newstr->len)
+             {
+               /* We have an exact match with a substring.  Free the memory
+                  we allocated.  */
+               st->left += st->backp - (char *) newstr;
+               st->backp = (char *) newstr;
+
+               return subs;
+             }
+
          /* We have a new substring.  This means we don't need the reverse
             string of this entry anymore.  */
          st->backp -= newstr->len;
@@ -238,6 +263,8 @@ strtabadd (struct Strtab *st, const char *str, size_t len)
             it is longer.  In this case we have to put it first.  */
          st->total += newstr->len - (*sep)->len;
          newstr->next = *sep;
+         newstr->left = (*sep)->left;
+         newstr->right = (*sep)->right;
          *sep = newstr;
        }
       else
index 44027ea39ef733d57b3d49267086f478563531f7..a6471ab335480597d93f4abdda4610e51e96e438 100644 (file)
@@ -801,7 +801,7 @@ static char *
 upcase (const char *str)
 {
   char *ptr, *hptr;
-  ptr = malloc (strlen (str));
+  ptr = malloc (strlen (str) + 1);
   if (ptr == NULL)
     {
       f_print (stderr, "malloc failed\n");
index 28846efe57bde92cc18126c9392b1b47c8c4ee0a..3a48afccd3506b5771aac892dfd6455ff2199429 100644 (file)
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -24,6 +25,8 @@
 #include <sys/syscall.h>
 #include <bp-checks.h>
 
+extern int __syscall_gethostname (char *name, size_t len);
+
 
 int
 __gethostname (char *name, size_t len)
This page took 0.050744 seconds and 5 git commands to generate.