CC: Tweaked

CC: Tweaked

57M Downloads

[1.14] io.lines appending a space to the end of each line read

HydrantHunter opened this issue ยท 1 comments

commented

cc:Tweaked 1.80pr1.14
Minecraft 1.12.2
Forge 14.23.5.2768

I've noticed a change in behavior with io.lines in cc:Tweaked compared to other builds of CC...please excuse my bumbling explanation...

The intent of the following chunk of code is to use io.lines to read input from a file, then print each line read.

for logEntry in io.lines("/history") do
  print("|" .. logEntry .. "|")
end

Example of file contents:

23 @  3:24 AM <Inbound> 99HV9OACF
23 @  4:17 AM <Inbound> 99HV9OACF
23 @ 10:04 AM <Outbound> 99HV9OACF
42 @  9:33 AM <Outbound> T9HRYNK8P
42 @ 10:04 AM <Outbound> T9NFGHWCI
42 @ 10:34 AM <Outbound> 99OHOHOGW
42 @ 11:04 AM <Outbound> X9IN0NIRS

When run in older versions of CC, or Crazed Programmer's latest build of CC, the results for any single line are what I think one would expect...
|23 @ 3:24 AM <Inbound> 99HV9OACF|

When run in cc:Tweaked, io.lines appears to append a space to the end of each line that is read, resulting in slightly different output...
|23 @ 3:24 AM <Inbound> 99HV9OACF |

I'm guessing this isn't an intended change in behavior. If you need more information I'm happy to oblige.

commented

I suspect this is actually a \r character rather than a space. At a guess, the file handle is no longer stripping \r when it reads a line, shouldn't be too hard to fix.