4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
24 * With mods by Terence Parr; AHPCRC, University of Minnesota
41 int err_found = 0; /* indicates whether problem found */
43 internal_error(s,file,line)
47 fprintf(stderr,s,file,line);
48 exit(PCCTS_EXIT_FAILURE);
51 char *dlg_malloc(bytes,file,line)
58 t = (char *) malloc(bytes);
61 internal_error("%s(%d): unable to allocate memory\n",
68 char *dlg_calloc(n,bytes,file,line)
75 t = (char *) calloc(n,bytes);
78 internal_error("%s(%d): unable to allocate memory\n",
85 FILE *read_stream(name)
92 fprintf(stderr, "dlg: invalid option: '%s'\n", name);
97 /* couldn't open file */
99 "dlg: Warning: Can't read file %s.\n",
104 /* open stdin if nothing there */
110 FILE *write_stream(name)
116 if (name[0] == '-') {
117 fprintf(stderr, "dlg: invalid option: '%s'\n", name);
120 f = fopen(OutMetaName(name), "w");
122 /* couldn't open file */
124 "dlg: Warning: Can't write to file %s.\n",
128 special_fopen_actions(OutMetaName(name));
131 /* open stdout if nothing there */
138 void fatal(message,line_no)
142 fprintf(stderr,ErrHdr,
143 (file_str[0] ? file_str[0] : "stdin"), line_no);
144 fprintf(stderr, " Fatal: %s\n", message);
145 exit(PCCTS_EXIT_FAILURE);
148 void error(message,line_no)
152 fprintf(stderr,ErrHdr,
153 (file_str[0] ? file_str[0] : "stdin"), line_no);
154 fprintf(stderr, " Error: %s\n", message);
158 void warning(message,line_no)
162 fprintf(stderr,ErrHdr,
163 (file_str[0] ? file_str[0] : "stdin"), line_no);
164 fprintf(stderr, " Warning: %s\n", message);
175 static char buf[200+1];
177 if ( strcmp(outdir,TopDirectory)==0 ) return n;
179 if ( strcmp(&buf[strlen(buf) - 1], DirectorySymbol ) )
180 strcat(buf, DirectorySymbol);