11#! /bin/bash
2- echo " Compiling the helper file to extract the raw list of parameters from cbmc"
3- g++ -c -MMD -MP -std=c++11 -Wall -I ../../src/ -ftrack-macro-expansion=0 -fno-diagnostics-show-caret switch_extractor_helper.c -o tmp.o 2> pragma.txt
42
5- retval= $?
3+ set -e
64
7- # clean up compiled files, we don't need them.
8- rm tmp.o 2> /dev/null
9- rm tmp.d 2> /dev/null
5+ # make sure we execute the remainder in the directory containing this script
6+ cd ` dirname $0 `
107
11- # check if compilation went fine
12- if [ $retval -ne 0 ]; then
13- echo " Problem compiling the helper file, parameter list not extracted."
14- exit 1;
15- fi
8+ echo " Compiling the helper file to extract the raw list of parameters from cbmc"
9+ g++ -E -dM -std=c++11 -I../../src ../../src/cbmc/cbmc_parse_options.cpp -o macros.c
10+ echo CBMC_OPTIONS >> macros.c
1611
1712echo " Converting the raw parameter list to the format required by autocomplete scripts"
18- rawstring=` sed " s/^.*pragma message: \(.*\)/\1/" pragma.txt`
19- # delete pragma file, we won't need it
20- rm pragma.txt 2> /dev/null
13+ rawstring=" ` gcc -E -P -w macros.c` \" ?h(help)\" "
14+ rm macros.c
2115
2216# now the main bit, convert from raw format to a proper list of switches
2317cleanstring=` (
@@ -26,7 +20,7 @@ cleanstring=`(
2620 (echo $rawstring | grep -o " ([^)]*)" | sed " s/^.\(.*\).$/--\1/" ) ;
2721 # extract 1-hyphen switches, such as -F
2822 # use sed to remove all (foo) expressions, then you're left with switches and ':', so grep the colons out and then use sed to include the '-'
29- (echo $rawstring | sed " s/([^)]*)//g" | grep -o " [a-zA-Z0-9]" | sed " s/\(.*\)/-\1/" )
23+ (echo $rawstring | sed " s/([^)]*)//g" | grep -o " [a-zA-Z0-9? ]" | sed " s/\(.*\)/-\1/" )
3024 ) | tr ' \n' ' ' `
3125
3226# sanity check that there is only one line of output
@@ -36,13 +30,10 @@ if [ `echo $cleanstring | wc -l | awk '{print $1}'` -ne 1 ]; then
3630fi
3731
3832# sanity check that there are no dangerous characters
39- echo $cleanstring | grep -q " [^a-zA-Z0-9 -]"
40- if [ $? -eq 0 ]; then
33+ if echo $cleanstring | grep -q " [^a-zA-Z0-9? -]" ; then
4134 echo " Problem converting the parameter list to the correct format, illegal characters detected. This is likely to be an error in this conversion script."
4235 exit 1;
4336fi
4437
4538echo " Injecting the parameter list to the autocomplete file."
4639sed " 5 s/.*/ local switches=\" $cleanstring \" /" cbmc.sh.template > cbmc.sh
47-
48- rm pragma.txt 2> /dev/null
0 commit comments