From: Bruno Haible Date: Thu, 29 Nov 2001 13:15:36 +0000 (+0000) Subject: Merge with glibc. X-Git-Tag: v0.11~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c203aa7b8b6fb4f0126d2a2e24c667aca58ee85;p=thirdparty%2Fgettext.git Merge with glibc. --- diff --git a/intl/ChangeLog b/intl/ChangeLog index ed03cfe22..d34bdfa38 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,8 @@ +2001-07-17 Ulrich Drepper + + * localealias.c (read_alias_file): Disable implicit locking + for the stream. Use _unlocked functions for glibc. + 2001-11-11 Bruno Haible * Makefile.in (dist): Avoid using hard links, because the automake-1.5 diff --git a/intl/localealias.c b/intl/localealias.c index 9c90cad5e..ef17b38c9 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -29,6 +29,9 @@ #include #include +#if defined _LIBC || defined HAVE___FSETLOCKING +# include +#endif #include #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 @@ -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;