-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdumb.l
203 lines (186 loc) · 3.49 KB
/
dumb.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
%{
/**********************************************************************
*
* dumb : 2013-03-20
*
* emptymonkey's dumb tool.
* Take smart terminal output and make it dumb.
*
*
* Dumb output is acheived by removing all valid control characters
* and escape sequences.
*
*
* Example usage:
*
* empty@monkey:~$ ls
* dumb dumb.l dumb.o Makefile test_cases
* empty@monkey:~$ ls --color | xxd
* 0000000: 1b5b 306d 1b5b 3031 3b33 326d 6475 6d62 .[0m.[01;32mdumb
* 0000010: 1b5b 306d 0a64 756d 622e 6c0a 6475 6d62 .[0m.dumb.l.dumb
* 0000020: 2e6f 0a4d 616b 6566 696c 650a 1b5b 3031 .o.Makefile..[01
* 0000030: 3b33 346d 7465 7374 5f63 6173 6573 1b5b ;34mtest_cases.[
* 0000040: 306d 0a 0m.
* empty@monkey:~$ ls --color | dumb | xxd
* 0000000: 6475 6d62 0a64 756d 622e 6c0a 6475 6d62 dumb.dumb.l.dumb
* 0000010: 2e6f 0a4d 616b 6566 696c 650a 7465 7374 .o.Makefile.test
* 0000020: 5f63 6173 6573 0a _cases.
*
**********************************************************************/
#include <stdio.h>
%}
%option noyywrap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