about summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cfg_defs.sh48
-rwxr-xr-xscripts/cfg_edit.sh17
-rwxr-xr-xscripts/cfg_path.sh5
-rwxr-xr-xscripts/fixtext.sh10
4 files changed, 80 insertions, 0 deletions
diff --git a/scripts/cfg_defs.sh b/scripts/cfg_defs.sh
new file mode 100755
index 00000000..5f37e962
--- /dev/null
+++ b/scripts/cfg_defs.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Translate the lynx_cfg.h and config.cache data into a table, useful for
+# display at runtime.
+
+TOP="${1-.}"
+OUT=cfg_defs.h
+
+# just in case we want to run this outside the makefile
+: ${SHELL:=/bin/sh}
+
+cat >$OUT <<EOF
+#ifndef CFG_DEFS_H
+#define CFG_DEFS_H 1
+
+static const struct {
+	const char *name;
+	const char *value;
+} config_cache[] = {
+EOF
+
+sed \
+	-e '/^#/d'     \
+	-e 's/^.[^=]*_cv_//' \
+	-e 's/=\${.*=/=/'  \
+	-e 's/}$//'          \
+	config.cache | $SHELL $TOP/scripts/cfg_edit.sh >>$OUT
+
+cat >>$OUT <<EOF
+};
+
+static const struct {
+	const char *name;
+	const char *value;
+} config_defines[] = {
+EOF
+fgrep	'#define' lynx_cfg.h |
+sed	-e 's@	@ @g' \
+	-e 's@  @ @g' \
+	-e 's@^[ 	]*#define[ 	]*@@' \
+	-e 's@[ ]*/\*.*\*/@@' \
+	-e 's@[ 	][ 	]*@=@' \
+    | $SHELL $TOP/scripts/cfg_edit.sh >>$OUT
+
+cat >>$OUT <<EOF
+};
+
+#endif /* CFG_DEFS_H */
+EOF
diff --git a/scripts/cfg_edit.sh b/scripts/cfg_edit.sh
new file mode 100755
index 00000000..6206c6c4
--- /dev/null
+++ b/scripts/cfg_edit.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Invoked from cfg_defs.sh as a filter
+# Strip leading and trailing whitespace
+# Escape any iternal '\'
+# Escape any iternal '"'
+# Entify any iternal '&', '<' or '>'
+# Append a '=' if none present'
+# Break into two strings at '='
+# Prefix ' { "' and suffix '" },'
+sort |
+sed	-e 's!^[ 	]*!!' -e 's![ 	]*$!!' \
+	-e 's!\\!\\\\!g'        \
+	-e 's!"!\\"!g'          \
+	-e 's!&!\&amp;!g' -e 's!<!\&lt;!g' -e 's!>!\&gt;!g' \
+	-e 's!^[^=]*$!&=!' \
+	-e 's!=!",	"!'     \
+	-e 's!^!	{ "!' -e 's!$!" },!'
diff --git a/scripts/cfg_path.sh b/scripts/cfg_path.sh
new file mode 100755
index 00000000..40ec863c
--- /dev/null
+++ b/scripts/cfg_path.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# Use this script for substituting the configured path into lynx.cfg -
+# not all paths begin with a slash.
+SECOND=`echo "$2" | sed -e s,^/,,`
+sed -e "/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]\+:file/s,/PATH_TO/$1,/$SECOND,"
diff --git a/scripts/fixtext.sh b/scripts/fixtext.sh
new file mode 100755
index 00000000..1f5c1abd
--- /dev/null
+++ b/scripts/fixtext.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# xgettext only processes literal strings.  Someone with a poor sense of humor
+# decided to ignore strings in preprocessor lines.  So we construct a fake
+# ".c" file with the definitions turned into literals.
+
+sed	-e 's/")/");/' \
+	-e 's/^#define[ 	]*\([^ 	]*\)[ 	]*gettext/char *\1 = gettext/' \
+	-e 's,^#define[ 	]*\([^ 	]*\)[ 	]*\\,/* #define \1 */char *\1 = \\,' \
+	$*