Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correct implementation of start/end tags when bypassing the parser.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 28 Sep 2010 08:54:26 +0000 (08:54 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 28 Sep 2010 08:54:26 +0000 (08:54 +0000)
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
include/surf/surfxml_parse.h
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index 60dfc3c..1e3c543 100644 (file)
@@ -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);
index c66cdf7..2246add 100644 (file)
@@ -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);
index 1e89a6e..3cf2818 100644 (file)
@@ -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);
index e101d03..02f3bbf 100644 (file)
@@ -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();