1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-05-02 06:16:58 +00:00
Files
rcornwell.sims/SEL32/taptools/renum.c
AZBevier 3ddc772ce2 SEL32: Continue Code cleanup and formatting.
SEL32: Finish adding preio entry to rest of devices.
SEL32: Remove attached test from SIO processing code.
SEL32: Add attached test to each device processing code.
SEL32: Correct renum.c tap tool tp handle large files.
SEL32: Fix device address assignment for sel32_com.c device.
SEL32: Fix deblk to handle more file formatting errors.
2021-03-04 08:24:01 -07:00

61 lines
1.2 KiB
C

/*
* renum.c
*
* This program truncates a line or expands a line with blanks to
* have a line length of 72 chars. A 7 digit line number is then
* append to the line. Numbers are in the form XXXX.000.
* input - stdin
* output - stdout
*/
#include <stdio.h>
#include <stdlib.h>
/* get a line of input. */
int ln = 1;
int getloi(s, lim) /* right from the book. */
char s[];
int lim;
{
int c, i, j;
char line[12];
for (i=0; --lim > 0;)
{
if ((c = getchar()) == EOF)
return 0;
if (c == '\r')
continue;
if (c == '\n')
break;
s[i++] = c;
}
if (i > 72) /* truncate at char 72 */
i = 72;
for (; i<72; i++)
s[i] = ' ';
// sprintf(line, "%04d.000", ln++);
sprintf(line, "%04d.%01d00", ln/10, ln%10);
ln++;
for (j=0; j<8; j++)
s[72+j] = line[j];
s[80] = '\n';
s[81] = '\0';
return (i);
}
int main (argc, argv)
int argc;
char *argv[];
{
char s[BUFSIZ];
while (1) {
if (getloi(s, BUFSIZ) == 0)
exit(0);
/* output line of text from the source */
printf("%s", s);
}
}