Commit 13f0e8c7 by Zachary T Welch Committed by Mike Stump

prune.exp (escape_regex_chars): New.

2016-03-29  Zachary T Welch <zwelch@codesourcery.com>

	* lib/prune.exp (escape_regex_chars): New.
	(prune_file_path): Update to quote metcharacters for regexp.

From-SVN: r234533
parent f8a1abf8
2016-03-29 Zachary T Welch <zwelch@codesourcery.com>
* lib/prune.exp (escape_regex_chars): New.
(prune_file_path): Update to quote metcharacters for regexp.
2016-03-29 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70429
......
......@@ -78,12 +78,33 @@ proc prune_gcc_output { text } {
return $text
}
# escape metacharacters in literal string, so it can be used in regex
proc escape_regex_chars { line } {
return [string map {"^" "\\^"
"$" "\\$"
"(" "\\("
")" "\\)"
"[" "\\["
"]" "\\]"
"{" "\\{"
"}" "\\}"
"." "\\."
"\\" "\\\\"
"?" "\\?"
"+" "\\+"
"*" "\\*"
"|" "\\|"} $line]
}
proc prune_file_path { text } {
global srcdir
set safedir [escape_regex_chars $srcdir]
regsub -all "$safedir\/" $text "" text
# Truncate absolute file path into relative path.
set topdir "[file dirname [file dirname [file dirname $srcdir]]]"
regsub -all "$srcdir\/" $text "" text
set topdir "[file dirname [file dirname [file dirname $safedir]]]"
regsub -all "$topdir\/" $text "" text
return $text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment