mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-02 10:16:19 +02:00
Remove "--compat=1.4" support.
Add "-d" and "-D" support. (deprecated_list): New var. (compat_mode_clean_xxx): Delete. (grep_deprecated): New func. ("main"): If "-d" or "-D", call `grep_deprecated'.
This commit is contained in:
parent
3b7163eefa
commit
ebc8b08d1e
1 changed files with 33 additions and 18 deletions
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
# Commentary:
|
# Commentary:
|
||||||
|
|
||||||
# Usage: guile-snarf [--compat=1.4] [-o OUTFILE] INFILE [CPP-OPTIONS ...]
|
# Usage: guile-snarf [-d | -D] [-o OUTFILE] INFILE [CPP-OPTIONS ...]
|
||||||
#
|
#
|
||||||
# Process INFILE using the C pre-processor and some other programs.
|
# Process INFILE using the C pre-processor and some other programs.
|
||||||
# Write output to a file, named OUTFILE if specified, or STEM.x if
|
# Write output to a file, named OUTFILE if specified, or STEM.x if
|
||||||
|
@ -32,14 +32,25 @@
|
||||||
# If there are errors during processing, delete OUTFILE and exit with
|
# If there are errors during processing, delete OUTFILE and exit with
|
||||||
# non-zero status.
|
# non-zero status.
|
||||||
#
|
#
|
||||||
# Optional arg "--compat=1.4" means emulate guile-1.4 guile-snarf.
|
# Optional arg "-d" means grep INFILE for deprecated macros and
|
||||||
# This option is easily misunderstood -- see Guile reference manual.
|
# issue a warning if any are found. Alternatively, "-D" means
|
||||||
|
# do the same thing but signal error and exit w/ non-zero status.
|
||||||
#
|
#
|
||||||
# If env var CPP is set, use its value instead of the C pre-processor
|
# If env var CPP is set, use its value instead of the C pre-processor
|
||||||
# determined at Guile configure-time: "@CPP@".
|
# determined at Guile configure-time: "@CPP@".
|
||||||
|
|
||||||
# Code:
|
# Code:
|
||||||
|
|
||||||
|
## config
|
||||||
|
|
||||||
|
deprecated_list="
|
||||||
|
SCM_CONST_LONG
|
||||||
|
SCM_VCELL
|
||||||
|
SCM_VCELL_INIT
|
||||||
|
SCM_GLOBAL_VCELL
|
||||||
|
SCM_GLOBAL_VCELL_INIT
|
||||||
|
"
|
||||||
|
|
||||||
## funcs
|
## funcs
|
||||||
|
|
||||||
modern_snarf () # writes stdout
|
modern_snarf () # writes stdout
|
||||||
|
@ -48,17 +59,19 @@ ${cpp} -DSCM_MAGIC_SNARF_INITS "$@" > ${temp} && cpp_ok_p=true
|
||||||
grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//"
|
grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//"
|
||||||
}
|
}
|
||||||
|
|
||||||
compat_mode_clean_xxx () # modifies $1
|
grep_deprecated () # $1 is the filename
|
||||||
{
|
{
|
||||||
filename=$1
|
regexp="(^greetings!spooks!hows!life)"
|
||||||
cp $filename ${temp}
|
for dep in `echo $deprecated_list` ; do
|
||||||
sed -e 's/SCM_CONST_LONG/SCM_GLOBAL_VCELL_INIT/g' \
|
regexp="(^${dep}[^_A-Z])|${regexp}"
|
||||||
-e 's/SCM_GLOBAL_VCELL_INIT/SCM_GLOBAL_VARIABLE_INIT/g' \
|
done
|
||||||
-e 's/SCM_GLOBAL_VCELL/SCM_GLOBAL_VARIABLE/g' \
|
egrep -n ${regexp} $1 /dev/null > ${temp}
|
||||||
-e 's/SCM_VCELL_INIT/SCM_VARIABLE_INIT/g' \
|
if [ -s ${temp} ] ; then
|
||||||
-e 's/SCM_VCELL/SCM_VARIABLE/g' \
|
if $grep_dep_exit_p ; then hey=ERROR ; else hey=WARNING ; fi
|
||||||
< ${temp} \
|
echo $0: $hey: deprecated macros found:
|
||||||
> $filename
|
sed -e 's/.clean.c:/:/g' ${temp}
|
||||||
|
$grep_dep_exit_p && exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## main
|
## main
|
||||||
|
@ -69,10 +82,10 @@ if [ x"$1" = x--help ] ; then
|
||||||
| sed -e 1,2d -e 's/^. *//g'
|
| sed -e 1,2d -e 's/^. *//g'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ x"$1" = x--compat=1.4 ]
|
case x"$1" in x-d) grep_dep_p=true ; grep_dep_exit_p=false ; shift ;;
|
||||||
then compat_mode_p=true ; shift
|
x-D) grep_dep_p=true ; grep_dep_exit_p=true ; shift ;;
|
||||||
else compat_mode_p=false
|
*) grep_dep_p=false ;;
|
||||||
fi
|
esac
|
||||||
if [ x"$1" = x-o ]
|
if [ x"$1" = x-o ]
|
||||||
then outfile=$2 ; shift ; shift ; infile=$1 ; shift
|
then outfile=$2 ; shift ; shift ; infile=$1 ; shift
|
||||||
else infile=$1 ; shift ; outfile=`basename $infile .c`.x
|
else infile=$1 ; shift ; outfile=`basename $infile .c`.x
|
||||||
|
@ -94,7 +107,9 @@ trap "rm -f $temp $clean_infile" 0 1 2 15
|
||||||
|
|
||||||
# clean input file
|
# clean input file
|
||||||
grep -v "$self_blind_regexp" $infile > $clean_infile
|
grep -v "$self_blind_regexp" $infile > $clean_infile
|
||||||
$compat_mode_p && compat_mode_clean_xxx $clean_infile
|
|
||||||
|
# grep deprecated
|
||||||
|
$grep_dep_p && grep_deprecated $clean_infile
|
||||||
|
|
||||||
# do the snarfing -- output something extra for needy cpp programs (AIX)
|
# do the snarfing -- output something extra for needy cpp programs (AIX)
|
||||||
{ echo "/* source: $infile */" ;
|
{ echo "/* source: $infile */" ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue