aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog25
-rw-r--r--README_d/ChangeLog4
-rw-r--r--README_d/README.pc9
-rw-r--r--TODO9
-rw-r--r--awk.h6
-rw-r--r--builtin.c27
-rw-r--r--extension/ChangeLog16
-rw-r--r--extension/filefuncs.c33
-rw-r--r--extension/gawkdirfd.h14
-rw-r--r--io.c14
-rw-r--r--profile.c4
-rw-r--r--test/ChangeLog8
-rw-r--r--test/Makefile.am11
-rw-r--r--test/Makefile.in11
-rw-r--r--test/mbprintf4.awk32
-rw-r--r--test/mbprintf4.in3
-rw-r--r--test/mbprintf4.ok81
17 files changed, 263 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 9bdbf836..2ac1a580 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-07-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * io.c (FAKE_FD_VALUE): Move definition from here ...
+ * awk.h (FAKE_FD_VALUE): ... to here. Fixes compilation on MinGW.
+
+2013-07-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * io.c (get_a_record): Change `min' to `MIN' for consistency with
+ other files and general practice.
+
2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
* configure.ac (AC_CHECK_FUNCS): Check for sigprocmask.
@@ -37,7 +47,7 @@
we reach the Op_after_beginfile opcode. We then run after_beginfile
manually and restore the value of currule and source.
-2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+2013-07-04 Andrew J. Schorr <aschorr@telemetry-investments.com>
* gawkapi.h (awk_element_t): Add comment indicating that the array
element index will always be a string!
@@ -85,6 +95,17 @@
through the API's new get_file hook.
(redirect): Now implemented by calling redirect_string backend function.
+2013-07-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * builtin.c (format_tree): Fixes for %c with multibyte characters
+ and field width > 1. Bugs reported by Nethox <nethox@gmail.com>.
+
+2013-07-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile.c (pp_string): Add a call to chksize and fix another.
+ Avoids valgrind errors on profile5 test. Thanks to Andrew
+ Schorr for the report.
+
2013-06-27 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y: Minor whitespace cleanup, remove redundant ifdef.
@@ -1845,7 +1866,7 @@
2012-06-19 Arnold D. Robbins <arnold@skeeve.com>
* main.c (main): Do setlocale to "C" if --characters-as-bytes.
- Thanks to "SP" <sp0sp0sp@gmail.com> for the bug report.
+ Thanks to "SP" for the bug report.
2012-05-09 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/README_d/ChangeLog b/README_d/ChangeLog
index 3bd99ad0..49c30f13 100644
--- a/README_d/ChangeLog
+++ b/README_d/ChangeLog
@@ -1,3 +1,7 @@
+2013-07-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * README.pc: Update that |& also now works on MinGW.
+
2013-05-14 Eli Zaretskii <eliz@gnu.org>
* README.pc: Update the pc build and test instructions.
diff --git a/README_d/README.pc b/README_d/README.pc
index 9971d7ba..32a81fc1 100644
--- a/README_d/README.pc
+++ b/README_d/README.pc
@@ -16,10 +16,11 @@ installation is the same as under Unix:
The `configure' step takes a long time, but works otherwise.
-******************************** N O T E **********************************
-* The `|&' operator only works when gawk is compiled for Cygwin. Neither *
-* socket support nor two-way pipes work in any other Windows environment! *
-***************************************************************************
+******************************** N O T E *******************************
+* The `|&' operator only works when gawk is compiled for Cygwin or for *
+* MinGW. Neither * socket support nor two-way pipes work in any other *
+* Windows environment! *
+************************************************************************
Building gawk
-------------
diff --git a/TODO b/TODO
index 8e98c70c..0b646997 100644
--- a/TODO
+++ b/TODO
@@ -15,7 +15,14 @@ TODO
Minor Cleanups and Code Improvements
------------------------------------
- Rationalize use of min/max/MIN/MAX in gawk code.
+ Put FAKE_FD_VALUE into a head included from awk.h and extension/
+ dirfd.h.
+
+ Mac OS X readline doesn't have history_list which is used from debug.c
+ functions do_save and serialize.
+ See http://ftp.samba.org/pub/unpacked/samba_3_current/source4/lib/smbreadline/readline.m4
+ for some help. Reported by Larry Baker, larry.baker@stanfordalumni.org
+
API:
??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS)
diff --git a/awk.h b/awk.h
index 7ca401a5..f8696179 100644
--- a/awk.h
+++ b/awk.h
@@ -206,6 +206,12 @@ typedef void *stackoverflow_context_t;
#define stackoverflow_install_handler(catchstackoverflow, extra_stack, STACK_SIZE) 0
#endif
+/*
+ * This is for fake directory file descriptors on systems that don't
+ * allow to open() a directory.
+ */
+#define FAKE_FD_VALUE 42
+
/* use this as lintwarn("...")
this is a hack but it gives us the right semantics */
#define lintwarn (*(set_loc(__FILE__, __LINE__),lintfunc))
diff --git a/builtin.c b/builtin.c
index ba1d8dcb..b8e24cb3 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1097,6 +1097,7 @@ out0:
* used to work? 6/2003.)
*/
cp = arg->stptr;
+ prec = 1;
#if MBS_SUPPORT
/*
* First character can be multiple bytes if
@@ -1108,17 +1109,14 @@ out0:
memset(& state, 0, sizeof(state));
count = mbrlen(cp, arg->stlen, & state);
- if (count == 0
- || count == (size_t)-1
- || count == (size_t)-2)
- goto out2;
- prec = count;
- goto pr_tail;
+ if (count > 0) {
+ prec = count;
+ /* may need to increase fw so that padding happens, see pr_tail code */
+ if (fw > 0)
+ fw += count - 1;
+ }
}
-out2:
- ;
#endif
- prec = 1;
goto pr_tail;
case 's':
need_format = false;
@@ -1421,9 +1419,14 @@ mpf1:
copy_count = prec;
if (fw == 0 && ! have_prec)
;
- else if (gawk_mb_cur_max > 1 && (cs1 == 's' || cs1 == 'c')) {
- assert(cp == arg->stptr || cp == cpbuf);
- copy_count = mbc_byte_count(arg->stptr, prec);
+ else if (gawk_mb_cur_max > 1) {
+ if (cs1 == 's') {
+ assert(cp == arg->stptr || cp == cpbuf);
+ copy_count = mbc_byte_count(arg->stptr, prec);
+ }
+ /* prec was set by code for %c */
+ /* else
+ copy_count = prec; */
}
bchunk(cp, copy_count);
while (fw > prec) {
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
diff --git a/io.c b/io.c
index 01dc7cbe..37ec892c 100644
--- a/io.c
+++ b/io.c
@@ -185,10 +185,6 @@
#define INCREMENT_REC(X) X++
#endif
-/* This is for fake directory file descriptors on systems that don't
- allow to open() a directory. */
-#define FAKE_FD_VALUE 42
-
typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type;
/* Several macros to make the code a bit clearer. */
@@ -3574,12 +3570,12 @@ get_a_record(char **out, /* pointer to pointer to data */
recm.rt_start = iop->off + recm.len;
/* read more data, break if EOF */
-#ifndef min
-#define min(x, y) (x < y ? x : y)
+#ifndef MIN
+#define MIN(x, y) (x < y ? x : y)
#endif
/* subtract one in read count to leave room for sentinel */
room_left = iop->end - iop->dataend - 1;
- amt_to_read = min(iop->readsize, room_left);
+ amt_to_read = MIN(iop->readsize, room_left);
if (amt_to_read < iop->readsize) {
grow_iop_buffer(iop);
@@ -3590,7 +3586,7 @@ get_a_record(char **out, /* pointer to pointer to data */
/* recalculate amt_to_read */
room_left = iop->end - iop->dataend - 1;
- amt_to_read = min(iop->readsize, room_left);
+ amt_to_read = MIN(iop->readsize, room_left);
}
while (amt_to_read + iop->readsize < room_left)
amt_to_read += iop->readsize;
@@ -3600,7 +3596,7 @@ get_a_record(char **out, /* pointer to pointer to data */
* POSIX limits read to SSIZE_MAX. There are (bizarre)
* systems where this amount is small.
*/
- amt_to_read = min(amt_to_read, SSIZE_MAX);
+ amt_to_read = MIN(amt_to_read, SSIZE_MAX);
#endif
iop->count = iop->public.read_func(iop->public.fd, iop->dataend, amt_to_read);
diff --git a/profile.c b/profile.c
index 223a4e33..eae24b1c 100644
--- a/profile.c
+++ b/profile.c
@@ -1232,6 +1232,8 @@ pp_string(const char *in_str, size_t len, int delim)
*obufout++ = '\\';
*obufout++ = delim;
} else if (*str == '\0') {
+ chksize(4);
+
*obufout++ = '\\';
*obufout++ = '0';
*obufout++ = '0';
@@ -1255,7 +1257,7 @@ pp_string(const char *in_str, size_t len, int delim)
obufout += len;
}
}
- chksize(1);
+ chksize(2);
*obufout++ = delim;
*obufout = '\0';
return obuf;
diff --git a/test/ChangeLog b/test/ChangeLog
index fcd922c1..87ad809f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2013-07-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (mbprintf4): New test.
+ * mbprintf4.awk, mbprintf4.in, mbprintf4.ok: New files.
+ Test cases from Nethox <nethox@gmail.com>.
+
2013-06-27 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (dfamb1): New test.
@@ -11,7 +17,7 @@
2013-06-22 Eli Zaretskii <eliz@gnu.org>
- * Maketests (clos1way): Set AC_ALL=C, since clos1way.awk no longer
+ * Maketests (clos1way): Set LC_ALL=C, since clos1way.awk no longer
does.
2013-06-03 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index fe6d3a59..e7c9cefd 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -493,6 +493,9 @@ EXTRA_DIST = \
mbprintf3.awk \
mbprintf3.in \
mbprintf3.ok \
+ mbprintf4.awk \
+ mbprintf4.in \
+ mbprintf4.ok \
mbstr1.awk \
mbstr1.ok \
membug1.awk \
@@ -991,7 +994,7 @@ MPFR_TESTS = mpfrnr mpfrrnd mpfrieee mpfrexprange mpfrsort mpfrbigint
LOCALE_CHARSET_TESTS = \
asort asorti fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \
- mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
+ mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
fnmatch filefuncs fork fork2 fts functab4 inplace1 inplace2 inplace3 \
@@ -1564,6 +1567,12 @@ mbprintf3::
$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+mbprintf4::
+ @echo $@
+ @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
+ $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
mbfw1::
@echo $@
@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
diff --git a/test/Makefile.in b/test/Makefile.in
index 06946c0c..147eeaf3 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -711,6 +711,9 @@ EXTRA_DIST = \
mbprintf3.awk \
mbprintf3.in \
mbprintf3.ok \
+ mbprintf4.awk \
+ mbprintf4.in \
+ mbprintf4.ok \
mbstr1.awk \
mbstr1.ok \
membug1.awk \
@@ -1204,7 +1207,7 @@ MACHINE_TESTS = double1 double2 fmtspcl intformat
MPFR_TESTS = mpfrnr mpfrrnd mpfrieee mpfrexprange mpfrsort mpfrbigint
LOCALE_CHARSET_TESTS = \
asort asorti fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \
- mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
+ mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
fnmatch filefuncs fork fork2 fts functab4 inplace1 inplace2 inplace3 \
@@ -1960,6 +1963,12 @@ mbprintf3::
$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+mbprintf4::
+ @echo $@
+ @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
+ $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
mbfw1::
@echo $@
@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
diff --git a/test/mbprintf4.awk b/test/mbprintf4.awk
new file mode 100644
index 00000000..a4b2a218
--- /dev/null
+++ b/test/mbprintf4.awk
@@ -0,0 +1,32 @@
+# printf with multi-byte text encoding, %c and %s, width and precision, and left-alignment.
+{
+ print "printf %c " $0
+ printf "|%c|\n", $0
+ printf "|%1c|\n", $0
+ printf "|%3c|\n", $0
+ # precision is ignored by %c.
+ printf "|%3.1c|\n", $0
+ printf "|%3.5c|\n", $0
+ print "printf %-c " $0
+ printf "|%-c|\n", $0
+ printf "|%-1c|\n", $0
+ printf "|%-3c|\n", $0
+ # precision is ignored by %c.
+ printf "|%-3.1c|\n", $0
+ printf "|%-3.5c|\n", $0
+ printf ORS
+
+ print "printf %s " $0
+ printf "|%s|\n", $0
+ printf "|%1s|\n", $0
+ printf "|%3s|\n", $0
+ printf "|%3.1s|\n", $0
+ printf "|%3.5s|\n", $0
+ print "printf %-s " $0
+ printf "|%-s|\n", $0
+ printf "|%-1s|\n", $0
+ printf "|%-3s|\n", $0
+ printf "|%-3.1s|\n", $0
+ printf "|%-3.5s|\n", $0
+ printf ORS ORS
+}
diff --git a/test/mbprintf4.in b/test/mbprintf4.in
new file mode 100644
index 00000000..c93d40de
--- /dev/null
+++ b/test/mbprintf4.in
@@ -0,0 +1,3 @@
+último
+áé
diff --git a/test/mbprintf4.ok b/test/mbprintf4.ok
new file mode 100644
index 00000000..9b9dd4e2
--- /dev/null
+++ b/test/mbprintf4.ok
@@ -0,0 +1,81 @@
+printf %c ú
+|ú|
+|ú|
+| ú|
+| ú|
+| ú|
+printf %-c ú
+|ú|
+|ú|
+|ú |
+|ú |
+|ú |
+
+printf %s ú
+|ú|
+|ú|
+| ú|
+| ú|
+| ú|
+printf %-s ú
+|ú|
+|ú|
+|ú |
+|ú |
+|ú |
+
+
+printf %c último
+|ú|
+|ú|
+| ú|
+| ú|
+| ú|
+printf %-c último
+|ú|
+|ú|
+|ú |
+|ú |
+|ú |
+
+printf %s último
+|último|
+|último|
+|último|
+| ú|
+|últim|
+printf %-s último
+|último|
+|último|
+|último|
+|ú |
+|últim|
+
+
+printf %c áé
+|á|
+|á|
+| á|
+| á|
+| á|
+printf %-c áé
+|á|
+|á|
+|á |
+|á |
+|á |
+
+printf %s áé
+|áé|
+|áé|
+| áé|
+| á|
+| áé|
+printf %-s áé
+|áé|
+|áé|
+|áé |
+|á |
+|áé |
+
+