Remove extra checks for empty strings together with IsValidIdent. It already handles an empty string.

git-svn-id: trunk@52812 -
This commit is contained in:
juha 2016-08-17 10:40:29 +00:00
parent ea7fcec8a1
commit 9367da0ae5
41 changed files with 70 additions and 78 deletions

View File

@ -1957,8 +1957,7 @@ begin
Layout.LoadFromConfig(Config); Layout.LoadFromConfig(Config);
for i:=FControlNames.Count-1 downto 0 do begin for i:=FControlNames.Count-1 downto 0 do begin
AName:=FControlNames[i]; AName:=FControlNames[i];
if (AName<>'') and IsValidIdent(AName) if IsValidIdent(AName) and (Layout.Root<>nil) then begin
and (Layout.Root<>nil) then begin
Node:=Layout.Root.FindChildNode(AName,true); Node:=Layout.Root.FindChildNode(AName,true);
if (Node<>nil) and (Node.NodeType in [adltnControl,adltnCustomSite]) then if (Node<>nil) and (Node.NodeType in [adltnControl,adltnCustomSite]) then
continue; continue;
@ -1979,8 +1978,7 @@ begin
Layout.LoadFromConfig(Path, Config); Layout.LoadFromConfig(Path, Config);
for i:=FControlNames.Count-1 downto 0 do begin for i:=FControlNames.Count-1 downto 0 do begin
AName:=FControlNames[i]; AName:=FControlNames[i];
if (AName<>'') and IsValidIdent(AName) if IsValidIdent(AName) and (Layout.Root<>nil) then begin
and (Layout.Root<>nil) then begin
Node:=Layout.Root.FindChildNode(AName,true); Node:=Layout.Root.FindChildNode(AName,true);
if (Node<>nil) and (Node.NodeType in [adltnControl,adltnCustomSite]) then if (Node<>nil) and (Node.NodeType in [adltnControl,adltnCustomSite]) then
continue; continue;

View File

@ -1076,7 +1076,7 @@ begin
if SearchCodeInSource(Source,FormClassName+'=class(',1,SrcPos,false)<1 then if SearchCodeInSource(Source,FormClassName+'=class(',1,SrcPos,false)<1 then
exit; exit;
Result:=ReadNextPascalAtom(Source,SrcPos,AtomStart); Result:=ReadNextPascalAtom(Source,SrcPos,AtomStart);
if (Result<>'') and (not IsValidIdent(Result)) then if not IsValidIdent(Result) then
Result:=''; Result:='';
end; end;

View File

@ -2897,7 +2897,7 @@ var
if Result='' then if Result='' then
Result:=ParamType; Result:=ParamType;
// otherwise use 'Param' // otherwise use 'Param'
if (Result='') or (not IsValidIdent(Result)) then if not IsValidIdent(Result) then
Result:='Param'; Result:='Param';
// prepend an 'a' // prepend an 'a'
if Result[1]<>'a' then if Result[1]<>'a' then

View File

@ -2623,7 +2623,7 @@ begin
Result:=true; Result:=true;
exit; exit;
end; end;
if (NewIdentifier='') or (not IsValidIdent(NewIdentifier)) then exit; if not IsValidIdent(NewIdentifier) then exit;
ClearCurCodeTool; ClearCurCodeTool;
SourceChangeCache.Clear; SourceChangeCache.Clear;

View File

@ -298,8 +298,7 @@ var
AtomStart: PChar; AtomStart: PChar;
SrcPos: PtrUInt; SrcPos: PtrUInt;
begin begin
if (Src='') or (OldName='') or (not IsValidIdent(OldName)) if (Src='') or not IsValidIdent(OldName) or (NewName='') then exit;
or (NewName='') then exit;
p:=PChar(Src); p:=PChar(Src);
//debugln(['RenameCTCSVariable START ',dbgstr(Src)]); //debugln(['RenameCTCSVariable START ',dbgstr(Src)]);
repeat repeat
@ -1181,7 +1180,7 @@ begin
Clear; Clear;
for i:=0 to Source.Count-1 do begin for i:=0 to Source.Count-1 do begin
Name:=Source.Names[i]; Name:=Source.Names[i];
if (Name='') or not IsValidIdent(Name) then continue; if not IsValidIdent(Name) then continue;
Value:=Source.ValueFromIndex[i]; Value:=Source.ValueFromIndex[i];
Define(PChar(Name),Value); Define(PChar(Name),Value);
end; end;

View File

