diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-24 14:14:47 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-24 14:27:11 +0300 |
commit | c047ed856d6d23137ef1df01c1297db36bad3f8c (patch) | |
tree | 1999db947cb5e38df8a85d314daa0eef7c7624d0 | |
parent | 07ea006a31def46ba6ea936dbea366219152d9b6 (diff) | |
download | wydawca-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-- | NEWS | 57 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | doc/wydawca.texi | 156 | ||||
-rw-r--r-- | etc/wydawca.rc | 25 | ||||
m--------- | grecs | 0 | ||||
-rw-r--r-- | include/wydawca/wydawca.h | 30 | ||||
-rw-r--r-- | modules/logstat/mod_logstat.c | 4 | ||||
-rw-r--r-- | modules/mailutils/Makefile.am | 1 | ||||
-rw-r--r-- | modules/mailutils/mod_mailutils.c | 64 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/dictionary.c | 2 | ||||
-rw-r--r-- | src/directive.c | 2 | ||||
-rw-r--r-- | src/meta.c | 191 | ||||
-rw-r--r-- | src/timer.c | 52 | ||||
-rw-r--r-- | src/triplet.c | 603 | ||||
-rw-r--r-- | src/wydawca.c | 54 | ||||
-rw-r--r-- | src/wydawca.h | 15 | ||||
-rw-r--r-- | tests/etc/notify.rcin | 16 |
18 files changed, 615 insertions, 661 deletions
@@ -1,7 +1,62 @@ | |||
1 | Wydawca NEWS -- history of user-visible changes. 2019-07-22 | 1 | Wydawca NEWS -- history of user-visible changes. 2019-07-24 |
2 | See the end of file for copying conditions. | 2 | See the end of file for copying conditions. |
3 | 3 | ||
4 | Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. | 4 | Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. |
5 | |||
6 | Version 3.0.90 (git) | ||
7 | |||
8 | * Variable expansion syntax | ||
9 | |||
10 | This release uses wordsplit v1.0-9-g7eaa3c4. Normal shell like | ||
11 | expansion is allowed. This means that curly braces around variable | ||
12 | names 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 | |||
40 | Attempt to expand undefined variable causes fatal error. Use one of | ||
41 | the advanced forms described above to handle such cases gracefully. | ||
42 | |||
43 | * Variable names | ||
44 | |||
45 | Several variable names have changed. Names that contained dash, | ||
46 | now 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 | |||
57 | Trailing newlines are automatically removed from all variable | ||
58 | expansions. Consequently, the $- marker (delete to the end of line) | ||
59 | has been removed. | ||
5 | 60 | ||
6 | 61 | ||
7 | Version 3.0, 2019-07-22 | 62 | Version 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 | ||
17 | AC_PREREQ(2.63) | 17 | AC_PREREQ(2.63) |
18 | AC_INIT([wydawca], 3.0, [bug-wydawca@gnu.org.ua], [wydawca], | 18 | AC_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]) |
20 | AC_CONFIG_SRCDIR([src/wydawca.c]) | 20 | AC_CONFIG_SRCDIR([src/wydawca.c]) |
21 | AC_CONFIG_AUX_DIR([build-aux]) | 21 | AC_CONFIG_AUX_DIR([build-aux]) |
@@ -148,6 +148,7 @@ AM_CONDITIONAL([COND_INOTIFY],[test $status_inotify = yes]) | |||
148 | 148 | ||
149 | GRECS_SETUP([grecs],[tree-api git2chg getopt tests shared install-headers | 149 | GRECS_SETUP([grecs],[tree-api git2chg getopt tests shared install-headers |
150 | std-pp-setup]) | 150 | std-pp-setup]) |
151 | AC_CONFIG_LINKS(include/wydawca/wordsplit.h:grecs/wordsplit/wordsplit.h) | ||
151 | 152 | ||
152 | AH_BOTTOM([ | 153 | AH_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 |
734 | Depending on the context, the contents of a quoted string may be | 734 | Depending on the context, the quoted string may be subject to |
735 | subject to @dfn{meta-variable interpretation}. During this process, | 735 | @dfn{variable expansion}. |
736 | any sequence | ||
737 | 736 | ||
738 | @smallexample | 737 | During variable expansion, references to variables |
739 | $@{@var{var}@} | 738 | in the string are replaced with their actual values. A variable |
740 | @end smallexample | 739 | reference has two basic forms: |
741 | 740 | ||
742 | @noindent | 741 | @example |
743 | where @var{var} is the name of a defined meta-variable, is replaced with | 742 | $@var{v} |
744 | the value of the variable. This sequence is called @dfn{meta- | 743 | $@{@var{v}@} |
745 | reference}. For example, if the meta-variable @samp{user} has the | 744 | @end example |
746 | value @samp{smith}, then the string | ||
747 | |||
748 | @smallexample | ||
749 | "where user = '$@{user@}'" | ||
750 | @end smallexample | ||
751 | 745 | ||
752 | @noindent | 746 | @noindent |
753 | becomes | 747 | where @var{v} is the variable name. The notation in curly braces |
748 | serves several purposes. First, it should be used if the variable | ||
749 | reference is immediately followed by an alphanumeric symbol, which | ||
750 | will otherwise be considered part of it (as in @samp{$@{home@}dir}). | ||
751 | Secondly, this form allows for specifying the action to take if the | ||
752 | variable is undefined or expands to an empty value. | ||
754 | 753 | ||
755 | @smallexample | 754 | The following special forms are recognized: |
756 | "where user = 'smith'" | ||
757 | @end smallexample | ||
758 | |||
759 | If the name of the variable consists of a single character, the curly | ||
760 | braces around it may be omitted. Thus, @code{$@{u@}} and @code{$u} are | ||
761 | equivalent. | ||
762 | 755 | ||
763 | If @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 | ||
759 | of @var{word} is substituted. Otherwise, the value of @var{variable} is | ||
760 | substituted. | ||
761 | |||
762 | @item $@{@var{variable}:=@var{word}@} | ||
763 | @dfn{Assign Default Values}. If @var{variable} is unset or null, the | ||
764 | expansion of @var{word} is assigned to variable. The value of | ||
765 | @var{variable} is then substituted. | ||
766 | |||
767 | The 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, | ||
771 | the expansion of @var{word} (or a message to that effect if @var{word} is | ||
772 | not present) is output to the current logging channel. Otherwise, the | ||
773 | value 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 | ||
777 | substituted, otherwise the expansion of @var{word} is substituted. | ||
778 | @end table | ||
764 | 779 | ||
765 | The special sequence @samp{$-} causes removal of it and any character | 780 | These constructs test for a variable that is unset or null. Omitting |
766 | following it. Most often it is used as a next-to-last character | 781 | the colon results in a test only for a variable that is unset. |
767 | on a line, right before the newline. In this position it causes the | ||
768 | removal of the trailing newline, similar to @samp{dnl} in @command{m4}. | ||
769 | @xref{listings, Triplet Listings}, for a detailed description and | ||
770 | examples of @samp{$-} use. | ||
771 | 782 | ||
772 | To insert a literal @samp{$} character in a string that is subject to | 783 | @anchor{handling of undefined variables} |
773 | meta-variable interpretation, duplicate it: @samp{$$}. | 784 | @cindex expansion of undefined variables |
785 | @cindex undefined variable, expansion | ||
786 | If a string contains a reference to an undefined variable, | ||
787 | @command{wydawca} will report an error and abort. To | ||
788 | gracefully handle such cases, use the @dfn{default value construct}, | ||
789 | defined above. | ||
774 | 790 | ||
775 | The exact set of defined meta-variables and their values depend on the | 791 | @FIXME{Implement the expand-undefined setting, similar to the one in |
776 | context and are discussed in detail below. | 792 | rush}. |
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 |
1498 | Sets the query used for retrieving the data. The @var{string} is | 1514 | Sets the query used for retrieving the data. The @var{string} is |