detok 1.0.2 merge commit II git-svn-id: svn://coreboot.org/openbios/fcode-utils@104 f158a5a8-5612-0410-a976-696ce0be7e32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
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;
}
+