scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <assert.h>
 2#include <stdio.h>
 3#include <stdlib.h>
 4#include <string.h>
 5
 6/*
 7output:
 8testing
 9test1
10one
11two
12three
13four
14test2
15one
16three
17test3
18one
19done
20end:
21*/
22
23void
24test(char *msg, char *fmt)
25{
26	char *s, buff[50];
27
28	puts(msg);
29
30	strcpy(buff, fmt);
31	for (s = strtok(buff, "-+"); s; s = strtok(NULL, "+-")) {
32		switch (atoi(s)) {
33		case 1:
34			puts("one");
35			break;
36		case 2:
37			puts("two");
38			break;
39		case 3:
40			puts("three");
41			break;
42		case 4:
43			puts("four");
44			break;
45		default:
46			puts("error");
47			break;
48		}
49	}
50}
51
52int
53main()
54{
55	puts("testing");
56	test("test1", "-+001--0002++3+-4");
57	test("test2", "001--+-+-+-3+-");
58	test("test3", "001");
59	puts("done");
60	return 0;
61}