>From ec548ecfa8846f40731a0945853d3ac9018b4d71 Mon Sep 17 00:00:00 2001 From: Akira Yokosawa <akiyks@xxxxxxxxx> Date: Sun, 4 Sep 2016 08:03:52 +0900 Subject: [PATCH 2/2] hyphen2endash.sh: Merge subst patterns This commit merges several rules by using "[abc]" patterns, as long as they are not too cryptic (at least for me). It also replaces patterns of "{.*}" with those of "{[^}]*}" for stable matching when there are multiple "{...}"s in a line. Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- utilities/hyphen2endash.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/utilities/hyphen2endash.sh b/utilities/hyphen2endash.sh index b495e33..39005a4 100644 --- a/utilities/hyphen2endash.sh +++ b/utilities/hyphen2endash.sh @@ -38,21 +38,12 @@ # Authors: Akira Yokosawa <akiyks@xxxxxxxxx> cat $1 | - sed -e 's/Lines~\([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ - -e 's/Lines \([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ - -e 's/lines~\([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ - -e 's/lines \([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ - -e 's/Line~\([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ - -e 's/Line \([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ - -e 's/line~\([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ - -e 's/line \([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ + sed -e 's/\([Ll]ines\?\)[ ~]\([0-9]\+\)-\([0-9]\+\)/\1~\2--\3/g' \ -e 's/Slides \([0-9]\+\)-\([0-9]\+\)/Slides~\1--\2/g' \ - -e 's/Figures~\(\\ref{.*}\)-\(\\ref{.*}\)/Figures~\1--\2/g' \ - -e 's/CPUs~\([0-9]\+\)-\([0-9]\+\)/CPUs~\1--\2/g' \ - -e 's/CPUs \([0-9]\+\)-\([0-9]\+\)/CPUs~\1--\2/g' \ - -e 's/and~\([0-9]\+\)-\([0-9]\+\)/and~\1--\2/g' \ - -e 's/and \([0-9]\+\)-\([0-9]\+\)/and~\1--\2/g' \ - -e 's/\(\\co{.*}\)-\(\\co{.*}\)/\1--\2/g' \ + -e 's/Figures~\(\\ref{[^}]*}\)-\(\\ref{[^}]*}\)/Figures~\1--\2/g' \ + -e 's/CPUs[ ~]\([0-9]\+\)-\([0-9]\+\)/CPUs~\1--\2/g' \ + -e 's/and[ ~]\([0-9]\+\)-\([0-9]\+\)/and~\1--\2/g' \ + -e 's/\(\\co{[^}]*}\)-\(\\co{[^}]*}\)/\1--\2/g' \ -e 's/\/\* Lines~\([0-9]\+\)--\([0-9]\+\) \*\//\/\* Lines \1-\2 \*\//g' # Last pattern is to preserve "Lines n-m" in comments within code snippet -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe perfbook" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html