Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sure that we use Cat.exe on Windows instead cat.exe (mingw32).
[simgrid.git] / tools / tesh2 / src / fstream.c
index 36bb0f1..f244865 100644 (file)
@@ -31,7 +31,7 @@
 \r
 #ifdef WIN32\r
 static int\r
-is_w32_cmd(const char* cmd, char** path)\r
+is_w32_cmd(char* cmd, char** path)\r
 {\r
        size_t i = 0;\r
        struct stat stat_buff = {0};\r
@@ -51,6 +51,9 @@ is_w32_cmd(const char* cmd, char** path)
                {\r
                        for (i = 0; path[i] != NULL; i++)\r
                        {\r
+                               /* use Cat.exe on Windows */\r
+                               if(!strcmp(cmd, "cat"))\r
+                                       cmd[0] = 'C';\r
                                \r
                                sprintf(buff,"%s\\%s",path[i], cmd);\r
                                \r
@@ -396,13 +399,13 @@ fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, con
        char* line2;\r
        variable_t variable;\r
        unsigned int i;\r
-       char exp[VAR_NAME_MAX + 1] = {0};\r
+       char exp[PATH_MAX + 1] = {0};\r
        unit_t unit = fstream->unit;\r
        xbt_dynar_t variables = unit->runner->variables;\r
        char* p= NULL;\r
        char* end = NULL;\r
        char* val = NULL;\r
-       char buff[VAR_NAME_MAX + 1] = {0}; \r
+       char buff[PATH_MAX + 1] = {0}; \r
        size_t len;\r
        char delimiters[4] = {' ', '\t', '\n', '\0'}; \r
        \r
@@ -1267,7 +1270,7 @@ fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex
 \r
                /* translate the command line */\r
 \r
-               char* path;\r
+               char* path = NULL;\r
                char* delimiter;\r
                char command_line[PATH_MAX + 1] = {0};\r
                size_t i = 0;\r
@@ -1275,9 +1278,9 @@ fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex
 \r
                \r
 \r
-               if(strstr(context->command_line,".exe"))\r
-                       strcpy(command_line,context->command_line);\r
-               else\r
+               /*if(strstr(context->command_line,".exe"))\r
+                       strcpy(command_line,context->command_line);*/\r
+               \r
                {\r
                        size_t len;\r
                        \r
@@ -1294,15 +1297,16 @@ fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex
                                        \r
                                i++;\r
                        }\r
-\r
-                       strcat(command_line,".exe");\r
+                       \r
+                       if(!strstr(context->command_line,".exe"))\r
+                               strcat(command_line,".exe");\r
 \r
                        args = strdup(context->command_line + i);\r
                }\r
                \r
-               if(getpath(command_line, &path) && !is_w32_cmd(command_line, fstream->unit->runner->path))\r
+               if(!is_w32_cmd(command_line, fstream->unit->runner->path) && getpath(command_line, &path) < 0)\r
                {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", filepos, context->command_line, error_to_string(ECMDNOTFOUND, 1));\r
+                       ERROR3("[%s] `%s' : NOK (%s)", filepos, command_line, error_to_string(ECMDNOTFOUND, 1));\r
                        unit_set_error(fstream->unit, ECMDNOTFOUND, 1, filepos);\r
                        failure(unit);\r
                        return;\r
@@ -1338,9 +1342,11 @@ fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex
                {\r
                        if(args)\r
                        {\r
+\r
                                context->t_command_line = (char*)calloc(strlen(command_line) + strlen(args) + 1, sizeof(char));\r
                                sprintf(context->t_command_line,"%s%s",command_line, args);\r
 \r
+                       \r
                                free(args);\r
 \r
                        }\r