[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tab characters in the source code
From: |
Ian Stirling |
Subject: |
Re: tab characters in the source code |
Date: |
Sun, 12 Apr 2009 01:19:54 -0400 |
User-agent: |
KMail/1.9.10 |
On Tuesday 07 April 2009 03:32:43 pm Mark Polesky wrote:
> I was fiddling around with output-ps.scm (specifically
> the grob-cause procedure on line 159) and was getting
> frustrated with the poor indentation displaying in my
> editor when I realized that this was being caused by
> tab characters in the source.
>
> Is there an easy way to address this? I don't know how
> many tab characters there are in the source, nor do I
> know how to find out. But it can be frustrating. Any
> solutions?
Here's a hack I wrote for my Amiga files in 1994 'cos I was fed up of tabs.
Error checking is minimal and boundary checking is non existent.
#include <stdio.h>
#include <ctype.h>
#include <math.h>
main(int argc, char *argv*[]) {
int tab, c, ts;
if (argc !=2 ) {
fprintf(stderr, "Use: expandtab n\n");
exit(27);
}
ts = atoi(argv[1]);
tab = 0;
while ((c=getchar()) != EOF) {
if (c=='\t') {
tab %= ts;
do {
putchar(' ');
++tab;
} while (tab != ts);
}
else {
putchar(c);
++tab;
}
if ( c=='\n' )
tab = 0;
}
}
Ian
--
- Re: tab characters in the source code, (continued)
Re: tab characters in the source code, Jan Nieuwenhuizen, 2009/04/08
Re: tab characters in the source code, Nicolas Sceaux, 2009/04/09
Re: tab characters in the source code,
Ian Stirling <=