|  | DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen RC700 "Piccolo" | 
This is an automatic "excavation" of a thematic subset of
 See our Wiki for more about RegneCentralen RC700 "Piccolo" Excavated with: AutoArchaeologist - Free & Open Source Software. | 
top - metrics - download
    Length: 2176 (0x880)
    Types: TextFile
    Names: »TABIFY.C«
└─⟦b35f94715⟧ Bits:30003295 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
└─⟦b35f94715⟧ Bits:30005324 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
    └─⟦this⟧ »TABIFY.C« 
/*
	Tabify.c	written by Leor Zolman
	This filter takes sequences of spaces in a file and turns
	them, whenever possible, into tabs. Usage:
		A>tabify oldfile newfile <cr>
	Quoted strings are not processed, but there should NOT be
	any `lone' double quotes within the file being tabified.
*/
#include <bdscio.h>
int scount, column, ifd, ofd, i;
int c;
char ibufÆBUFSIZÅ, obufÆBUFSIZÅ;
main(argc,argv)
char **argv;
æ
	if (argc < 2 øø argc > 3) æ
		printf("usage: tabify oldfile ÆnewfileÅØn");
		exit();
	å
	ifd = fopen(argvÆ1Å,ibuf);
	if (argc == 2) argvÆ2Å = "tabify.tmp";
	ofd = fcreat(argvÆ2Å,obuf);
	if (ifd == ERROR øø ofd == ERROR) æ
		printf("Can't open file(s)Øn");
		exit();
	å
	scount = column = 0;
	do æ
		c = getc(ibuf);
		if (c == ERROR) æ
			putc(CPMEOF,obuf);
			break;
		 å
		switch(c) æ
		   case 'Ør':	putc1(c,obuf);
				scount = column = 0;
				break;
		   case 'Øn':	putc1(c,obuf);
				scount = 0;
				putchar('*');
				break;
		   case ' ':	column++;
				scount++;
				if (!(column%8)) æ
				   if (scount > 1)
					putc1('Øt',obuf);
				   else
					putc1(' ',obuf);
					scount = 0;
				 å
				break;
		   case 'Øt':	scount = 0;
				column += (8-column%8);
				putc1('Øt',obuf);
				break;
		   case '"':	for (i = 0; i < scount; i++)
					putc1(' ',obuf);
				putc1('"',obuf);
				do æ
				   c = getc(ibuf);
				   if (c == ERROR) æ
				    printf("Quote error.Øn");
				    exit();
				   å
				   putc1(c,obuf);
				å while (c != '"');
				do æ
					c = getc(ibuf);
					putc1(c,obuf);
				å while (c != 'Øn');
				column = scount = 0;
				break;
		   case CPMEOF:	putc(CPMEOF,obuf);
				break;
		   default:	for (i=0; i<scount; i++)
					putc1(' ',obuf);
				scount = 0;
				column++;
				putc1 (c,obuf);
		 å
	 å while (c != CPMEOF);
	fclose(ibuf);
	fclose(obuf);
	if (argc == 2) æ
		unlink(argvÆ1Å);
		rename(argvÆ2Å,argvÆ1Å);
	å
å
putc1(c,buf)
char c;
æ
	if (putc(c,buf) < 0) æ
		printf("Write error (out of disk space?)Øn");
		exit();
	å
å
«eof»