From 1e404b93353a64d8d4c5e86bb1b28253efbf685b Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 27 2011 17:09:39 +0000 Subject: Update manual_restoreCrossReferences.sh. --- diff --git a/Scripts/Bash/centos-art/Functions/Manual/manual_restoreCrossReferences.sh b/Scripts/Bash/centos-art/Functions/Manual/manual_restoreCrossReferences.sh index fb8ece9..2c6f122 100755 --- a/Scripts/Bash/centos-art/Functions/Manual/manual_restoreCrossReferences.sh +++ b/Scripts/Bash/centos-art/Functions/Manual/manual_restoreCrossReferences.sh @@ -42,7 +42,9 @@ function manual_restoreCrossReferences { local NODE=$(echo "$ENTRY" \ | cut -d / -f8- \ | tr '/' ' ' \ - | sed -r "s/(${MANUALS_FILE[7]}|\.texi)$//") + | sed -r \ + -e "s/(chapter-intro\.texi|\.texi)$//" \ + -e 's! !( |\\n)!g') # Define regular expression patterns to match removed message # format produced by message_removeCrossReferences function. @@ -54,25 +56,27 @@ function manual_restoreCrossReferences { REPLACE[0]='@\1{\2}' REPLACE[1]='\1' - # Build list of source texinfo files to process, from section - # level on, and apply replacement string previously defined. At - # this point we don't touch chapter related texinfo files (i.e., - # repository-menu.texi and repository-nodes.texi) nor section - # related definition files (i.e., chapter-nodes.texi, - # chapter-menu.texi, chapter-index.texi) because they are handled - # by manual_updateChapterMenu, manual_updateChapterNode, - # manual_updateMenu, and manual_updateNodes functions - # respectively. If we don't sanitate messages built from broken - # cross reference messages, they may become obsolete since the - # documentation entry, they represent, can be recreated in the - # future and, at that time, the link wouldn't be broken any more, - # so we need to be aware of this. + # Define list of entries to process. local ENTRIES=$(cli_getFilesList "${MANUAL_DIR}" '.*\.texi') - if [[ $ENTRIES != '' ]];then - sed -r -i \ - -e "s!${PATTERN[0]}!${REPLACE[0]}!Mg" \ - -e "s!${PATTERN[1]}!${REPLACE[1]}!g" \ - $ENTRIES - fi + + # Set action preamble. + cli_printActionPreamble "$ENTRIES" + + # Update node-related cross references. The node-related cross + # reference definition, long ones specially, could require more + # than one line to be set. By default, GNU sed does not matches + # newline characters in the pattern space, so we need to make use + # of `label' feature and the `N' command in order to build a + # pattern space that includes the newline character in it. Here we + # use the `a' letter to name the label we use, followed by N + # command to expand the pattern space, the s command to make the + # pattern replacement using the `g' flag to make it global and + # finaly the command `b' to branch label named `a'. + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES} + + # Update menu-related cross references. Menu-related cross + # references hardly appear in more than one line, so there is no + # need to complicate the replacement command. + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES} }