annotate lib-src/=etags-vmslib.c @ 32418:425c90c35709

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Thu, 12 Oct 2000 12:07:26 +0000
parents 4df2f432697b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* File name wild card expansion for VMS.
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 This file is part of the etags program.
6113
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
3 Copyright (C) 1987 Free Software Foundation, Inc.
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
6113
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
5 This program is free software; you can redistribute it and/or modify
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
6 it under the terms of the GNU General Public License as published by
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
8 any later version.
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
9
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
10 This program is distributed in the hope that it will be useful,
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
13 GNU General Public License for more details.
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
14
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
15 You should have received a copy of the GNU General Public License
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
16 along with this program; if not, write to the Free Software
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 #include <stdio.h>
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 typedef char tbool;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 /* This is a BUG! ANY arbitrary limit is a BUG!
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 Won't someone please fix this? */
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #define MAX_FILE_SPEC_LEN 255
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 typedef struct {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 short curlen;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 char body[MAX_FILE_SPEC_LEN + 1];
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 } vspec;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 #define EOS '\0'
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #define NO 0
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #define YES 1
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #define NULL 0
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
6113
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
34 /* gfnames - return in successive calls the
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 name of each file specified by all the remaining args in the command-line
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 expanding wild cards and
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 stepping over arguments when they have been processed completely
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 */
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 char*
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 gfnames(pac, pav, p_error)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 int *pac;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 char **pav[];
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 tbool *p_error;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 short fn_exp();
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 while (1)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 if (*pac == 0)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 *p_error = NO;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 return(NULL);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 else switch(fn_exp(&filename, **pav))
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 case 1:
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 *p_error = NO;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 return(filename.body);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 break;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 case 0:
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 --*pac;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ++*pav;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 break;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 default:
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 *p_error = YES;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 return(filename.body);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 break;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
6113
4df2f432697b Use GPL.
David J. MacKenzie <djm@gnu.org>
parents: 615
diff changeset
72 /* fn_exp - expand specification of list of file names
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 returning in each successive call the next filename matching the input
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 spec. The function expects that each in_spec passed
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 to it will be processed to completion; in particular, up to and
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 including the call following that in which the last matching name
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 is returned, the function ignores the value of in_spec, and will
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 only start processing a new spec with the following call.
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 If an error occurs, on return out_spec contains the value
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 of in_spec when the error occurred.
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 With each successive filename returned in out_spec, the
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 function's return value is one. When there are no more matching
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 names the function returns zero. If on the first call no file
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 matches in_spec, or there is any other error, -1 is returned.
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 */
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 #include <rmsdef.h>
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 #include <descrip.h>
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 #define OUTSIZE MAX_FILE_SPEC_LEN
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 short
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 fn_exp(out, in)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 vspec *out;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 char *in;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 static long context = 0;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 static struct dsc$descriptor_s o;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 static struct dsc$descriptor_s i;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 static tbool pass1 = YES;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 long status;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 short retval;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 if (pass1)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 pass1 = NO;
615
e2b34caa2da8 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 15
diff changeset
106 o.dsc$a_pointer = (char *) out;
15
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 o.dsc$w_length = (short)OUTSIZE;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 i.dsc$a_pointer = in;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 i.dsc$w_length = (short)strlen(in);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 i.dsc$b_dtype = DSC$K_DTYPE_T;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 i.dsc$b_class = DSC$K_CLASS_S;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 o.dsc$b_dtype = DSC$K_DTYPE_VT;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 o.dsc$b_class = DSC$K_CLASS_VS;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 if ( (status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 out->body[out->curlen] = EOS;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 return(1);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 else if (status == RMS$_NMF)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 retval = 0;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 else
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 strcpy(out->body, in);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 retval = -1;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 lib$find_file_end(&context);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 pass1 = YES;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 return(retval);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 #ifndef OLD /* Newer versions of VMS do provide `system'. */
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 system(cmd)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 char *cmd;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 fprintf(stderr, "system() function not implemented under VMS\n");
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 #endif
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 #define VERSION_DELIM ';'
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 char *massage_name(s)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 char *s;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 char *start = s;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 for ( ; *s; s++)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 if (*s == VERSION_DELIM)
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 {
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 *s = EOS;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 break;
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 }
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 else
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 *s = tolower(*s);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 return(start);
72e5cc99eab0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 }