diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-06-16 15:00:46 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-06-16 15:00:46 +0000 |
commit | 4401ddfaa20d87492442cb7656c37d13b75995d7 (patch) | |
tree | 9caf2c1a46daf42f4ad8c5e7e2d3e59369ea3c73 /Game/Code/Classes/UCommon.pas | |
parent | f01995d31ad202ccbbe8f79213303e479923cd81 (diff) | |
download | usdx-4401ddfaa20d87492442cb7656c37d13b75995d7.tar.gz usdx-4401ddfaa20d87492442cb7656c37d13b75995d7.tar.xz usdx-4401ddfaa20d87492442cb7656c37d13b75995d7.zip |
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
Diffstat (limited to 'Game/Code/Classes/UCommon.pas')
-rw-r--r-- | Game/Code/Classes/UCommon.pas | 53 |
1 files changed, 38 insertions, 15 deletions
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; (* |