DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T d

⟦e4e48e9f7⟧ TextFile

    Length: 1392 (0x570)
    Types: TextFile
    Names: »detab.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/se/se_h/detab.c« 

TextFile

#ifndef lint
static char RCSid[] = "$Header: detab.c,v 1.1 86/05/06 14:04:37 arnold Locked $";
#endif

/*
 * $Log:	detab.c,v $
 * Revision 1.1  86/05/06  14:04:37  arnold
 * Initial revision
 * 
 * 
 */

/* Detab - convert tabs to appropriate number of spaces */

/* transcribed from Kernighan and Plaguer (Software Tools) */
/* fixed up by Arnold Robbins */

#include <stdio.h>

#define MAXLINE         132

#define repeat          do
#define until(x)        while(!(x))

#define tabpos(col, tabs)       ( (col > MAXLINE) ? 1 : tabs[col - 1])

main()
{
        int c, i, tabs[MAXLINE], col = 1;

        settabs(tabs);

        while ((c = getchar()) != EOF)
                switch(c) {
                case '\t':
                        repeat
                        {
                                putchar(' ');
                                col++;
                        } until(tabpos(col, tabs));
                        break;

                case '\n':
                        putchar('\n');
                        col = 1;
                        break;

                default:
                        putchar(c);
                        col++;
                        break;
                }
}

settabs(tabs)
int tabs[];
{
        int i;

        for(i = 1; i <= MAXLINE; i++)
                tabs[i - 1] = ((i % 8) == 1);
                /* result is either 1 or 0 */
}