-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
135 lines (110 loc) · 2.79 KB
/
README
File metadata and controls
135 lines (110 loc) · 2.79 KB
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
strdump will emit all the string literals and comments in a given C or C++
source file. This can be used as input to a spell checker. strdump will
mostly work with C# and Java source files too but needs some tweaks to deal
with verbatim literals and s1 + s2 concatenation.
strdump only cares about the syntax of strings, comments, and includes
so the input can actually be any suitable file, such as this one, which is
useful for documenting and testing strdump. However, strings, comments, and
includes must be well formed.
-- leading space is trimmed from strings and comments
-- multiline strings are concatenated; line number given is for start
-- multiline comments are not concatenated
-- #include "header.h" is not output
-- printf() % format strings are replaced with '%%'
-- escape sequences are output as a single '.'
-- a sequence of non-printable characters is output as a single '.'
-- specific code can be ignored with special comments (see example below)
Limitations include:
-- unicode escape sequences are not supported yet
-- any % is considered a format specification unless followed by '%', ' ', or '"'
Arguments:
-t enable trace (debugging only)
-c enable comments (disabled by default)
-d default disable (only output per comment controls)
<file> name of file to process
The following are strdump test cases. See check.out for the expected output when
running with this file. See build.sh and run.sh for how to build, test, and use
strdump.
No output: start
/ does not start a comment.
* neither does this.
No output: null comments
//
/**/
""
No output: only spaces
//
/* */
" "
No output: not a string
foo '"' bar
baz '\"' bat
No output: include
#include <pink_floyd.h>
#include "foo.h"
# include "bar.h"
Output: one line comments
// C++ style one line comment
/* C style one line comment */
Output: don't get confused by repeated *
/** 1 **/
/*** 2 ***/
/**** 3 ****/
Output: elided non-printable chars
// abcghi
/* RSTXYZ */
" 014589 "
Output: multiline comments
/*
* a
* *multiline*
* comment
*/
/*no
spaces*/
Output: basic strings
"lorem ipsum"
.
" otherstuff "
.
"don't be\ fooled"
.
"don't be\" fooled again"
Output: cat strings
" multi"
"-line"
" string"
.
"NO"
"spaces"
Output: mixed
" first string"
// interesting observation
" second string"
Output: % format strings
" %u "
" %3.3s "
" %*.*s "
" %hu "
" 100%% ok "
Output: printf examples
printf("-- value: %d\n", c);
printf("\t%s", str);
printf("%3d->%-5d\t", key, value);
Output: string escapes
" this is a \"quotable\" string"
.
"the\aquick\bbrown\ffox\tjumped\xfadover\vthe\rlazy\ndogs"
.
"\xfa\xfbw00t\xfc"
.
"\0octal\018stuff\012goes\0123here"
.
" alas, we need %"
" hueristics for % "
Conditional output: depends on -d
" maybe output "
// __STRDUMP_DISABLE__
" never output "
// __STRDUMP_ENABLE__
" always output "