diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2013-08-14 00:06:55 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2013-08-14 00:06:55 +0300 |
commit | c4300d657ba49db0b6d0f0884f41a29622edc58b (patch) | |
tree | a49e5590dab96979293e3c16455d9f305d9ce738 /extension | |
parent | 69b59a73db108ede65e4dfce90fcfb10723e1feb (diff) | |
parent | 15a922b8a62092fab8b0e9b9fa06c3182b38b596 (diff) | |
download | egawk-c4300d657ba49db0b6d0f0884f41a29622edc58b.tar.gz egawk-c4300d657ba49db0b6d0f0884f41a29622edc58b.tar.bz2 egawk-c4300d657ba49db0b6d0f0884f41a29622edc58b.zip |
Merge branch 'master' into select
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 16 | ||||
-rw-r--r-- | extension/filefuncs.c | 33 | ||||
-rw-r--r-- | extension/gawkdirfd.h | 14 |
3 files changed, 51 insertions, 12 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog index 76427971..2fb742a9 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,19 @@ +2013-08-06 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c: Change _WIN32 to __MINGW32__ globally, per + Eli Zaretskii. + +2013-08-02 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c (do_fts): Add a version for _WIN32 that prints a + "not supported" fatal message. This is slightly better than the + "fts not found" which is otherwise produced. + +2013-07-24 Arnold D. Robbins <arnold@skeeve.com> + + * gawkdirfd.h (FAKE_FD_VALUE): Move definition up in the file to give + clean compile on MinGW. + 2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com> * configure.ac (AC_CHECK_FUNCS): Check for fcntl. diff --git a/extension/filefuncs.c b/extension/filefuncs.c index ad6a991d..61cadfec 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -71,7 +71,7 @@ #define readlink(f,b,bs) (-1) #endif -#ifdef _WIN32 +#ifdef __MINGW32__ #define S_IRGRP S_IRUSR #define S_IWGRP S_IWUSR #define S_IXGRP S_IXUSR @@ -361,7 +361,7 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf) /* fill in the array */ array_set(array, "name", make_const_string(name, strlen(name), & tmp)); array_set_numeric(array, "dev", sbuf->st_dev); -#ifdef _WIN32 +#ifdef __MINGW32__ array_set_numeric(array, "ino", (double)get_inode (name)); #else array_set_numeric(array, "ino", sbuf->st_ino); @@ -371,7 +371,7 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf) array_set_numeric(array, "uid", sbuf->st_uid); array_set_numeric(array, "gid", sbuf->st_gid); array_set_numeric(array, "size", sbuf->st_size); -#ifdef _WIN32 +#ifdef __MINGW32__ array_set_numeric(array, "blocks", (sbuf->st_size + 4095) / 4096); #else array_set_numeric(array, "blocks", sbuf->st_blocks); @@ -389,7 +389,7 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf) #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE array_set_numeric(array, "blksize", sbuf->st_blksize); -#elif defined(_WIN32) +#elif defined(__MINGW32__) array_set_numeric(array, "blksize", 4096); #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ @@ -483,7 +483,7 @@ init_filefuncs(void) int i; awk_value_t value; -#ifndef _WIN32 +#ifndef __MINGW32__ /* at least right now, only FTS needs initializing */ static struct flagtab { const char *name; @@ -511,7 +511,24 @@ init_filefuncs(void) return errors == 0; } -#ifndef _WIN32 +#ifdef __MINGW32__ +/* do_fts --- walk a heirarchy and fill in an array */ + +/* + * Usage from awk: + * flags = or(FTS_PHYSICAL, ...) + * result = fts(pathlist, flags, filedata) + */ + +static awk_value_t * +do_fts(int nargs, awk_value_t *result) +{ + fatal(ext_id, _("fts is not supported on this system")); + + return NULL; /* for the compiler */ +} + +#else /* __MINGW32__ */ static int fts_errors = 0; @@ -815,12 +832,12 @@ out: return make_number(ret, result); } -#endif /* !_WIN32 */ +#endif /* ! __MINGW32__ */ static awk_ext_func_t func_table[] = { { "chdir", do_chdir, 1 }, { "stat", do_stat, 2 }, -#ifndef _WIN32 +#ifndef __MINGW32__ { "fts", do_fts, 3 }, #endif }; diff --git a/extension/gawkdirfd.h b/extension/gawkdirfd.h index 52b91804..4710dab4 100644 --- a/extension/gawkdirfd.h +++ b/extension/gawkdirfd.h @@ -25,6 +25,16 @@ # define ENOTSUP ENOSYS #endif +/* + * This is for fake directory file descriptors on systems that don't + * allow to open() a directory. + * + * It would be nice if this could be shared with the definition in awk.h + * in the main code base, but there's not a very clean way to do that, + * at least that I can see. + */ +#define FAKE_FD_VALUE 42 + #ifndef DIR_TO_FD # define DIR_TO_FD(d) (FAKE_FD_VALUE) #endif @@ -39,7 +49,3 @@ dirfd (DIR *dir_p) return fd; } #endif /* HAVE_DIRFD */ - -/* This is for fake directory file descriptors on systems that don't - allow to open() a directory. */ -#define FAKE_FD_VALUE 42 |