@ -7946,7 +7946,7 @@ begin
for i:=1 to Cnt do begin for i:=1 to Cnt do begin
SubPath:=Path+'Defines/Macro'+IntToStr(i)+'/'; SubPath:=Path+'Defines/Macro'+IntToStr(i)+'/';
DefineName:=UpperCaseStr(XMLConfig.GetValue(SubPath+'Name','')); DefineName:=UpperCaseStr(XMLConfig.GetValue(SubPath+'Name',''));
if (DefineName='') or (not IsValidIdent(DefineName)) then begin if not IsValidIdent(DefineName) then begin
DebugLn(['Warning: [TFPCTargetConfigCache.LoadFromXMLConfig] invalid define name ',DefineName]); DebugLn(['Warning: [TFPCTargetConfigCache.LoadFromXMLConfig] invalid define name ',DefineName]);
continue; continue;
end; end;
@ -7964,7 +7964,7 @@ begin
StartPos:=1; StartPos:=1;
while (p<=length(s)) and (s[p]<>';') do inc(p); while (p<=length(s)) and (s[p]<>';') do inc(p);
DefineName:=copy(s,StartPos,p-StartPos); DefineName:=copy(s,StartPos,p-StartPos);
if (DefineName<>'') and IsValidIdent(DefineName) then begin if IsValidIdent(DefineName) then begin
if Undefines=nil then if Undefines=nil then
Undefines:=TStringToStringTree.Create(false); Undefines:=TStringToStringTree.Create(false);
Undefines[DefineName]:=''; Undefines[DefineName]:='';
@ -8057,7 +8057,7 @@ begin
Node:=Defines.Tree.FindLowest; Node:=Defines.Tree.FindLowest;
while Node<>nil do begin while Node<>nil do begin
Item:=PStringToStringTreeItem(Node.Data); Item:=PStringToStringTreeItem(Node.Data);
if (Item^.Name<>'') and IsValidIdent(Item^.Name) then begin if IsValidIdent(Item^.Name) then begin
inc(Cnt); inc(Cnt);
SubPath:=Path+'Defines/Macro'+IntToStr(Cnt)+'/'; SubPath:=Path+'Defines/Macro'+IntToStr(Cnt)+'/';
XMLConfig.SetDeleteValue(SubPath+'Name',Item^.Name,''); XMLConfig.SetDeleteValue(SubPath+'Name',Item^.Name,'');

View File

@ -2520,8 +2520,8 @@ function TH2PasTool.CreateH2PNode(var PascalName: string; const CName: string;
const PascalCode: string; const PascalCode: string;
ParentNode: TH2PNode; IsGlobal: boolean; InsertAsPreLast: boolean): TH2PNode; ParentNode: TH2PNode; IsGlobal: boolean; InsertAsPreLast: boolean): TH2PNode;
begin begin
if (PascalName<>'') and (PascalDesc<>ctnNone) and IsValidIdent(PascalName) if (PascalDesc<>ctnNone) and IsValidIdent(PascalName) then
then begin begin
if WordIsKeyWord.DoItCaseInsensitive(PChar(PascalName)) then begin if WordIsKeyWord.DoItCaseInsensitive(PChar(PascalName)) then begin
// C name is keyword => auto rename // C name is keyword => auto rename
PascalName:=PascalName+'_'; PascalName:=PascalName+'_';

View File

