| 1 |
This is the change file for CWEB's COMMON under QSOD/SMSQ |
| 2 |
(Contributed by Robert H. Klein, September 1994) |
| 3 |
|
| 4 |
This change file is intended for use with C68 v4.13 (or later). |
| 5 |
compile with |
| 6 |
ex <dev_>cc;'-v -h -c -=500000 -DCWEBINPUTS=flp2_ common_c' |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
@x |
| 11 |
\def\v{\char'174} % vertical (|) in typewriter font |
| 12 |
|
| 13 |
\def\title{Common code for CTANGLE and CWEAVE (Version 4.12.2)} |
| 14 |
\def\topofcontents{\null\vfill |
| 15 |
\centerline{\titlefont Common code for {\ttitlefont CTANGLE} and |
| 16 |
{\ttitlefont CWEAVE}} |
| 17 |
\vskip 15pt |
| 18 |
\centerline{(Version 4.12.2)} |
| 19 |
\vfill} |
| 20 |
\def\botofcontents{\vfill |
| 21 |
\noindent |
| 22 |
@y |
| 23 |
\def\v{\char'174} % vertical (|) in typewriter font |
| 24 |
|
| 25 |
\def\title{Common code for CTANGLE and CWEAVE (QL Version 4.12.2)} |
| 26 |
\def\topofcontents{\null\vfill |
| 27 |
\centerline{\titlefont Common code for {\ttitlefont CTANGLE} and |
| 28 |
{\ttitlefont CWEAVE}} |
| 29 |
\vskip 15pt |
| 30 |
\centerline{(Version 4.12.2)} |
| 31 |
\vfill} |
| 32 |
\def\botofcontents{\vfill |
| 33 |
\noindent |
| 34 |
@z |
| 35 |
|
| 36 |
|
| 37 |
For use on QDOS/SMSQ systems the variable |max_file_name_length| is shortened |
| 38 |
to 42 characters, i.e. 5 characters for the device name, 36 characters |
| 39 |
for the file name plus one character as string terminator. (Note that |
| 40 |
(current) QDOS/SMSQ file systems have a limitation of 36 characters as |
| 41 |
maximum length for a file name. |
| 42 |
@x |
| 43 |
@d max_file_name_length 60 |
| 44 |
@y |
| 45 |
@d max_file_name_length 42 |
| 46 |
@z |
| 47 |
|
| 48 |
|
| 49 |
@x |
| 50 |
cur_file_name[l]='/'; /* \UNIX/ pathname separator */ |
| 51 |
@y |
| 52 |
cur_file_name[l]='_'; /* QDOS/SMSQ pathname separator */ |
| 53 |
@z |
| 54 |
|
| 55 |
|
| 56 |
@x |
| 57 |
@ We now must look at the command line arguments and set the file names |
| 58 |
accordingly. At least one file name must be present: the \.{CWEB} |
| 59 |
file. It may have an extension, or it may omit the extension to get |".w"| or |
| 60 |
|".web"| added. The \TEX/ output file name is formed by replacing the \.{CWEB} |
| 61 |
file name extension by |".tex"|, and the \CEE/ file name by replacing |
| 62 |
the extension by |".c"|, after removing the directory name (if any). |
| 63 |
|
| 64 |
If there is a second file name present among the arguments, it is the |
| 65 |
change file, again either with an extension or without one to get |".ch"|. |
| 66 |
An omitted change file argument means that |"/dev/null"| should be used, |
| 67 |
when no changes are desired. |
| 68 |
@^system dependencies@> |
| 69 |
|
| 70 |
If there's a third file name, it will be the output file. |
| 71 |
@y |
| 72 |
@ We now must look at the command line arguments and set the file names |
| 73 |
accordingly. At least one file name must be present: the \.{CWEB} |
| 74 |
file. It may have an extension, or it may omit the extension to get |"_w"| or |
| 75 |
|"_web"| added. The \TEX/ output file name is formed by replacing the \.{CWEB} |
| 76 |
file name extension by |"_tex"|, and the \CEE/ file name by replacing |
| 77 |
the extension by |"_c"|, after removing the directory name (if any). |
| 78 |
|
| 79 |
If there is a second file name present among the arguments, it is the |
| 80 |
change file, again either with an extension or without one to get |"_ch"|. |
| 81 |
An omitted change file argument means that |"NUL"| should be used, |
| 82 |
when no changes are desired. |
| 83 |
@^system dependencies@> |
| 84 |
|
| 85 |
If there's a third file name, it will be the output file. |
| 86 |
|
| 87 |
Because |"_"| is a directory {\em and} extension separator, \.{CWEB} will |
| 88 |
always use the {\em full} name (i.e. with full path). Fortunately the |
| 89 |
routine has been written to search for the last ``dot'', so the altered |
| 90 |
version will search for the last |"_"| (including directory separators), |
| 91 |
so we have what we want. |
| 92 |
@z |
| 93 |
|
| 94 |
|
| 95 |
@x |
| 96 |
char *dot_pos; /* position of |'.'| in the argument */ |
| 97 |
@y |
| 98 |
char *dot_pos; /* position of |'_'| in the argument */ |
| 99 |
@z |
| 100 |
|
| 101 |
|
| 102 |
@x |
| 103 |
strcpy(change_file_name,"/dev/null"); |
| 104 |
@y |
| 105 |
strcpy(change_file_name,"NUL"); |
| 106 |
@z |
| 107 |
|
| 108 |
|
| 109 |
@x |
| 110 |
if (*s=='.') dot_pos=s++; |
| 111 |
else if (*s=='/') dot_pos=NULL,name_pos=++s; |
| 112 |
else s++; |
| 113 |
@y |
| 114 |
if (*s=='_') dot_pos=s++; |
| 115 |
else if (*s=='_') dot_pos=NULL,name_pos=++s; |
| 116 |
else s++; |
| 117 |
@z |
| 118 |
|
| 119 |
|
| 120 |
@x |
| 121 |
@ We use all of |*argv| for the |web_file_name| if there is a |'.'| in it, |
| 122 |
otherwise we add |".w"|. If this file can't be opened, we prepare an |
| 123 |
|alt_web_file_name| by adding |"web"| after the dot. |
| 124 |
The other file names come from adding other things |
| 125 |
after the dot. We must check that there is enough room in |
| 126 |
|web_file_name| and the other arrays for the argument. |
| 127 |
@y |
| 128 |
@ We use all of |*argv| for the |web_file_name| if there is a |'_'| in it, |
| 129 |
otherwise we add |"_w"|. If this file can't be opened, we prepare an |
| 130 |
|alt_web_file_name| by adding |"web"| after the dot. |
| 131 |
The other file names come from adding other things |
| 132 |
after the dot. We must check that there is enough room in |
| 133 |
|web_file_name| and the other arrays for the argument. |
| 134 |
|
| 135 |
If you've read the section before carefully you'll have noticed, that |
| 136 |
QDOS/SMSQ file names contain almost a |"_"|, so this routine will not work, |
| 137 |
i.e. you'll {\em have} to add the |"_w"| always. Nevertheless I adapted |
| 138 |
the routine as if it would work. |
| 139 |
@z |
| 140 |
|
| 141 |
|
| 142 |
@x |
| 143 |
@<Make |web_file_name|...@>= |
| 144 |
{ |
| 145 |
if (s-*argv > max_file_name_length-5) |
| 146 |
@<Complain about argument length@>@; |
| 147 |
if (dot_pos==NULL) |
| 148 |
sprintf(web_file_name,"%s.w",*argv); |
| 149 |
else { |
| 150 |
strcpy(web_file_name,*argv); |
| 151 |
*dot_pos='\0'; /* string now ends where the dot was */ |
| 152 |
} |
| 153 |
sprintf(alt_web_file_name,"%s.web",*argv); |
| 154 |
sprintf(tex_file_name,"%s.tex",name_pos); /* strip off directory name */ |
| 155 |
if (make_xrefs) { /* indexes will be generated */ |
| 156 |
sprintf(idx_file_name,"%s.idx",name_pos); |
| 157 |
sprintf(scn_file_name,"%s.scn",name_pos); |
| 158 |
} |
| 159 |
sprintf(C_file_name,"%s.c",name_pos); |
| 160 |
found_web=true; |
| 161 |
} |
| 162 |
@y |
| 163 |
@<Make |web_file_name|...@>= |
| 164 |
{ |
| 165 |
if (s-*argv > max_file_name_length-5) |
| 166 |
@<Complain about argument length@>; |
| 167 |
if (dot_pos==NULL) |
| 168 |
sprintf(web_file_name,"%s_w",*argv); |
| 169 |
else { |
| 170 |
strcpy(web_file_name,*argv); |
| 171 |
*dot_pos='\0'; /* string now ends where the dot was */ |
| 172 |
} |
| 173 |
sprintf(alt_web_file_name,"%s_web",*argv); |
| 174 |
sprintf(tex_file_name,"%s_tex",name_pos); /* strip off directory name */ |
| 175 |
if (make_xrefs) { /* indexes will be generated */ |
| 176 |
sprintf(idx_file_name,"%s_idx",name_pos); |
| 177 |
sprintf(scn_file_name,"%s_scn",name_pos); |
| 178 |
} |
| 179 |
sprintf(C_file_name,"%s_c",name_pos); |
| 180 |
found_web=true; |
| 181 |
} |
| 182 |
@z |
| 183 |
|
| 184 |
|
| 185 |
@x |
| 186 |
@ @<Make |change_file_name|...@>= |
| 187 |
{ |
| 188 |
if (strcmp(*argv,"-")!=0) { |
| 189 |
if (s-*argv > max_file_name_length-4) |
| 190 |
@<Complain about argument length@>@; |
| 191 |
if (dot_pos==NULL) |
| 192 |
sprintf(change_file_name,"%s.ch",*argv); |
| 193 |
else strcpy(change_file_name,*argv); |
| 194 |
} |
| 195 |
found_change=true; |
| 196 |
} |
| 197 |
@y |
| 198 |
@ @<Make |change_file_name|...@>= |
| 199 |
{ |
| 200 |
if (strcmp(*argv,"-")!=0) { |
| 201 |
if (s-*argv > max_file_name_length-4) |
| 202 |
@<Complain about argument length@>; |
| 203 |
if (dot_pos==NULL) |
| 204 |
sprintf(change_file_name,"%s_ch",*argv); |
| 205 |
else strcpy(change_file_name,*argv); |
| 206 |
found_change=true; |
| 207 |
} |
| 208 |
} |
| 209 |
@z |
| 210 |
|
| 211 |
|
| 212 |
@x |
| 213 |
@ @<Override...@>= |
| 214 |
{ |
| 215 |
if (s-*argv > max_file_name_length-5) |
| 216 |
@<Complain about argument length@>@; |
| 217 |
if (dot_pos==NULL) { |
| 218 |
sprintf(tex_file_name,"%s.tex",*argv); |
| 219 |
sprintf(C_file_name,"%s.c",*argv); |
| 220 |
} else { |
| 221 |
strcpy(tex_file_name,*argv); |
| 222 |
strcpy(C_file_name,*argv); |
| 223 |
*dot_pos='\0'; /* string now ends where the dot was */ |
| 224 |
} |
| 225 |
if (make_xrefs) { /* indexes will be generated */ |
| 226 |
sprintf(idx_file_name,"%s.idx",*argv); |
| 227 |
sprintf(scn_file_name,"%s.scn",*argv); |
| 228 |
} |
| 229 |
found_out=true; |
| 230 |
} |
| 231 |
@y |
| 232 |
@ @<Override...@>= |
| 233 |
{ |
| 234 |
if (s-*argv > max_file_name_length-5) |
| 235 |
@<Complain about argument length@>; |
| 236 |
if (dot_pos==NULL) { |
| 237 |
sprintf(tex_file_name,"%s_tex",*argv); |
| 238 |
sprintf(C_file_name,"%s_c",*argv); |
| 239 |
} else { |
| 240 |
strcpy(tex_file_name,*argv); |
| 241 |
strcpy(C_file_name,*argv); |
| 242 |
*dot_pos='\0'; /* string now ends where the dot was */ |
| 243 |
} |
| 244 |
if (make_xrefs) { /* indexes will be generated */ |
| 245 |
sprintf(idx_file_name,"%s_idx",*argv); |
| 246 |
sprintf(scn_file_name,"%s_scn",*argv); |
| 247 |
} |
| 248 |
found_out=true; |
| 249 |
} |
| 250 |
@z |
| 251 |
|
| 252 |
|
| 253 |
@x |
| 254 |
@ @<Print usage error message and quit@>= |
| 255 |
{ |
| 256 |
if (program==ctangle) |
| 257 |
fatal( |
| 258 |
"! Usage: ctangle [options] webfile[.w] [{changefile[.ch]|-} [outfile[.c]]]\n" |
| 259 |
,""); |
| 260 |
@.Usage:@> |
| 261 |
else fatal( |
| 262 |
"! Usage: cweave [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]\n" |
| 263 |
,""); |
| 264 |
} |
| 265 |
@y |
| 266 |
@ @<Print usage error message and quit@>= |
| 267 |
{ |
| 268 |
if (program==ctangle) |
| 269 |
fatal( |
| 270 |
"! Usage: ctangle [options] webfile[_w] [{changefile[_ch]|-} [outfile[_c]]]\n" |
| 271 |
,""); |
| 272 |
@.Usage:@> |
| 273 |
else fatal( |
| 274 |
"! Usage: cweave [options] webfile[_w] [{changefile[_ch]|-} [outfile[_tex]]]\n" |
| 275 |
,""); |
| 276 |
} |
| 277 |
@z |