Changeset 3140 in kBuild for trunk/src/kmk/ar.c
- Timestamp:
- Mar 14, 2018 9:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/ar.c
r2591 r3140 1 /* Interface to `ar' archives for GNU Make. 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 1 /* Interface to 'ar' archives for GNU Make. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 6 4 This file is part of GNU Make. … … 18 16 this program. If not, see <http://www.gnu.org/licenses/>. */ 19 17 20 #include "make .h"21 22 #ifndef 18 #include "makeint.h" 19 20 #ifndef NO_ARCHIVES 23 21 24 22 #include "filedef.h" … … 27 25 28 26 /* Return nonzero if NAME is an archive-member reference, zero if not. An 29 archive-member reference is a name like `lib(member)' where member is a27 archive-member reference is a name like 'lib(member)' where member is a 30 28 non-empty string. 31 If a name like `lib((entry))' is used, a fatal error is signaled at29 If a name like 'lib((entry))' is used, a fatal error is signaled at 32 30 the attempt to use this unsupported feature. */ 33 31 … … 46 44 47 45 if (p[1] == '(' && end[-1] == ')') 48 fatal (NILF, _("attempt to use unsupported feature: `%s'"), name);46 OS (fatal, NILF, _("attempt to use unsupported feature: '%s'"), name); 49 47 50 48 return 1; … … 64 62 p = strchr (*arname_p, '('); 65 63 *(p++) = '\0'; 66 p[strlen (p) - 1] = '\0';64 p[strlen (p) - 1] = '\0'; 67 65 *memname_p = p; 68 66 } … … 70 68 71 69 72 /* This function is called by `ar_scan' to find which member to look at. */70 /* This function is called by 'ar_scan' to find which member to look at. */ 73 71 74 72 /* ARGSUSED */ 75 73 static long int 76 74 ar_member_date_1 (int desc UNUSED, const char *mem, int truncated, 77 75 long int hdrpos UNUSED, long int datapos UNUSED, 78 76 long int size UNUSED, long int date, 79 int uid UNUSED, int gid UNUSED, int mode UNUSED,80 77 int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED, 78 const void *name) 81 79 { 82 80 return ar_name_equal (name, mem, truncated) ? date : 0; … … 125 123 ar_touch (const char *name) 126 124 { 127 error (NILF, _("touch archive member is not available on VMS"));125 O (error, NILF, _("touch archive member is not available on VMS")); 128 126 return -1; 129 127 } … … 149 147 { 150 148 case -1: 151 error (NILF, _("touch: Archive `%s' does not exist"), arname);149 OS (error, NILF, _("touch: Archive '%s' does not exist"), arname); 152 150 break; 153 151 case -2: 154 error (NILF, _("touch: `%s' is not a valid archive"), arname);152 OS (error, NILF, _("touch: '%s' is not a valid archive"), arname); 155 153 break; 156 154 case -3: … … 158 156 break; 159 157 case 1: 160 error (NILF,161 _("touch: Member `%s' does not exist in `%s'"), memname, arname);158 OSS (error, NILF, 159 _("touch: Member '%s' does not exist in '%s'"), memname, arname); 162 160 break; 163 161 case 0: … … 165 163 break; 166 164 default: 167 error (NILF,168 _("touch: Bad return code from ar_member_touch on `%s'"), name);165 OS (error, NILF, 166 _("touch: Bad return code from ar_member_touch on '%s'"), name); 169 167 } 170 168 … … 176 174 177 175 178 /* State of an `ar_glob' run, passed to `ar_glob_match'. */ 176 /* State of an 'ar_glob' run, passed to 'ar_glob_match'. */ 177 178 /* On VMS, (object) modules in libraries do not have suffixes. That is, to 179 find a match for a pattern, the pattern must not have any suffix. So the 180 suffix of the pattern is saved and the pattern is stripped (ar_glob). 181 If there is a match and the match, which is a module name, is added to 182 the chain, the saved suffix is added back to construct a source filename 183 (ar_glob_match). */ 179 184 180 185 struct ar_glob_state … … 182 187 const char *arname; 183 188 const char *pattern; 189 #ifdef VMS 190 char *suffix; 191 #endif 184 192 unsigned int size; 185 193 struct nameseq *chain; … … 187 195 }; 188 196 189 /* This function is called by `ar_scan' to match one archive197 /* This function is called by 'ar_scan' to match one archive 190 198 element against the pattern in STATE. */ 191 199 192 200 static long int 193 201 ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, 194 202 long int hdrpos UNUSED, long int datapos UNUSED, 195 203 long int size UNUSED, long int date UNUSED, int uid UNUSED, 196 int gid UNUSED, int mode UNUSED, const void *arg)204 int gid UNUSED, unsigned int mode UNUSED, const void *arg) 197 205 { 198 206 struct ar_glob_state *state = (struct ar_glob_state *)arg; … … 202 210 /* We have a match. Add it to the chain. */ 203 211 struct nameseq *new = xcalloc (state->size); 204 new->name = strcache_add (concat (4, state->arname, "(", mem, ")")); 212 #ifdef VMS 213 if (state->suffix) 214 new->name = strcache_add( 215 concat(5, state->arname, "(", mem, state->suffix, ")")); 216 else 217 #endif 218 new->name = strcache_add(concat(4, state->arname, "(", mem, ")")); 205 219 new->next = state->chain; 206 220 state->chain = new; … … 214 228 Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ 215 229 static int 216 glob_pattern_p (const char *pattern, int quote)230 ar_glob_pattern_p (const char *pattern, int quote) 217 231 { 218 232 const char *p; … … 224 238 case '?': 225 239 case '*': 226 240 return 1; 227 241 228 242 case '\\': 229 230 231 243 if (quote) 244 ++p; 245 break; 232 246 233 247 case '[': 234 235 248 opened = 1; 249 break; 236 250 237 251 case ']': 238 239 240 252 if (opened) 253 return 1; 254 break; 241 255 } 242 256 … … 254 268 const char **names; 255 269 unsigned int i; 256 257 if (! glob_pattern_p (member_pattern, 1)) 270 #ifdef VMS 271 char *vms_member_pattern; 272 #endif 273 if (! ar_glob_pattern_p (member_pattern, 1)) 258 274 return 0; 259 275 … … 262 278 state.arname = arname; 263 279 state.pattern = member_pattern; 280 #ifdef VMS 281 { 282 /* In a copy of the pattern, find the suffix, save it and remove it from 283 the pattern */ 284 char *lastdot; 285 vms_member_pattern = xstrdup(member_pattern); 286 lastdot = strrchr(vms_member_pattern, '.'); 287 state.suffix = lastdot; 288 if (lastdot) 289 { 290 state.suffix = xstrdup(lastdot); 291 *lastdot = 0; 292 } 293 state.pattern = vms_member_pattern; 294 } 295 #endif 264 296 state.size = size; 265 297 state.chain = 0; 266 298 state.n = 0; 267 299 ar_scan (arname, ar_glob_match, &state); 300 301 #ifdef VMS 302 /* Deallocate any duplicated string */ 303 free(vms_member_pattern); 304 if (state.suffix) 305 { 306 free(state.suffix); 307 } 308 #endif 268 309 269 310 if (state.chain == 0) … … 288 329 } 289 330 290 #endif 331 #endif /* Not NO_ARCHIVES. */
Note:
See TracChangeset
for help on using the changeset viewer.