@ -390,7 +390,7 @@ begin
FAssignBodyNode:=nil; FAssignBodyNode:=nil;
FInheritedDeclContext:=CleanFindContext; FInheritedDeclContext:=CleanFindContext;
NewProcName:=ProcNameEdit.Text; NewProcName:=ProcNameEdit.Text;
if (NewProcName<>'') and IsValidIdent(NewProcName) then if IsValidIdent(NewProcName) then
FProcName:=NewProcName; FProcName:=NewProcName;
Result:=(FCode<>nil) and CodeToolBoss.FindAssignMethod(FCode,FX,FY, Result:=(FCode<>nil) and CodeToolBoss.FindAssignMethod(FCode,FX,FY,
@ -433,7 +433,7 @@ begin
DeclGroupBox.Caption:=crsCAMNewMethod; DeclGroupBox.Caption:=crsCAMNewMethod;
ProcNameLabel.Caption:=crsCAMMethodName; ProcNameLabel.Caption:=crsCAMMethodName;
if (NewProcName='') or (not IsValidIdent(NewProcName)) then if not IsValidIdent(NewProcName) then
ProcNameErrorLabel.Caption:=crsCAMInvalidIdentifier ProcNameErrorLabel.Caption:=crsCAMInvalidIdentifier
else if not Result then else if not Result then
ProcNameErrorLabel.Caption:=crsCAMCursorIsNotInAPascalClassDeclaration ProcNameErrorLabel.Caption:=crsCAMCursorIsNotInAPascalClassDeclaration
@ -445,7 +445,7 @@ begin
ParamNameLabel.Caption:=crsCAMParameterName; ParamNameLabel.Caption:=crsCAMParameterName;
if UseInheritedParam then if UseInheritedParam then
ParamNameEdit.Text:=FInheritedParamName; ParamNameEdit.Text:=FInheritedParamName;
if (ParamNameEdit.Text='') or not IsValidIdent(ParamNameEdit.Text) then if not IsValidIdent(ParamNameEdit.Text) then
ParamNameErrorLabel.Caption:=crsCAMInvalidIdentifier ParamNameErrorLabel.Caption:=crsCAMInvalidIdentifier
else else
ParamNameErrorLabel.Caption:=''; ParamNameErrorLabel.Caption:='';
@ -453,7 +453,7 @@ begin
ParamTypeLabel.Caption:=crsCAMParameterType; ParamTypeLabel.Caption:=crsCAMParameterType;
if UseInheritedParam then if UseInheritedParam then
ParamTypeEdit.Text:=FInheritedParamType; ParamTypeEdit.Text:=FInheritedParamType;
if (ParamTypeEdit.Text='') or not IsValidIdent(ParamTypeEdit.Text) then if not IsValidIdent(ParamTypeEdit.Text) then
ParamTypeErrorLabel.Caption:=crsCAMInvalidIdentifier ParamTypeErrorLabel.Caption:=crsCAMInvalidIdentifier
else else
ParamTypeErrorLabel.Caption:=''; ParamTypeErrorLabel.Caption:='';

View File

@ -100,11 +100,8 @@ begin
end; end;
function TNewIDEWndCfgDialog.IsFormNameValid: boolean; function TNewIDEWndCfgDialog.IsFormNameValid: boolean;
var
s: TCaption;
begin begin
s:=FormNameEdit.Text; Result:=IsValidIdent(FormNameEdit.Text);
Result:=(s<>'') and IsValidIdent(s);
end; end;
function TNewIDEWndCfgDialog.IsMenuCaptionValid: boolean; function TNewIDEWndCfgDialog.IsMenuCaptionValid: boolean;

View File

@ -388,7 +388,7 @@ begin
DoDataFunction:=ADataFunction; DoDataFunction:=ADataFunction;
end; end;
inc(FCount); inc(FCount);
if (AKeyWord='') or not IsValidIdent(AKeyWord) then if not IsValidIdent(AKeyWord) then
FHasOnlyIdentifiers:=false; FHasOnlyIdentifiers:=false;
end; end;

View File

@ -690,7 +690,7 @@ begin
if (CompareFileExt(Filename,'ppu',false)<>0) then continue; if (CompareFileExt(Filename,'ppu',false)<>0) then continue;
AUnitName:=ExtractFileNameOnly(Filename); AUnitName:=ExtractFileNameOnly(Filename);
Filename:=AppendPathDelim(Directory)+Filename; Filename:=AppendPathDelim(Directory)+Filename;
if (AUnitName='') or (not IsValidIdent(AUnitName)) then begin if not IsValidIdent(AUnitName) then begin
DebugLn(['TPPUGroups.AddFPCGroup NOTE: invalid ppu name: ',Filename]); DebugLn(['TPPUGroups.AddFPCGroup NOTE: invalid ppu name: ',Filename]);
continue; continue;
end; end;

View File

@ -281,7 +281,7 @@ var
begin begin
for i:=0 to ChildCount-1 do begin for i:=0 to ChildCount-1 do begin
Child:=Children[i]; Child:=Children[i];
if (Child.Name='') or (not IsValidIdent(Child.Name)) then continue; if not IsValidIdent(Child.Name) then continue;
Config.AppendBasePath(Child.Name); Config.AppendBasePath(Child.Name);
try try
Result:=Child.Load(Config); Result:=Child.Load(Config);
@ -300,7 +300,7 @@ var
begin begin
for i:=0 to ChildCount-1 do begin for i:=0 to ChildCount-1 do begin
Child:=Children[i]; Child:=Children[i];
if (Child.Name='') or (not IsValidIdent(Child.Name)) then continue; if not IsValidIdent(Child.Name) then continue;
Config.AppendBasePath(Child.Name); Config.AppendBasePath(Child.Name);
try try
Result:=Child.Save(Config); Result:=Child.Save(Config);

View File

@ -1643,7 +1643,7 @@ begin
while i > 0 do begin while i > 0 do begin
ID := Config.GetValue(Path+'Desktop/FormIdList/a'+IntToStr(i), ''); ID := Config.GetValue(Path+'Desktop/FormIdList/a'+IntToStr(i), '');
//debugln(['TSimpleWindowLayoutList.LoadFromConfig ',i,' ',ID]); //debugln(['TSimpleWindowLayoutList.LoadFromConfig ',i,' ',ID]);
if (ID <> '') and IsValidIdent(ID) then if IsValidIdent(ID) then
begin begin
xLayoutIndex := IndexOf(ID); xLayoutIndex := IndexOf(ID);
if (xLayoutIndex = -1) then if (xLayoutIndex = -1) then
@ -2297,7 +2297,7 @@ procedure TIDEWindowCreatorList.ShowForm(AForm: TCustomForm; BringToFront: boole
var var
Layout: TSimpleWindowLayout; Layout: TSimpleWindowLayout;
begin begin
if (AForm.Name='') or (not IsValidIdent(AForm.Name)) then if not IsValidIdent(AForm.Name) then
raise Exception.Create('TIDEWindowCreatorList.ShowForm invalid form name '+AForm.Name); raise Exception.Create('TIDEWindowCreatorList.ShowForm invalid form name '+AForm.Name);
// auto create a layout storage for every shown form // auto create a layout storage for every shown form

View File

@ -288,11 +288,11 @@ begin
for i:=0 to NewCount-1 do begin for i:=0 to NewCount-1 do begin
p:=Path+'Item'+IntToStr(i)+'/'; p:=Path+'Item'+IntToStr(i)+'/';
NewPropertyName:=ConfigStore.GetValue(p+'PropertyName',''); NewPropertyName:=ConfigStore.GetValue(p+'PropertyName','');
if (NewPropertyName='') or (not IsValidIdent(NewPropertyName)) then if not IsValidIdent(NewPropertyName) then
continue; continue;
NewInclude:=ConfigStore.GetValue(p+'Include',true); NewInclude:=ConfigStore.GetValue(p+'Include',true);
NewBaseClassname:=ConfigStore.GetValue(p+'BaseClass',''); NewBaseClassname:=ConfigStore.GetValue(p+'BaseClass','');
if (NewBaseClassname='') or (not IsValidIdent(NewBaseClassname)) then if not IsValidIdent(NewBaseClassname) then
continue; continue;
NewBaseClass:=GetClass(NewBaseClassname); NewBaseClass:=GetClass(NewBaseClassname);
NewItem:=TOIFavoriteProperty.Create(NewBaseClass,NewPropertyName, NewItem:=TOIFavoriteProperty.Create(NewBaseClass,NewPropertyName,

View File

@ -4885,7 +4885,7 @@ end;
procedure TComponentNamePropertyEditor.SetValue(const NewValue: ansistring); procedure TComponentNamePropertyEditor.SetValue(const NewValue: ansistring);
begin begin
if (not IsValidIdent(NewValue)) or (NewValue='') then if not IsValidIdent(NewValue) then
raise Exception.Create(Format(oisComponentNameIsNotAValidIdentifier, [NewValue])); raise Exception.Create(Format(oisComponentNameIsNotAValidIdentifier, [NewValue]));
inherited SetValue(NewValue); inherited SetValue(NewValue);
PropertyHook.ComponentRenamed(TComponent(GetComponent(0))); PropertyHook.ComponentRenamed(TComponent(GetComponent(0)));

View File

@ -1677,9 +1677,8 @@ procedure TCustomPropertyLink.SetObjectAndProperty(NewPersistent: TPersistent;
var var
AComponent: TComponent; AComponent: TComponent;
begin begin
// Note: checking for IsValidIdent is not needed, because // Note: checking for IsValidIdent is not needed, because an identifier
// an identifier is is only needed for streaming. So every string as Name is // is only needed for streaming. So every string as Name is allowed.
// allowed.
if (NewPersistent<>TIObject) or (NewPropertyName<>TIPropertyName) then begin if (NewPersistent<>TIObject) or (NewPropertyName<>TIPropertyName) then begin
FPropertyLoaded:=false; FPropertyLoaded:=false;
if (FTIObject is TComponent) then begin if (FTIObject is TComponent) then begin

View File

@ -452,7 +452,7 @@ begin
CurOwner:=nil; CurOwner:=nil;
CurProject:=nil; CurProject:=nil;
CurPkg:=nil; CurPkg:=nil;
if (IDEItem<>'') and IsValidIdent(IDEItem) then begin if IsValidIdent(IDEItem) then begin
// package // package
CurPkg:=PackageEditingInterface.FindPackageWithName(IDEItem); CurPkg:=PackageEditingInterface.FindPackageWithName(IDEItem);
CurOwner:=CurPkg; CurOwner:=CurPkg;

View File

@ -279,8 +279,8 @@ begin
end; end;
{ IsValidIdent returns true if the first character of Ident is in: { IsValidIdent returns true if the first character of Ident is in:
'A' to 'Z', 'a' to 'z' or '_' and the following characters are 'A' to 'Z', 'a' to 'z' or '_' and the following characters are one of:
on of: 'A' to 'Z', 'a' to 'z', '0'..'9' or '_' } 'A' to 'Z', 'a' to 'z', '0'..'9' or '_' }
function IsValidNodeName(const Ident: string): boolean; function IsValidNodeName(const Ident: string): boolean;
var var
p: PChar; p: PChar;
@ -412,7 +412,7 @@ end;
procedure TWiki2FPDocConverter.SetPackageName(AValue: string); procedure TWiki2FPDocConverter.SetPackageName(AValue: string);
begin begin
if (AValue='') or not IsValidIdent(AValue) then if not IsValidIdent(AValue) then
raise Exception.Create('invalid package name "'+AValue+'"'); raise Exception.Create('invalid package name "'+AValue+'"');
if FPackageName=AValue then Exit; if FPackageName=AValue then Exit;
FPackageName:=AValue; FPackageName:=AValue;

View File

@ -116,7 +116,7 @@ begin
ErrorMsg:=lisEmpty; ErrorMsg:=lisEmpty;
exit; exit;
end; end;
if (not IsValidIdent(AName)) then begin if not IsValidIdent(AName) then begin
ErrorMsg:=lisNotAValidPascalIdentifier; ErrorMsg:=lisNotAValidPascalIdentifier;
exit; exit;
end; end;

View File

@ -1228,7 +1228,7 @@ begin
if IndexOf(JITComponent)<0 then if IndexOf(JITComponent)<0 then
raise Exception.Create('TJITComponentList.RemoveMethod JITComponent.ClassName='+ raise Exception.Create('TJITComponentList.RemoveMethod JITComponent.ClassName='+
JITComponent.ClassName); JITComponent.ClassName);
if (AName='') or (not IsValidIdent(AName)) then if not IsValidIdent(AName) then
raise Exception.Create('TJITComponentList.RemoveMethod invalid name: "'+AName+'"'); raise Exception.Create('TJITComponentList.RemoveMethod invalid name: "'+AName+'"');
// delete TJITMethod // delete TJITMethod
@ -1254,7 +1254,7 @@ begin
if IndexOf(JITComponent)<0 then if IndexOf(JITComponent)<0 then
raise Exception.Create('TJITComponentList.RenameMethod JITComponent.ClassName='+ raise Exception.Create('TJITComponentList.RenameMethod JITComponent.ClassName='+
JITComponent.ClassName); JITComponent.ClassName);
if (NewName='') or (not IsValidIdent(NewName)) then if not IsValidIdent(NewName) then
raise Exception.Create('TJITComponentList.RenameMethod invalid name: "'+NewName+'"'); raise Exception.Create('TJITComponentList.RenameMethod invalid name: "'+NewName+'"');
// rename TJITMethod // rename TJITMethod
@ -1278,7 +1278,7 @@ begin
if IndexOf(JITComponent)<0 then if IndexOf(JITComponent)<0 then
raise Exception.Create('TJITComponentList.RenameComponentClass JITComponent.ClassName='+ raise Exception.Create('TJITComponentList.RenameComponentClass JITComponent.ClassName='+
JITComponent.ClassName); JITComponent.ClassName);
if (NewName='') or (not IsValidIdent(NewName)) then if not IsValidIdent(NewName) then
raise Exception.Create('TJITComponentList.RenameComponentClass invalid name: "'+NewName+'"'); raise Exception.Create('TJITComponentList.RenameComponentClass invalid name: "'+NewName+'"');
DoRenameClass(JITComponent.ClassType,NewName); DoRenameClass(JITComponent.ClassType,NewName);
end; end;
@ -1401,7 +1401,7 @@ begin
if IndexOf(JITComponent)<0 then if IndexOf(JITComponent)<0 then
raise Exception.Create('TJITComponentList.CreateNewMethod JITComponent.ClassName='+ raise Exception.Create('TJITComponentList.CreateNewMethod JITComponent.ClassName='+
JITComponent.ClassName); JITComponent.ClassName);
if (AName='') or (not IsValidIdent(AName)) then if not IsValidIdent(AName) then
raise Exception.Create('TJITComponentList.CreateNewMethod invalid name: "'+AName+'"'); raise Exception.Create('TJITComponentList.CreateNewMethod invalid name: "'+AName+'"');
OldCode:=JITComponent.MethodAddress(AName); OldCode:=JITComponent.MethodAddress(AName);
if OldCode<>nil then begin if OldCode<>nil then begin

View File

@ -85,7 +85,7 @@ end;
Function TMakeSkelForm.PackageOK : Boolean; Function TMakeSkelForm.PackageOK : Boolean;
begin begin
Result:=(EPackage.Text<>'') and IsValidIdent(EPackage.Text); Result:=IsValidIdent(EPackage.Text);
end; end;
Function TMakeSkelForm.InputFileOK : Boolean; Function TMakeSkelForm.InputFileOK : Boolean;

View File

@ -279,7 +279,7 @@ var
i: Integer; i: Integer;
Item: TPASObjectWriterStackEl; Item: TPASObjectWriterStackEl;
begin begin
if (Component.Name='') or (not IsValidIdent(Component.Name)) then if not IsValidIdent(Component.Name) then
raise Exception.Create('TPASObjectWriter.BeginComponent not pascal identifier'); raise Exception.Create('TPASObjectWriter.BeginComponent not pascal identifier');
if (FStack<>nil) and (FStack.Count>0) then begin if (FStack<>nil) and (FStack.Count>0) then begin
// auto create child components // auto create child components

View File

@ -185,7 +185,7 @@ begin
end; end;
// check packagename // check packagename
if (NewPkgName='') or (not IsValidIdent(NewPkgName)) then begin if not IsValidIdent(NewPkgName) then begin
IDEMessageDialog(lisProjAddInvalidPackagename, IDEMessageDialog(lisProjAddInvalidPackagename,
Format(lisProjAddThePackageNameIsInvalidPlaseChooseAnExistingPackag, Format(lisProjAddThePackageNameIsInvalidPlaseChooseAnExistingPackag,
[NewPkgName, LineEnding]), [NewPkgName, LineEnding]),

View File

@ -1585,7 +1585,7 @@ begin
else else
continue; continue;
CurUnitName:=ExtractFilenameOnly(FileInfo.Name); CurUnitName:=ExtractFilenameOnly(FileInfo.Name);
if (CurUnitName='') or (not IsValidIdent(CurUnitName)) then if not IsValidIdent(CurUnitName) then
continue; continue;
CurFilename:=CurDir+FileInfo.Name; CurFilename:=CurDir+FileInfo.Name;
//DebugLn(['TBuildManager.CheckUnitPathForAmbiguousPascalFiles ',CurUnitName,' ',CurFilename]); //DebugLn(['TBuildManager.CheckUnitPathForAmbiguousPascalFiles ',CurUnitName,' ',CurFilename]);

View File

@ -3327,7 +3327,7 @@ begin
end; end;
// get identifier // get identifier
if (Identifier='') or (not IsValidIdent(Identifier)) then begin if not IsValidIdent(Identifier) then begin
DebugLn(['TQuickFixIdentifierNotFound_Search.Execute not an identifier "',dbgstr(Identifier),'"']); DebugLn(['TQuickFixIdentifierNotFound_Search.Execute not an identifier "',dbgstr(Identifier),'"']);
exit; exit;
end; end;

View File

@ -4328,7 +4328,7 @@ end;
procedure TIDEBuildMacro.SetIdentifier(const AValue: string); procedure TIDEBuildMacro.SetIdentifier(const AValue: string);
begin begin
if FIdentifier=AValue then exit; if FIdentifier=AValue then exit;
if (AValue='') or (not IsValidIdent(AValue)) then if not IsValidIdent(AValue) then
raise Exception.Create('TIDEBuildMacro.SetIdentifier invalid identifier: '+AValue); raise Exception.Create('TIDEBuildMacro.SetIdentifier invalid identifier: '+AValue);
FIdentifier:=AValue; FIdentifier:=AValue;
{$IFDEF VerboseIDEModified} {$IFDEF VerboseIDEModified}
@ -4535,7 +4535,7 @@ begin
for i:=0 to NewCount-1 do begin for i:=0 to NewCount-1 do begin
NewItem:=TIDEBuildMacro.Create; NewItem:=TIDEBuildMacro.Create;
NewItem.LoadFromXMLConfig(AXMLConfig,Path+'Item'+IntToStr(i+1)+'/',DoSwitchPathDelims); NewItem.LoadFromXMLConfig(AXMLConfig,Path+'Item'+IntToStr(i+1)+'/',DoSwitchPathDelims);
if (NewItem.Identifier<>'') and IsValidIdent(NewItem.Identifier) then if IsValidIdent(NewItem.Identifier) then
FItems.Add(NewItem) FItems.Add(NewItem)
else else
NewItem.Free; NewItem.Free;

View File

@ -2350,7 +2350,7 @@ begin
Identifier:='' Identifier:=''
else begin else begin
Identifier:=GetFPCMsgValue1(MsgLine); Identifier:=GetFPCMsgValue1(MsgLine);
if (Identifier='') or not IsValidIdent(Identifier) then exit; if not IsValidIdent(Identifier) then exit;
end; end;
if MsgLine.Attribute[AttrPosChecked]<>'' then exit; if MsgLine.Attribute[AttrPosChecked]<>'' then exit;

View File

@ -266,7 +266,7 @@ begin
Tool.ReadNextAtom; Tool.ReadNextAtom;
Identifier:=Tool.GetAtom; Identifier:=Tool.GetAtom;
CleanPos:=Tool.CurPos.StartPos; CleanPos:=Tool.CurPos.StartPos;
Result:=(Identifier<>'') and IsValidIdent(Identifier); Result:=IsValidIdent(Identifier);
end; end;
function GetMsgSrcPosOfThisIdentifier(Msg: TMessageLine; const Identifier: string; function GetMsgSrcPosOfThisIdentifier(Msg: TMessageLine; const Identifier: string;

View File

@ -210,7 +210,7 @@ var
ProcName: String; ProcName: String;
begin begin
ProcName:=GetProcName; ProcName:=GetProcName;
if (ProcName='') or (not IsValidIdent(ProcName)) then begin if not IsValidIdent(ProcName) then begin
IDEMessageDialog(lisInvalidProcName, IDEMessageDialog(lisInvalidProcName,
Format(lisSVUOisNotAValidIdentifier, [ProcName]), mtError,[mbCancel]); Format(lisSVUOisNotAValidIdentifier, [ProcName]), mtError,[mbCancel]);
ModalResult:=mrNone; ModalResult:=mrNone;

View File

@ -588,7 +588,7 @@ var
NewIdentifier: String; NewIdentifier: String;
begin begin
NewIdentifier:=NewEdit.Text; NewIdentifier:=NewEdit.Text;
if (NewIdentifier='') or (not IsValidIdent(NewIdentifier)) then begin if not IsValidIdent(NewIdentifier) then begin
IDEMessageDialog(lisFRIInvalidIdentifier, IDEMessageDialog(lisFRIInvalidIdentifier,
Format(lisSVUOisNotAValidIdentifier, [NewIdentifier]), mtError, [mbCancel]); Format(lisSVUOisNotAValidIdentifier, [NewIdentifier]), mtError, [mbCancel]);
ModalResult:=mrNone; ModalResult:=mrNone;

View File

@ -192,7 +192,7 @@ begin
if not IsApplicable(Msg,MissingUnit,UsedByUnit) then exit; if not IsApplicable(Msg,MissingUnit,UsedByUnit) then exit;
DebugLn(['TQuickFixUnitNotFound_Search.Execute Unit=',MissingUnit]); DebugLn(['TQuickFixUnitNotFound_Search.Execute Unit=',MissingUnit]);
if (MissingUnit='') or (not IsValidIdent(MissingUnit)) then begin if not IsValidIdent(MissingUnit) then begin
DebugLn(['TQuickFixUnitNotFound_Search.Execute not an identifier "',dbgstr(MissingUnit),'"']); DebugLn(['TQuickFixUnitNotFound_Search.Execute not an identifier "',dbgstr(MissingUnit),'"']);
exit; exit;
end; end;

View File

@ -140,7 +140,7 @@ begin
ok:=false; ok:=false;
try try
// check syntax // check syntax
if (S='') or (not IsValidIdent(S)) then begin if not IsValidIdent(S) then begin
IDEMessageDialog(lisCCOErrorCaption, IDEMessageDialog(lisCCOErrorCaption,
Format(lisInvalidMacroTheMacroMustBeAPascalIdentifie, [S]), Format(lisInvalidMacroTheMacroMustBeAPascalIdentifie, [S]),
mtError,[mbCancel]); mtError,[mbCancel]);

View File

@ -693,8 +693,7 @@ begin
end; end;
AFilename:=SetDirSeparators(AFilename); AFilename:=SetDirSeparators(AFilename);
LazarusIDE.DoOpenFileAndJumpToPos(AFilename,p,-1,-1,-1,[]); LazarusIDE.DoOpenFileAndJumpToPos(AFilename,p,-1,-1,-1,[]);
end else if (URLScheme='openpackage') and (URLPath<>'') end else if (URLScheme='openpackage') and IsValidIdent(URLPath) then begin
and IsValidIdent(URLPath) then begin
PackageEditingInterface.DoOpenPackageWithName(URLPath,[],false); PackageEditingInterface.DoOpenPackageWithName(URLPath,[],false);
end else if (URLScheme='fpdoc') and (URLParams<>'') then begin end else if (URLScheme='fpdoc') and (URLParams<>'') then begin
OpenFPDoc(URLParams); OpenFPDoc(URLParams);
@ -744,7 +743,7 @@ begin
exit; exit;
end; end;
PkgName:=copy(PkgName,2,length(PkgName)); PkgName:=copy(PkgName,2,length(PkgName));
if (PkgName='') or not IsValidIdent(PkgName) then begin if not IsValidIdent(PkgName) then begin
InvalidPathError('It does not start with a package name, for example #rtl.'); InvalidPathError('It does not start with a package name, for example #rtl.');
exit; exit;
end; end;
@ -760,7 +759,7 @@ begin
end; end;
AnUnitName:=ExtractSubPath; AnUnitName:=ExtractSubPath;
if (AnUnitName='') or (not IsValidIdent(AnUnitName)) then begin if not IsValidIdent(AnUnitName) then begin
InvalidPathError('Unit name "'+AnUnitName+'" is invalid.'); InvalidPathError('Unit name "'+AnUnitName+'" is invalid.');
exit; exit;
end; end;

View File

@ -11319,7 +11319,7 @@ var
OldOpenEditorsOnCodeToolChange: Boolean; OldOpenEditorsOnCodeToolChange: Boolean;
begin begin
DebugLn('Hint: (lazarus) TMainIDE.OnDesignerRenameComponent Old=',AComponent.Name,':',AComponent.ClassName,' New=',NewName,' Owner=',dbgsName(AComponent.Owner)); DebugLn('Hint: (lazarus) TMainIDE.OnDesignerRenameComponent Old=',AComponent.Name,':',AComponent.ClassName,' New=',NewName,' Owner=',dbgsName(AComponent.Owner));
if (not IsValidIdent(NewName)) or (NewName='') then if not IsValidIdent(NewName) then
raise Exception.Create(Format(lisComponentNameIsNotAValidIdentifier, [Newname])); raise Exception.Create(Format(lisComponentNameIsNotAValidIdentifier, [Newname]));
if WordIsKeyWord.DoItCaseInsensitive(PChar(NewName)) if WordIsKeyWord.DoItCaseInsensitive(PChar(NewName))
or WordIsDelphiKeyWord.DoItCaseInsensitive(PChar(NewName)) or WordIsDelphiKeyWord.DoItCaseInsensitive(PChar(NewName))

View File

@ -3852,7 +3852,7 @@ begin
Prefix:=AnUnitName; Prefix:=AnUnitName;
while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do
Prefix:=copy(Prefix,1,length(Prefix)-1); Prefix:=copy(Prefix,1,length(Prefix)-1);
if (Prefix='') or (not IsValidIdent(Prefix)) then if not IsValidIdent(Prefix) then
Prefix:='Unit'; Prefix:='Unit';
u:=0; u:=0;
repeat repeat
@ -5483,7 +5483,7 @@ begin
end; end;
// check build macros // check build macros
if (MacroName<>'') and IsValidIdent(MacroName) then if IsValidIdent(MacroName) then
begin begin
Values:=GetBuildMacroValues(CompilerOptions,true); Values:=GetBuildMacroValues(CompilerOptions,true);
if Values<>nil then begin if Values<>nil then begin
@ -7121,7 +7121,7 @@ begin
for i:=1 to Cnt do begin for i:=1 to Cnt do begin
SubPath:=Path+'Macro'+IntToStr(i)+'/'; SubPath:=Path+'Macro'+IntToStr(i)+'/';
MacroName:=FXMLConfig.GetValue(SubPath+'Name',''); MacroName:=FXMLConfig.GetValue(SubPath+'Name','');
if (MacroName='') or not IsValidIdent(MacroName) then continue; if not IsValidIdent(MacroName) then continue;
MacroValue:=FXMLConfig.GetValue(SubPath+'Value',''); MacroValue:=FXMLConfig.GetValue(SubPath+'Value','');
//debugln(['LoadMacroValues Mode="',CurMode.Identifier,'" ',MacroName,'="',MacroValue,'" session=',CurMode.InSession]); //debugln(['LoadMacroValues Mode="',CurMode.Identifier,'" ',MacroName,'="',MacroValue,'" session=',CurMode.InSession]);
AddMatrixMacro(MacroName,MacroValue,CurMode.Identifier,CurMode.InSession); AddMatrixMacro(MacroName,MacroValue,CurMode.Identifier,CurMode.InSession);

View File

@ -1539,7 +1539,7 @@ begin
// for example 'SysUtils.CompareText' // for example 'SysUtils.CompareText'
FFileName:=FActiveSrcEdit.EditorComponent.GetWordAtRowCol( FFileName:=FActiveSrcEdit.EditorComponent.GetWordAtRowCol(
FActiveSrcEdit.EditorComponent.LogicalCaretXY); FActiveSrcEdit.EditorComponent.LogicalCaretXY);
if (FFileName<>'') and IsValidIdent(FFileName) then begin if IsValidIdent(FFileName) then begin
// search pascal unit // search pascal unit
AUnitName:=FFileName; AUnitName:=FFileName;
InFilename:=''; InFilename:='';
@ -4558,7 +4558,7 @@ function TLazSourceFileManager.NewUniqueComponentName(Prefix: string): string;
function IdentifierIsOk(Identifier: string): boolean; function IdentifierIsOk(Identifier: string): boolean;
begin begin
Result:=false; Result:=false;
if (Identifier='') or not IsValidIdent(Identifier) then exit; if not IsValidIdent(Identifier) then exit;
if AllKeyWords.DoIdentifier(PChar(Identifier)) then exit; if AllKeyWords.DoIdentifier(PChar(Identifier)) then exit;
if IdentifierExists(Identifier) then exit; if IdentifierExists(Identifier) then exit;
if IdentifierExists('T'+Identifier) then exit; if IdentifierExists('T'+Identifier) then exit;
@ -4572,7 +4572,7 @@ begin
exit(Prefix); exit(Prefix);
while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do
System.Delete(Prefix,length(Prefix),1); System.Delete(Prefix,length(Prefix),1);
if (Prefix='') or (not IsValidIdent(Prefix)) then if not IsValidIdent(Prefix) then
Prefix:='Resource'; Prefix:='Resource';
i:=0; i:=0;
repeat repeat
@ -6845,7 +6845,7 @@ begin
CTErrorLine:=0; CTErrorLine:=0;
CTErrorCol:=0; CTErrorCol:=0;
if (AComponentClassName='') or (not IsValidIdent(AComponentClassName)) then if not IsValidIdent(AComponentClassName) then
begin begin
DebugLn(['TLazSourceFileManager.FindComponentClass invalid component class name "',AComponentClassName,'"']); DebugLn(['TLazSourceFileManager.FindComponentClass invalid component class name "',AComponentClassName,'"']);
exit(mrCancel); exit(mrCancel);
@ -7017,7 +7017,7 @@ begin
Quiet:=([ofProjectLoading,ofQuiet]*Flags<>[]); Quiet:=([ofProjectLoading,ofQuiet]*Flags<>[]);
HideAbort:=not (ofProjectLoading in Flags); HideAbort:=not (ofProjectLoading in Flags);
if (AComponentClassName='') or (not IsValidIdent(AComponentClassName)) then if not IsValidIdent(AComponentClassName) then
begin begin
DebugLn(['TLazSourceFileManager.LoadComponentDependencyHidden invalid component class name "',AComponentClassName,'"']); DebugLn(['TLazSourceFileManager.LoadComponentDependencyHidden invalid component class name "',AComponentClassName,'"']);
exit(mrCancel); exit(mrCancel);

View File

@ -1959,7 +1959,7 @@ begin
for i:=0 to Count-1 do begin for i:=0 to Count-1 do begin
HelpDB:=Items[i]; HelpDB:=Items[i];
Path:=HelpDB.ID; Path:=HelpDB.ID;
if (Path='') or (not IsValidIdent(Path)) then continue; if not IsValidIdent(Path) then continue;
Storage.AppendBasePath(Path); Storage.AppendBasePath(Path);
try try
HelpDB.Load(Storage); HelpDB.Load(Storage);
@ -1978,7 +1978,7 @@ begin
for i:=0 to Count-1 do begin for i:=0 to Count-1 do begin
HelpDB:=Items[i]; HelpDB:=Items[i];
Path:=HelpDB.ID; Path:=HelpDB.ID;
if (Path='') or (not IsValidIdent(Path)) then continue; if not IsValidIdent(Path) then continue;
Storage.AppendBasePath(Path); Storage.AppendBasePath(Path);
try try
HelpDB.Save(Storage); HelpDB.Save(Storage);
@ -2069,7 +2069,7 @@ begin
for i:=0 to Count-1 do begin for i:=0 to Count-1 do begin
Viewer:=Items[i]; Viewer:=Items[i];
Path:=Viewer.StorageName; Path:=Viewer.StorageName;
if (Path='') or (not IsValidIdent(Path)) then continue; if not IsValidIdent(Path) then continue;
Storage.AppendBasePath(Path); Storage.AppendBasePath(Path);
try try
Viewer.Load(Storage); Viewer.Load(Storage);
@ -2088,7 +2088,7 @@ begin
for i:=0 to Count-1 do begin for i:=0 to Count-1 do begin
Viewer:=Items[i]; Viewer:=Items[i];
Path:=Viewer.StorageName; Path:=Viewer.StorageName;
if (Path='') or (not IsValidIdent(Path)) then continue; if not IsValidIdent(Path) then continue;
Storage.AppendBasePath(Path); Storage.AppendBasePath(Path);
try try
Viewer.Save(Storage); Viewer.Save(Storage);

View File

@ -1358,7 +1358,7 @@ begin
if Length(Result) > 0 then if Length(Result) > 0 then
LFMStream.Read(Result[1],length(Result)); LFMStream.Read(Result[1],length(Result));
LFMStream.Position:=0; LFMStream.Position:=0;
if (Result='') or (not IsValidIdent(Result)) then if not IsValidIdent(Result) then
Result:=''; Result:='';
end; end;

View File

@ -1122,7 +1122,7 @@ begin
IDEComponentPalette.FindComponent(fLastNewComponentAncestorType)); IDEComponentPalette.FindComponent(fLastNewComponentAncestorType));
// create unique classname // create unique classname
if (not IsValidIdent(ClassNameEdit.Text)) or (ClassNameEdit.Text='') then if not IsValidIdent(ClassNameEdit.Text) then
ClassNameEdit.Text:=IDEComponentPalette.CreateNewClassName( ClassNameEdit.Text:=IDEComponentPalette.CreateNewClassName(
fLastNewComponentAncestorType); fLastNewComponentAncestorType);
// choose the same page name // choose the same page name

View File

@ -308,7 +308,7 @@ begin
if not FilenameIsAbsolute(LPKFilename) then exit; if not FilenameIsAbsolute(LPKFilename) then exit;
if CompareFilenames(ExtractFileExt(LPKFilename),'.lpk')<>0 then exit; if CompareFilenames(ExtractFileExt(LPKFilename),'.lpk')<>0 then exit;
PkgName:=ExtractFileNameOnly(LPKFilename); PkgName:=ExtractFileNameOnly(LPKFilename);
if (PkgName='') or not IsValidIdent(PkgName) then exit; if not IsValidIdent(PkgName) then exit;
Result:=true; Result:=true;
end; end;

View File

@ -2225,7 +2225,7 @@ begin
end; end;
// check build macros // check build macros
if (MacroName<>'') and IsValidIdent(MacroName) then if IsValidIdent(MacroName) then
begin begin
Values:=GetBuildMacroValues(CompilerOptions,true); Values:=GetBuildMacroValues(CompilerOptions,true);
if Values<>nil then begin if Values<>nil then begin