mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-22 18:48:25 +02:00
LazUtils: Deprecate IsNumber(), rename to IsNumeric() for better clarity. Check for empty input string, issue #40935, patch by Ph B.
This commit is contained in:
parent
746d25dbe9
commit
4186cfe014
@ -1373,7 +1373,7 @@ begin
|
|||||||
if (ptprfPointer in PTReq.Result.Flags) and
|
if (ptprfPointer in PTReq.Result.Flags) and
|
||||||
( ( s = 'char') or (s = 'character') or (s = 'wchar') or (s = 'widechar') )
|
( ( s = 'char') or (s = 'character') or (s = 'wchar') or (s = 'widechar') )
|
||||||
then begin
|
then begin
|
||||||
if IsNumber(IdxPart.GetPlainText)
|
if IsNumeric(IdxPart.GetPlainText)
|
||||||
then begin
|
then begin
|
||||||
FMaybeString := True;
|
FMaybeString := True;
|
||||||
end
|
end
|
||||||
@ -1389,7 +1389,7 @@ begin
|
|||||||
if (PTReq.Result.Kind = ptprkSimple)
|
if (PTReq.Result.Kind = ptprkSimple)
|
||||||
then begin
|
then begin
|
||||||
ResultList := TGDBMINameValueList.Create(PTReq.Result.GdbDescription);
|
ResultList := TGDBMINameValueList.Create(PTReq.Result.GdbDescription);
|
||||||
FMaybeString := IsNumber(ResultList.Values['value']);
|
FMaybeString := IsNumeric(ResultList.Values['value']);
|
||||||
ResultList.Free;
|
ResultList.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -42,7 +42,8 @@ function LazEndsStr(const ASubText, AText: string): Boolean;
|
|||||||
function LazStartsText(const ASubText, AText: string): Boolean;
|
function LazStartsText(const ASubText, AText: string): Boolean;
|
||||||
function LazEndsText(const ASubText, AText: string): Boolean;
|
function LazEndsText(const ASubText, AText: string): Boolean;
|
||||||
function PosI(const SubStr, S: string): integer;
|
function PosI(const SubStr, S: string): integer;
|
||||||
function IsNumber(s: String): Boolean;
|
function IsNumeric(s: String): Boolean;
|
||||||
|
function IsNumber(s: String): Boolean; deprecated 'Use IsNumeric; to be removed in v4.99';
|
||||||
|
|
||||||
// Functions for line endings
|
// Functions for line endings
|
||||||
function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): integer;
|
function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): integer;
|
||||||
@ -204,14 +205,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IsNumber(s: String): Boolean;
|
function IsNumeric(s: String): Boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
i := Length(s);
|
i := Length(s);
|
||||||
while (i >= 1) and (s[i] in ['0'..'9']) do
|
if i > 0 then
|
||||||
dec(i);
|
begin
|
||||||
Result := i = 0;
|
while (i >= 1) and (s[i] in ['0'..'9']) do
|
||||||
|
dec(i);
|
||||||
|
Result := i = 0;
|
||||||
|
end else
|
||||||
|
Result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IsNumber(s: String): Boolean;
|
||||||
|
begin
|
||||||
|
Result := IsNumeric(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): integer;
|
function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): integer;
|
||||||
|
@ -446,7 +446,7 @@ begin
|
|||||||
LCLObject := TObject(data);
|
LCLObject := TObject(data);
|
||||||
if (widget <> nil) and (LCLObject is TCustomEdit) then
|
if (widget <> nil) and (LCLObject is TCustomEdit) then
|
||||||
{ NumbersOnly: stop signal if inserted text is not a number }
|
{ NumbersOnly: stop signal if inserted text is not a number }
|
||||||
if TCustomEdit(LCLObject).NumbersOnly and not IsNumber(ANewText) then
|
if TCustomEdit(LCLObject).NumbersOnly and not IsNumeric(ANewText) then
|
||||||
begin
|
begin
|
||||||
gtk_entry_set_text(PGtkEntry(widget), EntryText);
|
gtk_entry_set_text(PGtkEntry(widget), EntryText);
|
||||||
g_signal_stop_emission_by_name(Widget, 'insert-text');
|
g_signal_stop_emission_by_name(Widget, 'insert-text');
|
||||||
@ -535,7 +535,7 @@ begin
|
|||||||
FClip := gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
FClip := gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||||
if (FClip <> nil) and gtk_clipboard_wait_is_text_available(FClip) then
|
if (FClip <> nil) and gtk_clipboard_wait_is_text_available(FClip) then
|
||||||
FClipText := gtk_clipboard_wait_for_text(FClip);
|
FClipText := gtk_clipboard_wait_for_text(FClip);
|
||||||
if Assigned(FClip) and not IsNumber(FClipText) then
|
if Assigned(FClip) and not IsNumeric(FClipText) then
|
||||||
g_signal_stop_emission_by_name(Widget, 'paste-clipboard');
|
g_signal_stop_emission_by_name(Widget, 'paste-clipboard');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -1114,7 +1114,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'SetText') then
|
if not WSCheckHandleAllocated(AWinControl, 'SetText') then
|
||||||
Exit;
|
Exit;
|
||||||
if TCustomEdit(AWinControl).NumbersOnly and not IsNumber(AText) then
|
if TCustomEdit(AWinControl).NumbersOnly and not IsNumeric(AText) then
|
||||||
Exit;
|
Exit;
|
||||||
{$IFDEF VerboseTWinControlRealText}
|
{$IFDEF VerboseTWinControlRealText}
|
||||||
DebugLn(['TGtkWSCustomEdit.SetText START ',DbgSName(AWinControl),' AText="',AText,'"']);
|
DebugLn(['TGtkWSCustomEdit.SetText START ',DbgSName(AWinControl),' AText="',AText,'"']);
|
||||||
@ -1156,7 +1156,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ACustomEdit, 'SetSelText') then
|
if not WSCheckHandleAllocated(ACustomEdit, 'SetSelText') then
|
||||||
Exit;
|
Exit;
|
||||||
if ACustomEdit.NumbersOnly and not IsNumber(NewSelText) then
|
if ACustomEdit.NumbersOnly and not IsNumeric(NewSelText) then
|
||||||
Exit;
|
Exit;
|
||||||
Widget:={%H-}PGtkWidget(ACustomEdit.Handle);
|
Widget:={%H-}PGtkWidget(ACustomEdit.Handle);
|
||||||
if GTK_IS_SPIN_BUTTON(Widget) then
|
if GTK_IS_SPIN_BUTTON(Widget) then
|
||||||
|
Loading…
Reference in New Issue
Block a user