1This is the change file to CWEB's COMMON for porting to Macintoshes.
2No changes to CTANGLE or CWEAVE are needed.
3
4(Contributed 13 Oct 2000 by AndPio@aol.com; slightly edited by Don Knuth)
5
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)}
10@z
11
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
14support |feof|, |getc|, and |ungetc| you may have to change things here.
15@^system dependencies@>
16
17@c
18int input_ln(fp) /* copies a line into |buffer| or returns 0 */
19FILE *fp; /* what file to read from */
20{
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);
35}
36@y
37@ In the unlikely event that your standard I/O library does not
38support |feof|, |getc|, and |ungetc| you may have to change things here.
39
40This |input_ln| function accepts |"\n"|, |"\r"|, |"\n\r"| and |"\r\n"| as
41line endings, so that \.{CWEB} will works with ASCII files stored in
42\UNIX/, {\mc DOS} or {\mc MAC} format.
43@^system dependencies@>
44
45@c
46int input_ln(fp) /* copies a line into |buffer| or returns 0 */
47FILE *fp; /* what file to read from */
48{
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  }
71}
72@z
73
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@>;
77@y
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@>;
82@z
83
84@x section 19, don't try to open a change file if none was specified
85if ((change_file=fopen(change_file_name,"r"))==NULL)
86       fatal("! Cannot open change file ", change_file_name);
87@y
88if (change_file_name[0] == '\0')  /* no change file specified */
89        change_file = NULL; /* reset at least the |change_file| */
90else if ((change_file=fopen(change_file_name,"r"))==NULL)
91       fatal("! Cannot open change file ", change_file_name);
92@z
93
94@x section 22, declare colon as Mac's path separator
95(Colon-separated paths are not supported.)
96The remainder of the \.{@@i} line after the file name is ignored.
97
98@y
99(Colon-separated path alternatives in the style of \UNIX/ or Kpathsea
100are not supported. On a Macintosh, colons are used to separate the names on
101different levels of a path.)
102The remainder of the \.{@@i} line after the file name is ignored.
103
104@d PATH_SEP ':'   /* MacOS pathname separator */
105@^system dependencies@>
106@z
107
108@x section 23, use the path separator constant
109    cur_file_name[l]='/'; /* \UNIX/ pathname separator */
110@y
111    cur_file_name[l]=PATH_SEP; /* pathname separator */
112@z
113
114@x section 69, explain the convention for omitted change files
115An omitted change file argument means that |"/dev/null"| should be used,
116@y
117An omitted change file argument means that no change file should be used,
118@z
119
120@x section 70, use the Metrowerks |ccommand| to access command lines
121  while (--argc > 0) {
122@y
123  argc = ccommand (&argv); /* use Mac interface to command line */
124@^system dependencies@>
125  while (--argc > 0) {
126@z
127@x section 70, use the path separator constant
128        else if (*s=='/') dot_pos=NULL,name_pos=++s;
129@y
130        else if (*s==PATH_SEP) dot_pos=NULL,name_pos=++s;
131@z
132@x section 70, make change file name empty when it is unspecified
133  if (found_change<=0) strcpy(change_file_name,"/dev/null");
134@y
135  if (found_change<=0) change_file_name[0]='\0';   /* empty string */
136@z
137
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
142the |ccommand| function of Metrowerks CodeWarrior, as defined in
143the header file \.{console.h}.
144
145@<Include files@>=
146#include <console.h>
147@^system dependencies@>
148
149@** Index.
150@z
151