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 <wchar.h>
 5
 6/*
 7output:
 8testing
 9test1
10one
11two
12three
13four
14test2
15one
16three
17test3
18one
19done
20end:
21*/
22
23void
24test(char *msg, wchar_t *fmt)
25{
26	wchar_t *s, *p, buff[50];
27
28	puts(msg);
29
30	wcscpy(buff, fmt);
31	for (s = wcstok(buff, L"-+", &p); s; s = wcstok(NULL, L"+-", &p)) {
32		switch (*s) {
33		case L'1':
34			puts("one");
35			break;
36		case L'2':
37			puts("two");
38			break;
39		case L'3':
40			puts("three");
41			break;
42		case L'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", L"-+1--2++3+-4");
57	test("test2", L"1--+-+-+-3+-");
58	test("test3", L"1");
59	puts("done");
60	return 0;
61}