Return-Path: X-Authentication-Warning: harvey.cyclic.com: majordomo set sender to owner-bug-cvs-list@harvey.cyclic.com using -f From: Rex_Jolliff@notes.ymp.gov Date: Tue, 02 Mar 1999 10:06:05 -0800 Subject: Changes to implement VMS style wildcards for VMS (7.x) To: bug-cvs@gnu.org Content-type: text/plain; charset=us-ascii Content-disposition: inline X-Lotus-FromDomain: CRWMS Sender: owner-bug-cvs-list@cyclic.com Precedence: bulk The following is a set of diffs to implement VMS style wildcards for VMS 7.x. It also fixes a couple compilation problems with VMS 7.x. CVS still does not build cleanly, but you at least get a working executable. Perhaps we'll send diff to fix the other compilation and link problems. Rex & Shawn. Index: news =================================================================== RCS file: /CVS/IRM/cvssrc/news,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 2a3,4 > * The VMS client now accepts wildcards if you're running VMS 7.x. > Index: vms/changelog =================================================================== RCS file: /CVS/IRM/cvssrc/vms/changelog,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 0a1,12 > 1999-03-01 Shawn Smith > > * filesubr.c (expand_wild): rewrote for VMS 7.x. Actually > globs vms wildcarded filespecs now. > * pwd.h: put the pid_t define in a conditional since it's > now typedefed in VMS 7.x > * unlink.c: provided correct prototype for unlink based on > version of VMS since it changes. > * vms.h: put conditional compilation macros around mode_t as > it is defined as of VMS 7.x, and fixed prototype of unlink > as per above. > Index: vms/filesubr.c =================================================================== RCS file: /CVS/IRM/cvssrc/vms/filesubr.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 787a788,789 > #if defined(__VMS_VER) > #if __VMS_VER < 70000000 801c803 < (*pargv)[i] = xstrdup (argv[i]); --- > (*pargv)[i] = xstrdup (argv[i]); 802a805,971 > > #else /*--- __VMS_VER >= 70000000 ---*/ > > /* These global variables are necessary to pass information from the > * routine that calls decc$from_vms into the callback routine. In a > * multi-threaded environment, access to these variables MUST be > * serialized. > */ > static char CurWorkingDir[PATH_MAX+1]; > static char **ArgvList; > static int CurArg; > static int MaxArgs; > > static int ew_no_op (char *fname) { > (void) fname; /* Shut the compiler up */ > return 1; /* Continue */ > } > > static int ew_add_file (char *fname) { > char *lastslash, *firstper; > int i; > > if (strncmp(fname,CurWorkingDir,strlen(CurWorkingDir)) == 0) { > fname += strlen(CurWorkingDir); > } > lastslash = strrchr(fname,'/'); > if (!lastslash) { > lastslash = fname; > } > if ((firstper=strchr(lastslash,'.')) != strrchr(lastslash,'.')) { > /* We have two periods -- one is to separate the version off */ > *strrchr(fname,'.') = '\0'; > } > if (firstper && firstper[1]=='\0') { > *firstper = '\0'; > } > /* The following code is to insure that no duplicates appear, > * because most of the time it will just be a different version > */ > for (i=0; i ; > } > if (i==CurArg && CurArg ArgvList[CurArg++] = strdup(fname); > } > return ArgvList[CurArg-1] != 0; /* Stop if we couldn't dup the string */ > } > > /* The following two routines are meant to allow future versions of new_arglis t > * routine to be multi-thread-safe. It will be necessary in that environment > * to serialize access to CurWorkingDir, ArgvList, MaxArg, and CurArg. We > * currently don't do any multi-threaded programming, so right now these > * routines are no-ops. > */ > static void wait_and_protect_globs (void) { > return; > } > > static void release_globs (void) { > return; > } > > /*pf---------------------------------------------------------------- expand_wi ld > * > * New Argument List - (SDS) > * > * DESCRIPTION: > * This routine takes the argc, argv passed in from main() and returns a > * new argc, argv list, which simulates (to an extent) Unix-Style filename > * globbing with VMS wildcards. The key difference is that it will return > * Unix-style filenames, i.e., no VMS file version numbers. The complexity > * comes from the desire to not simply allocate 10000 argv entries. > * > * INPUTS: > * argc - The integer argc passed into main > * argv - The pointer to the array of char*'s passed into main > * > * OUTPUTS: > * pargv - A pointer to a (char **) to hold the new argv list > * pargc - A pointer to an int to hold the new argc > * > * RETURNS: > * NONE > * > * SIDE EFFECTS: > * This routine will normally modify the global statics CurArg, MaxArg, > * ArgvList, and CurWorkingDir. > * > * NOTES: > * It is ok for &argc == pargc and &argv == pargv. > * > *---------------------------------------------------------------------------- -- > */ > void expand_wild (int argc, char **argv, int *pargc, char ***pargv) { > int totfiles, filesgotten; > int i; > int largc; > char **largv; > > /* This first loop is to find out AT MOST how big to make the > * pargv array. > */ > for (totfiles=0,i=0; i char *arg = argv[i]; > > if ( strchr(arg,' ') != 0 || strchr(arg,',') != 0 > || strcmp(arg,".") == 0 || strcmp(arg,"..") == 0) { > ++totfiles; > }else { > int num = decc$from_vms (arg, ew_no_op, 1); > totfiles += num>0 ? num : 1; > } > } > if (totfiles) { > largv = malloc (sizeof*largv * (totfiles + 1)); > } > filesgotten = 0; > if (largv != 0) { > /* All bits set to zero may not be a NULL ptr */ > for (i=totfiles; --i>=0; ) { > largv[i] = 0; > } > largv[totfiles] = 0; > > wait_and_protect_globs (); > > /*--- getcwd has an OpenVMS extension that allows us to ---*/ > /*--- get back Unix-style path names ---*/ > (void) getcwd (CurWorkingDir, sizeof CurWorkingDir, 0); > if (CurWorkingDir[strlen(CurWorkingDir)-1] != '/') { > (void) strcat (CurWorkingDir, "/"); > } > CurArg = 0; > ArgvList = largv; > MaxArgs = totfiles + 1; > > for (i=0; i char *arg = argv[i]; > if ( strchr(arg,' ') != 0 || strchr(arg,',') != 0 > || strcmp(arg,".") == 0 || strcmp(arg,"..") == 0) { > if (CurArg < MaxArgs) { > ArgvList[CurArg++] = strdup(arg); > } > ++filesgotten; > }else if (*arg != '\0') { > int num = decc$from_vms (arg, ew_add_file, 1); > if (num <= 0 && CurArg < MaxArgs) { > ArgvList[CurArg++] = strdup(arg); > } > filesgotten += num>0 ? num : 1; > } > } > if (filesgotten != totfiles) { > /*--- Files must have been created/deleted here ---*/; > } > filesgotten = CurArg; > > release_globs(); > } > (*pargc) = largv ? filesgotten : 0; > (*pargv) = largv; > > return; > } > > #endif /*--- __VMS_VER >= 70000000 */ > #endif /*--- defined(VMS_VER) ---*/ Index: vms/pwd.h =================================================================== RCS file: /CVS/IRM/cvssrc/vms/pwd.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 10a11 > #if !defined(__VMS_VER) 11a13,15 > #elif __VMS_VER < 70000000 > #define pid_t int > #endif Index: vms/unlink.c =================================================================== RCS file: /CVS/IRM/cvssrc/vms/unlink.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 4a5 > #if !defined(__VMS_VER) 5a7,11 > #elif __VMS_VER < 70000000 > int unlink(char *path) > #else > int unlink(char const*path) > #endif Index: vms/vms.h =================================================================== RCS file: /CVS/IRM/cvssrc/vms/vms.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -r1.1.1.1 -r1.2 2a3 > #if !defined(__VMS_VER) 3a5,7 > #elif __VMS_VER < 70000000 > #define mode_t unsigned int > #endif 28a33,35 > #if !defined(__VMS_VER) > int unlink(char *path); > #elif __VMS_VER < 70000000 29a37,39 > #else > int unlink(char const*path); > #endif 32a43 > #define lstat stat