Explorar o código

* fixes feature defines after recent changes

git-svn-id: trunk@28743 -
florian %!s(int64=10) %!d(string=hai) anos
pai
achega
714901ce45
Modificáronse 4 ficheiros con 54 adicións e 13 borrados
  1. 6 2
      rtl/inc/file.inc
  2. 17 0
      rtl/inc/system.inc
  3. 2 1
      rtl/inc/systemh.inc
  4. 29 10
      rtl/inc/text.inc

+ 6 - 2
rtl/inc/file.inc

@@ -441,6 +441,7 @@ Begin
 End;
 
 
+{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 Procedure Rename(var f : File; const S : UnicodeString);[IOCheck];
 {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 var
@@ -471,8 +472,10 @@ Begin
 {$endif FPC_ANSI_TEXTFILEREC}
 {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 End;
+{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 
 
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 Procedure Rename(var f : File;const s : RawByteString);[IOCheck];
 var
 {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
@@ -517,6 +520,7 @@ Begin
     FileRec(f).Name:=fs
 {$endif FPC_ANSI_TEXTFILEREC and not FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 End;
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
 Procedure Rename(var f : File;const s : ShortString);[IOCheck];
@@ -542,7 +546,7 @@ Begin
 End;
 {$else FPC_HAS_FEATURE_ANSISTRINGS}
 var
-  len: SizeInt
+  len: SizeInt;
 Begin
   if InOutRes<>0 then
     exit;
@@ -551,7 +555,7 @@ Begin
       InOutRes:=102;
       exit;
     end;
-  Do_Rename(PFileTextRecChar(@FileRec(f).Name),p,false);
+  Do_Rename(PFileTextRecChar(@FileRec(f).Name),p,false,false);
   { check error code of do_rename }
   if InOutRes=0 then
     begin

+ 17 - 0
rtl/inc/system.inc

@@ -1519,6 +1519,7 @@ begin
 end;
 
 
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 procedure DoDirSeparators(var ps:RawByteString);
 var
   i : longint;
@@ -1538,7 +1539,10 @@ begin
         p[i-1]:=DirectorySeparator;
       end;
 end;
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
+
+{$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
 procedure DoDirSeparators(var ps:UnicodeString);
 var
   i : longint;
@@ -1558,6 +1562,7 @@ begin
         p[i-1]:=DirectorySeparator;
       end;
 end;
+{$endif FPC_HAS_FEATURE_UNICODESTRINGS}
 
 {$endif FPC_HAS_FEATURE_FILEIO}
 
@@ -1642,8 +1647,20 @@ end;
 
 {$endif FPC_HAS_FEATURE_FILEIO}
 
+{ helper for targets supporting no ansistrings, it is used
+  by non-ansistring code }
+function min(v1,v2 : SizeInt) : SizeInt;
+  begin
+    if v1<v2 then
+      result:=v1
+    else
+      result:=v2;
+  end;
+
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
 { Text file }
 {$i text.inc}
+{$endif FPC_HAS_FEATURE_TEXTIO}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
 { Untyped file }

+ 2 - 1
rtl/inc/systemh.inc

@@ -524,7 +524,8 @@ Type
   { the size of textrec/filerec is hardcoded in the 2.6 compiler binary }
   {$define FPC_ANSI_TEXTFILEREC}
 {$endif}
-  TFileTextRecChar    = {$ifdef FPC_ANSI_TEXTFILEREC}AnsiChar{$else}UnicodeChar{$endif};
+
+  TFileTextRecChar    = {$if defined(FPC_ANSI_TEXTFILEREC) or not(defined(FPC_HAS_FEATURE_WIDESTRINGS))}AnsiChar{$else}UnicodeChar{$endif};
   PFileTextRecChar    = ^TFileTextRecChar;
 
   TTextLineBreakStyle = (tlbsLF,tlbsCRLF,tlbsCR);

+ 29 - 10
rtl/inc/text.inc

@@ -200,10 +200,15 @@ Begin
   TextRec(t).mode:=mode;
   TextRec(t).bufpos:=0;
   TextRec(t).bufend:=0;
-  {$ifdef FPC_HAS_CPSTRING}
+
+{$ifdef FPC_HAS_CPSTRING}
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
   { if no codepage is yet assigned then assign default ansi codepage }
   TextRec(t).CodePage:=TranslatePlaceholderCP(TextRec(t).CodePage);
-  {$endif}
+{$else FPC_HAS_FEATURE_ANSISTRINGS}
+  TextRec(t).CodePage:=0;
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
+{$endif FPC_HAS_CPSTRING}
   FileFunc(TextRec(t).OpenFunc)(TextRec(t));
   { reset the mode to closed when an error has occured }
   if InOutRes<>0 then
@@ -266,6 +271,7 @@ Begin
 End;
 
 
+{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 Procedure Rename(var t : Text;const s : unicodestring);[IOCheck];
 {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 var
@@ -296,8 +302,11 @@ Begin
 {$endif FPC_ANSI_TEXTFILEREC}
 {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 End;
+{$endif FPC_HAS_FEATURE_WIDESTRINGS}
+
 
 
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 Procedure Rename(var t : Text;const s : rawbytestring);[IOCheck];
 var
 {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
@@ -342,6 +351,7 @@ Begin
     TextRec(t).Name:=fs
 {$endif FPC_ANSI_TEXTTextRec and not FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
 End;
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
 Procedure Rename(var t : Text;const s : ShortString);[IOCheck];
@@ -366,16 +376,16 @@ Begin
 End;
 {$else FPC_HAS_FEATURE_ANSISTRINGS}
 var
-  len: SizeInt
+  len: SizeInt;
 Begin
   if InOutRes<>0 then
     exit;
-  if TextRec(f).mode<>fmClosed then
+  if TextRec(t).mode<>fmClosed then
     begin
       InOutRes:=102;
       exit;
     end;
-  Do_Rename(PFileTextRecChar(@TextRec(t).Name),p,false);
+  Do_Rename(PFileTextRecChar(@TextRec(t).Name),p,false,false);
   { check error code of do_rename }
   if InOutRes=0 then
     begin
@@ -602,16 +612,17 @@ End;
 
 function GetTextCodePage(var T: Text): TSystemCodePage;
 begin
-{$ifdef FPC_HAS_CPSTRING}
+{$if defined(FPC_HAS_CPSTRING) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
   GetTextCodePage:=TextRec(T).CodePage;
 {$else}
   GetTextCodePage:=0;
 {$endif}
 end;
 
+
 procedure SetTextCodePage(var T: Text; CodePage: TSystemCodePage);
 begin
-{$ifdef FPC_HAS_CPSTRING}
+{$if defined(FPC_HAS_CPSTRING) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
   TextRec(T).CodePage:=TranslatePlaceholderCP(CodePage);
 {$endif}
 end;
@@ -631,7 +642,15 @@ end;
 
 Procedure fpc_textinit_iso(var t : Text;nr : DWord);compilerproc;
 begin
+{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
   assign(t,paramstr(nr));
+{$else FPC_HAS_FEATURE_COMMANDARGS}
+  { primitive workaround for targets supporting no command line arguments,
+    invent some file name, this will be fixed later on anways because
+    the current way of handling iso program parameters is apparently
+    wrong }
+  assign(t,chr((nr mod 16)+65));
+{$endif FPC_HAS_FEATURE_COMMANDARGS}
   reset(t);
 end;
 
@@ -2450,9 +2469,9 @@ begin
   t.mode:=fmOutput;
   t.OpenFunc:=nil;
   t.CloseFunc:=nil;
-  {$ifdef FPC_HAS_CPSTRING}
+{$if defined(FPC_HAS_CPSTRING) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
   t.CodePage:=TranslatePlaceholderCP(cp);
-  {$endif}
+{$endif}
 end;
 
 
@@ -2561,7 +2580,7 @@ begin
   t.mode:=fmInput;
   t.OpenFunc:=nil;
   t.CloseFunc:=nil;
-  {$ifdef FPC_HAS_CPSTRING}
+{$if defined(FPC_HAS_CPSTRING) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
   t.CodePage:=TranslatePlaceholderCP(cp);
   {$endif}
   PSizeInt(@t.userdata[BytesReadIndex])^:=0;