bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sieve: some corrections


From: Sergey Poznyakoff
Subject: sieve: some corrections
Date: Mon, 11 Jun 2001 11:44:14 +0300

Bonjour,

Maybe the following changes would allow to better integrate sieve
in the project. The patch below addresses the following:

  1. configure.in: AC_PROG_YACC and AM_PROG_LEX are needed.
  2. sieve/Makefile.am:
   * It seems unwise to list `test' in bin_PROGRAMS, its name
     coincides with the shell command and will thus cause problems
     when the packet is configured with --prefix=/
   * Header files were not listed in any of the _SOURCES and thus
     did not get distributed.
   * Use of slightly modified ylwrap scripts facilitates inclusion
     of multiple grammars/lexers in a program.
  3. sieve/sieve.c: EOK is not defined on some systems.

Some words about ylwrap: it is a modified version of the wrapper from
automake-1.4, it differs from the standard one in that it accepts an
optional switch -yy repl which allows to replace yy.* identifiers in
a uniform way, whether system's yacc/lex support -p feature or no. The
text of ylwrap follows the patches. It is supposed that ylwrap lives
in sieve subdirectory.


Cheers,
Sergey

Index: Makefile.am
===================================================================
RCS file: /cvs/mailutils/Makefile.am,v
retrieving revision 1.18
diff -p -u -w -b -r1.18 Makefile.am
--- Makefile.am 2001/04/16 02:26:31     1.18
+++ Makefile.am 2001/06/11 08:16:02
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4
 ACLOCAL_AMFLAGS = -I m4
 
 # imap4d
-SUBDIRS = include doc m4 lib argp mailbox frm from pop3d imap4d mail
+SUBDIRS = include doc m4 lib argp mailbox frm from pop3d imap4d mail sieve
 
 EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL
 
Index: configure.in
===================================================================
RCS file: /cvs/mailutils/configure.in,v
retrieving revision 1.48
diff -p -u -w -b -r1.48 configure.in
--- configure.in        2001/05/28 14:22:44     1.48
+++ configure.in        2001/06/11 08:16:03
@@ -8,6 +8,8 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AM_PROG_LIBTOOL
+AC_PROG_YACC
+AM_PROG_LEX
 
 dnl Check for arguments
 AC_ARG_ENABLE(pam,
@@ -162,4 +164,4 @@ dnl Output Makefiles
 AC_OUTPUT(Makefile mailutils.spec include/Makefile include/mailutils/Makefile
  m4/Makefile doc/Makefile argp/Makefile lib/Makefile mailbox/Makefile
  imap4d/Makefile mailbox/include/Makefile from/Makefile mail/Makefile
- pop3d/Makefile frm/Makefile)
+ pop3d/Makefile frm/Makefile sieve/Makefile)
Index: sieve/Makefile.am
===================================================================
RCS file: /cvs/mailutils/sieve/Makefile.am,v
retrieving revision 1.1
diff -p -u -w -b -r1.1 Makefile.am
--- sieve/Makefile.am   2001/06/08 01:07:29     1.1
+++ sieve/Makefile.am   2001/06/11 08:16:09
@@ -1,16 +1,20 @@
 CFLAGS = -Wall -pedantic -g -DTESTING
 INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/lib
+YLWRAP = $(SHELL) $(srcdir)/ylwrap
+YFLAGS = -d
+
+BUILT_SOURCES=sieve-gram.c sieve-gram.h \
+              sieve-lex.c addr-lex.c \
+              addr.c addr.h
 
 MOSTLYCLEANFILES=
 CLEANFILES=
 DISTCLEANFILES=
-MAINTAINERCLEANFILES=\
-  sieve-gram.c sieve-gram.h \
-  sieve-lex.c \
-  addr-lex.c \
-  addr.c addr.h
+MAINTAINERCLEANFILES=$(BUILT_SOURCES)
+EXTRA_DIST = $(BUILT_SOURCES)
 
-bin_PROGRAMS = test sieve
+bin_PROGRAMS = sieve
+noinst_PROGRAMS = test
 
 SRC = \
   addr-lex.c \
@@ -30,6 +34,25 @@ SRC = \
   util.c \
   xmalloc.c
 
+HDR = \
+  comparator.h \
+  exitcodes.h \
+  hmac-md5.h \
+  imparse.h \
+  interp.h \
+  md5.h \
+  md5global.h \
+  message.h \
+  parseaddr.h \
+  script.h \
+  sieve_err.h \
+  sieve_interface.h \
+  svfield.h \
+  sysexits.h \
+  tree.h \
+  util.h \
+  xmalloc.h 
+
 test_DEPENDENCIES =
 test_LDADD =
 test_SOURCES = \
@@ -41,27 +64,23 @@ sieve_DEPENDENCIES = ../mailbox/libmailb
 sieve_LDADD = ../mailbox/libmailbox.la ../lib/libmailutils.a
 sieve_SOURCES = \
   sieve.c \
-  ${SRC}
-
-YACC = bison -y
-YFLAGS = -d
-LEX = flex
-
-addr-lex.c: addr-lex.l addr.h
-       $(LEX) -t -Paddr addr-lex.l > $@
+  ${SRC} $(HDR)
 
-addr.c addr.h: addr.y
-       $(YACC) $(YFLAGS) -p addr addr.y
-       mv -f y.tab.c addr.c
-       mv -f y.tab.h addr.h
-
-sieve-lex.c: sieve-lex.l sieve-gram.h
-       $(LEX) -t sieve-lex.l > $@
-
-sieve-gram.c sieve-gram.h: sieve-gram.y
-       $(YACC) $(YFLAGS) sieve-gram.y
-       mv -f y.tab.c sieve-gram.c
-       mv -f y.tab.h sieve-gram.h
+addr-lex.c: $(srcdir)/addr-lex.l addr.h
+       $(YLWRAP) "$(LEX)" $(srcdir)/addr-lex.l lex.yy.c \
+                  addr-lex.c -- -yy addr
+
+addr.c addr.h: $(srcdir)/addr.y
+       $(YLWRAP) "$(YACC) $(YFLAGS)" $(srcdir)/addr.y \
+                  y.tab.c addr.c y.tab.h addr.h \
+                  -- -yy addr
+
+sieve-lex.c: $(srcdir)/sieve-lex.l sieve-gram.h
+       $(YLWRAP) "$(LEX)" $(srcdir)/sieve-lex.l lex.yy.c sieve-lex.c 
+
+sieve-gram.c sieve-gram.h: $(srcdir)/sieve-gram.y
+       $(YLWRAP) "$(YACC) $(YFLAGS)" $(srcdir)/sieve-gram.y \
+                 y.tab.c sieve-gram.c y.tab.h sieve-gram.h 
 
 comparator.o: sieve-gram.h
 script.o: sieve-gram.h
Index: sieve/sieve.c
===================================================================
RCS file: /cvs/mailutils/sieve/sieve.c,v
retrieving revision 1.1
diff -p -u -w -b -r1.1 sieve.c
--- sieve/sieve.c       2001/06/08 01:07:29     1.1
+++ sieve/sieve.c       2001/06/11 08:16:10
@@ -29,6 +29,10 @@
 
 #include "svfield.h"
 
+#ifndef EOK
+# define EOK 0
+#endif
+
 /** utility wrappers around mailutils functionality **/
 
 int
----End of patches -------

#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
# Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
# Written by Tom Tromey <address@hidden>.
# -yy modification by Sergey Poznyakoff <address@hidden>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Usage:
#     ylwrap PROGRAM [ARGS] INPUT [OUTPUT DESIRED]... -- [-yy repl] [ARGS]...
# * PROGRAM is program to run; options can follow but must start with `-'.
# * INPUT is the input file
# * OUTPUT is file PROG generates
# * DESIRED is file we actually want
# * ARGS are passed to PROG
# * Optional -yy introduces the sequence to replace yy prefixes with.
# Any number of OUTPUT,DESIRED pairs may be used.

