]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Merge with glibc.
authorBruno Haible <bruno@clisp.org>
Thu, 29 Nov 2001 13:15:36 +0000 (13:15 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 21:28:07 +0000 (23:28 +0200)
intl/ChangeLog
intl/localealias.c

index ed03cfe22fcc154bb6944cdbfd8718925833da7a..d34bdfa3801a843256805cdb1da2d64197950a0b 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-17  Ulrich Drepper  <drepper@redhat.com>
+
+       * localealias.c (read_alias_file): Disable implicit locking
+       for the stream.  Use _unlocked functions for glibc.
+
 2001-11-11  Bruno Haible  <haible@clisp.cons.org>
 
        * Makefile.in (dist): Avoid using hard links, because the automake-1.5
index 9c90cad5efb415f0145f3d6d0b07d6661e1802ef..ef17b38c94a68bdec543fb7863df6c50ead61ac7 100644 (file)
@@ -29,6 +29,9 @@
 
 #include <ctype.h>
 #include <stdio.h>
+#if defined _LIBC || defined HAVE___FSETLOCKING
+# include <stdio_ext.h>
+#endif
 #include <sys/types.h>
 
 #ifdef __GNUC__
@@ -65,6 +68,7 @@ char *alloca ();
 #  define mempcpy __mempcpy
 # endif
 # define HAVE_MEMPCPY  1
+# define HAVE___FSETLOCKING    1
 
 /* We need locking here since we can be called from different places.  */
 # include <bits/libc-lock.h>
@@ -76,6 +80,15 @@ __libc_lock_define_initialized (static, lock);
 # define internal_function
 #endif
 
+/* Some optimizations for glibc.  */
+#ifdef _LIBC
+# define FEOF(fp)              feof_unlocked (fp)
+# define FGETS(buf, n, fp)     fgets_unlocked (buf, n, fp)
+#else
+# define FEOF(fp)              feof (fp)
+# define FGETS(buf, n, fp)     fgets (buf, n, fp)
+#endif
+
 /* For those losing systems which don't have `alloca' we have to add
    some additional code emulating it.  */
 #ifdef HAVE_ALLOCA
@@ -206,8 +219,13 @@ read_alias_file (fname, fname_len)
   if (fp == NULL)
     return 0;
 
+#ifdef HAVE___FSETLOCKING
+  /* No threads present.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
+
   added = 0;
-  while (!feof (fp))
+  while (!FEOF (fp))
     {
       /* It is a reasonable approach to use a fix buffer here because
         a) we are only interested in the first two fields
@@ -219,7 +237,7 @@ read_alias_file (fname, fname_len)
       char *value;
       char *cp;
 
-      if (fgets (buf, sizeof buf, fp) == NULL)
+      if (FGETS (buf, sizeof buf, fp) == NULL)
        /* EOF reached.  */
        break;
 
@@ -229,7 +247,7 @@ read_alias_file (fname, fname_len)
        {
          char altbuf[BUFSIZ];
          do
-           if (fgets (altbuf, sizeof altbuf, fp) == NULL)
+           if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
              /* Make sure the inner loop will be left.  The outer loop
                 will exit at the `feof' test.  */
              break;