Cleanup runlex.sh to use builtin POSIX functions instead of sed

Bug: 13412

Change-Id: If43b30a33dcc4f23ba2bcb3cce3d0feea0d9fe40
Reviewed-on: https://code.wireshark.org/review/20120
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Mark Phillips 2016-10-20 18:50:26 +01:00 committed by Guy Harris
parent 0f5948015d
commit 64f83641ad
3 changed files with 7 additions and 18 deletions

View File

@ -77,7 +77,7 @@ am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@)
am__v_YACC_0 = @echo " YACC " $@;
.l.c:
$(AM_V_RUNLEX)$(RUNLEX) "$(LEX)" "$(SED)" -o$@ $<
$(AM_V_RUNLEX)$(RUNLEX) "$(LEX)" -o$@ $<
# abi-compliance-checker descriptor
abi_incdirs = $(subst -I,NEWLINE,$(filter -I%,$(AM_CPPFLAGS) -I$(abs_top_srcdir) -I$(abs_srcdir)))

View File

@ -36,7 +36,7 @@ MACRO(ADD_LEX_FILES _source _generated)
ADD_CUSTOM_COMMAND(
OUTPUT ${_outc} ${_outh}
COMMAND ${SH_EXECUTABLE} ${SH_FLAGS1} ${SH_FLAGS2} ${CMAKE_SOURCE_DIR}/tools/runlex.sh ${LEX_EXECUTABLE} ${SED_EXECUTABLE}
COMMAND ${SH_EXECUTABLE} ${SH_FLAGS1} ${SH_FLAGS2} ${CMAKE_SOURCE_DIR}/tools/runlex.sh ${LEX_EXECUTABLE}
-o${_outc}
${_in}
DEPENDS ${_in}

View File

@ -5,7 +5,6 @@
# Script to run Flex.
# First argument is the (quoted) name of the command; if it's null, that
# means that Flex wasn't found, so we report an error and quit.
# Second arg is the sed executable
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
@ -29,9 +28,9 @@
#
# Get the name of the command to run, and then shift to get the arguments.
#
if [ $# -lt 2 ]
if [ $# -lt 1 ]
then
echo "Usage: runlex <Flex command to run> <path to sed> [ arguments ]" 1>&2
echo "Usage: runlex <Flex command to run> [ arguments ]" 1>&2
exit 1
fi
@ -58,17 +57,6 @@ then
exit 1
fi
SED="$1"
shift
#
# Check whether we have sed.
#
if [ -z "${SED}" ]
then
echo "Sed was not found" 1>&2
exit 1
fi
#
# Process the flags. We don't use getopt because we don't want to
# embed complete knowledge of what options are supported by Flex.
@ -83,7 +71,8 @@ do
#
# Set the output file name.
#
outfile=`echo "$1" | ${SED} 's/-o\(.*\)/\1/'`
# remove the -o prefix using POSIX sh parameter expansion
outfile="${1#-o}"
;;
-*)
@ -109,7 +98,7 @@ done
# is .../foo.c, the header file will be .../foo_lex.h.
#
#echo "Getting header file name"
header_file=`dirname "$outfile"`/`basename "$outfile" .c`_lex.h
header_file="${outfile%.c}_lex.h"
#
# OK, run Flex.