codetools: FilenameIsPascalUnit now checks if unitname is valid identifier

git-svn-id: trunk@12871 -
This commit is contained in:
mattias 2007-11-14 19:51:28 +00:00
parent 3e60d686d5
commit d093a68232
3 changed files with 20 additions and 11 deletions

View File

@ -1017,7 +1017,8 @@ var
begin
StartPos:=FilenameLen-1;
while (StartPos>=0) and (Filename[StartPos]<>'.') do dec(StartPos);
if StartPos<0 then exit(false);
if StartPos<=0 then exit(false);
// check extension
ExtLen:=FilenameLen-StartPos;
for e:=Low(CTPascalExtension) to High(CTPascalExtension) do begin
if (CTPascalExtension[e]='') or (length(CTPascalExtension[e])<>ExtLen) then
@ -1036,7 +1037,17 @@ begin
inc(p);
end;
end;
if i=ExtLen then exit(true);
if i=ExtLen then begin
// check name is identifier
i:=0;
if not (Filename[i] in ['a'..'z','A'..'Z','_']) then exit(false);
inc(i);
while i<StartPos do begin
if not (Filename[i] in ['a'..'z','A'..'Z','_','0'..'9']) then exit(false);
inc(i);
end;
exit(true);
end;
end;
Result:=false;
end;

View File

@ -1,5 +1,3 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#163#1#6'Height'#3','#1#3'Top'#3#31#1#5'Wi'
+'dth'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'#1#7

View File

@ -11,7 +11,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="2"/>
</General>
<PublishOptions>
<Version Value="2"/>
@ -27,10 +27,10 @@
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="LCL"/>
<PackageName Value="LazOpenGLContext"/>
</Item1>
<Item2>
<PackageName Value="LazOpenGLContext"/>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
@ -40,7 +40,7 @@
<UnitName Value="TestOpenGLContext1"/>
<CursorPos X="1" Y="13"/>
<TopLine Value="1"/>
<UsageCount Value="144"/>
<UsageCount Value="145"/>
</Unit0>
<Unit1>
<Filename Value="mainunit.pas"/>
@ -48,10 +48,10 @@
<IsPartOfProject Value="True"/>
<ResourceFilename Value="mainunit.lrs"/>
<UnitName Value="MainUnit"/>
<CursorPos X="19" Y="51"/>
<TopLine Value="37"/>
<CursorPos X="24" Y="40"/>
<TopLine Value="19"/>
<EditorIndex Value="0"/>
<UsageCount Value="144"/>
<UsageCount Value="145"/>
<Loaded Value="True"/>
</Unit1>
</Units>