[OpenBIOS] [PATCH fcode-utils] toke: fix line parsing on big-endian

Laurent Vivier laurent at vivier.eu
Mon Nov 2 00:14:59 CET 2015


Trying to compile openbios on Fedora 22 ppc64, I had the following error:

toke -o QEMU,VGA.bin ~/openbios/drivers/vga.fs
...
Tokenizing  ~/openbios/drivers/vga.fs   Binary output to QEMU,VGA.bin 
Warning:  File ~/openbios/drivers/vga.fs, Line 1.  Unterminated comment
Nothing Tokenized.  1 Warning.

This can be reproduced with the fcode-utils examples.

"toke" is parsing the comment line until it finds a '\n'.
The '\n' is stored as a char in a field of an union,
but it is read as a long. It works well on little endian but
not on big endian.

Signed-off-by: Laurent Vivier <laurent at vivier.eu>
---
diff -ru fcode-utils/toke/scanner.c fcode-utils-new/toke/scanner.c
--- fcode-utils/toke/scanner.c	2006-10-30 09:48:28.000000000 +0100
+++ fcode-utils-new/toke/scanner.c	2015-10-19 00:21:43.417373690 +0200
@@ -1625,7 +1625,7 @@
 
 void user_message( tic_param_t pfield )
 {
-    char delim = (char)pfield.deflt_elem ;
+    char delim = (char)pfield.fw_token ;
     handle_user_message( delim, TRUE);
 }
 
@@ -5295,7 +5295,7 @@
 
 void process_remark( tic_param_t pfield )
 {
-    char until_char = (char)pfield.deflt_elem ;
+    char until_char = (char)pfield.fw_token ;
     unsigned int start_lineno = lineno;
 
 #ifdef DEBUG_SCANNER



More information about the OpenBIOS mailing list