The menu item "Tools -> Encode File List" reports an error if a file name includes embedded spaces.
So does Pac, but if you enclose the name in ' or " Pac works. The native tool does not.
Personally I hate file names with spaces, but I can't always choose what files I am given.
Do people think this is a bug that should be fixed? I am quite happy to continue using Pac.
The encoding tool & file names with spaces
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: The encoding tool & file names with spaces
I think this is a feature that should be added and documented.
The fix in StdCoder.ReadPath would look like this:
Note that a scanner cannot be used here easily because a scanner does not support the path format.
Therefore I extended ReadPath with a check for single or double quotes.
The extra check for (ch >= " ") is for breaking strings at end-of-line or rulers. It could also be removed.
My tests did not show any unwanted side effects or follow-up problems so far.
- Josef
The fix in StdCoder.ReadPath would look like this:
Code: Select all
PROCEDURE ReadPath(rd: TextModels.Reader; VAR path: ARRAY OF CHAR; VAR len: INTEGER);
VAR i, l: INTEGER; ch: CHAR; quote: CHAR;
BEGIN
i := 0; l := LEN(path) - 1;
REPEAT rd.ReadChar(ch) UNTIL rd.eot OR (ch > " ");
IF (ch = "'") OR (ch = '"') THEN quote := ch; rd.ReadChar(ch) ELSE quote := 0X END;
WHILE ~rd.eot & (i < l) & ((quote = 0X) & (ch > " ") OR (quote # 0X) & (ch # quote) & (ch >= " ")) DO
path[i] := ch; INC(i); rd.ReadChar(ch)
END;
path[i] := 0X; len := i
END ReadPath;
Therefore I extended ReadPath with a check for single or double quotes.
The extra check for (ch >= " ") is for breaking strings at end-of-line or rulers. It could also be removed.
My tests did not show any unwanted side effects or follow-up problems so far.
- Josef