Bug 5792 - Parser.Tabular handles Stdio.File objects bad
: Parser.Tabular handles Stdio.File objects bad
Status: RESOLVED FIXED
: Pike
Modules
: 7.8
: All All
: P3 (normal) normal
: ---
Assigned To:
:
:
:
  Show dependency treegraph
 
Reported: 2010-11-11 01:23 CET by
Modified: 2010-11-11 11:11 CET (History)
Scrum Prio:
In scrum?: ---
Story included in sprints:
Unplanned in sprints:


Attachments


Description From 2010-11-11 01:23:21 CET
Pike v7.8 release 468 running Hilfe v3.5 (Incremental Pike Frontend)
> Parser.Tabular(Stdio.File("data.csv"), Stdio.File("format.csv"));

Does not work.

If you changes those into Stdio.FILE object everything is fine.

The line that contains this statement is the fishy one:
(input=Stdio.FILE())->assign(input);

These changes helped me (maybe there are better ways?):

diff -u Tabular.pike.orig Tabular.pike
--- Tabular.pike.orig    2010-11-11 01:02:43.000000000 +0100
+++ Tabular.pike    2010-11-11 01:13:47.000000000 +0100
@@ -666,8 +666,11 @@
     input="";
   if(stringp(input))
     input=Stdio.FakeFile(input);
-  if(!input->unread)
-    (input=Stdio.FILE())->assign(input);
+  if(!input->unread) {
+    Stdio.FILE tmpf = Stdio.FILE();
+    tmpf->assign(input);
+    input = tmpf;
+  }
   int started=0;
   int lineno=0;
   string beginend="Tabular description ";
------- Comment #1 From 2010-11-11 01:26:44 CET -------
Forgot the error without my changes:

Pike v7.8 release 468 running Hilfe v3.5 (Incremental Pike Frontend)
> Parser.Tabular(Stdio.File("data.csv"), Stdio.File("format.csv"));
File not open.
-:1: Fd(-1)->read(8192,1)
-:1: Stdio.FILE(0, 0, 777 /* fd=-1 */)->read()
/Users/erikd/pike/lib/pike/modules/Stdio.pmod/module.pmod:1594: Stdio.FILE(0,
0, 777 /* fd=-1 */)->low_get_data()
/Users/erikd/pike/lib/pike/modules/Stdio.pmod/module.pmod:1629: Stdio.FILE(0,
0, 777 /* fd=-1 */)->get_lines()
/Users/erikd/pike/lib/pike/modules/Stdio.pmod/module.pmod:1712: Stdio.FILE(0,
0, 777 /* fd=-1 */)->gets(UNDEFINED)
/Users/erikd/pike/lib/pike/modules/Parser.pmod/Tabular.pike:683:
Parser.Tabular()->getline()
/Users/erikd/pike/lib/pike/modules/Parser.pmod/Tabular.pike:772:
Parser.Tabular()->compile(Stdio.FILE(0, 0, 777 /* fd=-1 */))
/Users/erikd/pike/lib/pike/modules/Parser.pmod/Tabular.pike:59:
Parser.Tabular()->create(Stdio.File("data.csv", 0, 777 /* fd=7
*/),Stdio.File("format.csv", 0, 777 /* fd=8 */),UNDEFINED)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
------- Comment #2 From 2010-11-11 11:11:48 CET -------
Applied, thanks.

Note

You need to log in before you can comment on or make changes to this bug.