# The program to run.
prog="$1"
shift
# Make any relative path in $prog absolute.
case "$prog" in
 /* | [A-Za-z]:*) ;;
 */*) prog="`pwd`/$prog" ;;
esac

# We also have to accept options here and append them to the program.
# Why?  Suppose YACC is set to `bison -y'.  Clearly nobody uses
# ylwrap, or this would have been discovered earlier!
while :; do
   case "$1" in
    -*)
       prog="$prog $1"
       shift
       ;;
    *)
       break
       ;;
   esac
done

# The input.
input="$1"
shift
case "$input" in
 /* | [A-Za-z]:*)
    # Absolute path; do nothing.
    ;;
 *)
    # Relative path.  Make it absolute.
    input="`pwd`/$input"
    ;;
esac

# The directory holding the input.
input_dir="`echo $input | sed -e 's,/[^/]*$,,'`"
# Quote $INPUT_DIR so we can use it in a regexp.
# FIXME: really we should care about more than `.'.
input_rx="`echo $input_dir | sed -e 's,\.,\\\.,g'`"

pairlist=
while test "$#" -ne 0; do
   if test "$1" = "--"; then
      shift
      break
   fi
   pairlist="$pairlist $1"
   shift
done

if [ $# -ne 0 ]; then
    if [ "x$1" = "x-yy" ]; then
        shift
        if [ $# -eq 0 ]; then 
                echo "ylwrap: -yy requires an argument"
                exit 1 
        fi
        YYREPL=$1
        shift
    fi
fi    

# FIXME: add hostname here for parallel makes that run commands on
# other machines.  But that might take us over the 14-char limit.
dirname=ylwrap$$
trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
mkdir $dirname || exit 1

cd $dirname

$prog ${1+"$@"} "$input"
status=$?

if test $status -eq 0; then
   set X $pairlist
   shift
   first=yes
   # Since DOS filename conventions don't allow two dots,
   # the DOS version of Bison writes out y_tab.c instead of y.tab.c
   # and y_tab.h instead of y.tab.h. Test to see if this is the case.
   y_tab_nodot="no"
   if test -f y_tab.c || test -f y_tab.h; then
      y_tab_nodot="yes"
   fi

   while test "$#" -ne 0; do
      from="$1"
      # Handle y_tab.c and y_tab.h output by DOS
      if test $y_tab_nodot = "yes"; then
         if test $from = "y.tab.c"; then
            from="y_tab.c"
         else
            if test $from = "y.tab.h"; then
               from="y_tab.h"
            fi
         fi
      fi
      if test -f "$from"; then
         # If $2 is an absolute path name, then just use that,
         # otherwise prepend `../'.
         case "$2" in
           /* | [A-Za-z]:*) target="$2";;
           *) target="../$2";;
         esac

         # Edit out `#line' or `#' directives.  We don't want the
         # resulting debug information to point at an absolute srcdir;
         # it is better for it to just mention the .y file with no
         # path.
         EXPR="/^#/ s,$input_rx/,,"
         if [ ! -z "$YYREPL" ]; then
            EXPR="$EXPR;s/yy/$YYREPL/g"
         fi
         sed -e "$EXPR" "$from" > "$target" || status=$?
      else
         # A missing file is only an error for the first file.  This
         # is a blatant hack to let us support using "yacc -d".  If -d
         # is not specified, we don't want an error when the header
         # file is "missing".
         if test $first = yes; then
            status=1
         fi
      fi
      shift
      shift
      first=no
   done
else
   status=$?
fi

# Remove the directory.
cd ..
rm -rf $dirname

exit $status



reply via email to

[Prev in Thread] Current Thread [Next in Thread]