• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Demonstration of groff .psbb request handling code, for EPS and PDF input files


Commit MetaInfo

修订版9a532c1800ae4204adf3b0f379ba00b71d4fbf14 (tree)
时间2021-10-20 07:48:11
作者Keith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Extend debugging diagnostics to report popped lexer state.

* psbblex.l (DEBUG_POP_STATE): New macro; define, and use it
as a debug-enabled diagnostic wrapper, in place of...
(yy_pop_state): ...this.

更改概述

差异

--- a/psbblex.l
+++ b/psbblex.l
@@ -49,8 +49,15 @@
4949 yy_push_state( NAME ); \
5050 } while(0)
5151
52+# define DEBUG_POP_STATE() \
53+ do { debug_msg("%d: revert to state ", YYSTATE); \
54+ yy_pop_state(); debug_msg("%d\n", YYSTATE); \
55+ } while(0)
56+
5257 # define DEBUG_RETURN(TOKEN, NAME) \
53- do { debug_msg("%d: return token %s (%d)\n", YYSTATE, NAME, TOKEN); \
58+ do { debug_msg("%d: return token %s (%d)\n", \
59+ YYSTATE, NAME, TOKEN \
60+ ); \
5461 return TOKEN; \
5562 } while(0)
5663
@@ -73,6 +80,7 @@ static void debug_msg (const char *fmt, ...)
7380 # define DEBUG_ECHO
7481 # define DEBUG_MSG(ARGLIST)
7582 # define DEBUG_PUSH_STATE(NAME) yy_push_state( NAME )
83+# define DEBUG_POP_STATE() yy_pop_state()
7684 # define DEBUG_RETURN(TOKEN, NAME) return TOKEN
7785 # define DEBUG_RETURN_VALUE return VALUE
7886 #endif
@@ -86,7 +94,10 @@ enum { PSBB_PHASE_INIT = 0, PSBB_IN_HEADER, PSBB_IN_TRAILER };
8694 static int psbb_phase, psbb_crescendo_seek( void ), psbb_parse_status;
8795
8896 #define DEBUG_PDFINVOKE(STATE, TOKEN, NAME) \
89- do { yy_push_state( STATE ); DEBUG_RETURN(TOKEN, NAME); \
97+ do { DEBUG_MSG(("%d: processing entry with key '%s'\n", \
98+ YYSTATE, yytext \
99+ )); \
100+ yy_push_state( STATE ); DEBUG_RETURN(TOKEN, NAME); \
90101 } while(0)
91102
92103 #define PDFINVOKE(STATE, TOKEN) DEBUG_PDFINVOKE(STATE, TOKEN, #TOKEN)
@@ -179,7 +190,7 @@ static int pdf_trailer( void )
179190 * not sufficient here, since we need to be prepared to handle any of
180191 * the CR only, LF only, or CRLF line ending conventions).
181192 */
182-<SKIP>{READLN} { yy_pop_state(); }
193+<SKIP>{READLN} { DEBUG_POP_STATE(); }
183194
184195
185196 /* State: PSHDR
@@ -345,10 +356,12 @@ static int pdf_trailer( void )
345356 "/Pages"/{PDFSEP} { DEBUG_PUSH_STATE( PDFREFER ); }
346357 "/Kids"/{PDFSEP} { DEBUG_PUSH_STATE( PDFALLKIDS ); }
347358 "/MediaBox"/{PDFSEP} { DEBUG_PUSH_STATE( PDFMEDIABOX ); }
348-"/"{PDFNAME}/{PDFSEP} { DEBUG_MSG(("%d: skipping entry with key '%s'\n", YYSTATE, yytext));
359+"/"{PDFNAME}/{PDFSEP} { DEBUG_MSG(("%d: skipping entry with key '%s'\n",
360+ YYSTATE, yytext
361+ ));
349362 DEBUG_PUSH_STATE( PDFIGNORE );
350363 }
351-">>" { yy_pop_state(); }
364+">>" { DEBUG_POP_STATE(); }
352365 .|\n
353366 }
354367
@@ -365,8 +378,8 @@ static int pdf_trailer( void )
365378 * object type which we do not expect to encounter.
366379 */
367380 <PDFOBJTYPE>{
368-"/Catalog"/{PDFSEP} { yy_pop_state(); RETURN(PDFOBJREF); }
369-"/Page"s?/{PDFSEP} { yy_pop_state(); }
381+"/Catalog"/{PDFSEP} { DEBUG_POP_STATE(); RETURN(PDFOBJREF); }
382+"/Page"s?/{PDFSEP} { DEBUG_POP_STATE(); }
370383 "/"{PDFNAME}/{PDFSEP} { DEBUG_MSG(("%d: ignoring unknown object type '%s'\n"
371384 "%d: fall back to state 'PDFIGNORE'\n",
372385 YYSTATE, yytext, YYSTATE
@@ -388,7 +401,7 @@ static int pdf_trailer( void )
388401 */
389402 <PDFALLKIDS>"["{SEP}* { BEGIN PDFKIDS; PDFINVOKE( PDFREFER, PDFOBJREF ); }
390403 <PDFKIDS,PDFALLKIDS>{
391-"]" { yy_pop_state(); }
404+"]" { DEBUG_POP_STATE(); }
392405 {INTVAL}/{SEP}
393406 "R"/{PDFSEP}
394407 {SEP}+
@@ -403,9 +416,9 @@ static int pdf_trailer( void )
403416 * start condition whence this state was attained.
404417 */
405418 <PDFREFER>{
406-"R"/{PDFSEP} { yy_pop_state(); RETURN('R'); }
419+"R"/{PDFSEP} { DEBUG_POP_STATE(); RETURN('R'); }
407420 {INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN_VALUE; }
408-./({EOL}|"/") { yy_pop_state(); }
421+./({EOL}|"/") { DEBUG_POP_STATE(); }
409422 [ \t\r\n]+
410423 }
411424
@@ -431,7 +444,7 @@ static int pdf_trailer( void )
431444 <PDFMEDIABOXEVAL>{
432445 {FLOATVAL}/{PDFSEP} { yylval = lround( atof( yytext )); RETURN_VALUE; }
433446 {INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN_VALUE; }
434-"]" { yy_pop_state(); }
447+"]" { DEBUG_POP_STATE(); }
435448 {SEP}+
436449 }
437450
@@ -442,7 +455,9 @@ static int pdf_trailer( void )
442455 * revert to the state whence this condition was invoked.
443456 */
444457 <PDFEVAL>{
445-{INTVAL}/{PDFSEP} { yylval = atol( yytext ); yy_pop_state(); RETURN_VALUE; }
458+{INTVAL}/{PDFSEP} { yylval = atol( yytext ); DEBUG_POP_STATE();
459+ RETURN_VALUE;
460+ }
446461 [ \t\r\n]+
447462 }
448463
@@ -454,8 +469,8 @@ static int pdf_trailer( void )
454469 <PDFIGNORE>{
455470 [^</>\r\n]+ { DEBUG_ECHO; }
456471 "<<" { DEBUG_PUSH_STATE( PDFDICT ); }
457-[</>] { yyless(0); yy_pop_state(); }
458-{EOL} { yy_pop_state(); }
472+[</>] { yyless(0); DEBUG_POP_STATE(); }
473+{EOL} { DEBUG_POP_STATE(); }
459474 }
460475
461476 /* State: PDFXREF
@@ -533,13 +548,18 @@ static int pdf_trailer( void )
533548 * specified object;
534549 */
535550 <PDFGOXREF>{READLN} { long offset, gen; char disp;
536- sscanf( yytext, "%10ld %5ld %c", &offset, &gen, &disp );
537- DEBUG_MSG(("%d: %.18s --> %d; %d %c\n", YYSTATE, yytext, offset, gen, disp));
551+ sscanf( yytext, "%10ld %5ld %c",
552+ &offset, &gen, &disp
553+ );
554+ DEBUG_MSG(("%d: %.18s --> %d; %d %c\n",
555+ YYSTATE, yytext, offset, gen, disp
556+ ));
538557 if( disp == 'n' && gen == ref[1] )
539558 { pdfseek( offset ); BEGIN PDFGETOBJECT;
540559 }
541560 else
542- { yyerror( "index entry '%.18s' unexpected in file '%s'",
561+ { yyerror(
562+ "index entry '%.18s' unexpected in file '%s'",
543563 yytext, psbb_input_file
544564 );
545565 return PSBB_PARSE_FAILURE;