comparison src/xrdb.c @ 620:88a29c720fa7

entered into RCS
author Jim Blandy <jimb@redhat.com>
date Fri, 24 Apr 1992 08:11:28 +0000
parents af0eae450bc9
children aaa628aaf808
comparison
equal deleted inserted replaced
619:239436e74f03 620:88a29c720fa7
1 /* Deal with the X Resource Manager. 1 /* Deal with the X Resource Manager.
2 Copyright (C) 1990 Free Software Foundation. 2 Copyright (C) 1990, 1992 Free Software Foundation.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 1, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144 magic_searchpath_decoder (incantation_string, file, return_path) 144 magic_searchpath_decoder (incantation_string, file, return_path)
145 char *incantation_string, *return_path, *file; 145 char *incantation_string, *return_path, *file;
146 { 146 {
147 register char *s = incantation_string; 147 register char *s = incantation_string;
148 register char *p; 148 register char *p;
149 register char string[MAXPATHLEN]; 149
150 /* Must be big enough for "%N%S". */
151 register int string_size = MAXPATHLEN;
152 register char *string = (char *) alloca (string_size * sizeof (*string));
150 153
151 while (*s) 154 while (*s)
152 { 155 {
153 p = s; 156 p = s;
154 157
155 while (*p && *p != ':') 158 while (*p && *p != ':')
156 p++; 159 p++;
157 160
158 if (*p == ':' && *(p + 1) == ':') 161 if (*p == ':' && *(p + 1) == ':')
159 { 162 {
163 /* We know string is big enough for this. */
160 bcopy ("%N%S", string, 5); 164 bcopy ("%N%S", string, 5);
161 if (decode_magic (string, file, return_path)) 165 if (decode_magic (string, file, return_path))
162 return 1; 166 return 1;
163 167
164 s = p + 1; 168 s = p + 1;
167 171
168 if (p > s) 172 if (p > s)
169 { 173 {
170 int len = p - s; 174 int len = p - s;
171 175
176 if (string_size < len+1)
177 {
178 string_size = 2 * len;
179 string = (char *) alloca (string_size * sizeof (*string));
180 }
172 bcopy (s, string, len); 181 bcopy (s, string, len);
173 string[len + 1] = '\0'; 182 string[len + 1] = '\0';
174 if (decode_magic (string, file, return_path)) 183 if (decode_magic (string, file, return_path))
175 return 1; 184 return 1;
176 } 185 }