summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/make-info-dir112
-rwxr-xr-xbuild-aux/msys-to-w32140
2 files changed, 78 insertions, 174 deletions
diff --git a/build-aux/make-info-dir b/build-aux/make-info-dir
index 3f927382ded..10a0b75fd6a 100755
--- a/build-aux/make-info-dir
+++ b/build-aux/make-info-dir
@@ -31,76 +31,44 @@
## installation directory. It does not handle info/dir being present
## but missing some entries.
-### Code:
-
-if test $# -ne 1; then
- echo "Specify destination file"
- exit 1
-fi
-
-outfile=$1
-
-echo "Creating $outfile..."
-
-if test -f "$outfile"; then
- echo "$outfile already present"
- exit 1
-fi
-
## Header contains non-printing characters, so this is more
-## reliable than using echo.
-basefile=build-aux/dir_top
-
-if test ! -f "$basefile"; then
- echo "$basefile not found"
- exit 1
-fi
-
-
-cp $basefile $outfile
-
-
-## FIXME inefficient looping.
-## What we should do is loop once over files, collecting topic and
-## direntry information for each. Then loop over topics and write
-## out the results. But that seems to require associative arrays,
-## and I do not know how to do that with portable sh.
-## Could use Emacs instead of sh, but till now info generation does
-## not require Emacs to have been built.
-for topic in "Texinfo documentation system" "Emacs" "Emacs lisp" \
- "Emacs editing modes" "Emacs network features" "Emacs misc features" \
- "Emacs lisp libraries"; do
-
- cat - <<EOF >> $outfile
-
-$topic
-EOF
- ## Bit faster than doc/*/*.texi.
- for file in doc/emacs/emacs.texi doc/lispintro/emacs-lisp-intro.texi \
- doc/lispref/elisp.texi doc/misc/*.texi; do
-
- ## FIXME do not ignore w32 if OS is w32.
- case $file in
- *-xtra.texi|*efaq-w32.texi|*doclicense.texi) continue ;;
- esac
-
- dircat=`sed -n -e 's/@value{emacsname}/Emacs/' -e 's/^@dircategory //p' $file`
-
- ## TODO warn about unknown topics.
- ## (check-info in top-level Makefile does that.)
- test "$dircat" = "$topic" || continue
-
-
- sed -n -e 's/@value{emacsname}/Emacs/' \
- -e 's/@acronym{\([A-Z]*\)}/\1/' \
- -e '/^@direntry/,/^@end direntry/ s/^\([^@]\)/\1/p' \
- $file >> $outfile
-
- done
-done
-
-echo "Created $outfile"
-
-exit 0
-
-### make-info-dir ends here
+## reliable than using awk.
+cat <"${1?}" || exit
+shift
+
+exec "${AWK-awk}" '
+ function detexinfo() {
+ gsub(/@value{emacsname}/, "Emacs")
+ gsub(/@[^{]*\{/, "")
+ gsub(/}/, "")
+ }
+ BEGIN {
+ ntopics = 0
+ topic[ntopics++] = "Texinfo documentation system"
+ topic[ntopics++] = "Emacs"
+ topic[ntopics++] = "Emacs lisp"
+ topic[ntopics++] = "Emacs editing modes"
+ topic[ntopics++] = "Emacs network features"
+ topic[ntopics++] = "Emacs misc features"
+ topic[ntopics++] = "Emacs lisp libraries"
+ topic[ntopics] = "Unknown category"
+ }
+ /^@dircategory / {
+ sub(/^@dircategory /, "")
+ detexinfo()
+ for (dircat = 0; dircat < ntopics && topic[dircat] != $0; dircat++)
+ continue;
+ }
+ /^@direntry/, /^@end direntry/ {
+ # FIXME do not ignore w32 if OS is w32.
+ if ($0 !~ /^@/ && $0 !~ /w32/) {
+ detexinfo()
+ data[dircat] = data[dircat] $0 "\n"
+ }
+ }
+ END {
+ for (dircat = 0; dircat <= ntopics; dircat++)
+ if (data[dircat])
+ printf "\n%s\n%s", topic[dircat], data[dircat]
+ }
+' "${@?}"
diff --git a/build-aux/msys-to-w32 b/build-aux/msys-to-w32
index 4c92cc91a3d..f0fd61d823f 100755
--- a/build-aux/msys-to-w32
+++ b/build-aux/msys-to-w32
@@ -1,6 +1,5 @@
-#!/bin/sh
-# Take a list of MSYS-compatible paths and convert them to native
-# MS-Windows format.
+#!/bin/bash
+# Convert a MSYS path list to Windows-native format.
# Status is zero if successful, nonzero otherwise.
# Copyright (C) 2013-2014 Free Software Foundation, Inc.
@@ -21,36 +20,19 @@
# Take only the basename from the full pathname
me=${0//*\//}
-usage="usage: ${me} PATHLIST [MUSTEXIST] [SEPARATOR [SEPARATOR2]]"
+usage="usage: ${me} PATHLIST"
help="$usage
or: ${me} OPTION
-Convert MSYS-compatible paths to MS-Windows native format.
+Convert a MSYS path list to Windows-native format.
+
+PATHLIST should be a colon-separated list of MSYS paths, which will be
+written to the standard output after performing these transformations:
-PATHLIST should be a list of paths separated by SEPARATOR. This list
-will be written to the standard output after performing the following
-transformations:
1. Discard empty paths.
-2. Replace backslashes with forward slashes.
-3. Replace two consecutive slashes with single ones.
-4. Translate to Windows-native format those paths that are not in such
- format already. The translated paths will not end with a slash,
- except for root directories (e.g. 'c:/' or 'c:/foo'). Paths
- starting with '%emacs_dir%' will not be translated.
-5. Escape with backslashes every occurrence of SEPARATOR2 within the paths.
-6. Concatenate the translated paths with SEPARATOR2.
-
-If MUSTEXIST is 'Y' or not supplied, then each path in PATHLIST must
-exist. Otherwise, only some part of each path is required to exist
-(the deepest existing subpath will be translated and the remainder
-concatenated to the translation).
-
-If SEPARATOR is not supplied, PATHLIST will be regarded as a single
-path.
-
-If SEPARATOR2 is not supplied, it will take the same value as
-SEPARATOR.
+2. Replace: '\' with '/', '//' with '/' and ':' with ';'.
+3. Translate absolute paths to Windows-native format.
Options:
--help display this help and exit
@@ -73,98 +55,52 @@ do
esac
done
-{ test $# -ge 1 && test $# -le 4; } ||
-{ echo "${me}: $usage" >&2; exit 1; }
-
-# Arguments
-pathlist="$1"
-mustexist="${2:-Y}"
-separator="$3"
-separator2="${4:-${separator}}"
-
-# Split pathlist into its path components
-if test -n "$separator"
-then
- IFS=${separator} patharray=( $pathlist )
-else
- patharray=( "$pathlist" )
-fi
+[ $# -eq 1 ] || {
+ echo "${me}: $usage" >&2
+ exit 1
+}
w32pathlist=""
-for p in "${patharray[@]}"
-do
- # Skip empty paths
- test "$p" = "" && continue
+# Put each MSYS path in one positional parameter and iterate through
+# them
+IFS=:
+set -- $1
- # Replace '\' with '/' and '//' with '/'
- p="${p//\\//}"
- p="${p//\/\///}"
+for p
+do
+ [ -z "$p" ] && continue
- if test "${p:0:11}" = "%emacs_dir%"
+ if [ "${p:0:1}" != "/" ]
then
- # Paths starting with "%emacs_dir%" will not be translated
w32p=$p
- elif test -d "$p"
+ elif [ -d "$p" ]
then
- # The path exists, so just translate it
- w32p=`cd "$p" && pwd -W`
+ w32p=$(cd "$p" && pwd -W)
else
- # The path does not exist. So, try to guess the
- # Windows-native translation, by looking for the deepest
- # existing directory in this path, and then translating the
- # existing part and concatenating the remainder.
+ # Make some cleanup in the path and look for its deepest
+ # existing directory
- test "${mustexist}" = "Y" &&
- { echo "${me}: invalid path: $p" >&2; exit 1; }
+ p=${p//\\//}
+ p=${p//\/\///}
+ p=${p%/}
p1=$p
- IFS=/ pcomponents=( $p )
-
- for (( i=${#pcomponents[@]}-1 ; i>=0 ; i-- ))
+ while :
do
-
- if test "${pcomponents[i]}" = ""
- then
- # The path component is empty. This can only mean
- # that the path starts with "/" and all components
- # have been stripped out already. So in this case we
- # want to test with the MSYS root directory
- p1="/"
- else
- p1="${p1%/}"
- p1="${p1%${pcomponents[i]}}"
- fi
-
- if test -d "${p1}"
- then
-
- # Existing path found
-
- # Translate the existing part and concatenate the
- # remainder (ensuring that only one slash is used in
- # the join, and no trailing slash is left)
- w32p1=`cd "${p1}" && pwd -W`
- remainder="${p#${p1}}"
- remainder="${remainder#/}"
- remainder="${remainder%/}"
- w32p="${w32p1%/}/${remainder}"
-
- break
- fi
-
+ p1=${p1%/*}
+ [ -z "$p1" ] && p1="/" && break
+ [ -d "$p1" ] && break
done
- # If no existing directory was found, error out
- test -e "${p1}" ||
- { echo "${me}: invalid path: ${p}" >&2; exit 1; }
+ # translate the existing part and append the rest
+ w32p=$(cd "${p1}" && pwd -W)
+ remainder=${p#$p1}
+ w32p+=/${remainder#/}
fi
- # Concatenate the translated path to the translated pathlist
- test "${w32pathlist}" = "" || w32pathlist="${w32pathlist}${separator2}"
- w32pathlist="${w32pathlist}${w32p//${separator2}/\\${separator2}}"
+ w32pathlist="${w32pathlist};${w32p}"
done
-# Write the translated pathlist to the standard output
-printf "%s" "${w32pathlist}"
+echo "${w32pathlist:1}"