Commit bf55ca78e94b1e309bd03190ad130dbdc606a048

Stefan Reinauer 2006-10-30T11:31:16

detok 1.0.2 merge commit II git-svn-id: svn://coreboot.org/openbios/fcode-utils@104 f158a5a8-5612-0410-a976-696ce0be7e32

diff --git a/detok/decode.c b/detok/decode.c
index 5f946f5..4217edc 100644
--- a/detok/decode.c
+++ b/detok/decode.c
@@ -38,6 +38,7 @@
 
 #include "detok.h"
 #include "stream.h"
+#include "addfcodes.h"
 
 static int indent;		/*  Current level of indentation   */
 
@@ -125,8 +126,7 @@ static void pretty_print_string(void)
 static void decode_lines(void)
 {
 	if (show_linenumbers) {
-		printf("%6d: ",
-		       show_offsets ? token_streampos : linenum++);
+		printf("%6d: ",show_offsets ? token_streampos : linenum++);
 	}
 }
 
@@ -384,6 +384,18 @@ static void blit(void)
 	printf("0x%x\n", lit);
 }
 
+static void double_length_literal(void)
+{
+	u16 quadhh, quadhl, quadlh, quadll;
+
+	output_token();
+	quadhh = get_num16();
+	quadhl = get_num16();
+	quadlh = get_num16();
+	quadll = get_num16();
+	printf("0x%04x.%04x.%04x.%04x\n", quadhh, quadhl, quadlh, quadll);
+}
+
 static void offset16(void)
 {
 	decode_default();
@@ -536,10 +548,28 @@ static void decode_token(u16 token)
 		end_found = TRUE;
 		decode_default();
 		break;
+
+#if  0  /*  Fooey on C's petty limitations!  */
+        /*  I'd like to be able to do this:  */
+	/*  Special Functions  */
+	case *double_lit_code:
+		double_length_literal();
+		break;
+#endif  /*  Fooey on C's petty limitations!  */
+
 	default:
+	{
+	    /*  Have to do this clumsy thing instead  */
+	    if ( token == *double_lit_code )
+	    {
+		double_length_literal();
+		break;
+	    }
+
 		decode_default();
 	}
 }
+}
 
 
 /* **************************************************************************
@@ -556,15 +586,18 @@ static void decode_token(u16 token)
  *      Outputs:
  *         Returned Value:      NONE
  *         Global/Static Variables:
- *             offs16           FALSE if Starter was version1, else TRUE
+ *             offs16           FALSE if Starter was version1, TRUE for all
+ *                                  other valid Starters, otherwise unchanged.
  *             fclen            On error, gets set to reach end of input stream
  *                                  Otherwise, gets set by  decode_start() 
  *         Printout:
+ *             On error, print a new-line to finish previous token's line.
  *
  *      Error Detection:
  *          First byte not a valid FCode Start:  Print message, restore
  *              input pointer to initial value, set fclen to [(end of
- *              input stream) - (input pointer)], return FALSE.
+ *              input stream) - (input pointer)], leave offs16 unchanged.
+ *              Return FALSE.
  *
  *      Process Explanation:
  *          This routine error-checks and dispatches to the routine that
@@ -578,18 +611,20 @@ static void decode_fcode_header(void)
 {
 	long err_pos;
 	u16 token;
+	bool new_offs16 = TRUE;
 
 	err_pos = get_streampos();
 	indent = 0;
 	token = next_token();
-	offs16 = TRUE;
+
 	switch (token) {
 	case 0x0fd:		/* version1 */
-		offs16 = FALSE;
+		new_offs16 = FALSE;
 	case 0x0f0:		/* start0 */
 	case 0x0f1:		/* start1 */
 	case 0x0f2:		/* start2 */
 	case 0x0f3:		/* start4 */
+		offs16 = new_offs16;
 		decode_start();
 		break;
 	default:
diff --git a/detok/detok.c b/detok/detok.c
index 67697c5..e38df05 100644
--- a/detok/detok.c
+++ b/detok/detok.c
@@ -45,7 +45,7 @@
 #include "stream.h"
 #include "addfcodes.h"
 
-#define DETOK_VERSION "1.0.0"
+#define DETOK_VERSION "1.0.2"
 
 #define CORE_COPYR   "(C) Copyright 2001-2006 Stefan Reinauer.\n" \
 		     "(C) Copyright 2006 coresystems GmbH <info@coresystems.de>"
@@ -69,8 +69,8 @@ static void print_copyright(bool is_error)
 		CORE_COPYR "\n" IBM_COPYR "\n"
 		"Written by Stefan Reinauer, <stepan@openbios.org>\n"
 		"This program is free software; you may redistribute it "
-		"under the terms of\nthe GNU General Public License v2. This "
-		"program has absolutely no warranty.\n\n");
+		"under the terms of\nthe GNU General Public License v2. "
+		"This program has absolutely no warranty.\n\n");
 
 	pfunct = (is_error ? (vfunct) printf : printremark);
 
@@ -190,3 +190,4 @@ int main(int argc, char **argv)
 
 	return 0;
 }
+