aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-24 14:14:47 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-24 14:27:11 +0300
commitc047ed856d6d23137ef1df01c1297db36bad3f8c (patch)
tree1999db947cb5e38df8a85d314daa0eef7c7624d0
parent07ea006a31def46ba6ea936dbea366219152d9b6 (diff)
downloadwydawca-c047ed856d6d23137ef1df01c1297db36bad3f8c.tar.gz
wydawca-c047ed856d6d23137ef1df01c1297db36bad3f8c.tar.bz2
Use wordsplit to expand variables in strings.
* NEWS: Raise version number. * configure.ac: Link wydawca.h to include/wydawca Raise version number * doc/wydawca.texi: Document changes. * etc/wydawca.rc: Fix the syntax. * grecs: Upgrace. * include/wydawca/wydawca.h (wy_vlog): New proto. (wy_log, wy_dbg): Format is const char *. (wy_triplet_t): Change typedef. (wy_metadef): Remove struct. (wy_vardef): New struct. (wy_triplet_expand_param) (wy_expand_copy): New protos. * modules/logstat/mod_logstat.c: Update. * modules/mailutils/Makefile.am (AM_CPPFLAGS): Modify, * modules/mailutils/mod_mailutils.c: Update. * src/Makefile.am (wydawca_SOURCES): Remove meta.c * src/dictionary.c: Fix comment. * src/directive.c (directive_get_value): Triplet pointer is const. * src/meta.c: Remove. * src/timer.c: (timer_fill_meta) (timer_free_meta): Remove. * src/triplet.c: Use wordsplit for expansions. * src/wydawca.c (wy_vlog): New function. (wy_stat_expansion): New function. * src/wydawca.h: Remove metadef protos. * tests/etc/notify.rcin: Update variable reference syntax.
-rw-r--r--NEWS57
-rw-r--r--configure.ac3
-rw-r--r--doc/wydawca.texi156
-rw-r--r--etc/wydawca.rc25
m---------grecs0
-rw-r--r--include/wydawca/wydawca.h30
-rw-r--r--modules/logstat/mod_logstat.c4
-rw-r--r--modules/mailutils/Makefile.am1
-rw-r--r--modules/mailutils/mod_mailutils.c64
-rw-r--r--src/Makefile.am1
-rw-r--r--src/dictionary.c2
-rw-r--r--src/directive.c2
-rw-r--r--src/meta.c191
-rw-r--r--src/timer.c52
-rw-r--r--src/triplet.c603
-rw-r--r--src/wydawca.c54
-rw-r--r--src/wydawca.h15
-rw-r--r--tests/etc/notify.rcin16
18 files changed, 615 insertions, 661 deletions
diff --git a/NEWS b/NEWS
index d99ce47..b73895b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,62 @@
1Wydawca NEWS -- history of user-visible changes. 2019-07-22 1Wydawca NEWS -- history of user-visible changes. 2019-07-24
2See the end of file for copying conditions. 2See the end of file for copying conditions.
3 3
4Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. 4Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>.
5
6Version 3.0.90 (git)
7
8* Variable expansion syntax
9
10This release uses wordsplit v1.0-9-g7eaa3c4. Normal shell like
11expansion is allowed. This means that curly braces around variable
12names are optional and that the following forms are now allowed:
13
14${VARIABLE:-WORD}
15 "Use Default Values". If VARIABLE is unset or null, the
16 expansion of WORD is substituted. Otherwise, the value of
17 VARIABLE is substituted.
18
19${VARIABLE:=WORD}
20 "Assign Default Values". If VARIABLE is unset or null, the
21 expansion of WORD is assigned to variable. The value of
22 VARIABLE is then substituted.
23
24 The assigned value remains in effet during expansion of the
25 current string.
26
27${VARIABLE:?WORD}
28 "Display Error if Null or Unset". If VARIABLE is null or
29 unset, the expansion of WORD (or a message to that effect if
30 WORD is not present) is output to the current logging channel.
31 Otherwise, the value of VARIABLE is substituted.
32
33${VARIABLE:+WORD}
34 "Use Alternate Value". If VARIABLE is null or unset, nothing
35 is substituted, otherwise the expansion of WORD is
36 substituted.
37
38* Handling of undefined variables
39
40Attempt to expand undefined variable causes fatal error. Use one of
41the advanced forms described above to handle such cases gracefully.
42
43* Variable names
44
45Several variable names have changed. Names that contained dash,
46now use underscore instead. These are:
47
48 Old name Use this instead
49 ------------------- -------------------
50 stat:check-failures stat:check_failures
51 dest-dir dest_dir
52 source-dir source_dir
53 user:real-name user:real_name
54
55* $- is gone
56
57Trailing newlines are automatically removed from all variable
58expansions. Consequently, the $- marker (delete to the end of line)
59has been removed.
5 60
6 61
7Version 3.0, 2019-07-22 62Version 3.0, 2019-07-22
diff --git a/configure.ac b/configure.ac
index 2eb680f..6a46de6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
15# along with wydawca. If not, see <http://www.gnu.org/licenses/>. 15# along with wydawca. If not, see <http://www.gnu.org/licenses/>.
16 16
17AC_PREREQ(2.63) 17AC_PREREQ(2.63)
18AC_INIT([wydawca], 3.0, [bug-wydawca@gnu.org.ua], [wydawca], 18AC_INIT([wydawca], 3.0.90, [bug-wydawca@gnu.org.ua], [wydawca],
19 [http://www.gnu.org.ua/software/wydawca]) 19 [http://www.gnu.org.ua/software/wydawca])
20AC_CONFIG_SRCDIR([src/wydawca.c]) 20AC_CONFIG_SRCDIR([src/wydawca.c])
21AC_CONFIG_AUX_DIR([build-aux]) 21AC_CONFIG_AUX_DIR([build-aux])
@@ -148,6 +148,7 @@ AM_CONDITIONAL([COND_INOTIFY],[test $status_inotify = yes])
148 148
149GRECS_SETUP([grecs],[tree-api git2chg getopt tests shared install-headers 149GRECS_SETUP([grecs],[tree-api git2chg getopt tests shared install-headers
150 std-pp-setup]) 150 std-pp-setup])
151AC_CONFIG_LINKS(include/wydawca/wordsplit.h:grecs/wordsplit/wordsplit.h)
151 152
152AH_BOTTOM([ 153AH_BOTTOM([
153#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 154#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 2763b6d..8950987 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -728,52 +728,68 @@ example above:
728@end group 728@end group
729@end smallexample 729@end smallexample
730 730
731@anchor{meta-interpretation} 731@anchor{variable expansion}
732@cindex meta-interpretation 732@cindex variable expansion
733@cindex meta-variables 733@cindex variables
734Depending on the context, the contents of a quoted string may be 734Depending on the context, the quoted string may be subject to
735subject to @dfn{meta-variable interpretation}. During this process, 735@dfn{variable expansion}.
736any sequence
737 736
738@smallexample 737During variable expansion, references to variables
739$@{@var{var}@} 738in the string are replaced with their actual values. A variable
740@end smallexample 739reference has two basic forms:
741 740
742@noindent 741@example
743where @var{var} is the name of a defined meta-variable, is replaced with 742 $@var{v}
744the value of the variable. This sequence is called @dfn{meta- 743 $@{@var{v}@}
745reference}. For example, if the meta-variable @samp{user} has the 744@end example
746value @samp{smith}, then the string
747
748@smallexample
749"where user = '$@{user@}'"
750@end smallexample
751 745
752@noindent 746@noindent
753becomes 747where @var{v} is the variable name. The notation in curly braces
748serves several purposes. First, it should be used if the variable
749reference is immediately followed by an alphanumeric symbol, which
750will otherwise be considered part of it (as in @samp{$@{home@}dir}).
751Secondly, this form allows for specifying the action to take if the
752variable is undefined or expands to an empty value.
754 753
755@smallexample 754The following special forms are recognized:
756"where user = 'smith'"
757@end smallexample
758
759If the name of the variable consists of a single character, the curly
760braces around it may be omitted. Thus, @code{$@{u@}} and @code{$u} are
761equivalent.
762 755
763If @var{var} is not defined, the meta-reference is left unchanged. 756@table @asis
757@item $@{@var{variable}:-@var{word}@}
758@dfn{Use Default Values}. If @var{variable} is unset or null, the expansion
759of @var{word} is substituted. Otherwise, the value of @var{variable} is
760substituted.
761
762@item $@{@var{variable}:=@var{word}@}
763@dfn{Assign Default Values}. If @var{variable} is unset or null, the
764expansion of @var{word} is assigned to variable. The value of
765@var{variable} is then substituted.
766
767The assigned value remains in effet during expansion of the current string.
768
769@item $@{@var{variable}:?@var{word}@}
770@dfn{Display Error if Null or Unset}. If @var{variable} is null or unset,
771the expansion of @var{word} (or a message to that effect if @var{word} is
772not present) is output to the current logging channel. Otherwise, the
773value of @var{variable} is substituted.
774
775@item $@{@var{variable}:+@var{word}@}
776@dfn{Use Alternate Value}. If @var{variable} is null or unset, nothing is
777substituted, otherwise the expansion of @var{word} is substituted.
778@end table
764 779
765The special sequence @samp{$-} causes removal of it and any character 780These constructs test for a variable that is unset or null. Omitting
766following it. Most often it is used as a next-to-last character 781the colon results in a test only for a variable that is unset.
767on a line, right before the newline. In this position it causes the
768removal of the trailing newline, similar to @samp{dnl} in @command{m4}.
769@xref{listings, Triplet Listings}, for a detailed description and
770examples of @samp{$-} use.
771 782
772To insert a literal @samp{$} character in a string that is subject to 783@anchor{handling of undefined variables}
773meta-variable interpretation, duplicate it: @samp{$$}. 784@cindex expansion of undefined variables
785@cindex undefined variable, expansion
786If a string contains a reference to an undefined variable,
787@command{wydawca} will report an error and abort. To
788gracefully handle such cases, use the @dfn{default value construct},
789defined above.
774 790
775The exact set of defined meta-variables and their values depend on the 791@FIXME{Implement the expand-undefined setting, similar to the one in
776context and are discussed in detail below. 792rush}.
777 793
778@anchor{here-document} 794@anchor{here-document}
779@item Here-document 795@item Here-document
@@ -1496,41 +1512,42 @@ See below for a detailed description of these dictionary types.
1496@anchor{query} 1512@anchor{query}
1497@deffn {Config: dictionary} query string 1513@deffn {Config: dictionary} query string
1498Sets the query used for retrieving the data. The @var{string} is 1514Sets the query used for retrieving the data. The @var{string} is