Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

fix fscanf (it was not working at all, reading from console by accident) #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion KopiLua/src/luaconf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,15 @@ public static Stream tmpfile()

public static int fscanf(Stream f, CharPtr format, params object[] argp)
{
string str = Console.ReadLine();
StringBuilder sb = new StringBuilder();
for (;;)
{
int c = f.ReadByte();
if (c == -1) break;
if (c == '\n') break; //we should be transforming \r\n to \n before we get here, but that isn't done
sb.Append((char)c);
}
string str = sb.ToString();
return parse_scanf(str, format, argp);
}

Expand Down