aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-08-02 20:40:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-08-02 20:40:50 +0300
commitc5137ae530c49765049adb53777c79ebb7607ebe (patch)
treee168aec9e1c771058688df892368fbdba5de40e3
parentfa460b53f8173ebee36dbe672a9d95d3d69c9a9c (diff)
downloadegawk-c5137ae530c49765049adb53777c79ebb7607ebe.tar.gz
egawk-c5137ae530c49765049adb53777c79ebb7607ebe.tar.bz2
egawk-c5137ae530c49765049adb53777c79ebb7607ebe.zip
Bug fix in revoutput extension.
-rw-r--r--extension/ChangeLog6
-rw-r--r--extension/revoutput.3am4
-rw-r--r--extension/revoutput.c15
3 files changed, 18 insertions, 7 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 993729a5..3cd932b6 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * revoutput.c (init_revoutput): Don't install REVOUT if it's
+ there already. Makes the extension usable with -v.
+ * revoutput.3am: Add a BUGS section.
+
2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
* inplace.3am (BUGS): Document that ACLs are not preserved, and
diff --git a/extension/revoutput.3am b/extension/revoutput.3am
index 9c8f062f..8620935b 100644
--- a/extension/revoutput.3am
+++ b/extension/revoutput.3am
@@ -1,4 +1,4 @@
-.TH REVOUTPUT 3am "Jan 15 2013" "Free Software Foundation" "GNU Awk Extension Modules"
+.TH REVOUTPUT 3am "Aug 02 2015" "Free Software Foundation" "GNU Awk Extension Modules"
.SH NAME
revoutput \- Reverse output strings sample extension
.SH SYNOPSIS
@@ -35,6 +35,8 @@ The output from this program is:
dlrow ,olleh
.fi
.ft R
+.SH BUGS
+This extension does not affect the default standard output.
.SH "SEE ALSO"
.IR "GAWK: Effective AWK Programming" ,
.IR filefuncs (3am),
diff --git a/extension/revoutput.c b/extension/revoutput.c
index ae4b444a..69257167 100644
--- a/extension/revoutput.c
+++ b/extension/revoutput.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2012, 2013 the Free Software Foundation, Inc.
+ * Copyright (C) 2012, 2013, 2015 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -47,7 +47,7 @@
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t *ext_id;
-static const char *ext_version = "revoutput extension: version 1.0";
+static const char *ext_version = "revoutput extension: version 1.1";
static awk_bool_t init_revoutput(void);
static awk_bool_t (*init_func)(void) = init_revoutput;
@@ -120,11 +120,14 @@ init_revoutput()
register_output_wrapper(& output_wrapper);
- make_number(0.0, & value); /* init to false */
- if (! sym_update("REVOUT", & value)) {
- warning(ext_id, _("revoutput: could not initialize REVOUT variable"));
+ if (! sym_lookup("REVOUT", AWK_SCALAR, & value)) {
+ /* only install it if not there, e.g. -v REVOUT=1 */
+ make_number(0.0, & value); /* init to false */
+ if (! sym_update("REVOUT", & value)) {
+ warning(ext_id, _("revoutput: could not initialize REVOUT variable"));
- return awk_false;
+ return awk_false;
+ }
}
return awk_true;