/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "nomultiblank.p" */ #include /* nomultiblank: remove all multiple blank lines from a file Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.ccrnp.ncifcrf.gov/~toms/ */ /* label 1; (* end of program *) */ /* begin module version */ #define version 1.00 /* of nomultiblank.p 2006 Nov 25 origin 2006 Nov 25 from noblank */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ #define debugging false /* set true to see counts */ /* end module version */ /* begin module describe.nomultiblank */ /* name nomultiblank: remove all multiple blank lines from a file synopsis nomultiblank(input: in, out, output: out) files input: a text file output: the text file with multile blank lines in the middle replaced by a single blank line. description This program will remove multiple blanks lines in the middle of a file. It will also remove lines that have only blank characters. examples documentation see also rembla.p noblank.p author Thomas Dana Schneider bugs technical notes */ /* end module describe.nomultiblank */ /* (* begin module halt *) procedure halt; (* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. *) begin writeln(output,' program halt.'); goto 1 end; (* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; *) */ /* begin module nomultiblank.themain */ Static Void themain(fin, fout) _TEXT *fin, *fout; { /* the main procedure of the program */ Char c; /* a character in fin */ long b; /* index to blanks */ long blanks; /* number of leading blank characters */ boolean blankline; /* the line was totally blank */ long countblanklines = 0; /* count of the blank lines */ while (!BUFEOF(fin->f)) { blanks = 0; blankline = true; while (!P_eoln(fin->f)) { c = getc(fin->f); if (c == '\n') c = ' '; if (c == ' ' && blankline) blanks++; else { blankline = false; countblanklines = 0; for (b = 1; b <= blanks; b++) putc(' ', fout->f); blanks = 0; } if (!blankline) putc(c, fout->f); } fscanf(fin->f, "%*[^\n]"); getc(fin->f); countblanklines++; if (debugging) fprintf(fout->f, "[%ld]", countblanklines); if (countblanklines <= 2) putc('\n', fout->f); } } #undef debugging /* end module nomultiblank.themain */ main(argc, argv) int argc; Char *argv[]; { _TEXT TEMP, TEMP1; PASCAL_MAIN(argc, argv); TEMP.f = stdin; *TEMP.name = '\0'; TEMP1.f = stdout; *TEMP1.name = '\0'; themain(&TEMP, &TEMP1); /*1:*/ exit(EXIT_SUCCESS); } /* End. */