Bring ansistrings back
authorunc0rr
Fri, 23 Nov 2012 13:08:50 +0400
changeset 8107 ee21b816394f
parent 8104 09c38cdf380d
child 8110 9f5fe3fc9d16
Bring ansistrings back
hedgewars/uLocale.pas
hedgewars/uPhysFSLayer.pas
--- a/hedgewars/uLocale.pas	Fri Nov 23 10:43:15 2012 +0100
+++ b/hedgewars/uLocale.pas	Fri Nov 23 13:08:50 2012 +0400
@@ -40,7 +40,7 @@
     trevt_n: array[TEventId] of integer;
 
 procedure LoadLocale(FileName: shortstring);
-var s: shortstring;
+var s: ansistring;
     f: pfsFile;
     a, b, c: LongInt;
     first: array[TEventId] of boolean;
@@ -58,7 +58,7 @@
     begin
     while not pfsEof(f) do
         begin
-        pfsReadLn(f, s);
+        pfsReadLnA(f, s);
         if Length(s) = 0 then
             continue;
         if (s[1] < '0') or (s[1] > '9') then
--- a/hedgewars/uPhysFSLayer.pas	Fri Nov 23 10:43:15 2012 +0100
+++ b/hedgewars/uPhysFSLayer.pas	Fri Nov 23 13:08:50 2012 +0400
@@ -30,6 +30,7 @@
 function pfsClose(f: PFSFile): boolean;
 
 procedure pfsReadLn(f: PFSFile; var s: shortstring);
+procedure pfsReadLnA(f: PFSFile; var s: ansistring);
 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
 function pfsEOF(f: PFSFile): boolean;
 
@@ -99,6 +100,28 @@
         end
 end;
 
+procedure pfsReadLnA(f: PFSFile; var s: ansistring);
+var c: char;
+    b: shortstring;
+begin
+s:= '';
+b[0]:= #0;
+
+while (PHYSFS_readBytes(f, @c, 1) = 1) and (c <> #10) do
+    if (c <> #13) then
+        begin
+        inc(b[0]);
+        b[byte(b[0])]:= c;
+        if b[0] = #255 then
+            begin
+            s:= s + b;
+            b[0]:= #0
+            end
+        end;
+        
+s:= s + b
+end;
+
 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
 var r: Int64;
 begin