/[guile]/guile/guile-core/libguile/guile-snarf.in
ViewVC logotype

Diff of /guile/guile-core/libguile/guile-snarf.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by mvo, Wed Apr 17 17:44:28 2002 UTC revision 1.22 by mvo, Sat Aug 24 00:53:44 2002 UTC
# Line 20  Line 20 
20    
21  # Commentary:  # Commentary:
22    
23  # Usage: guile-snarf [-d | -D] [-o OUTFILE] INFILE [CPP-OPTIONS ...]  # Usage: guile-snarf [-o OUTFILE] [CPP-ARGS ...]
24  #  
25  # Process INFILE using the C pre-processor and some other programs.  # Initialization actions are extracted to OUTFILE or to standard
26  # Write output to a file named OUTFILE or to the standard output when no  # output when no OUTFILE has been specified or when OUTFILE is "-".
27  # OUTFILE has been specified or when OUTFILE is "-".  # The C preprocessor is called with CPP-ARGS (which usually include a
28  #  # input file) and the output is filtered for the actions.
29  # If there are errors during processing, delete OUTFILE and exit with  #
30  # non-zero status.  # If there are errors during processing, OUTFILE is deleted and the
31  #  # program exits with non-zero status.
32    #
33  # During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is  # During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is
34  # defined.  # defined.  You can use this to avoid including snarfer output files
35  #  # that don't yet exist by writing code like this:
36  # Optional arg "-d" means grep INFILE for deprecated macros and  #
37  # issue a warning if any are found.  Alternatively, "-D" means  #   #ifndef SCM_MAGIC_SNARFER
38  # do the same thing but signal error and exit w/ non-zero status.  #   #include "foo.x"
39  #  #   #endif
40  # If env var CPP is set, use its value instead of the C pre-processor  #
41  # determined at Guile configure-time: "@CPP@".  # If the environment variable CPP is set, use its value instead of the
42    # C pre-processor determined at Guile configure-time: "@CPP@".
43    
44  # Code:  # Code:
45    
 ## config  
   
 deprecated_list="  
  SCM_CONST_LONG  
  SCM_VCELL  
  SCM_VCELL_INIT  
  SCM_GLOBAL_VCELL  
  SCM_GLOBAL_VCELL_INIT  
 "  
   
46  ## funcs  ## funcs
47    
48  modern_snarf ()                         # writes stdout  modern_snarf ()                         # writes stdout
49  {  {
50      ## Apparently, AIX's preprocessor is unhappy if you try to #include an      ## Apparently, AIX's preprocessor is unhappy if you try to #include an
51      ## empty file.      ## empty file.
     echo "/* source: $infile */" ;  
52      echo "/* cpp arguments: $@ */" ;      echo "/* cpp arguments: $@ */" ;
53      ${cpp} -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp} && cpp_ok_p=true      ${cpp} -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp} && cpp_ok_p=true
54      grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//" -e "s/\^\ *:\ *\^.*/;/"      grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//" -e "s/\^\ *:\ *\^.*/;/"
55  }  }
56    
 grep_deprecated ()                      # $1 is the filename  
 {  
 regexp="(^greetings!spooks!hows!life)"  
 for dep in `echo $deprecated_list` ; do  
     regexp="(^${dep}[^_A-Z])|${regexp}"  
 done  
 egrep -n ${regexp} $1 /dev/null > ${temp}  
 if [ -s ${temp} ] ; then  
     if $grep_dep_exit_p ; then hey=ERROR ; else hey=WARNING ; fi  
     echo $0: $hey: deprecated macros found:  
     sed -e 's/.clean.c:/:/g' ${temp}  
     $grep_dep_exit_p && exit 1  
 fi  
 }  
   
57  ## main  ## main
58    
59  # process command line  # process command line
# Line 86  if [ x"$1" = x--help ] ; then Line 62  if [ x"$1" = x--help ] ; then
62          | sed -e 1,2d -e 's/^. *//g'          | sed -e 1,2d -e 's/^. *//g'
63      exit 0      exit 0
64  fi  fi
 case x"$1" in x-d) grep_dep_p=true ; grep_dep_exit_p=false ; shift ;;  
               x-D) grep_dep_p=true ; grep_dep_exit_p=true  ; shift ;;  
               *)   grep_dep_p=false                                ;;  
 esac  
65  if [ x"$1" = x-o ]  if [ x"$1" = x-o ]
66      then outfile=$2 ; shift ; shift ; infile=$1 ; shift      then outfile="$2" ; shift ; shift ;
67      else outfile="-"; infile=$1 ; shift      else  outfile="-" ;
68  fi  fi
69    
 [ x"$infile" = x ] && { echo $0: No input file ; exit 1 ; }  
 [ ! -f "$infile" ] && { echo $0: No such file: $infile ; exit 1 ; }  
   
70  # set vars and handler -- handle CPP override  # set vars and handler -- handle CPP override
71  cpp_ok_p=false  cpp_ok_p=false
72  temp="/tmp/snarf.$$"  temp="/tmp/snarf.$$"
# Line 105  if [ x"$CPP" = x ] ; then cpp="@CPP@" ; Line 74  if [ x"$CPP" = x ] ; then cpp="@CPP@" ;
74    
75  trap "rm -f $temp" 0 1 2 15  trap "rm -f $temp" 0 1 2 15
76    
77  if [ ! "$outfile" = "-" ]; then  if [ ! "$outfile" = "-" ] ; then
78      modern_snarf "$@" $infile > $outfile      modern_snarf "$@" > $outfile
79  else  else
80      modern_snarf "$@" $infile      modern_snarf "$@"
81  fi  fi
82    
 # grep deprecated  
 $grep_dep_p && grep_deprecated $infile  
   
83  # zonk outfile if errors occurred  # zonk outfile if errors occurred
84  if $cpp_ok_p ; then  if $cpp_ok_p ; then
85      exit 0      exit 0

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26