Open tueda opened 1 year ago
Here, I built Windows binaries with MSVC as well as MSYS2. Both give the same output. In the following, new-line characters are explicitly shown as \r
-> <CR>
and \n
-> <LF>\n
.
Input:
S x,y;<CR><LF>
L F = (x+y)^10;<CR><LF>
P;<CR><LF>
.end
FORM output to log file (-l
)
FORM 5.0.0-beta.1 (Apr 2 2024, v5.0.0-beta.1-58-g88f6930) Run: Thu Apr 25 19:54:50 2024<LF>
S x,y;<LF>
L F = (x+y)^10;<LF>
P;<LF>
.end<LF>
<CR><LF>
Time = 0.00 sec Generated terms = 11<CR><LF>
F Terms in output = 11<CR><LF>
Bytes used = 364<CR><LF>
<CR><LF>
F =<CR><LF>
y^10 + 10*x*y^9 + 45*x^2*y^8 + 120*x^3*y^7 + 210*x^4*y^6 + 252*x^5*y^5<CR><LF>
+ 210*x^6*y^4 + 120*x^7*y^3 + 45*x^8*y^2 + 10*x^9*y + x^10;<CR><LF>
<CR><LF>
0.00 sec out of 0.00 sec<CR><LF>
FORM output to stdout
FORM 5.0.0-beta.1 (Apr 2 2024, v5.0.0-beta.1-58-g88f6930) Run: Thu Apr 25 19:54:50 2024<CR><LF>
S x,y;<CR><LF>
L F = (x+y)^10;<CR><LF>
P;<CR><LF>
.end<CR><LF>
<CR><CR><LF>
Time = 0.00 sec Generated terms = 11<CR><CR><LF>
F Terms in output = 11<CR><CR><LF>
Bytes used = 364<CR><CR><LF>
<CR><LF>
F =<CR><LF>
y^10 + 10*x*y^9 + 45*x^2*y^8 + 120*x^3*y^7 + 210*x^4*y^6 + 252*x^5*y^5<CR><LF>
+ 210*x^6*y^4 + 120*x^7*y^3 + 45*x^8*y^2 + 10*x^9*y + x^10;<CR><LF>
<CR><LF>
0.00 sec out of 0.00 sec<CR><CR><LF>
So, there are three combinations of new-line characters: | log file (binary mode) | stdout (text mode) |
---|---|---|
LF |
CR LF |
|
CR LF |
CR CR LF |
|
CR LF |
CR LF |
where the last row is the correct pair.
I don't yet fully understand it, but it seems that on Windows (without POSIX;
UNIX
is undefined andWINDOWS
is defined, which meansWITHRETURN
is defined), FORM tries to putCR
beforeLF
for newline characters. For example: https://github.com/vermaseren/form/blob/e15da79ddec5dcb9432614e96854c7780496537c/sources/sch.c#L94-L97But, in text mode,
LF
written to output is converted toCR+LF
, andCR+LF
from input is converted toLF
:In fact,
stdout
is opened with text mode:while other files in FORM are always opened in binary mode:
Consequently, FORM outputs to
stdout
contain wrong newline charactersCR+CR+LF
on Windows. This breaks some test cases where newline characters do matter.