home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / pascal / PTC / _PtC1 / ansi-patch next >
Encoding:
Text File  |  1991-04-25  |  2.5 KB  |  89 lines

  1. *** $.gtoal.ansii_pcc.c.toansi Thu Jul 13 15:13:52 1989
  2. --- c.toansip                  Thu Jul 13 15:13:52 1989
  3. ***************
  4. *** 41,46 ****
  5. --- 41,48 ----
  6.   #define  HEADER_BRKLEN    72
  7.   #define  DEPTH_STACKSZ    50
  8.   
  9. + static char cur_hdr[256];
  10.   static FILE *in_file, *out_file;
  11.   
  12.   static int next_ch, copied_line_len, line_no, brace_depth, depth_sp;
  13. ***************
  14. *** 145,150 ****
  15. --- 147,165 ----
  16.       if (brace_depth != temp)
  17.         errf("confused by mismatched, conditionally included braces...\n");
  18.     }
  19. +   else if (strcmp(pp, "ptcheader") == 0)
  20. +   {
  21. +     lookaside = NULL;
  22. +     fprintf(out_file, "#include \"%s\"\n", cur_hdr);
  23. + #ifdef NEVER
  24. +     if ((strcmp(cur_hdr, "PTC.h") == 0) || (strcmp(cur_hdr, "PTCPAS.h") == 0)) {
  25. +       fprintf(out_file, "#include \"argvgt.h\"\n");
  26. +       fprintf(out_file, "#include \"fopen.h\"\n");
  27. +       fprintf(out_file, "#include \"getl.h\"\n");
  28. +       fprintf(out_file, "#include \"ptcerror.h\"\n");
  29. +     }
  30. + #endif
  31. +   }
  32.   }
  33.   
  34.   static int get_tokch(int ch)
  35. ***************
  36. *** 164,173 ****
  37. --- 179,194 ----
  38.           /* pre-processor directive */
  39.           int j = 0, last_ch;
  40.           char pp[ID_MAX];
  41. +         lookaside = lookaside_buf;
  42.           ch = skip1_blanks(ch);
  43.           do {pp[j++] = ch;  ch = getch(ch);} while (char_class[ch] & ID_CL);
  44.           pp[j] = 0;
  45.           pp_directive(pp);
  46. +         if (lookaside != NULL) {
  47. +           *lookaside = '\0';
  48. +           fputs(lookaside_buf, out_file);
  49. +           lookaside = NULL;
  50. +         }
  51.           last_ch = 0;
  52.           while ((ch != '\n' || last_ch == '\\') && ch != EOF)
  53.             last_ch = ch, ch = getch(ch);
  54. ***************
  55. *** 674,681 ****
  56.     if (in_file == NULL)
  57.     { in_file = stdin;
  58.       cur_name = "<stdin>";
  59.     }
  60. !   else cur_name = in_name;
  61.   
  62.     if (out_name) out_file = fopen(out_name, "w");
  63.     else out_file = NULL;
  64. --- 695,717 ----
  65.     if (in_file == NULL)
  66.     { in_file = stdin;
  67.       cur_name = "<stdin>";
  68. +     cur_hdr[0] = '\0';
  69. +   }
  70. +   else
  71. +   {  char *cp;
  72. +      char leaf[256];
  73. +      cur_name = in_name;
  74. +      strcpy(cur_hdr, cur_name);
  75. +      cp = strrchr(cur_hdr, '.');
  76. +      if (cp == NULL) errf("cannot generate header file for %s", cur_name);
  77. +      strcpy(leaf, cp+1);
  78. +      cp -= 2;
  79. +      if (!(cp[0] == '.' && tolower(cp[1]) == 'c'))
  80. +        errf("cannot generate header file for %s", cur_name);
  81. +      sprintf(cur_hdr, "%s.h", leaf);
  82.     }
  83.   
  84.     if (out_name) out_file = fopen(out_name, "w");
  85.     else out_file = NULL;
  86.