fix #26, DUB excludedSourceFiles are not well managed

This commit is contained in:
Basile Burg 2016-03-14 03:49:23 +01:00
parent 7915a315ee
commit f0bd30c948
2 changed files with 77 additions and 7 deletions

View File

@ -268,6 +268,13 @@ type
*)
function isBlank(const str: string): boolean;
(**
* Converts a global match expression to a regular expression.
* Limitation: Windows style, [] not handled.
* src: github.com/spring/svn-spring-archive/blob/master/branches/greenail/rts/System/Platform/filefunctions.h#L29
*)
function globToReg(const glob: string ): string;
var
// supplementatl directories to find background tools
additionalPath: string;
@ -1160,6 +1167,52 @@ begin
exit(false);
end;
function globToReg(const glob: string ): string;
procedure quote(var r: string; c: char);
begin
if not (c in ['a'..'z', 'A'..'Z', '0'..'9', '_']) then
r += '\';
r += c;
end;
var
i: integer = 0;
b: integer = 0;
begin
result := '^';
while i < length(glob) do
begin
i += 1;
case glob[i] of
'*': result += '.*';
'?': result += '.';
'{':
begin
b += 1;
result += '(';
end;
'}':
begin
b -= 1;
result += ')';
end;
',':
begin
if b > 0 then
result += '|'
else
quote(result, glob[i]);
end;
'\':
begin
i += 1;
quote(result, glob[i]);
end;
else
quote(result, glob[i]);
end;
end;
end;
initialization
registerClasses([TCEPersistentShortcut]);
end.

View File

@ -5,7 +5,8 @@ unit ce_dubproject;
interface
uses
Classes, SysUtils, xfpjson, xjsonparser, xjsonscanner, process, strutils, LazFileUtils,
Classes, SysUtils, xfpjson, xjsonparser, xjsonscanner, process, strutils,
LazFileUtils, RegExpr,
ce_common, ce_interfaces, ce_observer, ce_dialogs, ce_processes;
type
@ -595,6 +596,7 @@ begin
end;
var
pth: string;
glb: TRegExpr;
begin
fSrcs.Clear;
if not assigned(fJSON) then
@ -662,14 +664,29 @@ begin
// exclusions
lst.Clear;
getExclusion(fJSON);
conf := getCurrentCustomConfig;
conf := getCurrentCustomConfig;
if conf.isNotNil then
getExclusion(conf);
for i := fSrcs.Count-1 downto 0 do
for j := 0 to lst.Count-1 do
if SameFileName(fSrcs[i], lst[j]) then
fSrcs.Delete(i);
// TODO-cDUB: manage exclusions with http://dlang.org/phobos/std_path.html#.globMatch
if lst.Count > 0 then
begin
glb := TRegExpr.Create;
try
for j := 0 to lst.Count-1 do
begin
try
glb.Expression := globToReg(lst[j]);
glb.Compile;
for i := fSrcs.Count-1 downto 0 do
if glb.Exec(fSrcs[i]) then
fSrcs.Delete(i);
except
continue;
end;
end;
finally
glb.Free;
end;
end;
finally
lst.Free;
end;