beta-0.89.2
[luatex.git] / source / texk / web2c / cwebdir / comm-mac.ch
blobb9bd408655e581e7f068ad441c334cf698ead96d
1 This is the change file to CWEB's COMMON for porting to Macintoshes.
2 No changes to CTANGLE or CWEAVE are needed.
4 (Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth)
6 @x in limbo, change the title page document to specify Mac version
7   \centerline{(Version 3.64)}
8 @y
9   \centerline{(Version 3.64 for MacOS)}
12 @x section 9: Make input_ln accept \n, \r, \n\r, or \r\n as line endings
13 @ In the unlikely event that your standard I/O library does not
14 support |feof|, |getc|, and |ungetc| you may have to change things here.
15 @^system dependencies@>
18 int input_ln(fp) /* copies a line into |buffer| or returns 0 */
19 FILE *fp; /* what file to read from */
21   register int  c=EOF; /* character read; initialized so some compilers won't complain */
22   register char *k;  /* where next character goes */
23   if (feof(fp)) return(0);  /* we have hit end-of-file */
24   limit = k = buffer;  /* beginning of buffer */
25   while (k<=buffer_end && (c=getc(fp)) != EOF && c!='\n')
26     if ((*(k++) = c) != ' ') limit = k;
27   if (k>buffer_end)
28     if ((c=getc(fp))!=EOF && c!='\n') {
29       ungetc(c,fp); loc=buffer; err_print("! Input line too long");
30 @.Input line too long@>
31   }
32   if (c==EOF && limit==buffer) return(0);  /* there was nothing after
33     the last newline */
34   return(1);
37 @ In the unlikely event that your standard I/O library does not
38 support |feof|, |getc|, and |ungetc| you may have to change things here.
40 This |input_ln| function accepts |"\n"|, |"\r"|, |"\n\r"| and |"\r\n"| as
41 line endings, so that \.{CWEB} will works with ASCII files stored in
42 \UNIX/, {\mc DOS} or {\mc MAC} format.
43 @^system dependencies@>
46 int input_ln(fp) /* copies a line into |buffer| or returns 0 */
47 FILE *fp; /* what file to read from */
49   register int  c=EOF; /* character read; initialized so some compilers won't complain */
50   register char *k;  /* where next character goes */
51   if (feof(fp)) return(0);  /* we have hit end-of-file */
52   limit = k = buffer;  /* beginning of buffer */
53   while (1) {
54     c = getc(fp);
55     if (c==EOF)  return (limit!=buffer); /* 0, if there was nothing after
56       the last newline */
57     else if (c=='\n' || c=='\r') { /* we have hit end-of-line */
58       int d = getc(fp);
59       if (c+d!='\n'+'\r') /* no combination |"\n\r"| or |"\r\n"| */
60         ungetc(d,fp);
61       return (1);
62     }
63     else if (k>buffer_end) {
64       ungetc(c,fp); loc=buffer; err_print("! Input line too long");
65       return (1);
66 @.Input line too long@>
67     }
68     else
69       if ((*(k++)=c) != ' ')  limit = k;
70   }
74 @x section 12, simply return if no change file was specified
75   change_limit=change_buffer; /* this value is used if the change file ends */
76   @<Skip over comment lines in the change file; |return| if end of file@>;
78   change_limit=change_buffer; /* this value is used if the change file ends */
79   if (change_file_name[0] == '\0') /* no change file specified */
80     return; /* so we have reached the end of that file */
81   @<Skip over comment lines in the change file; |return| if end of file@>;
84 @x section 19, don't try to open a change file if none was specified
85 if ((change_file=fopen(change_file_name,"r"))==NULL)
86        fatal("! Cannot open change file ", change_file_name);
88 if (change_file_name[0] == '\0')  /* no change file specified */
89         change_file = NULL; /* reset at least the |change_file| */
90 else if ((change_file=fopen(change_file_name,"r"))==NULL)
91        fatal("! Cannot open change file ", change_file_name);
94 @x section 22, declare colon as Mac's path separator
95 (Colon-separated paths are not supported.)
96 The remainder of the \.{@@i} line after the file name is ignored.
99 (Colon-separated path alternatives in the style of \UNIX/ or Kpathsea
100 are not supported. On a Macintosh, colons are used to separate the names on
101 different levels of a path.)
102 The remainder of the \.{@@i} line after the file name is ignored.
104 @d PATH_SEP ':'   /* MacOS pathname separator */
105 @^system dependencies@>
108 @x section 23, use the path separator constant
109     cur_file_name[l]='/'; /* \UNIX/ pathname separator */
111     cur_file_name[l]=PATH_SEP; /* pathname separator */
114 @x section 69, explain the convention for omitted change files
115 An omitted change file argument means that |"/dev/null"| should be used,
117 An omitted change file argument means that no change file should be used,
120 @x section 70, use the Metrowerks |ccommand| to access command lines
121   while (--argc > 0) {
123   argc = ccommand (&argv); /* use Mac interface to command line */
124 @^system dependencies@>
125   while (--argc > 0) {
127 @x section 70, use the path separator constant
128         else if (*s=='/') dot_pos=NULL,name_pos=++s;
130         else if (*s==PATH_SEP) dot_pos=NULL,name_pos=++s;
132 @x section 70, make change file name empty when it is unspecified
133   if (found_change<=0) strcpy(change_file_name,"/dev/null");
135   if (found_change<=0) change_file_name[0]='\0';   /* empty string */
138 @x section 82, insert an extra module before the index
139 @** Index.
140 @y by putting the new module here, we preserve all the previous section numbers
141 @ We assume an interface to \CEE/ command-line emulation as supplied by
142 the |ccommand| function of Metrowerks CodeWarrior, as defined in
143 the header file \.{console.h}.
145 @<Include files@>=
146 #include <console.h>
147 @^system dependencies@>
149 @** Index.