[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, xgawk, updated. 3438b2129cd933e430349a6b
From: |
Andrew J. Schorr |
Subject: |
[gawk-diffs] [SCM] gawk branch, xgawk, updated. 3438b2129cd933e430349a6bd66a1933071c92c2 |
Date: |
Sun, 01 Apr 2012 21:08:15 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, xgawk has been updated
via 3438b2129cd933e430349a6bd66a1933071c92c2 (commit)
from 4d26f7436c0acf8617c4736f110f06e2f4531bbd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=3438b2129cd933e430349a6bd66a1933071c92c2
commit 3438b2129cd933e430349a6bd66a1933071c92c2
Author: Andrew J. Schorr <address@hidden>
Date: Sun Apr 1 17:07:45 2012 -0400
Update ERRNO API.
diff --git a/ChangeLog b/ChangeLog
index fb1b247..f9786df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-04-01 Andrew J. Schorr <address@hidden>
+
+ * TODO.xgawk: Move ERRNO item into "done" section.
+ * awk.h (update_ERRNO, update_ERRNO_saved): Remove declarations.
+ (update_ERRNO_int, enum errno_translate, update_ERRNO_string,
+ unset_ERRNO): Add new declarations.
+ * eval.c (update_ERRNO_saved): Renamed to update_ERRNO_int.
+ (update_ERRNO_string, unset_ERRNO): New functions.
+ * ext.c (do_ext): Use new update_ERRNO_string function.
+ * io.c (ERRNO_node): Remove redundant extern declaration (in awk.h).
+ (after_beginfile, nextfile): Replace update_ERRNO() with
+ update_ERRNO_int(errno).
+ (inrec): Replace update_ERRNO_saved with update_ERRNO_int.
+ (do_close): Use new function update_ERRNO_string.
+ (close_redir, do_getline_redir, do_getline): Replace update_ERRNO_saved
+ with update_ERRNO_int.
+
2012-03-27 Andrew J. Schorr <address@hidden>
* TODO.xgawk: Update to reflect debate about how to support Cygwin
diff --git a/TODO.xgawk b/TODO.xgawk
index 0198a45..56b13e1 100644
--- a/TODO.xgawk
+++ b/TODO.xgawk
@@ -13,6 +13,12 @@ Done:
- Implement @load
+- Patch ERRNO handling to create a simple API for use by extensions:
+ extern void update_ERRNO_int(int)
+ enum errno_translate { TRANSLATE, DONT_TRANSLATE };
+ extern void update_ERRNO_string(const char *string, enum errno_translate);
+ extern void unset_ERRNO(void);
+
To do (not necessarily in this order):
@@ -49,12 +55,6 @@ To do (not necessarily in this order):
- Add tests for standard extensions.
-- Patch ERRNO handling to create a simple API for use by extensions:
- extern void update_ERRNO_int(int)
- enum errno_translate { TRANSLATE, DONT_TRANSLATE };
- extern void update_ERRNO_string(const char *string, enum errno_translate);
- extern void unset_ERRNO(void);
-
- Develop a libgawk shared library for use by extensions. In particular,
a few existing extensions use a hash API for mapping string handles to
structures. In xgawk, we had this API inside array.c, but it probably
diff --git a/awk.h b/awk.h
index d670780..26c8717 100644
--- a/awk.h
+++ b/awk.h
@@ -1376,8 +1376,10 @@ extern void set_CONVFMT(void);
extern void set_BINMODE(void);
extern void set_LINT(void);
extern void set_TEXTDOMAIN(void);
-extern void update_ERRNO(void);
-extern void update_ERRNO_saved(int);
+extern void update_ERRNO_int(int);
+enum errno_translate { TRANSLATE, DONT_TRANSLATE };
+extern void update_ERRNO_string(const char *string, enum errno_translate);
+extern void unset_ERRNO(void);
extern void update_NR(void);
extern void update_NF(void);
extern void update_FNR(void);
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 815644c..568d7c7 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,10 @@
+2012-04-01 Andrew J. Schorr <address@hidden>
+
+ * gawk.texi: Replace documentation of removed functions update_ERRNO and
+ update_ERRNO_saved with descriptions new functions update_ERRNO_int,
+ update_ERRNO_string and unset_ERRNO. And fix a couple of examples
+ to use update_ERRNO_int instead of update_ERRNO.
+
2012-03-26 Arnold D. Robbins <address@hidden>
* gawk.texi: Minor style edits.
diff --git a/doc/gawk.texi b/doc/gawk.texi
index eaad54d..7b46026 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -29460,21 +29460,29 @@ This is a convenience macro that calls
@code{get_actual_argument()}.
@cindex functions, return address@hidden setting
@cindex @code{ERRNO} variable
address@hidden @code{update_ERRNO()} internal function
address@hidden internal function, @code{update_ERRNO()}
address@hidden void update_ERRNO(void)
address@hidden @code{update_ERRNO_int()} internal function
address@hidden internal function, @code{update_ERRNO_int()}
address@hidden void update_ERRNO_int(int errno_saved)
This function is called from within a C extension function to set
-the value of @command{gawk}'s @code{ERRNO} variable, based on the current
-value of the C @code{errno} global variable.
+the value of @command{gawk}'s @code{ERRNO} variable, based on the error
+value provided as the argument.
It is provided as a convenience.
@cindex @code{ERRNO} variable
address@hidden @code{update_ERRNO_saved()} internal function
address@hidden internal function, @code{update_ERRNO_saved()}
address@hidden void update_ERRNO_saved(int errno_saved)
address@hidden @code{update_ERRNO_string()} internal function
address@hidden internal function, @code{update_ERRNO_string()}
address@hidden void update_ERRNO_string(const char *string, enum
errno_translate)
This function is called from within a C extension function to set
-the value of @command{gawk}'s @code{ERRNO} variable, based on the error
-value provided as the argument.
+the value of @command{gawk}'s @code{ERRNO} variable to a given string.
+The second argument determines whether the string is translated before being
+installed into @code{ERRNO}. It is provided as a convenience.
+
address@hidden @code{ERRNO} variable
address@hidden @code{unset_ERRNO()} internal function
address@hidden internal function, @code{unset_ERRNO()}
address@hidden void unset_ERRNO(void)
+This function is called from within a C extension function to set
+the value of @command{gawk}'s @code{ERRNO} variable to a null string.
It is provided as a convenience.
@cindex @code{ENVIRON} array
@@ -29838,7 +29846,7 @@ is updated.
(void) force_string(newdir);
ret = chdir(newdir->stptr);
if (ret < 0)
- update_ERRNO();
+ update_ERRNO_int(errno);
@end example
Finally, the function returns the return value to the @command{awk} level:
@@ -29907,7 +29915,7 @@ If there's an error, it sets @code{ERRNO} and returns:
(void) force_string(file);
ret = lstat(file->stptr, & sbuf);
if (ret < 0) @{
- update_ERRNO();
+ update_ERRNO_int(errno);
return make_number((AWKNUM) ret);
@}
@end example
diff --git a/eval.c b/eval.c
index 78598b2..82cca9e 100644
--- a/eval.c
+++ b/eval.c
@@ -988,10 +988,10 @@ set_TEXTDOMAIN()
*/
}
-/* update_ERRNO_saved --- update the value of ERRNO based on argument */
+/* update_ERRNO_int --- update the value of ERRNO based on argument */
void
-update_ERRNO_saved(int errcode)
+update_ERRNO_int(int errcode)
{
char *cp;
@@ -1004,12 +1004,24 @@ update_ERRNO_saved(int errcode)
ERRNO_node->var_value = make_string(cp, strlen(cp));
}
-/* update_ERRNO --- update the value of ERRNO based on errno */
+/* update_ERRNO_string --- update ERRNO with optionally translated string */
void
-update_ERRNO()
+update_ERRNO_string(const char *string, enum errno_translate translate)
{
- update_ERRNO_saved(errno);
+ if (translate == TRANSLATE)
+ string = gettext(string);
+ unref(ERRNO_node->var_value);
+ ERRNO_node->var_value = make_string(string, strlen(string));
+}
+
+/* unset_ERRNO --- eliminate the value of ERRNO */
+
+void
+unset_ERRNO(void)
+{
+ unref(ERRNO_node->var_value);
+ ERRNO_node->var_value = Nnull_string;
}
/* update_NR --- update the value of NR */
diff --git a/ext.c b/ext.c
index 39e512f..3c30b1a 100644
--- a/ext.c
+++ b/ext.c
@@ -254,8 +254,7 @@ do_ext(int nargs)
{
const char *emsg = _("Operation Not Supported");
- unref(ERRNO_node->var_value);
- ERRNO_node->var_value = make_string(emsg, strlen(emsg));
+ update_ERRNO_string(emsg, DONT_TRANSLATE);
return make_number((AWKNUM) -1);
}
diff --git a/extension/ChangeLog b/extension/ChangeLog
index e0a6245..dc017d3 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,11 @@
+2012-04-01 Andrew J. Schorr <address@hidden>
+
+ * filefuncs.c (do_chdir, do_stat): Replace update_ERRNO() with
+ update_ERRNO_int(errno).
+ * fork.c (do_fork, do_waitpid): Ditto.
+ * readfile.c (do_readfile): Ditto.
+ * rwarray.c (do_writea, do_reada): Ditto.
+
2012-03-25 Andrew J. Schorr <address@hidden>
* Makefile.am: Major cleanup. Use libtool options -module and
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index dd1b29a..63010c3 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -48,7 +48,7 @@ do_chdir(int nargs)
(void) force_string(newdir);
ret = chdir(newdir->stptr);
if (ret < 0)
- update_ERRNO();
+ update_ERRNO_int(errno);
return make_number((AWKNUM) ret);
}
@@ -183,7 +183,7 @@ do_stat(int nargs)
(void) force_string(file);
ret = lstat(file->stptr, & sbuf);
if (ret < 0) {
- update_ERRNO();
+ update_ERRNO_int(errno);
return make_number((AWKNUM) ret);
}
diff --git a/extension/fork.c b/extension/fork.c
index 8835387..8b8558e 100644
--- a/extension/fork.c
+++ b/extension/fork.c
@@ -44,7 +44,7 @@ do_fork(int nargs)
ret = fork();
if (ret < 0)
- update_ERRNO();
+ update_ERRNO_int(errno);
else if (ret == 0) {
/* update PROCINFO in the child */
@@ -83,7 +83,7 @@ do_waitpid(int nargs)
options = WNOHANG|WUNTRACED;
ret = waitpid(pid, NULL, options);
if (ret < 0)
- update_ERRNO();
+ update_ERRNO_int(errno);
} else if (do_lint)
lintwarn("wait: called with no arguments");
diff --git a/extension/readfile.c b/extension/readfile.c
index c9b1efc..9c18601 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -59,18 +59,18 @@ do_readfile(int nargs)
ret = stat(filename->stptr, & sbuf);
if (ret < 0) {
- update_ERRNO();
+ update_ERRNO_int(errno);
goto done;
} else if ((sbuf.st_mode & S_IFMT) != S_IFREG) {
errno = EINVAL;
ret = -1;
- update_ERRNO();
+ update_ERRNO_int(errno);
goto done;
}
if ((fd = open(filename->stptr, O_RDONLY|O_BINARY)) < 0) {
ret = -1;
- update_ERRNO();
+ update_ERRNO_int(errno);
goto done;
}
@@ -80,7 +80,7 @@ do_readfile(int nargs)
if ((ret = read(fd, text, sbuf.st_size)) != sbuf.st_size) {
(void) close(fd);
ret = -1;
- update_ERRNO();
+ update_ERRNO_int(errno);
goto done;
}
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 8175c7c..f4f8cd5 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -115,7 +115,7 @@ do_writea(int nargs)
done1:
ret = -1;
- update_ERRNO();
+ update_ERRNO_int(errno);
unlink(file->stptr);
done0:
@@ -297,7 +297,7 @@ do_reada(int nargs)
done1:
ret = -1;
- update_ERRNO();
+ update_ERRNO_int(errno);
done0:
close(fd);
diff --git a/io.c b/io.c
index e3327f1..b2d2982 100644
--- a/io.c
+++ b/io.c
@@ -230,7 +230,6 @@ extern int output_is_tty;
extern NODE *ARGC_node;
extern NODE *ARGV_node;
extern NODE *ARGIND_node;
-extern NODE *ERRNO_node;
extern NODE **fields_arr;
@@ -308,7 +307,7 @@ after_beginfile(IOBUF **curfile)
errcode = iop->errcode;
iop->errcode = 0;
errno = 0;
- update_ERRNO();
+ update_ERRNO_int(errno);
iop_close(iop);
*curfile = NULL;
if (errcode == EISDIR && ! do_traditional) {
@@ -382,7 +381,7 @@ nextfile(IOBUF **curfile, int skipping)
fd = devopen(fname, binmode("r"));
errcode = errno;
if (! do_traditional)
- update_ERRNO();
+ update_ERRNO_int(errno);
/* This is a kludge. */
unref(FILENAME_node->var_value);
@@ -404,7 +403,7 @@ nextfile(IOBUF **curfile, int skipping)
/* FNR is init'ed to 0 */
errno = 0;
if (! do_traditional)
- update_ERRNO();
+ update_ERRNO_int(errno);
unref(FILENAME_node->var_value);
FILENAME_node->var_value = make_string("-", 1);
FILENAME_node->var_value->flags |= MAYBE_NUM; /* be pedantic */
@@ -415,7 +414,7 @@ nextfile(IOBUF **curfile, int skipping)
if (iop->fd == INVALID_HANDLE) {
errcode = errno;
errno = 0;
- update_ERRNO();
+ update_ERRNO_int(errno);
(void) iop_close(iop);
*curfile = NULL;
fatal(_("cannot open file `%s' for reading (%s)"),
@@ -462,7 +461,7 @@ inrec(IOBUF *iop, int *errcode)
if (cnt == EOF) {
retval = 1;
if (*errcode > 0)
- update_ERRNO_saved(*errcode);
+ update_ERRNO_int(*errcode);
} else {
NR += 1;
FNR += 1;
@@ -990,8 +989,7 @@ do_close(int nargs)
if (! do_traditional) {
/* update ERRNO manually, using errno = ENOENT is a
stretch. */
cp = _("close of redirection that was never opened");
- unref(ERRNO_node->var_value);
- ERRNO_node->var_value = make_string(cp, strlen(cp));
+ update_ERRNO_string(cp, DONT_TRANSLATE);
}
DEREF(tmp);
@@ -1111,7 +1109,7 @@ close_redir(struct redirect *rp, int exitwarn,
two_way_close_type how)
if (! do_traditional) {
/* set ERRNO too so that program can get at it */
- update_ERRNO_saved(save_errno);
+ update_ERRNO_int(save_errno);
}
}
@@ -2228,7 +2226,7 @@ do_getline_redir(int intovar, int redirtype)
if (rp == NULL) {
if (redir_error) { /* failed redirect */
if (! do_traditional)
- update_ERRNO_saved(redir_error);
+ update_ERRNO_int(redir_error);
}
return make_number((AWKNUM) -1.0);
}
@@ -2240,7 +2238,7 @@ do_getline_redir(int intovar, int redirtype)
cnt = get_a_record(&s, iop, &errcode);
if (errcode != 0) {
if (! do_traditional && (errcode != -1))
- update_ERRNO_saved(errcode);
+ update_ERRNO_int(errcode);
return make_number((AWKNUM) -1.0);
}
@@ -2288,7 +2286,7 @@ do_getline(int intovar, IOBUF *iop)
cnt = get_a_record(&s, iop, &errcode);
if (errcode != 0) {
if (! do_traditional && (errcode != -1))
- update_ERRNO_saved(errcode);
+ update_ERRNO_int(errcode);
if (intovar)
(void) POP_ADDRESS();
return make_number((AWKNUM) -1.0);
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 17 +++++++++++++++++
TODO.xgawk | 12 ++++++------
awk.h | 6 ++++--
doc/ChangeLog | 7 +++++++
doc/gawk.texi | 32 ++++++++++++++++++++------------
eval.c | 22 +++++++++++++++++-----
ext.c | 3 +--
extension/ChangeLog | 8 ++++++++
extension/filefuncs.c | 4 ++--
extension/fork.c | 4 ++--
extension/readfile.c | 8 ++++----
extension/rwarray.c | 4 ++--
io.c | 22 ++++++++++------------
13 files changed, 100 insertions(+), 49 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, xgawk, updated. 3438b2129cd933e430349a6bd66a1933071c92c2,
Andrew J. Schorr <=