Browse Source

* unicode fixes in TInputLine.Valid

git-svn-id: branches/unicodekvm@48619 -
nickysn 4 years ago
parent
commit
f64bd5c079
3 changed files with 19 additions and 6 deletions
  1. 5 5
      packages/fv/src/dialogs.inc
  2. 6 1
      packages/fv/src/fvcommon.inc
  3. 8 0
      packages/fv/src/platform.inc

+ 5 - 5
packages/fv/src/dialogs.inc

@@ -1410,11 +1410,11 @@ FUNCTION TInputLine.Valid (Command: Word): Boolean;
    FUNCTION AppendError (AValidator: PValidator): Boolean;
    BEGIN
      AppendError := False;                            { Preset false }
-     If (Data <> Nil) Then
+     If Data <> Sw_PString_Empty Then
        With AValidator^ Do
          If (Options AND voOnAppend <> 0) AND         { Check options }
-         (CurPos <> Length(Data^)) AND                { Exceeds max length }
-         NOT IsValidInput(Data^, True) Then Begin     { Check data valid }
+         (CurPos <> Length(Data Sw_PString_DeRef)) AND  { Exceeds max length }
+         NOT IsValidInput(Data Sw_PString_DeRef, True) Then Begin  { Check data valid }
            Error;                                     { Call error }
            AppendError := True;                       { Return true }
          End;
@@ -1422,13 +1422,13 @@ FUNCTION TInputLine.Valid (Command: Word): Boolean;
 
 BEGIN
    Valid := Inherited Valid(Command);                 { Call ancestor }
-   If (Validator <> Nil) AND (Data <> Nil) AND        { Validator present }
+   If (Validator <> Nil) AND (Data <> Sw_PString_Empty) AND  { Validator present }
    (State AND sfDisabled = 0) Then                    { Not disabled }
      If (Command = cmValid) Then                      { Valid command }
        Valid := Validator^.Status = vsOk              { Validator result }
        Else If (Command <> cmCancel) Then             { Not cancel command }
          If AppendError(Validator) OR                 { Append any error }
-         NOT Validator^.Valid(Data^) Then Begin       { Check validator }
+         NOT Validator^.Valid(Data Sw_PString_DeRef) Then Begin  { Check validator }
            Select;                                    { Reselect view }
            Valid := False;                            { Return false }
          End;

+ 6 - 1
packages/fv/src/fvcommon.inc

@@ -145,15 +145,20 @@ TYPE
 {---------------------------------------------------------------------------}
 {               SHORT/ANSI/UNICODE SWITCHED STRING TYPE                     }
 {---------------------------------------------------------------------------}
-TYPE
 {$IFDEF FV_UNICODE}
+TYPE
    Sw_String = UnicodeString;
    Sw_PString = UnicodeString;
    Sw_ExtendedGraphemeCluster = UnicodeString;
+CONST
+   Sw_PString_Empty = '';
 {$ELSE FV_UNICODE}
+TYPE
    Sw_String = ShortString;
    Sw_PString = PShortString;
    Sw_ExtendedGraphemeCluster = Char;
+CONST
+   Sw_PString_Empty = Nil;
 {$ENDIF FV_UNICODE}
 
 {---------------------------------------------------------------------------}

+ 8 - 0
packages/fv/src/platform.inc

@@ -177,6 +177,14 @@ FOR FPC THESE ARE THE TRANSLATIONS
 {$IFDEF FPC}
   {$mode objfpc}
 
+  {$MACRO ON}
+
+  {$IFDEF FV_UNICODE}
+    {$DEFINE Sw_PString_DeRef:=}
+  {$ELSE FV_UNICODE}
+    {$DEFINE Sw_PString_DeRef:=^}
+  {$ENDIF FV_UNICODE}
+
   {$UNDEF PROC_Real}
   {$DEFINE PROC_Protected}
   {$IFNDEF CPU16}