/[bison]/bison/intl/localealias.c
ViewVC logotype

Diff of /bison/intl/localealias.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.1 by akim, Thu Sep 27 14:06:38 2001 UTC revision 1.2.2.2 by akim, Wed Mar 20 08:43:12 2002 UTC
# Line 29  Line 29 
29    
30  #include <ctype.h>  #include <ctype.h>
31  #include <stdio.h>  #include <stdio.h>
32    #if defined _LIBC || defined HAVE___FSETLOCKING
33    # include <stdio_ext.h>
34    #endif
35  #include <sys/types.h>  #include <sys/types.h>
36    
37  #ifdef __GNUC__  #ifdef __GNUC__
# Line 49  char *alloca (); Line 52  char *alloca ();
52  #endif  #endif
53    
54  #include <stdlib.h>  #include <stdlib.h>
   
55  #include <string.h>  #include <string.h>
 #if !HAVE_STRCHR && !defined _LIBC  
 # ifndef strchr  
 #  define strchr index  
 # endif  
 #endif  
56    
57  #include "gettextP.h"  #include "gettextP.h"
58    
# Line 71  char *alloca (); Line 68  char *alloca ();
68  #  define mempcpy __mempcpy  #  define mempcpy __mempcpy
69  # endif  # endif
70  # define HAVE_MEMPCPY   1  # define HAVE_MEMPCPY   1
71    # define HAVE___FSETLOCKING     1
72    
73  /* We need locking here since we can be called from different places.  */  /* We need locking here since we can be called from different places.  */
74  # include <bits/libc-lock.h>  # include <bits/libc-lock.h>
# Line 82  __libc_lock_define_initialized (static, Line 80  __libc_lock_define_initialized (static,
80  # define internal_function  # define internal_function
81  #endif  #endif
82    
83    /* Some optimizations for glibc.  */
84    #ifdef _LIBC
85    # define FEOF(fp)               feof_unlocked (fp)
86    # define FGETS(buf, n, fp)      fgets_unlocked (buf, n, fp)
87    #else
88    # define FEOF(fp)               feof (fp)
89    # define FGETS(buf, n, fp)      fgets (buf, n, fp)
90    #endif
91    
92  /* For those losing systems which don't have `alloca' we have to add  /* For those losing systems which don't have `alloca' we have to add
93     some additional code emulating it.  */     some additional code emulating it.  */
94  #ifdef HAVE_ALLOCA  #ifdef HAVE_ALLOCA
# Line 128  const char * Line 135  const char *
135  _nl_expand_alias (name)  _nl_expand_alias (name)
136      const char *name;      const char *name;
137  {  {
138    static const char *locale_alias_path = LOCALE_ALIAS_PATH;    static const char *locale_alias_path;
139    struct alias_map *retval;    struct alias_map *retval;
140    const char *result = NULL;    const char *result = NULL;
141    size_t added;    size_t added;
# Line 137  _nl_expand_alias (name) Line 144  _nl_expand_alias (name)
144    __libc_lock_lock (lock);    __libc_lock_lock (lock);
145  #endif  #endif
146    
147      if (locale_alias_path == NULL)
148        locale_alias_path = LOCALE_ALIAS_PATH;
149    
150    do    do
151      {      {
152        struct alias_map item;        struct alias_map item;
# Line 212  read_alias_file (fname, fname_len) Line 222  read_alias_file (fname, fname_len)
222    if (fp == NULL)    if (fp == NULL)
223      return 0;      return 0;
224    
225    #ifdef HAVE___FSETLOCKING
226      /* No threads present.  */
227      __fsetlocking (fp, FSETLOCKING_BYCALLER);
228    #endif
229    
230    added = 0;    added = 0;
231    while (!feof (fp))    while (!FEOF (fp))
232      {      {
233        /* It is a reasonable approach to use a fix buffer here because        /* It is a reasonable approach to use a fix buffer here because
234           a) we are only interested in the first two fields           a) we are only interested in the first two fields
# Line 225  read_alias_file (fname, fname_len) Line 240  read_alias_file (fname, fname_len)
240        char *value;        char *value;
241        char *cp;        char *cp;
242    
243        if (fgets (buf, sizeof buf, fp) == NULL)        if (FGETS (buf, sizeof buf, fp) == NULL)
244          /* EOF reached.  */          /* EOF reached.  */
245          break;          break;
246    
# Line 235  read_alias_file (fname, fname_len) Line 250  read_alias_file (fname, fname_len)
250          {          {
251            char altbuf[BUFSIZ];            char altbuf[BUFSIZ];
252            do            do
253              if (fgets (altbuf, sizeof altbuf, fp) == NULL)              if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
254                /* Make sure the inner loop will be left.  The outer loop                /* Make sure the inner loop will be left.  The outer loop
255                   will exit at the `feof' test.  */                   will exit at the `feof' test.  */
256                break;                break;
# Line 244  read_alias_file (fname, fname_len) Line 259  read_alias_file (fname, fname_len)
259    
260        cp = buf;        cp = buf;
261        /* Ignore leading white space.  */        /* Ignore leading white space.  */
262        while (isspace (cp[0]))        while (isspace ((unsigned char) cp[0]))
263          ++cp;          ++cp;
264    
265        /* A leading '#' signals a comment line.  */        /* A leading '#' signals a comment line.  */
266        if (cp[0] != '\0' && cp[0] != '#')        if (cp[0] != '\0' && cp[0] != '#')
267          {          {
268            alias = cp++;            alias = cp++;
269            while (cp[0] != '\0' && !isspace (cp[0]))            while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
270              ++cp;              ++cp;
271            /* Terminate alias name.  */            /* Terminate alias name.  */
272            if (cp[0] != '\0')            if (cp[0] != '\0')
273              *cp++ = '\0';              *cp++ = '\0';
274    
275            /* Now look for the beginning of the value.  */            /* Now look for the beginning of the value.  */
276            while (isspace (cp[0]))            while (isspace ((unsigned char) cp[0]))
277              ++cp;              ++cp;
278    
279            if (cp[0] != '\0')            if (cp[0] != '\0')
# Line 267  read_alias_file (fname, fname_len) Line 282  read_alias_file (fname, fname_len)
282                size_t value_len;                size_t value_len;
283    
284                value = cp++;                value = cp++;
285                while (cp[0] != '\0' && !isspace (cp[0]))                while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
286                  ++cp;                  ++cp;
287                /* Terminate value.  */                /* Terminate value.  */
288                if (cp[0] == '\n')                if (cp[0] == '\n')

Legend:
Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26