summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Phillips <mark.phil@samsung.com>2016-10-20 18:50:26 +0100
committerGuy Harris <guy@alum.mit.edu>2017-02-15 20:58:43 +0000
commit64f83641ad1ddd8969b08ccb64975daa582427f5 (patch)
treeb698af9c643fa0c79df879e2467ed4a023f85372
parent0f5948015d96fdb198fb4b26a810404b1225462c (diff)
downloadwireshark-64f83641ad1ddd8969b08ccb64975daa582427f5.tar.gz
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>
-rw-r--r--Makefile.am.inc2
-rw-r--r--cmake/modules/FindLEX.cmake2
-rwxr-xr-xtools/runlex.sh21
3 files changed, 7 insertions, 18 deletions
diff --git a/Makefile.am.inc b/Makefile.am.inc
index c19ed62615..87ee199dd6 100644
--- a/Makefile.am.inc
+++ b/Makefile.am.inc
@@ -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)))
diff --git a/cmake/modules/FindLEX.cmake b/cmake/modules/FindLEX.cmake
index 6a9c0fc702..28fc6678fb 100644
--- a/cmake/modules/FindLEX.cmake
+++ b/cmake/modules/FindLEX.cmake
@@ -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}
diff --git a/tools/runlex.sh b/tools/runlex.sh
index 48a27b6142..cc77d31543 100755
--- a/tools/runlex.sh
+++ b/tools/runlex.sh
@@ -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.