From 4401ddfaa20d87492442cb7656c37d13b75995d7 Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 16 Jun 2008 15:00:46 +0000 Subject: Delphi 7 compatibility fix: - "in"-operator does not work with WideChar operands, e.g. "mychar in ['a..z'] - FPC_VERSION/RELEASE/PATCH (e.g. {$IF FPC_VERSION > 2}) must be defined as constants because delphi 7 does not care about {$IFDEF FPC} sections and complains about undefined constant expressions. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1150 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCommon.pas | 53 +++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'Game/Code/Classes/UCommon.pas') diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas index fe3ea6a4..3c32a804 100644 --- a/Game/Code/Classes/UCommon.pas +++ b/Game/Code/Classes/UCommon.pas @@ -16,6 +16,7 @@ uses Messages, {$ENDIF} sdl, + UConfig, ULog; {$IFNDEF DARWIN} @@ -88,11 +89,12 @@ uses {$IFDEF Delphi} Dialogs, {$ENDIF} - {$IFDEF FPC_VERSION_2_2_2_PLUS} + {$IFDEF FPC} + {$IF FPC_VERSION_INT >= 2002002} // >= 2.2.2 clocale, + {$IFEND} {$ENDIF} - UMain, - UConfig; + UMain; // data used by the ...Locale() functions @@ -100,11 +102,13 @@ uses var PrevNumLocale: string; -{$IFNDEF FPC_VERSION_2_2_2_PLUS} +{$IFDEF FPC} +{$IF FPC_VERSION_INT < 2002002} // < 2.2.2 const __LC_NUMERIC = 1; function setlocale(category: integer; locale: pchar): pchar; cdecl; external 'c' name 'setlocale'; +{$IFEND} {$ENDIF} {$ENDIF} @@ -660,19 +664,27 @@ end; function IsAlphaChar(ch: WideChar): boolean; begin // TODO: add chars > 255 when unicode-fonts work? - Result := ch in - ['A'..'Z', // A-Z - 'a'..'z', // a-z - #170, #181, #186, - #192..#214, - #216..#246, - #248..#255 - ]; + case ch of + 'A'..'Z', // A-Z + 'a'..'z', // a-z + #170,#181,#186, + #192..#214, + #216..#246, + #248..#255: + Result := true; + else + Result := false; + end; end; function IsNumericChar(ch: WideChar): boolean; begin - Result := ch in ['0'..'9']; + case ch of + '0'..'9': + Result := true; + else + Result := false; + end; end; function IsAlphaNumericChar(ch: WideChar): boolean; @@ -683,12 +695,23 @@ end; function IsPunctuationChar(ch: WideChar): boolean; begin // TODO: add chars outside of Latin1 basic (0..127)? - Result := ch in [ ' '..'/', ':'..'@', '['..'`', '{'..'~' ]; + case ch of + ' '..'/',':'..'@','['..'`','{'..'~': + Result := true; + else + Result := false; + end; end; function IsControlChar(ch: WideChar): boolean; begin - Result := ch in [ #0..#31, #127..#159 ]; + case ch of + #0..#31, + #127..#159: + Result := true; + else + Result := false; + end; end; (* -- cgit v1.2.3