[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MiNTlib PL48 released
On Mon, 11 May 1998 18:35:27 -0400 (EDT), Yves Pelletier wrote:
YP>If no issues are raised in the next 7-10 days, I will distribute
YP>to worldwide archive sites then.
Seems like you forgot to include Chris' patch for quoted filenames.
Here's his original readme and below is the patch updated for pl48.
###
Hi all!
The code in crtinit.c for extracting the argv from the environment
doesn't handle quoted filenames correctly. Modern desktops (Thing,
Gemini) use ' for filenames that containing special characters, e.g. a
blank. If you doubleclick the file <i:\with blank> it would be send as
'i:\with blank' to the program.
The code in crtinit.c (PL46, PL47) split this name into two args:
argv[1] = 'i:\with
argv[2] = blank'
I've implemented a simple parser that looks for ' in the cmdline. It
create a correct argv:
argv[1] = i:\with blank
Please test it out and integrate it into the next PL. I've test it only
with PL46 for PureC.
Chris.
###
--- 48/lib/crtinit.c Wed Jan 7 00:24:12 1998
+++ crtinit.c Sat May 16 08:17:28 1998
@@ -410,6 +410,10 @@
while(i > 0 && isspace(*cmdln) )
cmdln++,--i;
+#if 0
+/*
+ * This code doesn't handle quoted file names correctly!
+*/
while (i > 0) {
if (isspace(*cmdln)) {
--i; cmdln++;
@@ -422,6 +426,44 @@
--i;
}
}
+#else
+{
+ int in_quote = 0;
+
+ while (i > 0)
+ {
+ if (*cmdln == '\'')
+ {
+ i--; cmdln++;
+ if (in_quote)
+ {
+ if (*cmdln == '\'') /* double ': file name contains ' */
+ {
+ *to++ = *cmdln++;
+ i--;
+ }
+ else
+ in_quote = 0;
+ }
+ else
+ in_quote = 1;
+ }
+ if ((*cmdln != ' ') || ((*cmdln == ' ' && in_quote)))
+ {
+ *to++ = *cmdln++;
+ i--;
+ }
+ else
+ {
+ --i; cmdln++;
+ while (i > 0 && isspace(*cmdln))
+ --i,cmdln++;
+ *to++ = 0;
+ }
+ }
+}
+#endif
+
*to++ = '\0';
*to = '\0'; /* bug fix example:cmdln == '\3' 'a' ' ' 'b' '\0' */
/* the loop below expects \0\0 at end to terminate! */
--
E-mail: stehlik@cas3.zlin.vutbr.cz PARCP developer
WWW: http://cas3.zlin.vutbr.cz/~stehlik/ MiNTOS/Linux user
mirror: http://users.zln.cz/~pstehlik/ Atari 800XL emulation
mirror: http://www.stehlik.cyberstrider.org/ Atari Falcon040