974695 Update texinfo_renameCrossReferences.sh.

Authored and Committed by areguera 13 years ago
Scripts/Functions/Help/Backends/Texinfo/texinfo_renameCrossReferences.sh CHANGED
@@ -36,7 +36,7 @@ function texinfo_renameCrossReferences {
36
36
local NODE_DST=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY_DST")
37
37
38
38
# Define list of entries to process.
39
- local ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern=".*\.${FLAG_BACKEND}")
39
+ local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern=".*\.${FLAG_BACKEND}")
40
40
41
41
# Update node-related cross-references. The node-related cross
42
42
# reference definition, long ones specially, could require more
@@ -48,7 +48,19 @@ function texinfo_renameCrossReferences {
48
48
# command to add a newline to the pattern space, the s command to
49
49
# make the pattern replacement using the `g' flag to make it
50
50
# global and finaly the command `b' to branch label named `a'.
51
- sed -r -i ":a;N;s!${NODE_SRC}!${NODE_DST}!g;ba" ${ENTRIES}
51
+ #
52
+ # Inside the pattern space, the `\<' and `\>' are used to restrict
53
+ # the match pattern to a word boundary. The word boundary
54
+ # restriction applied here is required to avoid undesired
55
+ # replacements when we replace singular words with their plurals.
56
+ # For example, if we need to change the word `Manual' to its
57
+ # plular (i.e., `Manuals'), and no boundary restriction is used in
58
+ # the pattern space to do that, we might end up having words like
59
+ # `Manualsssss'. This is because this sed command might be applied
60
+ # to the same file many times; and each time it is applied a new
61
+ # `Manuals' replaces the previous `Manuals' replacement to form
62
+ # `Manualss', `Manualsss', and so on for each interaction.
63
+ sed -r -i ":a;N;s!\<${NODE_SRC}\>!${NODE_DST}!g;ba" ${MANUAL_ENTRIES}
52
64
53
65
# At this point, source documentation entry has been renamed from
54
66
# source to target documentation entry, but they are still