home *** CD-ROM | disk | FTP | other *** search
- *** $.gtoal.ansii_pcc.c.toansi Thu Jul 13 15:13:52 1989
- --- c.toansip Thu Jul 13 15:13:52 1989
- ***************
- *** 41,46 ****
- --- 41,48 ----
- #define HEADER_BRKLEN 72
- #define DEPTH_STACKSZ 50
-
- + static char cur_hdr[256];
- +
- static FILE *in_file, *out_file;
-
- static int next_ch, copied_line_len, line_no, brace_depth, depth_sp;
- ***************
- *** 145,150 ****
- --- 147,165 ----
- if (brace_depth != temp)
- errf("confused by mismatched, conditionally included braces...\n");
- }
- + else if (strcmp(pp, "ptcheader") == 0)
- + {
- + lookaside = NULL;
- + fprintf(out_file, "#include \"%s\"\n", cur_hdr);
- + #ifdef NEVER
- + if ((strcmp(cur_hdr, "PTC.h") == 0) || (strcmp(cur_hdr, "PTCPAS.h") == 0)) {
- + fprintf(out_file, "#include \"argvgt.h\"\n");
- + fprintf(out_file, "#include \"fopen.h\"\n");
- + fprintf(out_file, "#include \"getl.h\"\n");
- + fprintf(out_file, "#include \"ptcerror.h\"\n");
- + }
- + #endif
- + }
- }
-
- static int get_tokch(int ch)
- ***************
- *** 164,173 ****
- --- 179,194 ----
- /* pre-processor directive */
- int j = 0, last_ch;
- char pp[ID_MAX];
- + lookaside = lookaside_buf;
- ch = skip1_blanks(ch);
- do {pp[j++] = ch; ch = getch(ch);} while (char_class[ch] & ID_CL);
- pp[j] = 0;
- pp_directive(pp);
- + if (lookaside != NULL) {
- + *lookaside = '\0';
- + fputs(lookaside_buf, out_file);
- + lookaside = NULL;
- + }
- last_ch = 0;
- while ((ch != '\n' || last_ch == '\\') && ch != EOF)
- last_ch = ch, ch = getch(ch);
- ***************
- *** 674,681 ****
- if (in_file == NULL)
- { in_file = stdin;
- cur_name = "<stdin>";
- }
- ! else cur_name = in_name;
-
- if (out_name) out_file = fopen(out_name, "w");
- else out_file = NULL;
- --- 695,717 ----
- if (in_file == NULL)
- { in_file = stdin;
- cur_name = "<stdin>";
- + cur_hdr[0] = '\0';
- + }
- + else
- + { char *cp;
- + char leaf[256];
- + cur_name = in_name;
- + strcpy(cur_hdr, cur_name);
- + cp = strrchr(cur_hdr, '.');
- + if (cp == NULL) errf("cannot generate header file for %s", cur_name);
- + strcpy(leaf, cp+1);
- + cp -= 2;
- + if (!(cp[0] == '.' && tolower(cp[1]) == 'c'))
- + errf("cannot generate header file for %s", cur_name);
- + sprintf(cur_hdr, "%s.h", leaf);
- }
- !
- !
-
- if (out_name) out_file = fopen(out_name, "w");
- else out_file = NULL;
-