[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: patch bug: prompting for filename doesn't accept filenames with spac
From: |
Ed Avis |
Subject: |
Re: patch bug: prompting for filename doesn't accept filenames with spaces |
Date: |
Wed, 3 Dec 2008 12:33:09 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Here is a patch to fix this bug:
diff -ru patch-2.5.4/pch.c patch-2.5.4-new/pch.c
--- patch-2.5.4/pch.c 1999-08-30 07:20:08.000000000 +0100
+++ patch-2.5.4-new/pch.c 2008-12-03 12:33:30.000000000 +0000
@@ -253,7 +253,29 @@
return TRUE;
}
ask ("File to patch: ");
- inname = fetchname (buf, 0, (time_t *) 0);
+
+ /* Strip off the trailing newline from user input and treat
+ the empty string as null, but apart from that do not alter
+ it. A filename is allowed to contain spaces and other
+ weird characters. */
+ inname = savestr (buf);
+ const size_t l = strlen (inname);
+ if (l == 0)
+ {
+ free (inname);
+ inname = 0;
+ }
+ else if (inname[l - 1] == '\n')
+ {
+ if (l == 1)
+ {
+ free (inname);
+ inname = 0;
+ }
+ else
+ inname[l - 1] = '\0';
+ }
+
if (inname)
{
if (stat (inname, &instat) == 0)
--
Ed Avis <address@hidden>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: patch bug: prompting for filename doesn't accept filenames with spaces,
Ed Avis <=