File tree Expand file tree Collapse file tree 2 files changed +6
-23
lines changed Expand file tree Collapse file tree 2 files changed +6
-23
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ struct CommandLineArgs parseCommandLineArgs(int argc, char* argv[]) {
60
60
if (strcmp (argv [i ], "--output" ) == 0 || strcmp (argv [i ], "-of" ) == 0 ) {
61
61
// 指定输出流
62
62
if (i + 1 < argc ) {
63
- puts ("Output: " ); puts (argv [i + 1 ]); puts ("\n" );
63
+ fputs ("Output: " , stdout ); fputs (argv [i + 1 ], stdout ); fputs ("\n" , stdout );
64
64
args .output = fopen (argv [i + 1 ], "w" );
65
65
// args.outputFilePath = argv[i + 1];
66
66
if (args .output == NULL ) {
Original file line number Diff line number Diff line change @@ -46,33 +46,15 @@ struct JsonString* parseStringToStr(char token) {
46
46
47
47
while ((c = fgetc (f )) && c != EOF && c != token ) {
48
48
if (c == '\\' ) {
49
+ JsonStringPushBackChar (c , str );
49
50
c = fgetc (f );
50
51
if (c == EOF ) {
51
52
fprintf (stderr , "Unexpected EOF after escape character.\tString value parse begin with %llu\n" , pos );
52
53
exit (1 );
53
54
}
54
- switch (c ) {
55
- case '"' :
56
- case '\'' :
57
- case '\\' :
58
- JsonStringPushBackChar (c , str );
59
- break ;
60
- case 'n' :
61
- JsonStringPushBackChar ('\n' , str );
62
- break ;
63
- case 't' :
64
- JsonStringPushBackChar ('\t' , str );
65
- break ;
66
- case 'u' :
67
- JsonStringPushBackChar ('\\' , str );
68
- JsonStringPushBackChar ('u' , str );
69
- break ;
70
- default :
71
- fprintf (stderr , "Invalid escape sequence: \\%c\tString value parse begin with %llu\n" , c , pos );
72
- exit (1 );
73
- }
55
+ JsonStringPushBackChar (c , str );
74
56
}
75
- else { JsonStringPushBackChar (c , str ); }
57
+ else JsonStringPushBackChar (c , str );
76
58
}
77
59
78
60
if (c != token ) {
@@ -197,13 +179,14 @@ struct JsonVal* parseBool() {
197
179
exit (1 );
198
180
}
199
181
ungetc (c , f );
200
- struct JsonVal * res = malloc ( sizeof ( struct JsonVal ));
182
+
201
183
if (res == NULL ) {
202
184
// 内存分配失败 OOM (?)
203
185
// 异常退出, OS进行内存回收
204
186
exit (1 );
205
187
}
206
188
res -> val = JsonStringFromCharArray ("false" );
189
+ return res ;
207
190
}
208
191
else {
209
192
fprintf (
You can’t perform that action at this time.
0 commit comments