mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 09:02:22 +01:00 
			
		
		
		
	* improved feature defines
+ basic consoleio support for the embedded target git-svn-id: trunk@12637 -
This commit is contained in:
		
							parent
							
								
									c127154efa
								
							
						
					
					
						commit
						1b79f2ebcf
					
				@ -30,39 +30,43 @@ Unit System;
 | 
			
		||||
 | 
			
		||||
const
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_TEXTIO}
 | 
			
		||||
 LineEnding = #10;
 | 
			
		||||
  LineEnding = #10;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_TEXTIO}
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_FILEIO}
 | 
			
		||||
 LFNSupport = true;
 | 
			
		||||
 DirectorySeparator = '/';
 | 
			
		||||
 DriveSeparator = ':';
 | 
			
		||||
 ExtensionSeparator = '.';
 | 
			
		||||
 PathSeparator = ':';
 | 
			
		||||
 AllowDirectorySeparators : set of char = ['\','/'];
 | 
			
		||||
 AllowDriveSeparators : set of char = [':'];
 | 
			
		||||
  LFNSupport = true;
 | 
			
		||||
  DirectorySeparator = '/';
 | 
			
		||||
  DriveSeparator = ':';
 | 
			
		||||
  ExtensionSeparator = '.';
 | 
			
		||||
  PathSeparator = ':';
 | 
			
		||||
  AllowDirectorySeparators : set of char = ['\','/'];
 | 
			
		||||
  AllowDriveSeparators : set of char = [':'];
 | 
			
		||||
{$endif FPC_HAS_FEATURE_FILEIO}
 | 
			
		||||
 | 
			
		||||
{ FileNameCaseSensitive is defined below! }
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_EXITCODE}
 | 
			
		||||
 maxExitCode = 255;
 | 
			
		||||
  maxExitCode = 255;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_EXITCODE}
 | 
			
		||||
{
 | 
			
		||||
 MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
 | 
			
		||||
 AllFilesMask = '*';
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_FILEIO}
 | 
			
		||||
 | 
			
		||||
  MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
 | 
			
		||||
  AllFilesMask = '*';
 | 
			
		||||
 | 
			
		||||
const
 | 
			
		||||
  UnusedHandle    = -1;
 | 
			
		||||
  StdInputHandle  = 0;
 | 
			
		||||
  StdOutputHandle = 1;
 | 
			
		||||
  StdErrorHandle  = 2;
 | 
			
		||||
 | 
			
		||||
  FileNameCaseSensitive : boolean = true;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_FILEIO}
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_TEXTIO}
 | 
			
		||||
  CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *)
 | 
			
		||||
 | 
			
		||||
  sLineBreak = LineEnding;
 | 
			
		||||
  DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_TEXTIO}
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
var
 | 
			
		||||
  argc:longint;external name 'operatingsystem_parameter_argc';
 | 
			
		||||
  argv:PPchar;external name 'operatingsystem_parameter_argv';
 | 
			
		||||
@ -266,6 +270,18 @@ var
 | 
			
		||||
 | 
			
		||||
{$endif FPC_HAS_FEATURE_STACKCHECK}
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 | 
			
		||||
procedure SysInitStdIO;
 | 
			
		||||
begin
 | 
			
		||||
  OpenStdIO(Input,fmInput,0);
 | 
			
		||||
  OpenStdIO(Output,fmOutput,0);
 | 
			
		||||
  OpenStdIO(ErrOutput,fmOutput,0);
 | 
			
		||||
  OpenStdIO(StdOut,fmOutput,0);
 | 
			
		||||
  OpenStdIO(StdErr,fmOutput,0);
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_CONSOLEIO}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_FPU}
 | 
			
		||||
  SysResetFPU;
 | 
			
		||||
 | 
			
		||||
@ -469,7 +469,9 @@ Procedure fpc_Write_Text_AnsiStr (Len : Longint; Var f : Text; const S : AnsiStr
 | 
			
		||||
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 | 
			
		||||
Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; const S : WideString); compilerproc;
 | 
			
		||||
{$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
Procedure fpc_Write_Text_UnicodeStr (Len : Longint; Var f : Text; const S : WideString); compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); compilerproc;
 | 
			
		||||
Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); compilerproc;
 | 
			
		||||
{$ifndef CPU64}
 | 
			
		||||
@ -485,15 +487,25 @@ Procedure fpc_Write_Text_Currency(fixkomma,Len : Longint;var t : Text;c : Curren
 | 
			
		||||
{$endif FPC_HAS_STR_CURRENCY}
 | 
			
		||||
Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); compilerproc;
 | 
			
		||||
Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); compilerproc;
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
function fpc_SetupWriteStr_Shortstr(out s: shortstring): PText; compilerproc;
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
function fpc_SetupWriteStr_Ansistr(out s: ansistring): PText; compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
function fpc_SetupWriteStr_Widestr(out s: widestring): PText; compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
function fpc_SetupReadStr_Shortstr(const s: shortstring): PText; compilerproc;
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
function fpc_SetupReadStr_Ansistr(const s: ansistring): PText; compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
function fpc_SetupReadStr_Widestr(const s: widestring): PText; compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
{$endif FPC_HAS_FEATURE_TEXTIO}
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_VARIANTS}
 | 
			
		||||
