annotate src/audacious/intl/localealias.c @ 4793:7f318fa97ea3

Only gtk.h should be included, as per -DGTK_DISABLE_SINGLE_INCLUDES (GTK+ 3 compatibility project).
author Tony Vroon <chainsaw@gentoo.org>
date Sat, 04 Oct 2008 23:41:34 +0100
parents 59452118044d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Handle aliases for locale names.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2 Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify it
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 under the terms of the GNU Library General Public License as published
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 by the Free Software Foundation; either version 2, or (at your option)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 any later version.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
12 Library General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 You should have received a copy of the GNU Library General Public
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 License along with this program; if not, write to the Free Software
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 USA. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
19 /* Tell glibc's <string.h> to provide a prototype for mempcpy().
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
20 This must come before <config.h> because <config.h> may include
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
21 <features.h>, and once <features.h> has been included, it's too late. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
22 #ifndef _GNU_SOURCE
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
23 # define _GNU_SOURCE 1
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
24 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
25
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
27 # include <config.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
29
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 #include <ctype.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31 #include <stdio.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 #if defined _LIBC || defined HAVE___FSETLOCKING
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33 # include <stdio_ext.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
35 #include <sys/types.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 #ifdef __GNUC__
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 # undef alloca
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
39 # define alloca __builtin_alloca
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40 # define HAVE_ALLOCA 1
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
41 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
42 # ifdef _MSC_VER
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
43 # include <malloc.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
44 # define alloca _alloca
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
45 # else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
46 # if defined HAVE_ALLOCA_H || defined _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
47 # include <alloca.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
48 # else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
49 # ifdef _AIX
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
50 #pragma alloca
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
51 # else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
52 # ifndef alloca
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
53 char *alloca ();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
54 # endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
55 # endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
56 # endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
57 # endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
58 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
59
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
60 #include <stdlib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
61 #include <string.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
62
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
63 #include "gettextP.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
64
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
65 #if ENABLE_RELOCATABLE
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
66 # include "relocatable.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
67 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
68 # define relocate(pathname) (pathname)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
69 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
70
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
71 /* @@ end of prolog @@ */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
72
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
73 #ifdef _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
74 /* Rename the non ANSI C functions. This is required by the standard
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
75 because some ANSI C functions will require linking with this object
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
76 file and the name space must not be polluted. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
77 # define strcasecmp __strcasecmp
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
78
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
79 # ifndef mempcpy
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
80 # define mempcpy __mempcpy
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
81 # endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
82 # define HAVE_MEMPCPY 1
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
83 # define HAVE___FSETLOCKING 1
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
84
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
85 /* We need locking here since we can be called from different places. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
86 # include <bits/libc-lock.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
87
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
88 __libc_lock_define_initialized (static, lock);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
89 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
90
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
91 #ifndef internal_function
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
92 # define internal_function
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
93 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
94
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
95 /* Some optimizations for glibc. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
96 #ifdef _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
97 # define FEOF(fp) feof_unlocked (fp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
98 # define FGETS(buf, n, fp) fgets_unlocked (buf, n, fp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
99 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
100 # define FEOF(fp) feof (fp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
101 # define FGETS(buf, n, fp) fgets (buf, n, fp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
102 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
103
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
104 /* For those losing systems which don't have `alloca' we have to add
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
105 some additional code emulating it. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
106 #ifdef HAVE_ALLOCA
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
107 # define freea(p) /* nothing */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
108 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
109 # define alloca(n) malloc (n)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
110 # define freea(p) free (p)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
111 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
112
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
113 #if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
114 # undef fgets
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
115 # define fgets(buf, len, s) fgets_unlocked (buf, len, s)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
116 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
117 #if defined _LIBC_REENTRANT || defined HAVE_FEOF_UNLOCKED
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
118 # undef feof
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
119 # define feof(s) feof_unlocked (s)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
120 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
121
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
122
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
123 struct alias_map
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
124 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
125 const char *alias;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
126 const char *value;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
127 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
128
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
129
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
130 #ifndef _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
131 # define libc_freeres_ptr(decl) decl
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
132 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
133
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
134 libc_freeres_ptr (static char *string_space);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
135 static size_t string_space_act;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
136 static size_t string_space_max;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
137 libc_freeres_ptr (static struct alias_map *map);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
138 static size_t nmap;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
139 static size_t maxmap;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
140
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
141
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
142 /* Prototypes for local functions. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
143 static size_t read_alias_file PARAMS ((const char *fname, int fname_len))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
144 internal_function;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
145 static int extend_alias_table PARAMS ((void));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
146 static int alias_compare PARAMS ((const struct alias_map *map1,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
147 const struct alias_map *map2));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
148
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
149
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
150 const char *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
151 _nl_expand_alias (name)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
152 const char *name;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
153 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
154 static const char *locale_alias_path;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
155 struct alias_map *retval;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
156 const char *result = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
157 size_t added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
158
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
159 #ifdef _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
160 __libc_lock_lock (lock);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
161 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
162
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
163 if (locale_alias_path == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
164 locale_alias_path = LOCALE_ALIAS_PATH;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
165
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
166 do
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
167 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
168 struct alias_map item;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
169
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
170 item.alias = name;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
171
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
172 if (nmap > 0)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
173 retval = (struct alias_map *) bsearch (&item, map, nmap,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 sizeof (struct alias_map),
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
175 (int (*) PARAMS ((const void *,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
176 const void *))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177 ) alias_compare);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
178 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179 retval = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
181 /* We really found an alias. Return the value. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
182 if (retval != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184 result = retval->value;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
185 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
186 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
187
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
188 /* Perhaps we can find another alias file. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189 added = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190 while (added == 0 && locale_alias_path[0] != '\0')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
192 const char *start;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
193
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
194 while (locale_alias_path[0] == PATH_SEPARATOR)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195 ++locale_alias_path;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
196 start = locale_alias_path;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
197
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
198 while (locale_alias_path[0] != '\0'
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
199 && locale_alias_path[0] != PATH_SEPARATOR)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
200 ++locale_alias_path;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
201
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
202 if (start < locale_alias_path)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
203 added = read_alias_file (start, locale_alias_path - start);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
204 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
205 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
206 while (added != 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
207
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
208 #ifdef _LIBC
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209 __libc_lock_unlock (lock);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
210 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
211
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
212 return result;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
213 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
214
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
215
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
216 static size_t
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
217 internal_function
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
218 read_alias_file (fname, fname_len)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
219 const char *fname;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
220 int fname_len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
221 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
222 FILE *fp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
223 char *full_fname;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
224 size_t added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
225 static const char aliasfile[] = "/locale.alias";
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
226
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
227 full_fname = (char *) alloca (fname_len + sizeof aliasfile);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
228 #ifdef HAVE_MEMPCPY
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
229 mempcpy (mempcpy (full_fname, fname, fname_len),
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
230 aliasfile, sizeof aliasfile);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
231 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
232 memcpy (full_fname, fname, fname_len);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
233 memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
234 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
235
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
236 fp = fopen (relocate (full_fname), "r");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
237 freea (full_fname);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
238 if (fp == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
239 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
240
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
241 #ifdef HAVE___FSETLOCKING
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
242 /* No threads present. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
243 __fsetlocking (fp, FSETLOCKING_BYCALLER);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
244 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
245
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
246 added = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
247 while (!FEOF (fp))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
248 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
249 /* It is a reasonable approach to use a fix buffer here because
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
250 a) we are only interested in the first two fields
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
251 b) these fields must be usable as file names and so must not
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
252 be that long
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
253 We avoid a multi-kilobyte buffer here since this would use up
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
254 stack space which we might not have if the program ran out of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
255 memory. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
256 char buf[400];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
257 char *alias;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
258 char *value;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
259 char *cp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
260
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
261 if (FGETS (buf, sizeof buf, fp) == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
262 /* EOF reached. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
263 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
264
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
265 cp = buf;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
266 /* Ignore leading white space. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
267 while (isspace ((unsigned char) cp[0]))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
268 ++cp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
269
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
270 /* A leading '#' signals a comment line. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
271 if (cp[0] != '\0' && cp[0] != '#')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
272 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
273 alias = cp++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
274 while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
275 ++cp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
276 /* Terminate alias name. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
277 if (cp[0] != '\0')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
278 *cp++ = '\0';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
279
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
280 /* Now look for the beginning of the value. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
281 while (isspace ((unsigned char) cp[0]))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
282 ++cp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
283
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
284 if (cp[0] != '\0')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
285 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
286 size_t alias_len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
287 size_t value_len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
288
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
289 value = cp++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
290 while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
291 ++cp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
292 /* Terminate value. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
293 if (cp[0] == '\n')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
294 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
295 /* This has to be done to make the following test
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
296 for the end of line possible. We are looking for
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
297 the terminating '\n' which do not overwrite here. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
298 *cp++ = '\0';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
299 *cp = '\n';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
300 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
301 else if (cp[0] != '\0')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
302 *cp++ = '\0';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
303
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
304 if (nmap >= maxmap)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
305 if (__builtin_expect (extend_alias_table (), 0))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
306 return added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
307
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
308 alias_len = strlen (alias) + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
309 value_len = strlen (value) + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
310
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
311 if (string_space_act + alias_len + value_len > string_space_max)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
312 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
313 /* Increase size of memory pool. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
314 size_t new_size = (string_space_max
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
315 + (alias_len + value_len > 1024
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
316 ? alias_len + value_len : 1024));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
317 char *new_pool = (char *) realloc (string_space, new_size);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
318 if (new_pool == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
319 return added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
320
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
321 if (__builtin_expect (string_space != new_pool, 0))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
322 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
323 size_t i;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
324
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
325 for (i = 0; i < nmap; i++)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
326 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
327 map[i].alias += new_pool - string_space;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
328 map[i].value += new_pool - string_space;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
329 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
330 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
331
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
332 string_space = new_pool;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
333 string_space_max = new_size;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
334 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
335
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
336 map[nmap].alias = memcpy (&string_space[string_space_act],
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
337 alias, alias_len);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
338 string_space_act += alias_len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
339
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
340 map[nmap].value = memcpy (&string_space[string_space_act],
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
341 value, value_len);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
342 string_space_act += value_len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
343
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
344 ++nmap;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
345 ++added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
346 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
347 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
348
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
349 /* Possibly not the whole line fits into the buffer. Ignore
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
350 the rest of the line. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
351 while (strchr (buf, '\n') == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
352 if (FGETS (buf, sizeof buf, fp) == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
353 /* Make sure the inner loop will be left. The outer loop
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
354 will exit at the `feof' test. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
355 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
356 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
357
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
358 /* Should we test for ferror()? I think we have to silently ignore
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
359 errors. --drepper */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
360 fclose (fp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
361
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
362 if (added > 0)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
363 qsort (map, nmap, sizeof (struct alias_map),
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
364 (int (*) PARAMS ((const void *, const void *))) alias_compare);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
365
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
366 return added;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
367 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
368
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
369
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
370 static int
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
371 extend_alias_table ()
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
372 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
373 size_t new_size;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
374 struct alias_map *new_map;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
375
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
376 new_size = maxmap == 0 ? 100 : 2 * maxmap;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
377 new_map = (struct alias_map *) realloc (map, (new_size
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
378 * sizeof (struct alias_map)));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
379 if (new_map == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
380 /* Simply don't extend: we don't have any more core. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
381 return -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
382
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
383 map = new_map;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
384 maxmap = new_size;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
385 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
386 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
387
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
388
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
389 static int
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
390 alias_compare (map1, map2)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
391 const struct alias_map *map1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
392 const struct alias_map *map2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
393 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
394 #if defined _LIBC || defined HAVE_STRCASECMP
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
395 return strcasecmp (map1->alias, map2->alias);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
396 #else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
397 const unsigned char *p1 = (const unsigned char *) map1->alias;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
398 const unsigned char *p2 = (const unsigned char *) map2->alias;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
399 unsigned char c1, c2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
400
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
401 if (p1 == p2)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
402 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
403
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
404 do
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
405 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
406 /* I know this seems to be odd but the tolower() function in
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
407 some systems libc cannot handle nonalpha characters. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
408 c1 = isupper (*p1) ? tolower (*p1) : *p1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
409 c2 = isupper (*p2) ? tolower (*p2) : *p2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
410 if (c1 == '\0')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
411 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
412 ++p1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
413 ++p2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
414 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
415 while (c1 == c2);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
416
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
417 return c1 - c2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
418 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
419 }