[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 3/4] Pascal-RTL: Libc-Pufferung auf Streams deaktivieren



* pascal/rtl: Libc-Pufferung auf Streams deaktivieren, da die RTL intern
              selbst puffert.

Signed-off-by: Antoine Kaufmann <toni@xxxxxxxxxx>
---
 src/modules/pas/lib/rtl/sysfile.inc |    4 ++++
 src/modules/pas/lib/rtl/system.pas  |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/modules/pas/lib/rtl/sysfile.inc b/src/modules/pas/lib/rtl/sysfile.inc
index 068936e..fceeb22 100644
--- a/src/modules/pas/lib/rtl/sysfile.inc
+++ b/src/modules/pas/lib/rtl/sysfile.inc
@@ -12,6 +12,9 @@ function c_fseek(f: THandle; offset, whence: longint): longint; cdecl; external
 
 function c_feof(f: THandle): boolean; cdecl; external name 'feof';
 
+function c_setvbuf(f: THandle; buf: Pointer; mode: integer; size: TSize):
+    integer; cdecl; external name 'setvbuf';
+
 
 { TODO errno setzen nicht vergessen }
 
@@ -109,6 +112,7 @@ begin
         end;
 
         frec^.handle := c_fopen(name, @c_mode[1]);
+        c_setvbuf(frec^.handle, nil, 1, 0);
 
     end else begin
 
diff --git a/src/modules/pas/lib/rtl/system.pas b/src/modules/pas/lib/rtl/system.pas
index b9e1f6f..516570f 100644
--- a/src/modules/pas/lib/rtl/system.pas
+++ b/src/modules/pas/lib/rtl/system.pas
@@ -166,6 +166,8 @@ end;
 *)
 
 procedure c_stdio_init(); cdecl; external name 'stdio_init';
+function c_setvbuf(f: Pointer; buf: Pointer; mode: integer; size: TSize):
+    integer; cdecl; external name 'setvbuf';
 
 var
     c_stdin:  dword; external name 'stdin';
@@ -204,6 +206,8 @@ begin
     StdOutputHandle := c_stdout;
     StdErrorHandle  := c_stderr;
 
+    c_setvbuf(c_stdout, nil, 1, 0);
+
     OpenStdIO(Input,  fmInput,  StdInputHandle); 
     OpenStdIO(Output, fmOutput, StdOutputHandle);
     OpenStdIO(StdOut, fmOutput, StdOutputHandle);
-- 
1.6.0.6