[AD] small dat2c fixes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


1. When specifying no header file name, dat2c would crash.

2. Outputting characters >= 127 causes problems when viewing files as
UTF8, so I made them be escaped like < 32.

(Oh.. and would I be allowed to run indent with Allegro's indent.pro
over the file before committing? It contains lots of ugly trailing
spaces.)

-- 
Elias Pschernig <elias@xxxxxxxxxx>
Index: tools/dat2c.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/dat2c.c,v
retrieving revision 1.15
diff -u -p -r1.15 dat2c.c
--- tools/dat2c.c	4 Nov 2003 09:38:26 -0000	1.15
+++ tools/dat2c.c	20 Apr 2004 19:41:36 -0000
@@ -600,7 +600,7 @@ static void _cwrite_esc(FILE* fp, const 
                 break;
             
             default:
-                if(*rd < 32) {
+                if(*rd < 32 || *rd >= 127) {
                     _cwrite_esc_char(fp, *rd);
                     was_num_escape = 2;
                 } else {
@@ -1668,7 +1668,8 @@ int do_conversion(struct dat2c* dat2c)
         dat2c->prefix ? "_" : "", 
         dat2c->datafile_name ? dat2c->datafile_name : "data");
 
-    write_header_start(dat2c);
+    if (dat2c->fname_h)
+        write_header_start(dat2c);
     write_source_start(dat2c);
     
     result = write_datafile(dat2c, dat2c->dat, 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/