Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ok, I'm a lammer, and I cannot get the rule from an unit to its mother file right...
[simgrid.git] / src / surf / surf_parse.c
index 776cb64..e432e14 100644 (file)
@@ -6,8 +6,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/misc.h"
-#include "xbt/error.h"
-#include "surf/surf_parse.h"
+#include "xbt/log.h"
+#include "surf/surf_parse_private.h"
 #include "surf/surf_private.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(parse, surf ,"Logging specific to the SURF  module");
 
@@ -150,6 +150,10 @@ void ETag_argument(void)
 }
 
 void  surf_parse_open(const char *file) {
+  if(!file) {
+    WARN0("I hope you know what you're doing... you just gave me a NULL pointer!");
+    return;
+  }
   if(!surf_input_buffer_stack) 
     surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE),NULL);
   if(!surf_file_to_parse_stack) 
@@ -168,15 +172,20 @@ void  surf_parse_close(void) {
   if(surf_file_to_parse_stack) 
     xbt_dynar_free(&surf_file_to_parse_stack);
 
-  surf_parse__delete_buffer(surf_input_buffer);
-  fclose(surf_file_to_parse);
+  if(surf_file_to_parse) {
+    surf_parse__delete_buffer(surf_input_buffer);
+    fclose(surf_file_to_parse);
+  }
 }
 
-int surf_parse(void)
+
+static int _surf_parse(void)
 {
   return surf_parse_lex();
 }
 
+int_f_void_t surf_parse = _surf_parse;
+
 void surf_parse_get_double(double *value,const char *string)
 { 
   int ret = 0;