Improve usability command line under windows.
authorConti Manuele <conti.ma@alice.it>
Tue, 17 Apr 2012 17:41:58 +0200
changeset 521 3127ddda2be2
parent 520 fb381d2cd25b
child 522 f9cff11ae622
Improve usability command line under windows.
main.cc
--- a/main.cc	Tue Apr 17 17:59:02 2012 +0100
+++ b/main.cc	Tue Apr 17 17:41:58 2012 +0200
@@ -124,6 +124,7 @@
   char * builddir = NULL;
   stage1_2_options_t stage1_2_options = {false, false, NULL};
   int optres, errflg = 0;
+  int path_len;
 /*
   extern char *optarg;
   extern int optind, optopt;
@@ -148,9 +149,19 @@
       stage1_2_options.safe_extensions = true;
       break;
     case 'I':
+      /* NOTE: To improve the usability under windows:
+       *       We delete last char's path if it ends with "\".
+       *       In this way compiler front-end accepts paths with or without
+       *       slash terminator.
+       */
+      path_len = strlen(optarg) - 1;
+      if (optarg[path_len] == '\\') optarg[path_len]= '\0';
       stage1_2_options.includedir = optarg;
       break;
     case 'T':
+      /* NOTE: see note above */
+      path_len = strlen(optarg) - 1;
+      if (optarg[path_len] == '\\') optarg[path_len]= '\0';
       builddir = optarg;
       break;
     case ':':       /* -I or -T without operand */