From 95ffcda425a74059c219874fd6101504b4df01ed Mon Sep 17 00:00:00 2001 From: Hartmut Becker Date: Thu, 4 Sep 2014 21:04:52 +0200 Subject: Fix and enhance VMS library support. * ar.c: fix VMS library search for members, which do not have suffixes, aka filename extensions. * arscan.c: fix time conversion and library callback routines. * default.c: more suffixes and automatically create the VMS library if it doesn't exists. --- ar.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'ar.c') diff --git a/ar.c b/ar.c index 5d2f000..675572a 100644 --- a/ar.c +++ b/ar.c @@ -1,5 +1,5 @@ /* Interface to 'ar' archives for GNU Make. -Copyright (C) 1988-2013 Free Software Foundation, Inc. +Copyright (C) 1988-2014 Free Software Foundation, Inc. This file is part of GNU Make. @@ -172,10 +172,20 @@ ar_touch (const char *name) /* State of an 'ar_glob' run, passed to 'ar_glob_match'. */ +/* On VMS, (object) modules in libraries do not have suffixes. That is, to + find a match for a pattern, the pattern must not have any suffix. So the + suffix of the pattern is saved and the pattern is stripped (ar_glob). + If there is a match and the match, which is a module name, is added to + the chain, the saved suffix is added back to construct a source filename + (ar_glob_match). */ + struct ar_glob_state { const char *arname; const char *pattern; +#ifdef VMS + char *suffix; +#endif unsigned int size; struct nameseq *chain; unsigned int n; @@ -196,7 +206,13 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, { /* We have a match. Add it to the chain. */ struct nameseq *new = xcalloc (state->size); - new->name = strcache_add (concat (4, state->arname, "(", mem, ")")); +#ifdef VMS + if (state->suffix) + new->name = strcache_add( + concat(5, state->arname, "(", mem, state->suffix, ")")); + else +#endif + new->name = strcache_add(concat(4, state->arname, "(", mem, ")")); new->next = state->chain; state->chain = new; ++state->n; @@ -248,7 +264,9 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size) struct nameseq *n; const char **names; unsigned int i; - +#ifdef VMS + char *vms_member_pattern; +#endif if (! glob_pattern_p (member_pattern, 1)) return 0; @@ -256,11 +274,36 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size) ar_glob_match will accumulate them in STATE.chain. */ state.arname = arname; state.pattern = member_pattern; +#ifdef VMS + { + /* In a copy of the pattern, find the suffix, save it and remove it from + the pattern */ + char *lastdot; + vms_member_pattern = xstrdup(member_pattern); + lastdot = strrchr(vms_member_pattern, '.'); + state.suffix = lastdot; + if (lastdot) + { + state.suffix = xstrdup(lastdot); + *lastdot = 0; + } + state.pattern = vms_member_pattern; + } +#endif state.size = size; state.chain = 0; state.n = 0; ar_scan (arname, ar_glob_match, &state); +#ifdef VMS + /* Deallocate any duplicated string */ + free(vms_member_pattern); + if (state.suffix) + { + free(state.suffix); + } +#endif + if (state.chain == 0) return 0; -- cgit v1.2.3