summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-05-19 00:22:04 +0000
committerKarl Berry <karl@freefriends.org>2010-05-19 00:22:04 +0000
commiteb07d6a8223898ec3dc5a8eecf34a474d5d848a9 (patch)
treebb8e2b82e23e8c30a9dc686cfa7ae58b26221cec /Master/texmf-dist/scripts
parentbe5a4c024b0705f0eb9ca28fd902cbcf6a9c31ae (diff)
listings-ext v58 (18may10)
git-svn-id: svn://tug.org/texlive/trunk@18344 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/listings-ext/listings-ext.sh69
1 files changed, 38 insertions, 31 deletions
diff --git a/Master/texmf-dist/scripts/listings-ext/listings-ext.sh b/Master/texmf-dist/scripts/listings-ext/listings-ext.sh
index 49728fcfb9e..1ae88ac0568 100755
--- a/Master/texmf-dist/scripts/listings-ext/listings-ext.sh
+++ b/Master/texmf-dist/scripts/listings-ext/listings-ext.sh
@@ -2,9 +2,9 @@
### listings-ext.sh ---
## Author: Dr. Jobst Hoffmann <j.hoffmann@fh-aachen.de>
-## Version: $Id: listings-ext.dtx 48 2009-08-31 18:30:48Z ax006ho $
+## Version: $Id: listings-ext.dtx 58 2010-05-18 14:23:40Z ax006ho $
## Keywords: LaTeX, listings
-## Copyright: (C) 2008-2009 Jobst Hoffmann, <j.hoffmann@fh-aachen.de>
+## Copyright: (C) 2008-2010 Jobst Hoffmann, <j.hoffmann@fh-aachen.de>
##-------------------------------------------------------------------
##
## This file may be distributed and/or modified under the
@@ -26,30 +26,29 @@
## with the distribution package.
ERR_HELP=1
ME=$(basename $0)
-USAGE="usage:\n\t${ME} [-c|--command] [-h|--help] [-g|--debug] \\\\\n \
-\t\t[-n|--no-header] \\\\\n \
-\t\t[{-o|--output-file} [<output filename>]] <filename>, ...\n \
-\t-c:\tgenerate commands, which can be input and later used by\n \
-\t\t\\\\lstuse, optional\n \
-\t-g:\tdebug mode, create some additional output, optional\n \
-\t-h:\tshow this help, optional\n \
-\t-n:\twrite no header into the LaTeX code, optional; valid only,\n \
-\t\tif -c isn't used\n \
-\t-o [<output filename>]: if this argument is present, the output will\n \
-\t\tbe written into a file <output filename>; if the\n \
-\t\t<output filename> is omitted, the output is redirected\n \
-\t\tinto a file with a basename, which corresponds to the name\n \
-\t\tof the current directory, it has an extension of \".lst\".\n\n \
-remark:\n\tIf <filename> contains characters others than lower \
-and upper\n\tcase characters, \"-\" and \"_\", <output filename> can't be\
- directly\n\tprocessed by TeX.\n \
+USAGE="usage:\n\t${ME} [-c|--command] [-e|--ext] [-g|--debug] \\\\\n\
+\t\t[-h|--help] [-n|--no-header] \\\\\n\
+\t\t[{-o|--output-file} [<output filename>]] <filename>, ...\n\
+\t-c:\tgenerate commands, which can be input and later used by\n\
+\t\t\\\\lstuse, optional\n\
+\t-e:\tinclude file name extension into the identifier\n\
+\t-g:\tdebug mode, create some additional output, optional\n\
+\t-h:\tshow this help, optional\n\
+\t-n:\twrite no header into the LaTeX code, optional; valid only,\n\
+\t\tif -c isn't used\n\
+\t-o [<output filename>]: if this argument is present, the output will\n\
+\t\tbe written into a file <output filename>; if the\n\
+\t\t<output filename> is omitted, the output is redirected\n\
+\t\tinto a file with a basename corresponding to the name\n\
+\t\tof the current directory, it has an extension of \".lst\".\n\
"
+DEBUG_MODE=0
+EXTENSION=0
HEADER=1
-DEBUGMODE=0
show_usage() # display help massage
{
- echo -e ${USAGE}
+ printf "${USAGE}"
exit ${ERR_HELP}
}
print_header()
@@ -58,7 +57,7 @@ print_header()
echo "%% -- file $1 generated on $(date) by ${ME}"
FILE=$(echo $(basename $1 .lst) | sed -e s/[_\-]//g)
echo "\\csname ${FILE}LstLoaded\\endcsname"
- echo "\\let\\${FILE}LstLoaded\\endinput"
+ echo "\\expandafter\\let\\csname ${FILE}LstLoaded\\endcsname\\endinput"
}
do_the_job()
{
@@ -72,10 +71,10 @@ do_the_job()
fi
SOURCEFILE=${SOURCEFILE##${PATHCOMPONENT}/}
- grep -n "[/%;#!][/\* ;]\ *[cbe]e:" $1 | \
- awk -v pathcomponent="$PATHCOMPONENT" -v file="$SOURCEFILE" \
- -v header="$HEADER" -v command="$COMMAND" -v application="${ME}" \
- -v debugmode="$DEBUG_MODE" \
+ grep -n "^ *[/%;#!][/\* ;]\ *[cbe]e:" $1 | \
+ awk -v pathcomponent="${PATHCOMPONENT}" -v file="${SOURCEFILE}" \
+ -v header="${HEADER}" -v command="${COMMAND}" -v application="${ME}" \
+ -v debugmode="${DEBUG_MODE}" -v respect_extension="${EXTENSION}"\
-F : \
'
BEGIN {
@@ -114,6 +113,9 @@ BEGIN {
{
identifier = identifier parts[i]
}
+ if ( respect_extension ) {
+ identifier = identifier parts[n]
+ }
identifier = replace_characters(identifier)
if ( debugmode ) printf("identifier: %s\n", identifier) > "/dev/stderr"
}
@@ -182,7 +184,8 @@ BEGIN {
combine_array[closing_tag] = \
combine_array[closing_tag] ", " start "-" $1-1
}
- if ( debugmode ) printf("combine_array: >%s<\n", combine_array[closing_tag]) > "/dev/stderr"
+ if ( debugmode ) printf("combine_array: >%s<\n",\
+ combine_array[closing_tag]) > "/dev/stderr"
} else {
linerange = start "-" $1-1;
if ( command ) {
@@ -205,6 +208,9 @@ BEGIN {
}
}
END {
+ if ( is_opened ) {
+ print_error($1, "missing \"ee\" declaration")
+ }
caption = "\\lstinline|" file "|";
if ( join ) {
sub(/, /, "", linerange);
@@ -316,8 +322,8 @@ if [ $# -eq 0 ]
then
show_usage
fi
-GETOPT=$(getopt -o cghno:: \
- --longoptions command,debug-mode,help,no-header,output-file:: \
+GETOPT=$(getopt -o ceghno:: \
+ --longoptions command,debug-mode,ext,help,no-header,output-file:: \
-n ${ME} -- "$@")
if [ $? -ne 0 ] # no success
@@ -331,6 +337,7 @@ while true
do
case "$1" in
-c|--command) COMMAND=1; HEADER=0; shift;;
+ -e|--ext) EXTENSION=1; shift;;
-g|--debug-mode) DEBUG_MODE=1; shift;;
-h|--help) show_usage ;;
-n|--no-header) HEADER=0; shift;;
@@ -347,7 +354,7 @@ if [ -n "${OUTFILE}" ]
then
if [ -f "${OUTFILE}" ]
then
- echo -e "%--> file \"${OUTFILE}\" already exists, creating backup"
+ echo "%--> file \"${OUTFILE}\" already exists, creating backup"
mv ${OUTFILE} ${OUTFILE}~
fi
exec > ${OUTFILE} # redirect stdout to ${OUTFILE}
@@ -357,7 +364,7 @@ fi
# now take all remaining arguments (should be all filenames) and do the job
for arg do
- echo -e "%-->" processing file \"$arg\" 1>&2 # echo the current
+ echo "%-->" processing file \"$arg\" 1>&2 # echo the current
# filename to stderr
do_the_job $arg
done