Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Be compatible with windows
[simgrid.git] / tools / tesh / tesh.c
index 2b1068f..0a495b8 100644 (file)
@@ -6,6 +6,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid_config.h"     /* FILE for getline */
+
 /* specific to Borland Compiler */
 #ifdef __BORLANDDC__
 #pragma hdrstop
@@ -82,7 +84,7 @@ static void handle_line(const char *filepos, char *line)
   }
 }
 
-static void handle_suite(const char *filename, FILE * IN)
+static void handle_suite(const char *filename, FILE * FICIN)
 {
   size_t len;
   int blankline;
@@ -97,7 +99,7 @@ static void handle_suite(const char *filename, FILE * IN)
   buff = xbt_strbuff_new();
   rctx = rctx_new();
 
-  while (getline(&line, &len, IN) != -1) {
+  while (getline(&line, &len, FICIN) != -1) {
     line_num++;
 
     /* Count the line length while checking wheather it's blank */
@@ -187,7 +189,7 @@ static void parse_environ()
 
 int main(int argc, char *argv[])
 {
-  FILE *IN = NULL;
+  FILE *FICIN = NULL;
   int i;
   char *suitename = NULL;
 
@@ -232,23 +234,24 @@ int main(int argc, char *argv[])
   } else {
     for (i = 1; i < argc; i++) {
       suitename = xbt_strdup(argv[i]);
-      if (!strcmp("./", suitename))
+      if (!strncmp("./", suitename, 2))
         memmove(suitename, suitename + 2, strlen(suitename + 2));
 
-      if (!strcmp(".tesh", suitename + strlen(suitename) - 5))
+      if (strlen(suitename) > 5 &&
+          !strcmp(".tesh", suitename + strlen(suitename) - 5))
         suitename[strlen(suitename) - 5] = '\0';
 
       INFO1("Test suite `%s'", suitename);
       testsuite_name = suitename;
-      IN = fopen(argv[i], "r");
-      if (!IN) {
+      FICIN = fopen(argv[i], "r");
+      if (!FICIN) {
         perror(bprintf("Impossible to open the suite file `%s'", argv[i]));
         ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
         rctx_armageddon(rctx, 1);
       }
-      handle_suite(suitename, IN);
+      handle_suite(suitename, FICIN);
       rctx_wait_bg();
-      fclose(IN);
+      fclose(FICIN);
       INFO1("Test suite `%s' OK", suitename);
       free(suitename);
     }