summaryrefslogtreecommitdiff
path: root/parse-sgml-catalog.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'parse-sgml-catalog.sh.in')
-rwxr-xr-xparse-sgml-catalog.sh.in82
1 files changed, 82 insertions, 0 deletions
diff --git a/parse-sgml-catalog.sh.in b/parse-sgml-catalog.sh.in
new file mode 100755
index 0000000..a758410
--- /dev/null
+++ b/parse-sgml-catalog.sh.in
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Copyright (C) 2002 by SuSE Linux AG.
+# Author: Karl Eichwalder <ke@suse.de>, 2002.
+# GPL
+
+package=@PACKAGE@
+version=@VERSION@
+
+LANGUAGE=C; export LANGUAGE
+LC_ALL=C; export LC_ALL
+
+# debug=yes
+
+progname=${0##*/}
+usage="\
+Usage: $progname file...
+Print normalized SGML catalog files.
+
+ -d, --debug
+ -h, --help
+
+Example:
+
+Version info: $progname ($package) $version
+
+Please, report bugs to Karl Eichwalder <feedback@suse.de>."
+
+while test $# -gt 0; do
+ case $1 in
+ -d | --debug) debug=yes; shift 1; ;;
+ -h | --h* ) echo "$usage"; exit 0 ;;
+ -*) echo "Try '$progname --help' for more information."; exit 1 ;;
+ *) break
+ esac
+done
+
+_debug(){
+ [ x$debug = xyes ] && echo -e $1
+}
+
+cat_norm() {
+#!/bin/sed -f
+ sed '
+s/--/\
+&\
+/g
+
+/^$/d
+s/^[ ]*//' "$1"
+}
+
+cat_del_empty_lines() {
+#!/bin/sed -f
+ sed '
+/^$/d
+s/^[ ]*//'
+}
+
+cat_print_norm() {
+#!/bin/gawk -f
+awk '
+BEGIN{IGNORECASE=1;p=1; c=0;}
+
+p == 1 && ! /--/ {
+ # if (/^[A-Za-z]/) {
+ if (/^(sgmldecl|dtddecl|doctype|entity|public|override|catalog)[ ]/) {
+ if (line != "") {print line; line="";}
+ line=$0}
+ else
+ line = line " " $0;
+};
+/^--/ && c == 0 {
+ if (line != "") {print line; line="";}
+ p=0; c=1; next;};
+/^--/ && c == 1 {p=1; c=0;};
+
+END{print line}'
+}
+
+cat_norm "$@" | cat_del_empty_lines | cat_print_norm
+
+exit