From f4abe2b3df488258ee269bdaeca00ab52c1dd564 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 22 Oct 1998 04:38:24 +0000 Subject: [PATCH] Improve command-line parser to recognize double-quoted arguments. This is necessary to support quoted long filenames as arguments. --- v7/src/microcode/ntgui.c | 48 +++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/v7/src/microcode/ntgui.c b/v7/src/microcode/ntgui.c index cd88e5fe9..3fcf8c092 100644 --- a/v7/src/microcode/ntgui.c +++ b/v7/src/microcode/ntgui.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntgui.c,v 1.23 1998/04/18 05:39:22 cph Exp $ +$Id: ntgui.c,v 1.24 1998/10/22 04:38:24 cph Exp $ Copyright (c) 1993-98 Massachusetts Institute of Technology @@ -80,14 +80,46 @@ WinMain (HANDLE hInst, HANDLE hPrevInst, LPSTR lpCmdLine, int nCmdShow) s = strcpy (cmdline, lpCmdLine); - while (*s) { - if (*s==' ') - *s++ = 0; - else { - argv[argc++] = s; - while (*s != 0 && *s != ' ') s++; + while ((*s) != '\0') + { + while ((*s) == ' ') + s += 1; + if ((*s) == '"') + { + s += 1; + (argv[argc++]) = s; + while (1) + { + if ((*s) == '"') + { + (*s++) = '\0'; + break; + } + if ((*s) == '\0') + { + outf_fatal ("WinMain: unterminated quoted argument."); + outf_flush_fatal (); + return (FALSE); + } + s += 1; + } + } + else + { + (argv[argc++]) = s; + while (1) + { + if ((*s) == ' ') + { + (*s++) = '\0'; + break; + } + if ((*s) == '\0') + break; + s += 1; + } + } } - } argv[argc] = 0; } -- 2.25.1