3838
3939#include "detok.h"
4040#include "stream.h"
41+ #include "addfcodes.h"
4142
4243static int indent ; /* Current level of indentation */
4344
@@ -125,8 +126,7 @@ static void pretty_print_string(void)
125126static void decode_lines (void )
126127{
127128 if (show_linenumbers ) {
128- printf ("%6d: " ,
129- show_offsets ? token_streampos : linenum ++ );
129+ printf ("%6d: " ,show_offsets ? token_streampos : linenum ++ );
130130 }
131131}
132132
@@ -384,6 +384,18 @@ static void blit(void)
384384 printf ("0x%x\n" , lit );
385385}
386386
387+ static void double_length_literal (void )
388+ {
389+ u16 quadhh , quadhl , quadlh , quadll ;
390+
391+ output_token ();
392+ quadhh = get_num16 ();
393+ quadhl = get_num16 ();
394+ quadlh = get_num16 ();
395+ quadll = get_num16 ();
396+ printf ("0x%04x.%04x.%04x.%04x\n" , quadhh , quadhl , quadlh , quadll );
397+ }
398+
387399static void offset16 (void )
388400{
389401 decode_default ();
@@ -536,10 +548,28 @@ static void decode_token(u16 token)
536548 end_found = TRUE;
537549 decode_default ();
538550 break ;
551+
552+ #if 0 /* Fooey on C's petty limitations! */
553+ /* I'd like to be able to do this: */
554+ /* Special Functions */
555+ case * double_lit_code :
556+ double_length_literal ();
557+ break ;
558+ #endif /* Fooey on C's petty limitations! */
559+
539560 default :
561+ {
562+ /* Have to do this clumsy thing instead */
563+ if ( token == * double_lit_code )
564+ {
565+ double_length_literal ();
566+ break ;
567+ }
568+
540569 decode_default ();
541570 }
542571}
572+ }
543573
544574
545575/* **************************************************************************
@@ -556,15 +586,18 @@ static void decode_token(u16 token)
556586 * Outputs:
557587 * Returned Value: NONE
558588 * Global/Static Variables:
559- * offs16 FALSE if Starter was version1, else TRUE
589+ * offs16 FALSE if Starter was version1, TRUE for all
590+ * other valid Starters, otherwise unchanged.
560591 * fclen On error, gets set to reach end of input stream
561592 * Otherwise, gets set by decode_start()
562593 * Printout:
594+ * On error, print a new-line to finish previous token's line.
563595 *
564596 * Error Detection:
565597 * First byte not a valid FCode Start: Print message, restore
566598 * input pointer to initial value, set fclen to [(end of
567- * input stream) - (input pointer)], return FALSE.
599+ * input stream) - (input pointer)], leave offs16 unchanged.
600+ * Return FALSE.
568601 *
569602 * Process Explanation:
570603 * This routine error-checks and dispatches to the routine that
@@ -578,18 +611,20 @@ static void decode_fcode_header(void)
578611{
579612 long err_pos ;
580613 u16 token ;
614+ bool new_offs16 = TRUE;
581615
582616 err_pos = get_streampos ();
583617 indent = 0 ;
584618 token = next_token ();
585- offs16 = TRUE;
619+
586620 switch (token ) {
587621 case 0x0fd : /* version1 */
588- offs16 = FALSE;
622+ new_offs16 = FALSE;
589623 case 0x0f0 : /* start0 */
590624 case 0x0f1 : /* start1 */
591625 case 0x0f2 : /* start2 */
592626 case 0x0f3 : /* start4 */
627+ offs16 = new_offs16 ;
593628 decode_start ();
594629 break ;
595630 default :
0 commit comments