diff options
author | Michael Biebl <biebl@debian.org> | 2011-07-11 11:44:16 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2011-07-11 11:44:16 +0200 |
commit | 6b2af45bc8b2aa4292e3cf92986c01a728ef4d8c (patch) | |
tree | 15c4d4604294a232bf1126f969318ed659b2dc52 | |
parent | d5294b644649f563f4aa77735ebc6db6ee1776de (diff) | |
download | rsyslog-6b2af45bc8b2aa4292e3cf92986c01a728ef4d8c.tar.gz |
Imported Upstream version 5.8.3upstream/5.8.3
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rwxr-xr-x | configure | 22 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/log_rotation_fix_size.html | 2 | ||||
-rw-r--r-- | doc/manual.html | 2 | ||||
-rw-r--r-- | doc/rsyslog_conf_actions.html | 20 | ||||
-rw-r--r-- | doc/rsyslog_conf_output.html | 2 | ||||
-rw-r--r-- | doc/v4compatibility.html | 19 | ||||
-rw-r--r-- | plugins/imdiag/imdiag.c | 23 | ||||
-rw-r--r-- | rsyslog.service.in | 1 | ||||
-rw-r--r-- | runtime/rsyslog.h | 1 | ||||
-rwxr-xr-x | tests/diag.sh | 4 | ||||
-rw-r--r-- | tools/omfile.c | 17 | ||||
-rw-r--r-- | tools/omusrmsg.c | 4 | ||||
-rwxr-xr-x | ylwrap | 222 |
16 files changed, 321 insertions, 38 deletions
@@ -1,4 +1,12 @@ --------------------------------------------------------------------------- +Version 5.8.3 [V5-stable] (rgerhards), 2011-07-11 +- systemd support: set stdout/stderr to null - thx to Lennart for the patch +- added support for the ":omusrmsg:" syntax in configuring user messages +- added support for the ":omfile:" syntax in configuring user messages + Note: previous outchannel syntax will generate a warning message. This + may be surprising to some users, but it is quite urgent to alert them + of the new syntax as v6 can no longer support the previous one. +--------------------------------------------------------------------------- Version 5.8.2 [V5-stable] (rgerhards), 2011-06-21 - bugfix: problems in failover action handling closes: http://bugzilla.adiscon.com/show_bug.cgi?id=270 @@ -844,7 +852,11 @@ Version 4.7.0 [v4-devel] (rgerhards), 2010-04-14 Thanks for varmojfekoj for pointing me at this bug. - imported changes from 4.5.6 and below --------------------------------------------------------------------------- -Version 4.6.6 [v4-stable] (rgerhards), 2010-11-?? +Version 4.6.7 [v4-stable] (rgerhards), 2011-07-11 +- added support for the ":omusrmsg:" syntax in configuring user messages +- added support for the ":omfile:" syntax in configuring user messages +--------------------------------------------------------------------------- +Version 4.6.6 [v4-stable] (rgerhards), 2011-06-24 - bugfix: memory leak in imtcp & subsystems under some circumstances This leak is tied to error conditions which lead to incorrect cleanup of some data structures. [backport from v6, limited testing under v4] diff --git a/Makefile.in b/Makefile.in index b89c85b..d64cb83 100644 --- a/Makefile.in +++ b/Makefile.in @@ -82,7 +82,7 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING COPYING.LESSER \ ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \ - install-sh ltmain.sh missing + install-sh ltmain.sh missing ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/atomic_operations.m4 \ $(top_srcdir)/m4/atomic_operations_64bit.m4 \ @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.66 for rsyslog 5.8.2. +# Generated by GNU Autoconf 2.66 for rsyslog 5.8.3. # # Report bugs to <rsyslog@lists.adiscon.com>. # @@ -562,8 +562,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rsyslog' PACKAGE_TARNAME='rsyslog' -PACKAGE_VERSION='5.8.2' -PACKAGE_STRING='rsyslog 5.8.2' +PACKAGE_VERSION='5.8.3' +PACKAGE_STRING='rsyslog 5.8.3' PACKAGE_BUGREPORT='rsyslog@lists.adiscon.com' PACKAGE_URL='' @@ -1475,7 +1475,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures rsyslog 5.8.2 to adapt to many kinds of systems. +\`configure' configures rsyslog 5.8.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1545,7 +1545,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of rsyslog 5.8.2:";; + short | recursive ) echo "Configuration of rsyslog 5.8.3:";; esac cat <<\_ACEOF @@ -1591,7 +1591,7 @@ Optional Features: --enable-mysql-tests enable MySQL specific tests in testbench [default=no] --enable-mail Enable mail support [default=no] - --enable-imdiag Enable imdiag [default=yes] + --enable-imdiag Enable imdiag [default=no] --enable-relp Enable RELP support [default=no] --enable-rfc3195 Enable RFC3195 support [default=no] --enable-testbench testbench enabled [default=yes] @@ -1720,7 +1720,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -rsyslog configure 5.8.2 +rsyslog configure 5.8.3 generated by GNU Autoconf 2.66 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2299,7 +2299,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by rsyslog $as_me 5.8.2, which was +It was created by rsyslog $as_me 5.8.3, which was generated by GNU Autoconf 2.66. Invocation command line was $ $0 $@ @@ -3114,7 +3114,7 @@ fi # Define the identity of the package. PACKAGE='rsyslog' - VERSION='5.8.2' + VERSION='5.8.3' cat >>confdefs.h <<_ACEOF @@ -17336,7 +17336,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by rsyslog $as_me 5.8.2, which was +This file was extended by rsyslog $as_me 5.8.3, which was generated by GNU Autoconf 2.66. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -17402,7 +17402,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -rsyslog config.status 5.8.2 +rsyslog config.status 5.8.3 configured by $0, generated by GNU Autoconf 2.66, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 5873c66..427c0b0 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[5.8.2],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[5.8.3],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -772,7 +772,7 @@ AM_CONDITIONAL(ENABLE_MAIL, test x$enable_mail = xyes) # would complicate things if we first needed to tell them how to enable imdiag. # rgerhards, 2008-07-25 AC_ARG_ENABLE(imdiag, - [AS_HELP_STRING([--enable-imdiag],[Enable imdiag @<:@default=yes@:>@])], + [AS_HELP_STRING([--enable-imdiag],[Enable imdiag @<:@default=no@:>@])], [case "${enableval}" in yes) enable_imdiag="yes" ;; no) enable_imdiag="no" ;; diff --git a/doc/log_rotation_fix_size.html b/doc/log_rotation_fix_size.html index 190b24c..51edf03 100644 --- a/doc/log_rotation_fix_size.html +++ b/doc/log_rotation_fix_size.html @@ -34,7 +34,7 @@ Channels to achieve this. Putting the following directive</p> # outchannel definiation $outchannel log_rotation,/var/log/log_rotation.log, 52428800,/home/me/./log_rotation_script # activate the channel and log everything to it -*.* $log_rotation +*.* :omfile:$log_rotation # end log rotation via outchannel </pre></p> diff --git a/doc/manual.html b/doc/manual.html index db9eb90..2c13e27 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@ rsyslog support</a> available directly from the source!</p> <p><b>Please visit the <a href="http://www.rsyslog.com/sponsors">rsyslog sponsor's page</a> to honor the project sponsors or become one yourself!</b> We are very grateful for any help towards the project goals.</p> -<p><b>This documentation is for version 5.8.2 (stable branch) of rsyslog.</b> +<p><b>This documentation is for version 5.8.3 (v5-stable branch) of rsyslog.</b> Visit the <i><a href="http://www.rsyslog.com/status">rsyslog status page</a></i></b> to obtain current version information and project status. </p><p><b>If you like rsyslog, you might diff --git a/doc/rsyslog_conf_actions.html b/doc/rsyslog_conf_actions.html index 6020dd8..2e2293c 100644 --- a/doc/rsyslog_conf_actions.html +++ b/doc/rsyslog_conf_actions.html @@ -23,7 +23,7 @@ definition. If you do this, the action will be ignored.</p> more precisely a single filter of such a selector line). Each action must be on its own line and the line must start with an ampersand ('&') character and have no filters. An example would be</p> -<p><code><b>*.=crit rger<br> +<p><code><b>*.=crit :omusrmsg:rger<br> & root<br> & /var/log/critmsgs</b></code></p> <p>These three lines send critical messages to the user rger and @@ -32,7 +32,7 @@ actions per selector is</b> convenient and also <b>offers a performance benefit</b>. As the filter needs to be evaluated only once, there is less computation required to process the directive compared to the otherwise-equal config directives below:</p> -<p><code><b>*.=crit rger<br> +<p><code><b>*.=crit :omusrmsg:rger<br> *.=crit root<br> *.=crit /var/log/critmsgs</b></code></p> <p> </p> @@ -211,13 +211,19 @@ sysklogd,"<%PRI%>%TIMESTAMP% %syslogtag%%msg%\""<br> <h3>List of Users</h3> <p>Usually critical messages are also directed to "root'' on that machine. You can specify a list of users that shall get the -message by simply writing the login. You may specify more than one user -by separating them with commas (",''). If they're logged in they get -the message. Don't think a mail would be sent, that might be too late.</p> +message by simply writing ":omusrmsg: followed by the login name. For example, +the send messages to root, use ":omusrmsg:root". +You may specify more than one user +by separating them with commas (",''). Do not repeat the ":omusrmsg:" prefix in +this case. For example, to send data to users root and rger, use +":omusrmsg:root,rger" (do not use ":omusrmsg:root,:omusrmsg:rger", this is invalid). +If they're logged in they get +the message.</p> <h3>Everyone logged on</h3> <p>Emergency messages often go to all users currently online to notify them that something strange is happening with the system. To -specify this wall(1)-feature use an asterisk ("*'').</p> +specify this wall(1)-feature use an asterisk as the user message +destination(":omusrmsg:*'').</p> <h3>Call Plugin</h3> <p>This is a generic way to call an output plugin. The plugin must support this functionality. Actual parameters depend on the @@ -331,7 +337,7 @@ what you can do with it, see "TEMPLATES" at the top of this document.</p> [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p> <p><font size="2">This documentation is part of the <a href="http://www.rsyslog.com/">rsyslog</a> project.<br> -Copyright © 2008 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and +Copyright © 2008-2011 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and <a href="http://www.adiscon.com/">Adiscon</a>. Released under the GNU GPL version 2 or higher.</font></p> </body> diff --git a/doc/rsyslog_conf_output.html b/doc/rsyslog_conf_output.html index c52aaa5..426f2f2 100644 --- a/doc/rsyslog_conf_output.html +++ b/doc/rsyslog_conf_output.html @@ -49,7 +49,7 @@ does not activate it. To do so, you must use a selector line (see below). That selector line includes the channel name plus an $ sign in front of it. A sample might be:<br> <br> -*.* $mychannel<br> +*.* :omfile:$mychannel<br> <br> In its current form, output channels primarily provide the ability to size-limit an output file. To do so, specify a maximum size. When this diff --git a/doc/v4compatibility.html b/doc/v4compatibility.html index 5d877af..72b0f5a 100644 --- a/doc/v4compatibility.html +++ b/doc/v4compatibility.html @@ -74,4 +74,23 @@ So it is a good idea to become ready for the new version now and also enjoy some benefits of the "real restart", like the better error-reporting capability. <p>Note that code complexity reduction (and thus performance improvement) needs the restart-type HUP code to be removed, so these changes can (and will) only happen in version 5. +<h2>outchannels</h2> +Note: as always documented, outchannels are an experimental feature that may be +removed and/or changed in the future. +There is one concrete change done starting with 4.6.7: let's assume an +outchannel "mychannel" was defined. Then, this channel could be used inside an +<code> +*.* $mychannel +</code> +This is still supported and will remain to be supported in v4. However, there is +a new variant which explicitely tells this is to be handled by omfile. This new +syntax is as follows: +<code> +*.* :omfile:$mychannel +</code> +Note that future versions, specifically starting with v6, the older syntax is no +longer supported. So users are strongly advised to switch to the new syntax. As an +aid to the conversion process, rsyslog 4.7.4 and above issue a warning message +if the old-style directive is seen -- but still accept the old syntax without +any problems. </body></html> diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c index ed6ef50..912c7bb 100644 --- a/plugins/imdiag/imdiag.c +++ b/plugins/imdiag/imdiag.c @@ -255,6 +255,8 @@ finalize_it: /* This function waits until the main queue is drained (size = 0) + * To make sure it really is drained, we check three times. Otherwise we + * may just see races. */ static rsRetVal waitMainQEmpty(tcps_sess_t *pSess) @@ -264,19 +266,22 @@ waitMainQEmpty(tcps_sess_t *pSess) DEFiRet; CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize)); - while(iMsgQueueSize > 0) { - /* DEV DEBUG ONLY if(iPrint++ % 500) - printf("imdiag: main msg queue size: %d\n", iMsgQueueSize); - */ - if(iPrint++ % 500 == 0) - dbgprintf("imdiag sleeping, wait mainq drain, curr size %d\n", iMsgQueueSize); - srSleep(0,2); /* wait a little bit */ - CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize)); + while(1) { if(iMsgQueueSize == 0) { /* verify that queue is still empty (else it could just be a race!) */ - srSleep(1,5); /* wait a little bit */ + srSleep(0,250000);/* wait a little bit */ CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize)); + if(iMsgQueueSize == 0) { + srSleep(0,500000);/* wait a little bit */ + CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize)); + } } + if(iMsgQueueSize == 0) + break; + if(iPrint++ % 500 == 0) + dbgprintf("imdiag sleeping, wait mainq drain, curr size %d\n", iMsgQueueSize); + srSleep(0,200000);/* wait a little bit */ + CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize)); } CHKiRet(sendResponse(pSess, "mainqueue empty\n")); diff --git a/rsyslog.service.in b/rsyslog.service.in index 898354d..c03c900 100644 --- a/rsyslog.service.in +++ b/rsyslog.service.in @@ -5,6 +5,7 @@ Description=System Logging Service ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service ExecStart=@sbindir@/rsyslogd -n -c5 Sockets=syslog.socket +StandardOutput=null [Install] WantedBy=multi-user.target diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 52b29ac..f14e072 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -343,6 +343,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth RS_RET_FILE_NOT_SPECIFIED = -2180, /**< file name not configured where this was required */ RS_RET_ERR_WRKDIR = -2181, /**< problems with the rsyslog working directory */ RS_RET_WRN_WRKDIR = -2182, /**< correctable problems with the rsyslog working directory */ + RS_RET_OUTDATED_STMT = -2184, /**< some outdated statement/functionality is being used in conf file */ /* RainerScript error messages (range 1000.. 1999) */ RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */ diff --git a/tests/diag.sh b/tests/diag.sh index 617118b..3e0263c 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -20,7 +20,7 @@ case $1 in rm -f rsyslogd.started work-*.conf rsyslog.random.data rm -f rsyslogd2.started work-*.conf rm -f work rsyslog.out.log rsyslog2.out.log rsyslog.out.log.save # common work files - rm -rf test-spool test-logdir + rm -rf test-spool test-logdir stat-file1 rm -f rsyslog.out.*.log work-presort rsyslog.pipe rm -f rsyslog.input rsyslog.empty rm -f core.* vgcore.* @@ -29,7 +29,7 @@ case $1 in 'exit') rm -f rsyslogd.started work-*.conf diag-common.conf rm -f rsyslogd2.started diag-common2.conf rsyslog.action.*.include rm -f work rsyslog.out.log rsyslog2.out.log rsyslog.out.log.save # common work files - rm -rf test-spool test-logdir + rm -rf test-spool test-logdir stat-file1 rm -f rsyslog.out.*.log rsyslog.random.data work-presort rsyslog.pipe rm -f rsyslog.input stat-file1 #rsyslog.empty echo ------------------------------------------------------------------------------- diff --git a/tools/omfile.c b/tools/omfile.c index 08f965b..150848e 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -16,7 +16,7 @@ * pipes. These have been moved to ompipe, to reduced the entanglement * between the two different functionalities. -- rgerhards * - * Copyright 2007-2009 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2011 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -713,6 +713,21 @@ ENDdoAction BEGINparseSelectorAct CODESTARTparseSelectorAct + /* Note: the indicator sequence permits us to use '$' to signify + * outchannel, what otherwise is not possible due to truely + * unresolvable grammar conflicts (*this time no way around*). + * rgerhards, 2011-07-09 + */ + if(!strncmp((char*) p, ":omfile:", sizeof(":omfile:") - 1)) { + p += sizeof(":omfile:") - 1; + } else { + if(*p == '$') { + errmsg.LogError(0, RS_RET_OUTDATED_STMT, + "action '%s' treated as ':omfile:%s' - please " + "change syntax, '%s' will not be supported in " + "rsyslog v6 and above.", p, p, p); + } + } if(!(*p == '$' || *p == '?' || *p == '/' || *p == '.' || *p == '-')) ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED); diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index 2d99c1e..c737454 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -279,7 +279,9 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * [a-zA-Z0-9_.] * plus '*' for wall */ - if(!*p || !((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') + if(!strncmp((char*) p, ":omusrmsg:", sizeof(":omusrmsg:") - 1)) { + p += sizeof(":omusrmsg:") - 1; /* eat indicator sequence (-1 because of '\0'!) */ + } else if(!*p || !((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_' || *p == '.' || *p == '*')) ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED); @@ -0,0 +1,222 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. + +scriptversion=2009-04-28.21; # UTC + +# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, +# 2007, 2009 Free Software Foundation, Inc. +# +# Written by Tom Tromey <tromey@cygnus.com>. +# +# 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, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +case "$1" in + '') + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 + ;; + --basedir) + basedir=$2 + shift 2 + ;; + -h|--h*) + cat <<\EOF +Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... + +Wrapper for lex/yacc invocations, renaming files as desired. + + INPUT is the input file + OUTPUT is one file PROG generates + DESIRED is the file we actually want instead of OUTPUT + PROGRAM is program to run + ARGS are passed to PROG + +Any number of OUTPUT,DESIRED pairs may be used. + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v|--v*) + echo "ylwrap $scriptversion" + exit $? + ;; +esac + + +# The input. +input="$1" +shift +case "$input" in + [\\/]* | ?:[\\/]*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. + input="`pwd`/$input" + ;; +esac + +pairlist= +while test "$#" -ne 0; do + if test "$1" = "--"; then + shift + break + fi + pairlist="$pairlist $1" + shift +done + +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog="`pwd`/$prog" ;; +esac + +# 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 + +case $# in + 0) "$prog" "$input" ;; + *) "$prog" "$@" "$input" ;; +esac +ret=$? + +if test $ret -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 + + # The directory holding the input. + input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` + # Quote $INPUT_DIR so we can use it in a regexp. + # FIXME: really we should care about more than `.' and `\'. + input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` + + 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 + [\\/]* | ?:[\\/]*) target="$2";; + *) target="../$2";; + esac + + # We do not want to overwrite a header file if it hasn't + # changed. This avoid useless recompilations. However the + # parser itself (the first file) should always be updated, + # because it is the destination of the .y.c rule in the + # Makefile. Divert the output of all other files to a temporary + # file so we can compare them to existing versions. + if test $first = no; then + realtarget="$target" + target="tmp-`echo $target | sed s/.*[\\/]//g`" + fi + # 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. + # + # We want to use the real output file name, not yy.lex.c for + # instance. + # + # We want the include guards to be adjusted too. + FROM=`echo "$from" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + + sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ + -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? + + # Check whether header files must be updated. + if test $first = no; then + if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then + echo "$2" is unchanged + rm -f "$target" + else + echo updating "$2" + mv -f "$target" "$realtarget" + fi + fi + 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 + ret=1 + fi + fi + shift + shift + first=no + done +else + ret=$? +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: |