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[]) {
6060 if (strcmp (argv [i ], "--output" ) == 0 || strcmp (argv [i ], "-of" ) == 0 ) {
6161 // 指定输出流
6262 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 );
6464 args .output = fopen (argv [i + 1 ], "w" );
6565 // args.outputFilePath = argv[i + 1];
6666 if (args .output == NULL ) {
Original file line number Diff line number Diff line change @@ -46,33 +46,15 @@ struct JsonString* parseStringToStr(char token) {
4646
4747 while ((c = fgetc (f )) && c != EOF && c != token ) {
4848 if (c == '\\' ) {
49+ JsonStringPushBackChar (c , str );
4950 c = fgetc (f );
5051 if (c == EOF ) {
5152 fprintf (stderr , "Unexpected EOF after escape character.\tString value parse begin with %llu\n" , pos );
5253 exit (1 );
5354 }
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 );
7456 }
75- else { JsonStringPushBackChar (c , str ); }
57+ else JsonStringPushBackChar (c , str );
7658 }
7759
7860 if (c != token ) {
@@ -197,13 +179,14 @@ struct JsonVal* parseBool() {
197179 exit (1 );
198180 }
199181 ungetc (c , f );
200- struct JsonVal * res = malloc ( sizeof ( struct JsonVal ));
182+
201183 if (res == NULL ) {
202184 // 内存分配失败 OOM (?)
203185 // 异常退出, OS进行内存回收
204186 exit (1 );
205187 }
206188 res -> val = JsonStringFromCharArray ("false" );
189+ return res ;
207190 }
208191 else {
209192 fprintf (
You can’t perform that action at this time.
0 commit comments