diff options
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-02 19:24:03 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-01-02 19:24:03 +0200
commitc44f0f83448b426935e9aeb07c5d761299144d14 (patch)
parent1b0a4de9fa73dd2453cbd2902c2cd4d000f4abe7 (diff)
$- construct (similar to m4's dnl).
* src/meta.c: Special construct $- removes the character immediately following it. * doc/wydawca.texi: Document the use of $- construct. * src/triplet.c (expand_triplet_ls_full) (expand_triplet_ls_upload): Keep trailing newline in the expansion. * tests/etc/notify.rc: Update.
5 files changed, 40 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index cad6ca1..bbceb00 100644
--- a/NEWS
+++ b/NEWS
@@ -19,10 +19,17 @@ The following meta-variables are renamed:
triplet:sig triplet:ls:sig
triplet:dir triplet:ls:dir
+The expansions of {triplet:ls:full} and {triplet:ls:upload} include
+trailing newline. This means that if your config contains one of these
+variables on a line by itself, you will need to add $- at the end of
+that line, to suppress an extra newline. See "listings" in subsection
+4.14.4 "Event Notification", for an example.
To update your configuration, use the following (extended) sed expression:
- s/\{(triplet):(full|upload|dist|sig|dir)\}/{\1:ls:\2}/g
+ s/\{(triplet):(full|upload)\}/{\1:ls:\2}$-/g
+ s/\{(triplet):(dist|sig|dir)\}/{\1:ls:\2}/g
* Distribution verification.
The new keyword `check-script' defines a shell script to
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 88c2e6c..e9e63be 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -684,6 +684,8 @@ example above:
@end smallexample
+@cindex meta-interpretation
+@cindex meta-variables
Depending on the context, the contents of a quoted string may be
subject to @dfn{meta-variable interpretation}. During this process,
any sequence
@@ -715,6 +717,13 @@ equivalent.
If @var{var} is not defined, the meta-reference is left unchanged.
+The special sequence @samp{$-} causes removal of it and any character
+following it. Most often it is used as a next-to-last character
+on a line, right before the newline. In this position it causes the
+removal of the trailing newline, similar to @samp{dnl} in @command{m4}.
+@xref{listings, Triplet Listings}, for a detailed description and
+examples of @samp{$-} use.
To insert a literal @samp{$} character in a string that is subject to
meta-variable interpretation, duplicate it: @samp{$$}.
@@ -2631,8 +2640,11 @@ processing this spool.
processing this spool.
@end multitable
+@cindex listing, triplet
+@cindex triplet listing
@dfn{Listings} referred to in the table above, are similar to those
-produced by @code{ls} command, and include information
+produced by the @code{ls} command, and include information
on file permissions, ownership, size and modification date. For
example, here is a possible @code{$@{triplet:ls:full@}} listing:
@@ -2642,9 +2654,14 @@ example, here is a possible @code{$@{triplet:ls:full@}} listing:
-rw-r--r-- gray user 62 2007-09-06 22:14:35 tar-1.18.tar.gz.directive.asc
@end smallexample
The following example shows how to configure success notification
-for the user:
+for the user. Notice the use of the @samp{$-} after
+@samp{$@{triplet:ls:upload@}}: it removes the newline character after
+it and thus allows for more natural indentation of the next
+line. Without it, the expanded message would have contained two
+newlines after the full listing: one produced by
+@samp{$@{triplet:ls:upload@}} and the second one taken verbatim from
+the message template.
notify-event @{
@@ -2656,7 +2673,7 @@ Subject: Upload of $@{project@} successful
Upload of $@{project@} to $@{url@}/$@{dir@} finished successfully.
Files uploaded:
Resource usage: $@{timer:triplet:real@}/$@{timer:wydawca:real@}r \
$@{timer:triplet:user@}/$@{timer:wydawca:user@}u \
diff --git a/src/meta.c b/src/meta.c
index fc88c6b..545ac36 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -78,6 +78,11 @@ meta_expand_string (const char *string, struct metadef *def, void *data,
+ case '-':
+ if (*++p)
+ p++;
+ break;
case '{':
e = strchr (p + 1, '}');
if (e && (s = find_expansion_word (p + 1, e - p - 1, def, data)))
diff --git a/src/triplet.c b/src/triplet.c
index f18f573..7f6ac68 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -399,7 +399,6 @@ expand_triplet_ls_full (struct metadef *def, void *data)
strcat (def->value, buf[file_directive]);
strcat (def->value, "\n");
- def->value[size-1] = 0; /* Kill terminating newline */
free (buf[file_dist]);
free (buf[file_signature]);
free (buf[file_directive]);
@@ -430,7 +429,6 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
strcat (def->value, buf[file_signature]);
strcat (def->value, "\n");
- def->value[size-1] = 0; /* Kill terminating newline */
free (buf[file_dist]);
free (buf[file_signature]);
diff --git a/tests/etc/notify.rc b/tests/etc/notify.rc
index 4461ce3..138d6bb 100644
--- a/tests/etc/notify.rc
+++ b/tests/etc/notify.rc
@@ -24,7 +24,7 @@ Subject: Upload of ${project} successful
Upload of ${project} to ${url}/${dir} finished successfully.
Files uploaded:
@@ -42,7 +42,7 @@ Subject: Upload of ${project} successful
${user:real-name} (${user:email}) successfully uploaded files
for ${project} to ${url}/${dir}. Files uploaded:
@@ -61,7 +61,7 @@ Subject: Suspicious upload of ${project}
Someone not authorized to make releases for ${project}
has attempted to upload the following files to ${url}/${dir}:
This upload has been ignored and the files removed. The person who attempted
the upload was ${user:real-name}, user name ${user:name}, email ${user:email}.
@@ -184,7 +184,8 @@ Subject: ${triplet:dist} rejected
Your upload of ${triplet:dist} has been rejected by the distribution
verification procedure with the following diagnostics:
Please fix the tarball and resubmit.

Return to:

Send suggestions and report system problems to the System administrator.