/* replaces tabs in the input with the proper number of blanks to * space to the next tab stop */ #include #define TABSPC 8 #define MAXSTOPS 1000 char stops[MAXSTOPS] = "\0"; int sti = 0; int count = 0; /*void getargs(int argc, char *argv[]) { int i; for (i = 0; i < MAXSTOPS; i++) { if (--argc > 0) { if ((stops[i] = atoi((++argv)[0])) == 0) { printf("hey you BITCH\n"); exit(1); } } else { stops[i] = TABSPC; } } }*/ void getargs(int argc, char *argv[]) { int i, j, flag = 0; for (i = 0; i < MAXSTOPS; i++) { if (--argc > 0) { if (*(++argv)[0] == '-') { stops[0] = atoi(++argv[0]); if (stops[0] == 0) { printf("you motherFUCKER!\n"); exit(1); } flag = 1; } else if (*argv[0] == '+') { if (flag == 0) { printf("don't FUCK with me!\n"); exit(1); } j = atoi(++argv[0]); if (j == 0) { printf("SLUT!\n"); exit(1); } while (i < MAXSTOPS) stops[i++] = j; return; } else if ((stops[i] = atoi(argv[0])) == 0) { printf("hey you BITCH\n"); exit(1); } } else { stops[i] = TABSPC; } } } void up(int i) { if ((count+=i) >= stops[sti]) { sti++; count = 0; } } void clear(void) { count = 0; sti = 0; } int main(int argc, char *argv[]) { int c, i, j; getargs(argc, argv); while((c=getchar()) != EOF) { if (c == '\t') { j = stops[sti]; for (i = count; i < j; i++) { putchar(' '); up(1); } } else if (c == '\n') { putchar(c); clear(); } else { putchar(c); up(1); } } return 0; }