00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "h.h"
00020
00021
00022
00023
00024
00025 void error(msg, a1)
00026 char *msg;
00027 char *a1;
00028 {
00029 fprintf(stderr, "%s: ", myname);
00030 fprintf(stderr, msg, a1);
00031 if (lineno) fprintf(stderr, " in %s near line %d", makefile, lineno);
00032 fputc('\n', stderr);
00033 exit(1);
00034 }
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 bool getline(strs, fd)
00047 struct str *strs;
00048 FILE *fd;
00049 {
00050 register char *p;
00051 char *q;
00052 int c;
00053
00054 for (;;) {
00055 strs->pos = 0;
00056 for (;;) {
00057 do {
00058 if (strs->pos >= strs->len)
00059 strrealloc(strs);
00060 if ((c = getc(fd)) == EOF)
00061 return TRUE;
00062 (*strs->ptr)[strs->pos++] = c;
00063 } while (c != '\n');
00064
00065 lineno++;
00066
00067 if (strs->pos >= 2 && (*strs->ptr)[strs->pos - 2] == '\\') {
00068 (*strs->ptr)[strs->pos - 2] = '\n';
00069 strs->pos--;
00070 } else {
00071 break;
00072 }
00073 }
00074
00075 if (strs->pos >= strs->len)
00076 strrealloc(strs);
00077 (*strs->ptr)[strs->pos] = '\0';
00078
00079 p = q = *strs->ptr;
00080 while (isspace(*q)) q++;
00081 if (*p != '\t' || *q == '#') {
00082 while (((q = strchr(p, '#')) != (char *)0) &&
00083 (p != q) && (q[-1] == '\\'))
00084 {
00085 char *a;
00086
00087 a = q - 1;
00088 p = q;
00089 while (*a++ = *q++)
00090 ;
00091 }
00092 if (q != (char *)0)
00093 {
00094 q[0] = '\n';
00095 q[1] = '\0';
00096 }
00097 }
00098
00099 p = *strs->ptr;
00100 while (isspace(*p))
00101 p++;
00102
00103 if (*p != '\0')
00104 return FALSE;
00105 }
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 char *gettok(ptr)
00115 register char **ptr;
00116 {
00117 register char *p;
00118
00119
00120 while (isspace(**ptr))
00121 (*ptr)++;
00122
00123 if (**ptr == '\0')
00124 return ((char *)NULL);
00125
00126 p = *ptr;
00127
00128 while ((**ptr != '\0') && (!isspace(**ptr)))
00129 (*ptr)++;
00130
00131 *(*ptr)++ = '\0';
00132
00133 return(p);
00134 }