From dc27419d79eebc2c435b5eab6161239a2df61f8f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 10 Apr 2003 11:06:16 +0000 Subject: warn when using a regexp terminated with .* or .*$ (which is useless) --- perl_checker.src/parser_helper.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'perl_checker.src/parser_helper.ml') diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d5869ec..fc84b93 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -778,7 +778,15 @@ let to_String parse strict (l, (_, pos)) = String(l', raw_pos2pos pos) let from_PATTERN parse ((s, opts), (_, pos)) = - [ String(parse_interpolated parse s, raw_pos2pos pos) ; + let re = parse_interpolated parse s in + (match List.rev re with + | (s, List []) :: _ -> + if str_ends_with s ".*" then + warn_rule (sprintf "you can remove \"%s\" at the end of your regexp" ".*") + else if str_ends_with s ".*$" then + warn_rule (sprintf "you can remove \"%s\" at the end of your regexp" ".*$") + | _ -> ()); + [ String(re, raw_pos2pos pos) ; Raw_string(opts, raw_pos2pos pos) ] let from_PATTERN_SUBST parse ((s1, s2, opts), (_, pos)) = [ String(parse_interpolated parse s1, raw_pos2pos pos) ; -- cgit v1.2.1