@ -517,7 +529,9 @@ Procedure fpc_ReadLn_End(var f : Text); compilerproc;
 | 
			
		||||
Procedure fpc_Read_Text_ShortStr(var f : Text;out s : String); compilerproc;
 | 
			
		||||
Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text; const s : PChar); compilerproc;
 | 
			
		||||
Procedure fpc_Read_Text_PChar_As_Array(var f : Text;out s : array of char; zerobased: boolean = false); compilerproc;
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
Procedure fpc_Read_Text_AnsiStr(var f : Text;out s : AnsiString); compilerproc;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
Procedure fpc_Read_Text_Char(var f : Text; out c : char); compilerproc;
 | 
			
		||||
Procedure fpc_Read_Text_SInt(var f : Text; out l :ValSInt); compilerproc;
 | 
			
		||||
Procedure fpc_Read_Text_UInt(var f : Text; out u :ValUInt); compilerproc;
 | 
			
		||||
 | 
			
		||||
@ -617,6 +617,7 @@ begin
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
Procedure fpc_Write_Text_UnicodeStr (Len : Longint; Var f : Text; const S : WideString); iocheck; compilerproc;
 | 
			
		||||
{
 | 
			
		||||
 Writes a UnicodeString to the Text file T
 | 
			
		||||
@ -641,6 +642,8 @@ begin
 | 
			
		||||
    else InOutRes:=103;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 | 
			
		||||
Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; const S : WideString); iocheck; compilerproc;
 | 
			
		||||
@ -866,6 +869,7 @@ Begin
 | 
			
		||||
End;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); iocheck; compilerproc;
 | 
			
		||||
var
 | 
			
		||||
  a : ansistring;
 | 
			
		||||
@ -888,6 +892,7 @@ Begin
 | 
			
		||||
  a:=c;
 | 
			
		||||
  fpc_WriteBuffer(t,pchar(a)^,length(a));
 | 
			
		||||
End;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{*****************************************************************************
 | 
			
		||||
@ -1111,6 +1116,7 @@ Begin
 | 
			
		||||
End;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
Procedure fpc_Read_Text_AnsiStr(var f : Text;out s : AnsiString); iocheck; compilerproc;
 | 
			
		||||
var
 | 
			
		||||
  slen,len : SizeInt;
 | 
			
		||||
@ -1125,6 +1131,8 @@ Begin
 | 
			
		||||
  // Set actual length
 | 
			
		||||
  SetLength(S,Slen);
 | 
			
		||||
End;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
procedure fpc_Read_Text_Char(var f : Text; out c: char); iocheck;compilerproc;
 | 
			
		||||
Begin
 | 
			
		||||
@ -1364,6 +1372,7 @@ begin
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
procedure WriteStrAnsi(var t: textrec);
 | 
			
		||||
var
 | 
			
		||||
  str: pansistring;
 | 
			
		||||
@ -1377,8 +1386,10 @@ begin
 | 
			
		||||
  move(t.bufptr^,str^[oldlen+1],t.bufpos);
 | 
			
		||||
  t.bufpos:=0;
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
procedure WriteStrWide(var t: textrec);
 | 
			
		||||
var
 | 
			
		||||
  temp: ansistring;
 | 
			
		||||
@ -1392,6 +1403,7 @@ begin
 | 
			
		||||
  str^:=str^+temp;
 | 
			
		||||
  t.bufpos:=0;
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
procedure SetupWriteStrCommon(out t: textrec);
 | 
			
		||||
@ -1416,6 +1428,7 @@ begin
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
function fpc_SetupWriteStr_Ansistr(out s: ansistring): PText; compilerproc;
 | 
			
		||||
begin
 | 
			
		||||
  setupwritestrcommon(ReadWriteStrText);
 | 
			
		||||
@ -1426,8 +1439,10 @@ begin
 | 
			
		||||
  ReadWriteStrText.FlushFunc:=@WriteStrAnsi;
 | 
			
		||||
  result:=@ReadWriteStrText;
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
function fpc_SetupWriteStr_Widestr(out s: widestring): PText; compilerproc;
 | 
			
		||||
begin
 | 
			
		||||
  setupwritestrcommon(ReadWriteStrText);
 | 
			
		||||
@ -1438,7 +1453,7 @@ begin
 | 
			
		||||
  ReadWriteStrText.FlushFunc:=@WriteStrWide;
 | 
			
		||||
  result:=@ReadWriteStrText;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
procedure ReadAnsiStrFinal(var t: textrec);
 | 
			
		||||
@ -1525,16 +1540,22 @@ begin
 | 
			
		||||
    An ansistring is the easiest way to get a threadsafe copy, and allows us
 | 
			
		||||
    to use the other ansistring readstr helpers too.
 | 
			
		||||
  }
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
  result:=fpc_SetupReadStr_Ansistr_Intern(s);
 | 
			
		||||
{$else FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
  runerror(217);
 | 
			
		||||
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
function fpc_SetupReadStr_Widestr(const s: widestring): PText; compilerproc;
 | 
			
		||||
begin
 | 
			
		||||
  { we use an ansistring to avoid code duplication, and let the    }
 | 
			
		||||
  { assignment convert the widestring to an equivalent ansistring  }
 | 
			
		||||
  result:=fpc_SetupReadStr_Ansistr_Intern(s);
 | 
			
		||||
end;
 | 
			
		||||
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{*****************************************************************************
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user