diff options
Diffstat (limited to 'posix')
-rw-r--r-- | posix/ChangeLog | 27 | ||||
-rw-r--r-- | posix/gawkmisc.c | 37 |
2 files changed, 60 insertions, 4 deletions
diff --git a/posix/ChangeLog b/posix/ChangeLog index d684afe9..17a93f7f 100644 --- a/posix/ChangeLog +++ b/posix/ChangeLog @@ -1,3 +1,30 @@ +2012-10-14 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.c (os_isreadable): Change name of input parameter to + awk_inputbuf_t. + +2012-08-08 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_isreadable): Take IOBUF_PUBLIC instead of fd and + use passed in info. + +2012-07-29 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.c (os_isreadable): Add isdir pointer parameter to be + set to true if fd is for a directory. + +2012-07-26 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.c (os_isreadable): New function. + +2012-05-11 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.c: Use `bool', `true', and `false' everywhere. + +2012-03-20 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawkmisc.c (deflibpath): New global variable. + 2012-03-28 Arnold D. Robbins <arnold@skeeve.com> * 4.0.1: Release tar ball made. diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c index acc3c9d5..90bf1c38 100644 --- a/posix/gawkmisc.c +++ b/posix/gawkmisc.c @@ -26,6 +26,7 @@ char quote = '\''; char *defpath = DEFPATH; +char *deflibpath = DEFLIBPATH; char envsep = ':'; #ifndef INVALID_HANDLE @@ -92,8 +93,8 @@ optimal_bufsize(int fd, struct stat *stb) { char *val; static size_t env_val = 0; - static short first = TRUE; - static short exact = FALSE; + static bool first = true; + static bool exact = false; /* force all members to zero in case OS doesn't use all of them. */ memset(stb, '\0', sizeof(struct stat)); @@ -103,11 +104,11 @@ optimal_bufsize(int fd, struct stat *stb) fatal("can't stat fd %d (%s)", fd, strerror(errno)); if (first) { - first = FALSE; + first = false; if ((val = getenv("AWKBUFSIZE")) != NULL) { if (strcmp(val, "exact") == 0) - exact = TRUE; + exact = true; else if (isdigit((unsigned char) *val)) { for (; *val && isdigit((unsigned char) *val); val++) env_val = (env_val * 10) + *val - '0'; @@ -203,6 +204,34 @@ os_isdir(int fd) return (fstat(fd, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)); } +/* os_isreadable --- fd can be read from */ + +int +os_isreadable(const awk_input_buf_t *iobuf, bool *isdir) +{ + *isdir = false; + + if (iobuf->fd == INVALID_HANDLE) + return false; + + switch (iobuf->sbuf.st_mode & S_IFMT) { + case S_IFREG: + case S_IFCHR: /* ttys, /dev/null, .. */ +#ifdef S_IFSOCK + case S_IFSOCK: +#endif +#ifdef S_IFIFO + case S_IFIFO: +#endif + return true; + case S_IFDIR: + *isdir = true; + /* fall through */ + default: + return false; + } +} + /* os_is_setuid --- true if running setuid root */ int |