File: printer_function_with_indentation.k

package info (click to toggle)
kimwitu-doc 10a-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,192 kB
  • ctags: 341
  • sloc: makefile: 166; yacc: 125; ansic: 40; lex: 18; sh: 2
file content (18 lines) | stat: -rw-r--r-- 357 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include "unpk.h"
static indent=0;

void printer(char *s, uview v) {
    char c; int j;

    while(c=*s++) {
	if (c!='%') putchar(c);
	else switch(c=*s++) {
	case 'b':	indent--; break;
	case 't':	indent++; break;
	case 'n':	putchar('\n');
			for (j=indent; j>0; j--) putchar('\t');
			break;
	case '\0':	return;
	default:	putchar(c);
}}}