|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo_restoreCrossReferences.sh -- This function looks inside
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo source files, from section level on, and restores any cross
|
|
Alain Reguera Delgado |
8f60cb |
# reference related to a documentation entry. This function is used in
|
|
Alain Reguera Delgado |
8f60cb |
# those cases where documentation entries are created/recreated to
|
|
Alain Reguera Delgado |
8f60cb |
# documentation structure. It is a verification that looks for
|
|
Alain Reguera Delgado |
8f60cb |
# matching documentation entries previously defined as removed by
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo_deleteCrossReferences function. The
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo_restoreCrossReferences function relays in the removed
|
|
Alain Reguera Delgado |
8f60cb |
# message format produced by texinfo_deleteCrossReferences
|
|
Alain Reguera Delgado |
8f60cb |
# function, in order to return them back into the link format.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
8f60cb |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
8f60cb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
8f60cb |
# your option) any later version.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
8f60cb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
8f60cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
8f60cb |
# General Public License for more details.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
8f60cb |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
8f60cb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
# $Id$
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
function texinfo_restoreCrossReferences {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
local -a PATTERN
|
|
Alain Reguera Delgado |
8f60cb |
local -a REPLACE
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define documentation entry.
|
|
Alain Reguera Delgado |
8f60cb |
local MANUAL_ENTRY="$1"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify documentation entry. If documentation entry is empty,
|
|
Alain Reguera Delgado |
8f60cb |
# stop script execution with an error message.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ $MANUAL_ENTRY == '' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "`gettext "The first positional parameter cannot be empty."`" --as-error-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Build the node string using entry location.
|
|
Alain Reguera Delgado |
8f60cb |
local NODE="$(texinfo_getEntryNode "$MANUAL_ENTRY")"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define regular expression patterns to match removed message
|
|
Alain Reguera Delgado |
8f60cb |
# format produced by message_removeCrossReferences function.
|
|
Alain Reguera Delgado |
8f60cb |
PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):(${NODE})\) ---"
|
|
Alain Reguera Delgado |
8f60cb |
PATTERN[1]="^@comment --- `gettext "Removed"`\((\* ${NODE}:(.*)?:(.*)?)\) ---$"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define replacement string to turn removed message back to cross
|
|
Alain Reguera Delgado |
8f60cb |
# reference link.
|
|
Alain Reguera Delgado |
8f60cb |
REPLACE[0]='\@\1{\2}'
|
|
Alain Reguera Delgado |
8f60cb |
REPLACE[1]='\1'
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define list of entries to process.
|
|
Alain Reguera Delgado |
8f60cb |
local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \
|
|
Alain Reguera Delgado |
8f60cb |
--pattern="^.+\.${MANUAL_EXTENSION}$")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Update node-related cross references. The node-related cross
|
|
Alain Reguera Delgado |
8f60cb |
# reference definition, long ones specially, could require more
|
|
Alain Reguera Delgado |
8f60cb |
# than one line to be set. By default, GNU sed does not matches
|
|
Alain Reguera Delgado |
8f60cb |
# newline characters in the pattern space, so we need to make use
|
|
Alain Reguera Delgado |
8f60cb |
# of `label' feature and the `N' command in order to build a
|
|
Alain Reguera Delgado |
8f60cb |
# pattern space that includes the newline character in it. Here we
|
|
Alain Reguera Delgado |
8f60cb |
# use the `a' letter to name the label we use, followed by N
|
|
Alain Reguera Delgado |
8f60cb |
# command to add a newline to the pattern space, the s command to
|
|
Alain Reguera Delgado |
8f60cb |
# make the pattern replacement using the `g' flag to make it
|
|
Alain Reguera Delgado |
8f60cb |
# global and finally the command `b' to branch label named `a'.
|
|
Alain Reguera Delgado |
8f60cb |
sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Update menu-related cross references. Menu-related cross
|
|
Alain Reguera Delgado |
8f60cb |
# references hardly appear in more than one line, so there is no
|
|
Alain Reguera Delgado |
8f60cb |
# need to complicate the replacement command.
|
|
Alain Reguera Delgado |
8f60cb |
sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${MANUAL_ENTRIES}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|