From 41a43790bf6c6331ca0f1283e3402f6dc6574072 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 7 Dec 2010 15:18:43 +0000 Subject: [PATCH] new function: MSG_action_paranoid_mode_set (allowing to tell the parser that our input is clean and that he don't need to be paranoid about it git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9069 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/msg/msg.h | 1 + src/msg/msg_actions.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/msg/msg.h b/include/msg/msg.h index 8850105c0b..7b5e58e301 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -217,6 +217,7 @@ XBT_PUBLIC(MSG_error_t) /************************** Action handling **********************************/ typedef void (*msg_action_fun) (xbt_dynar_t args); +XBT_PUBLIC(void) MSG_action_paranoid_mode_set(int mode); XBT_PUBLIC(void) MSG_action_register(const char *action_name, msg_action_fun function); XBT_PUBLIC(void) MSG_action_unregister(const char *action_name); diff --git a/src/msg/msg_actions.c b/src/msg/msg_actions.c index 6410d2221e..bba22414d7 100644 --- a/src/msg/msg_actions.c +++ b/src/msg/msg_actions.c @@ -12,6 +12,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg, "MSG actions for trace driven simulation"); +static int paranoid_action_replayer=1; +/** \ingroup msg_actions + * \brief set the paranoid mode: true if we must check our input, false if it's well formated + */ +void MSG_action_paranoid_mode_set(int mode) { + paranoid_action_replayer = mode; +} + static xbt_dict_t action_funs; static xbt_dict_t action_queues; @@ -79,13 +87,17 @@ static int MSG_action_runner(int argc, char *argv[]) // Read lines and execute them until I reach the end of file while ((read = getline(&line, &line_len, fp)) != -1) { // cleanup and split the string I just read - comment = strchr(line, '#'); - if (comment != NULL) - *comment = '\0'; - xbt_str_trim(line, NULL); - if (line[0] == '\0') - continue; + if (paranoid_action_replayer) { + comment = strchr(line, '#'); + if (comment != NULL) + *comment = '\0'; + xbt_str_trim(line, NULL); + } evt = xbt_str_split_quoted(line); + if (xbt_dynar_length(evt)==0) { + xbt_dynar_free(&evt); + continue; + } evtname = xbt_dynar_get_as(evt, 0, char *); if (!strcmp(argv[0], evtname)) { -- 2.20.1