Commits

scherer  committed 5f2b930

PR#5312: remove the Windows @responsefile feature, that conflicted
with '-w @...' command-line warning specifications [breaking change]

This change has relatively wide consequences as it modifies the windows
OCaml runtime: when the runtime computed the argument vector "argv"
passed to the program, it automatically expanded arguments of the form
@foo into the content of the filename "foo" (parsed as a sequence of
command-line arguments). This means that this "feature" was
automatically enabled for all user programs written in OCaml and
linking to the usual runtime.

This conflicted with the more recent feature of the OCaml *compiler*
(which is affected, as an OCaml program), that allows to pass warning
specifications of the form "-w @...", for example -w @ae. On windows,
it would try to replace it by the content of the file "ae", leading to
an error.

Given the warning specifications are widely used in OCaml programs
(causing silly Windows portability problems), and the @reponsefile is
anecdotical at best (at poll [1] on the Caml-list revealed no user
using this feature), it was decided to remove @responsefile
altogether.

[1] see mailing-list thread "[community poll for PR#5312] Do some
OCaml Windows users still use the @responsefile feature?"

This change affects all OCaml programs compiled under Windows. Users
previously relying on the @responsefile feature should now explicitely
expand Sys.argv themselves; use Arg.parse_argv to rerun Arg
command-line handlers on user-provided string arrays.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12685f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

  • Participants
  • Parent commits f0f5004

Comments (0)

Files changed (2)

 - PR#5309: Queue.add is not thread/signal safe
 - PR#5310: Ratio.create_ratio/create_normalized_ratio have misleading names
 - PR#5311: better message for warning 23
+* PR#5312: command-line arguments @reponsefile auto-expansion feature
+  removed from the Windows OCaml runtime, to avoid conflicts with "-w @..."
 - PR#5313: ocamlopt -g misses optimizations
 - PR#5316: objinfo now shows ccopts/ccobjs/force_link when applicable
 - PR#5318: segfault on stack overflow when reading marshaled data

File byterun/win32.c

 static void store_argument(char * arg);
 static void expand_argument(char * arg);
 static void expand_pattern(char * arg);
-static void expand_diversion(char * filename);
 
 static void out_of_memory(void)
 {
 {
   char * p;
 
-  if (arg[0] == '@') {
-    expand_diversion(arg + 1);
-    return;
-  }
   for (p = arg; *p != 0; p++) {
     if (*p == '*' || *p == '?') {
       expand_pattern(arg);
   _findclose(handle);
 }
 
-static void expand_diversion(char * filename)
-{
-  struct _stat stat;
-  int fd;
-  char * buf, * endbuf, * p, * q, * s;
-  int inquote;
-
-  if (_stat(filename, &stat) == -1 ||
-      (fd = _open(filename, O_RDONLY | O_BINARY, 0)) == -1) {
-    fprintf(stderr, "Cannot open file %s\n", filename);
-    exit(2);
-  }
-  buf = (char *) malloc(stat.st_size + 1);
-  if (buf == NULL) out_of_memory();
-  _read(fd, buf, stat.st_size);
-  endbuf = buf + stat.st_size;
-  _close(fd);
-  for (p = buf; p < endbuf; /*nothing*/) {
-    /* Skip leading blanks */
-    while (p < endbuf && isspace(*p)) p++;
-    if (p >= endbuf) break;
-    s = p;
-    /* Skip to end of argument, taking quotes into account */
-    q = s;
-    inquote = 0;
-    while (p < endbuf) {
-      if (! inquote) {
-        if (isspace(*p)) break;
-        if (*p == '"') { inquote = 1; p++; continue; }
-        *q++ = *p++;
-      } else {
-        switch (*p) {
-          case '"':
-            inquote = 0; p++; continue;
-          case '\\':
-            if (p + 4 <= endbuf && strncmp(p, "\\\\\\\"", 4) == 0) {
-              p += 4; *q++ = '\\'; *q++ = '"'; continue;
-            }
-            if (p + 3 <= endbuf && strncmp(p, "\\\\\"", 3) == 0) {
-              p += 3; *q++ = '\\'; inquote = 0; continue;
-            }
-            if (p + 2 <= endbuf && p[1] == '"') {
-              p += 2; *q++ = '"'; continue;
-            }
-            /* fallthrough */
-        default:
-          *q++ = *p++;
-        }
-      }
-    }
-    /* Delimit argument and expand it */
-    *q++ = 0;
-    expand_argument(s);
-    p++;
-  }
-}
 
 CAMLexport void caml_expand_command_line(int * argcp, char *** argvp)
 {