From 31bfa073530d5b1154c51c5f5f24269a7399409a Mon Sep 17 00:00:00 2001 From: navarrop Date: Tue, 28 Sep 2010 08:54:26 +0000 Subject: [PATCH] Correct implementation of start/end tags when bypassing the parser. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8280 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/msg/masterslave/masterslave_bypass.c | 2 -- include/surf/surfxml_parse.h | 22 ++++++++++++------- src/surf/surf_routing.c | 7 ++++-- src/surf/surfxml_parse.c | 8 +++++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/examples/msg/masterslave/masterslave_bypass.c b/examples/msg/masterslave/masterslave_bypass.c index 60dfc3c873..1e3c543642 100644 --- a/examples/msg/masterslave/masterslave_bypass.c +++ b/examples/msg/masterslave/masterslave_bypass.c @@ -18,8 +18,6 @@ static int surf_parse_bypass_platform(void) { static int AX_ptr = 0; static int surfxml_bufferstack_size = 2048; - static int surfxml_buffer_stack_stack_ptr = 0; - static int surfxml_buffer_stack_stack[1024]; /* allocating memory for the buffer, I think 2kB should be enough */ surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); diff --git a/include/surf/surfxml_parse.h b/include/surf/surfxml_parse.h index c66cdf7ec3..2246add4a9 100644 --- a/include/surf/surfxml_parse.h +++ b/include/surf/surfxml_parse.h @@ -76,6 +76,9 @@ XBT_PUBLIC_DATA(int_f_void_t) surf_parse; /* Entry-point to the parser. Se /* Set of macros to make the bypassing work easier. * See examples/msg/masterslave_bypass.c for an example of use */ +extern unsigned int surfxml_buffer_stack_stack_ptr; +extern unsigned int surfxml_buffer_stack_stack[1024]; + #define SURFXML_BUFFER_SET(key,val) do { \ AX_surfxml_##key=AX_ptr; \ strcpy(A_surfxml_##key,val); \ @@ -86,15 +89,18 @@ XBT_PUBLIC_DATA(int_f_void_t) surf_parse; /* Entry-point to the parser. Se memset(surfxml_bufferstack,0,surfxml_bufferstack_size); } while(0) #define SURFXML_START_TAG(tag) do{ \ - surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr] = AX_ptr;\ - surfxml_buffer_stack_stack_ptr++;\ - STag_surfxml_##tag(); \ - }while(0) + surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr] = AX_ptr;\ + DEBUG2("surfxml_buffer_stack_stack[%d]=%d",surfxml_buffer_stack_stack_ptr,surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr]);\ + surfxml_buffer_stack_stack_ptr++;\ + STag_surfxml_##tag(); \ + }while(0) + #define SURFXML_END_TAG(tag) do{ \ - AX_ptr = surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr-1];\ - surfxml_buffer_stack_stack_ptr--;\ - ETag_surfxml_##tag();\ - } while(0) + surfxml_buffer_stack_stack_ptr--;\ + AX_ptr = surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr-1];\ + DEBUG1("AX_ptr=%d",AX_ptr);\ + ETag_surfxml_##tag();\ + } while(0) XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function); XBT_PUBLIC(void) surfxml_del_callback(xbt_dynar_t* cb_list, void_f_void_t function); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 1e89a6e388..3cf2818419 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -2222,8 +2222,10 @@ static void routing_full_parse_Scluster(void) xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; - static int surfxml_buffer_stack_stack_ptr = 0; - static int surfxml_buffer_stack_stack[1024]; + static unsigned int surfxml_buffer_stack_stack_ptr = 1; + static unsigned int surfxml_buffer_stack_stack[1024]; + + surfxml_buffer_stack_stack[0]= 0; surfxml_bufferstack_push(1); @@ -2275,6 +2277,7 @@ static void routing_full_parse_Scluster(void) surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *)); surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *)); + DEBUG2("Create hosts and links from %d to %d",start,end); for (i = start; i <= end; i++) { host_id = bprintf("%s%d%s", cluster_prefix, i, cluster_suffix); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index e101d03a32..02f3bbf36b 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -31,6 +31,10 @@ int surfxml_bufferstack_size = 2048; static char *old_buff = NULL; static void surf_parse_error(char *msg); +unsigned int surfxml_buffer_stack_stack_ptr; +unsigned int surfxml_buffer_stack_stack[1024]; + + void surfxml_bufferstack_push(int new) { if (!new) @@ -356,6 +360,10 @@ static void free_data(void) void parse_platform_file(const char *file) { int parse_status; + + surfxml_buffer_stack_stack_ptr = 1; + surfxml_buffer_stack_stack[0] = 0; + surf_parse_open(file); init_data(); parse_status = surf_parse(); -- 2.20.1