/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "concat.p" */ #include /* copies afile and bfile into abfile billie lemmon and thomas schneider, copyright (c) 1985 module libraries: delman, delmods */ /* begin module version */ #define version 1.08 /* concat 1986 dec 9 origin: 1982 august 15 */ /* end module version */ /* begin module describe.concat */ /* name concat: concatenate files together synopsis concat(afile: in, bfile: in, abfile: out, output: out) files afile: the first file to be copied to abfile bfile: the second file to be copied to abfile abfile: the concatenation of afile and bfile output: messages to the user description concat joins two files, afile and bfile, into a single file named abfile. afile is first copied to abfile, followed by bfile. a warning is given to the user if either afile or bfile is empty, but in this case, the program copies the other file to abfile anyway. examples one can use concat to join delila instruction sets in the cyclic teaching of the perceptron (see our third nar paper). note that delila will not accept several titles in the instructions, so be sure that one of the two sets has no title, or remove it by hand. author billie lemmon and thomas schneider bugs none known */ /* end module describe.concat */ Static _TEXT afile, bfile; /* input files */ Static _TEXT abfile; /* result of the operation */ /* begin module unlimitln */ Static Void unlimitln(afile) _TEXT *afile; { /* this procedure removes a stupid system dependent limit on the number of lines that one can write to a file. you may remove it from the code if your system does not want or need this. suggested method: place comments around the contents of the procedure. */ /* linelimit(afile, maxint); (* set 'infinite' lines allowed for afile */ } /* end module unlimitln version = 'delmod 6.51 85 apr 17 tds/gds' */ Static Void onecopy(sin, sout) _TEXT *sin, *sout; { /* copy sin to sout */ Char c; /* character of the text */ while (!BUFEOF(sin->f)) { while (!P_eoln(sin->f)) { c = getc(sin->f); if (c == '\n') c = ' '; putc(c, sout->f); } fscanf(sin->f, "%*[^\n]"); getc(sin->f); putc('\n', sout->f); } } /* onecopy */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); abfile.f = NULL; strcpy(abfile.name, "abfile"); bfile.f = NULL; strcpy(bfile.name, "bfile"); afile.f = NULL; strcpy(afile.name, "afile"); printf(" concat %4.2f\n", version); if (*afile.name != '\0') { if (afile.f != NULL) afile.f = freopen(afile.name, "r", afile.f); else afile.f = fopen(afile.name, "r"); } else rewind(afile.f); if (afile.f == NULL) _EscIO2(FileNotFound, afile.name); RESETBUF(afile.f, Char); if (*bfile.name != '\0') { if (bfile.f != NULL) bfile.f = freopen(bfile.name, "r", bfile.f); else bfile.f = fopen(bfile.name, "r"); } else rewind(bfile.f); if (bfile.f == NULL) _EscIO2(FileNotFound, bfile.name); RESETBUF(bfile.f, Char); if (*abfile.name != '\0') { if (abfile.f != NULL) abfile.f = freopen(abfile.name, "w", abfile.f); else abfile.f = fopen(abfile.name, "w"); } else { if (abfile.f != NULL) rewind(abfile.f); else abfile.f = tmpfile(); } if (abfile.f == NULL) _EscIO2(FileNotFound, abfile.name); SETUPBUF(abfile.f, Char); unlimitln(&abfile); if (!BUFEOF(afile.f)) onecopy(&afile, &abfile); else printf("afile is empty\n"); if (!BUFEOF(bfile.f)) onecopy(&bfile, &abfile); else { printf("bfile is empty\n"); } if (afile.f != NULL) fclose(afile.f); if (bfile.f != NULL) fclose(bfile.f); if (abfile.f != NULL) fclose(abfile.f); exit(EXIT_SUCCESS); } /* concat */ /* End. */