Skip to contentSkip to conversation

stand-alone build of sxpr parser

PATCH New Charles Coffing 1 participant 1 message Nov 22, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stand-alone build of sxpr parser

This patch applies to 2.0-testing.

It updates/fixes the stand-alone build of the S-expression parser, so that it may be debugged more easily. It makes no code changes to the normal build.

Quoted 1 line

From tools/xfrd, you may do...

SXPR_DEBUG=1 make
...to get a version of xfrd solely meant to test the S-expression parser.

Thanks,
Charles

===== tools/xfrd/Makefile 1.7 vs edited =====

tools/xfrd/Makefile +5 -1
@@ -26,11 +26,15 @@
 # Define to use stubs, undefine to use the real Xen functions.
 #CPPFLAGS += -D _XEN_XFR_STUB_
 
+ifeq ($(SXPR_DEBUG),1)
+CPPFLAGS += -D _XEN_XFR_STUB_ -D SXPR_PARSER_MAIN
+endif
+
 CC := gcc
 
 CFLAGS += -g
 CFLAGS += -Wall
-CFALGS += -Werror
+CFLAGS += -Werror
 CFLAGS += $(INCLUDES)
 # Make gcc generate dependencies.
 CFLAGS += -Wp,-MD,.$(@F).d

===== tools/xfrd/debug.h 1.2 vs edited =====

tools/xfrd/debug.h +1 -0
@@ -45,6 +45,7 @@
 #else
 
 #include <stdio.h>
+#include <unistd.h>
 
 #ifdef DEBUG
 

===== tools/xfrd/sxpr_parser.c 1.1 vs edited =====

tools/xfrd/sxpr_parser.c +2 -30
@@ -808,26 +808,13 @@
     return p->eof;
 }
 
-//#define SXPR_PARSER_MAIN
 #ifdef SXPR_PARSER_MAIN
 /* Stuff for standalone testing. */
 
 #include "file_stream.h"
 #include "string_stream.h"
 
-int stringof(Sxpr exp, char **s){
-    int err = 0;
-    if(ATOMP(exp)){
-        *s = atom_name(exp);
-    } else if(STRINGP(exp)){
-        *s = string_string(exp);
-    } else {
-        err = -EINVAL;
-        *s = NULL;
-    }
-    return err;
-}
-
+extern int stringof(Sxpr exp, char **s);
 int child_string(Sxpr exp, Sxpr key, char **s){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);
@@ -835,22 +822,7 @@
     return err;
 }
 
-int intof(Sxpr exp, int *v){
-    int err = 0;
-    char *s;
-    unsigned long l;
-    if(INTP(exp)){
-        *v = OBJ_INT(exp);
-    } else {
-        err = stringof(exp, &s);
-        if(err) goto exit;
-        err = convert_atoul(s, &l);
-        *v = (int)l;
-    }
- exit:
-    return err;
-}
-
+extern int intof(Sxpr exp, int *v);
 int child_int(Sxpr exp, Sxpr key, int *v){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);

===== tools/xfrd/xen_domain.c 1.20 vs edited =====

tools/xfrd/xen_domain.c +1 -1
@@ -83,7 +83,7 @@
     }
     
     dom = 99;
-    err = domain_suspend(dom, xend);
+    err = domain_suspend(xend, dom);
     IOStream_close(io);
   exit:
 #else 

===== tools/xfrd/xfrd.c 1.18 vs edited =====

tools/xfrd/xfrd.c +26 -23

77 lines not on this page · raw message