diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-01-10 22:14:27 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-01-10 22:14:27 +0200 |
commit | cc8c981c9eaed42e1afd278afac787cd2aeab55f (patch) | |
tree | 66daeb2dc1049a6112445705f6b92cea55958bd7 | |
parent | dd2516767fa58d56684e003f646ef6d611051a64 (diff) | |
parent | 7d463f19f1fc98a7d4f99e3575c545ca7009d9db (diff) | |
download | egawk-cc8c981c9eaed42e1afd278afac787cd2aeab55f.tar.gz egawk-cc8c981c9eaed42e1afd278afac787cd2aeab55f.tar.bz2 egawk-cc8c981c9eaed42e1afd278afac787cd2aeab55f.zip |
Merge branch 'master' into feature/fix-comments
-rw-r--r-- | ChangeLog | 53 | ||||
-rw-r--r-- | NEWS | 15 | ||||
-rw-r--r-- | array.c | 5 | ||||
-rw-r--r-- | awk.h | 17 | ||||
-rw-r--r-- | awkgram.c | 3 | ||||
-rw-r--r-- | awkgram.y | 5 | ||||
-rw-r--r-- | builtin.c | 9 | ||||
-rw-r--r-- | doc/ChangeLog | 17 | ||||
-rw-r--r-- | doc/gawk.info | 370 | ||||
-rw-r--r-- | doc/gawk.texi | 84 | ||||
-rw-r--r-- | doc/gawktexi.in | 45 | ||||
-rw-r--r-- | field.c | 5 | ||||
-rw-r--r-- | gawkapi.c | 5 | ||||
-rw-r--r-- | interpret.h | 5 | ||||
-rw-r--r-- | io.c | 308 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | mpfr.c | 7 | ||||
-rw-r--r-- | node.c | 11 | ||||
-rw-r--r-- | pc/ChangeLog | 4 | ||||
-rw-r--r-- | pc/Makefile.tst | 43 | ||||
-rw-r--r-- | str_array.c | 4 | ||||
-rw-r--r-- | symbol.c | 5 | ||||
-rw-r--r-- | test/ChangeLog | 14 | ||||
-rw-r--r-- | test/Makefile.am | 21 | ||||
-rw-r--r-- | test/Makefile.in | 21 | ||||
-rw-r--r-- | test/mpfrrndeval.awk | 35 | ||||
-rw-r--r-- | test/mpfrrndeval.ok | 18 | ||||
-rw-r--r-- | test/pty2.awk | 9 | ||||
-rw-r--r-- | test/pty2.ok | 2 | ||||
-rw-r--r-- | vms/ChangeLog | 4 | ||||
-rw-r--r-- | vms/vmstest.com | 14 |
31 files changed, 823 insertions, 339 deletions
@@ -1,3 +1,56 @@ +2018-01-08 John E. Malmberg <wb8tyw@qsl.net> + + * io.c (set_slave_pty_attributes) Currently no termios on VMS. + (set_slave_pty_attributes) No fork on VMS. + +2018-01-04 Arnold D. Robbins <arnold@skeeve.com> + + Refactor handling of slave pty. On AIX and HP-UX open + slave in the child. Otherwise open slave in the parent + before forking (restoring code mostly from 4.1.3). Thanks + to Andrew Schorr for the bug report. + + * io.c (fork_and_open_slave_pty): New routine. Two versions. + (set_slave_pty_attributes): New routine. Common code used by + both versions of fork_and_open_slave_pty. + (push_pty_line_disciplines): New routine. Common code used by + both versions of fork_and_open_slave_pty. + (two_way_open): Call fork_and_open_slave_pty instead of + doing it inline. + +2018-01-03 Arnold D. Robbins <arnold@skeeve.com> + + * main.c (UPDATE_YEAR): Move to 2018. Revise copyright year. + * NEWS: Bring up to date. + +2018-01-02 Arnold D. Robbins <arnold@skeeve.com> + + If ROUNDMODE changes, cause cached string conversions + to become invalid. Thanks to Nethox <nethox@gmail.com> + for the report. Day 1 bug from 4.1.0 release. + + In all the below files, bump copyright year, too. + + * array.c (value_info): Include strndmode in the output. + * awk.h (NODE): New member, strndmode. + (MPFR_round_mode): Add extern declaration. + (force_string_fmt): Check s->strnmode against MPFR_round_mode. + * awkgram.y (set_profile_text): Set n->strndmode to MPFR_round_mode. + * builtin.c (do_print): Remove tests and just call force_string_fmt. + * field.c (set_record): Set n->strndmode to MPFR_round_mode. + * gawk_api.c (api_sym_update_scalar): Set r->strndmode to + MPFR_round_mode. + * interpret.h (r_interpret): For Op_assign_concat, set t1->strndmode + to MPFR_round_mode. + * mpfr.c (MPFR_round_mode): Define and initialize. + (mpfr_format_val): Set s->strndmode to MPFR_round_mode. + (set_ROUNDMODE): Update MPFR_round_mode when ROUNDMODE changes + successfully. + * node.c (r_format_val): Set s->strndmode to MPFR_round_mode. + (make_str_node): Set r->strndmode to MPFR_round_mode. + * str_array.c (str_kilobytes): Update a comment. + * symbol.c (check_param_names): Set n.strndmode to MPFR_round_mode. + 2017-12-24 Arnold D. Robbins <arnold@skeeve.com> Avoid some compiler warnings. Thanks to Michal Jaegermann @@ -1,4 +1,4 @@ - Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 + Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, @@ -22,6 +22,17 @@ Changes from 4.2.0 to 4.2.1 accidentally omitted from the initial 4.2 release, for which we apologize. +2. The manual received a number of updates to make it format better + for PDF. + +3. A configure new option, --enable-versioned-dir, causes the directory + holding extensions to include the API version in its name. + +4. extension/configure.ac has been improved considerably. + +5. A number of bugs, some of them quite significant, have been fixed. + See the ChangeLog for details. + Changes from 4.1.4 to 4.2.0 --------------------------- @@ -106,7 +117,7 @@ Changes from 4.1.4 to 4.2.0 disable optimizations so that the output program is the same as the original input program. -18. Gawk now uses fwrite_unlocked if it's available. The yields a 7% - 18% +18. Gawk now uses fwrite_unlocked if it's available. This yields a 7% - 18% improvement in raw output speed (gawk '{ print }' on a large file). 19. Passing negative operands to any of the bitwise functions now @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2014, 2016, 2017, + * Copyright (C) 1986, 1988, 1989, 1991-2014, 2016, 2018, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -716,6 +716,9 @@ value_info(NODE *n) fprintf(output_fp, "FMT=\"%s\"", n->stfmt == STFMT_UNUSED ? "<unused>" : fmt_list[n->stfmt]->stptr); +#ifdef HAVE_MPFR + fprintf(output_fp, ", RNDMODE=\"%c\"", n->strndmode); +#endif } #undef PREC_NUM @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -359,6 +359,7 @@ typedef struct exp_node { mpfr_t mpnum; mpz_t mpi; } nm; + int rndmode; #else AWKNUM fltnum; #endif @@ -483,6 +484,7 @@ typedef struct exp_node { #define stlen sub.val.slen #define valref sub.val.sref #define stfmt sub.val.idx +#define strndmode sub.val.rndmode #define wstptr sub.val.wsp #define wstlen sub.val.wslen #ifdef HAVE_MPFR @@ -1091,6 +1093,9 @@ extern char *OFMT; extern char *CONVFMT; extern int CONVFMTidx; extern int OFMTidx; +#ifdef HAVE_MPFR +extern int MPFR_round_mode; +#endif extern char *TEXTDOMAIN; extern NODE *BINMODE_node, *CONVFMT_node, *FIELDWIDTHS_node, *FILENAME_node; extern NODE *FNR_node, *FS_node, *IGNORECASE_node, *NF_node; @@ -1846,14 +1851,20 @@ dupnode(NODE *n) * and OFMT values. But if the value entered gawk as a string or strnum, then * stfmt should be set to STFMT_UNUSED, and the string representation should * not change. + * + * Additional twist: If ROUNDMODE changed at some point we have to + * recompute also. */ static inline NODE * force_string_fmt(NODE *s, const char *fmtstr, int fmtidx) { if ((s->flags & STRCUR) != 0 - && (s->stfmt == STFMT_UNUSED || s->stfmt == fmtidx) - ) + && (s->stfmt == STFMT_UNUSED || (s->stfmt == fmtidx +#ifdef HAVE_MPFR + && s->strndmode == MPFR_round_mode +#endif + ))) return s; return format_val(fmtstr, fmtidx, s); } @@ -8789,6 +8789,9 @@ set_profile_text(NODE *n, const char *str, size_t len) // Thanks and a tip of the hatlo to valgrind. n->flags |= (NUMCONSTSTR|STRCUR); n->stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + n->strndmode = MPFR_round_mode; +#endif } return n; @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -6361,6 +6361,9 @@ set_profile_text(NODE *n, const char *str, size_t len) // Thanks and a tip of the hatlo to valgrind. n->flags |= (NUMCONSTSTR|STRCUR); n->stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + n->strndmode = MPFR_round_mode; +#endif } return n; @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -2242,10 +2242,9 @@ do_print(int nargs, int redirtype) DEREF(args_array[i]); fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp)); } - if ( (tmp->flags & STRCUR) == 0 - || ( tmp->stfmt != STFMT_UNUSED - && tmp->stfmt != OFMTidx)) - args_array[i] = force_string_ofmt(tmp); + // Let force_string_ofmt handle checking if things + // are already valid. + args_array[i] = force_string_ofmt(tmp); } if (redir_exp != NULL) { diff --git a/doc/ChangeLog b/doc/ChangeLog index b19a57b6..a8f90b81 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,18 @@ +2018-01-08 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in (Checking for MPFR): Add warnings about exit's processing + of END rules. + +2018-01-03 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Update copryight year, and some small cleanups. + +2018-01-02 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Setting the rounding mode): Add a sidebar + with sample code (courtesy of <nethox@gmail.com>) to + demonstrate how ROUNDMODE affects number to string conversion. + 2017-12-28 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Updated. @@ -49,7 +64,7 @@ 2017-11-17 Arnold D. Robbins <arnold@skeeve.com> - * gawktexi.in(Changes from API V1): Give a list of things + * gawktexi.in (Changes from API V1): Give a list of things that changed, with xrefs. Thanks to Andrew Schorr for the push. 2017-11-09 Arnold D. Robbins <arnold@skeeve.com> diff --git a/doc/gawk.info b/doc/gawk.info index c3c4e8e7..aafd94bf 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -1,11 +1,11 @@ This is gawk.info, produced by makeinfo version 6.1 from gawk.texi. -Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2017 +Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2018 Free Software Foundation, Inc. This is Edition 4.2 of 'GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.2.0 (or later) version of the GNU +Guide for GNU Awk', for the 4.2.1 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -37,12 +37,12 @@ General Introduction This file documents 'awk', a program that you can use to select particular records in a file and perform operations upon them. - Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2017 + Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2018 Free Software Foundation, Inc. This is Edition 4.2 of 'GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.2.0 (or later) version of the GNU +Guide for GNU Awk', for the 4.2.1 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -23137,6 +23137,26 @@ cause any accumulating round-off error to cancel itself out. This is the default rounding mode for IEEE 754 computing functions and operators. + Rounding Modes and Conversion + + It's important to understand that, along with 'CONVFMT' and 'OFMT', +the rounding mode affects how numbers are converted to strings. For +example, consider the following program: + + BEGIN { + pi = 3.1416 + OFMT = "%.f" # Print value as integer + print pi # ROUNDMODE = "N" by default. + ROUNDMODE = "U" # Now change ROUNDMODE + print pi + } + +Running this program produces this output: + + $ gawk -M -f roundmode.awk + -| 3 + -| 4 + The other rounding modes are rarely used. Rounding toward positive infinity ('roundTowardPositive') and toward negative infinity ('roundTowardNegative') are often used to implement interval arithmetic, @@ -23273,10 +23293,14 @@ arbitrary-precision arithmetic is available: if (! adequate_math_precision(fpbits)) { print("Error: insufficient computation precision available.\n" \ "Try again with the -M argument?") > "/dev/stderr" + # Note: you may need to set a flag here to bail out of END rules exit 1 } } + Please be aware that 'exit' will jump to the 'END' rules, if present +(*note Exit Statement::). + File: gawk.info, Node: POSIX Floating Point Problems, Next: Floating point summary, Prev: Checking for MPFR, Up: Arbitrary Precision Arithmetic @@ -28593,7 +28617,7 @@ There are two ways to get GNU software: supported. If you have the 'wget' program, you can use a command like the following: - wget https://ftp.gnu.org/gnu/gawk/gawk-4.2.0.tar.gz + wget https://ftp.gnu.org/gnu/gawk/gawk-4.2.1.tar.gz The GNU software archive is mirrored around the world. The up-to-date list of mirror sites is available from the main FSF website @@ -28615,25 +28639,25 @@ compression programs: 'gzip', 'bzip2', and 'xz'. For simplicity, the rest of these instructions assume you are using the one compressed with the GNU Gzip program ('gzip'). - Once you have the distribution (e.g., 'gawk-4.2.0.tar.gz'), use + Once you have the distribution (e.g., 'gawk-4.2.1.tar.gz'), use 'gzip' to expand the file and then use 'tar' to extract it. You can use the following pipeline to produce the 'gawk' distribution: - gzip -d -c gawk-4.2.0.tar.gz | tar -xvpf - + gzip -d -c gawk-4.2.1.tar.gz | tar -xvpf - On a system with GNU 'tar', you can let 'tar' do the decompression for you: - tar -xvpzf gawk-4.2.0.tar.gz + tar -xvpzf gawk-4.2.1.tar.gz -Extracting the archive creates a directory named 'gawk-4.2.0' in the +Extracting the archive creates a directory named 'gawk-4.2.1' in the current directory. The distribution file name is of the form 'gawk-V.R.P.tar.gz'. The V represents the major version of 'gawk', the R represents the current release of version V, and the P represents a "patch level", meaning that minor bugs have been fixed in the release. The current patch level is -0, but when retrieving distributions, you should get the version with +1, but when retrieving distributions, you should get the version with the highest version, release, and patch level. (Note, however, that patch levels greater than or equal to 70 denote "beta" or nonproduction software; you might not want to retrieve such a version unless you don't @@ -28860,7 +28884,7 @@ Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin environment for MS-Windows. After you have extracted the 'gawk' distribution, 'cd' to -'gawk-4.2.0'. As with most GNU software, you configure 'gawk' for your +'gawk-4.2.1'. As with most GNU software, you configure 'gawk' for your system by running the 'configure' program. This program is a Bourne shell script that is generated automatically using GNU Autoconf. (The Autoconf software is described fully starting with *note (Autoconf, @@ -29192,8 +29216,8 @@ environment provides an excellent simulation of GNU/Linux, using Bash, GCC, GNU Make, and other GNU programs. Compilation and installation for Cygwin is the same as for a Unix system: - tar -xvpzf gawk-4.2.0.tar.gz - cd gawk-4.2.0 + tar -xvpzf gawk-4.2.1.tar.gz + cd gawk-4.2.1 ./configure make && make check @@ -29817,9 +29841,9 @@ B.6 Summary * The 'gawk' distribution is available from the GNU Project's main distribution site, 'ftp.gnu.org'. The canonical build recipe is: - wget https://ftp.gnu.org/gnu/gawk/gawk-4.2.0.tar.gz - tar -xvpzf gawk-4.2.0.tar.gz - cd gawk-4.2.0 + wget https://ftp.gnu.org/gnu/gawk/gawk-4.2.1.tar.gz + tar -xvpzf gawk-4.2.1.tar.gz + cd gawk-4.2.1 ./configure && make && make check NOTE: Because of the 'https://' URL, you may have to supply @@ -35415,6 +35439,8 @@ Index * round() user-defined function: Round Function. (line 16) * rounding numbers: Round Function. (line 6) * ROUNDMODE variable: User-modified. (line 131) +* ROUNDMODE variable <1>: Setting the rounding mode. + (line 6) * RS variable: awk split records. (line 12) * RS variable <1>: User-modified. (line 136) * RS variable, multiline records and: Multiple Line. (line 17) @@ -35542,6 +35568,8 @@ Index * sidebar, Pre-POSIX awk Used OFMT for String Conversion: Strings And Numbers. (line 54) * sidebar, Recipe for a Programming Language: History. (line 6) +* sidebar, Rounding Modes and Conversion: Setting the rounding mode. + (line 65) * sidebar, RS = "\0" Is Not Portable: gawk split records. (line 63) * sidebar, So Why Does gawk Have BEGINFILE and ENDFILE?: Filetrans Function. (line 83) @@ -36367,160 +36395,160 @@ Node: Setting precision933040 Ref: table-predefined-precision-strings933737 Node: Setting the rounding mode935567 Ref: table-gawk-rounding-modes935941 -Ref: Setting the rounding mode-Footnote-1939316 -Node: Arbitrary Precision Integers939495 -Ref: Arbitrary Precision Integers-Footnote-1942670 -Node: Checking for MPFR942819 -Node: POSIX Floating Point Problems944116 -Ref: POSIX Floating Point Problems-Footnote-1947987 -Node: Floating point summary948025 -Node: Dynamic Extensions950215 -Node: Extension Intro951768 -Node: Plugin License953034 -Node: Extension Mechanism Outline953831 -Ref: figure-load-extension954270 -Ref: figure-register-new-function955835 -Ref: figure-call-new-function956927 -Node: Extension API Description958989 -Node: Extension API Functions Introduction960631 -Node: General Data Types966171 -Ref: General Data Types-Footnote-1974532 -Node: Memory Allocation Functions974831 -Ref: Memory Allocation Functions-Footnote-1979041 -Node: Constructor Functions979140 -Node: Registration Functions982726 -Node: Extension Functions983411 -Node: Exit Callback Functions988626 -Node: Extension Version String989876 -Node: Input Parsers990539 -Node: Output Wrappers1003260 -Node: Two-way processors1007772 -Node: Printing Messages1010037 -Ref: Printing Messages-Footnote-11011208 -Node: Updating ERRNO1011361 -Node: Requesting Values1012100 -Ref: table-value-types-returned1012837 -Node: Accessing Parameters1013773 -Node: Symbol Table Access1015008 -Node: Symbol table by name1015520 -Node: Symbol table by cookie1017309 -Ref: Symbol table by cookie-Footnote-11021494 -Node: Cached values1021558 -Ref: Cached values-Footnote-11025094 -Node: Array Manipulation1025247 -Ref: Array Manipulation-Footnote-11026338 -Node: Array Data Types1026375 -Ref: Array Data Types-Footnote-11029033 -Node: Array Functions1029125 -Node: Flattening Arrays1033623 -Node: Creating Arrays1040599 -Node: Redirection API1045366 -Node: Extension API Variables1048199 -Node: Extension Versioning1048910 -Ref: gawk-api-version1049339 -Node: Extension GMP/MPFR Versioning1051070 -Node: Extension API Informational Variables1052698 -Node: Extension API Boilerplate1053771 -Node: Changes from API V11057745 -Node: Finding Extensions1059317 -Node: Extension Example1059876 -Node: Internal File Description1060674 -Node: Internal File Ops1064754 -Ref: Internal File Ops-Footnote-11076105 -Node: Using Internal File Ops1076245 -Ref: Using Internal File Ops-Footnote-11078628 -Node: Extension Samples1078902 -Node: Extension Sample File Functions1080431 -Node: Extension Sample Fnmatch1088080 -Node: Extension Sample Fork1089567 -Node: Extension Sample Inplace1090785 -Node: Extension Sample Ord1094002 -Node: Extension Sample Readdir1094838 -Ref: table-readdir-file-types1095727 -Node: Extension Sample Revout1096532 -Node: Extension Sample Rev2way1097121 -Node: Extension Sample Read write array1097861 -Node: Extension Sample Readfile1099803 -Node: Extension Sample Time1100898 -Node: Extension Sample API Tests1102246 -Node: gawkextlib1102738 -Node: Extension summary1105194 -Node: Extension Exercises1108896 -Node: Language History1110394 -Node: V7/SVR3.11112050 -Node: SVR41114202 -Node: POSIX1115636 -Node: BTL1117016 -Node: POSIX/GNU1117745 -Node: Feature History1123523 -Node: Common Extensions1139382 -Node: Ranges and Locales1140665 -Ref: Ranges and Locales-Footnote-11145281 -Ref: Ranges and Locales-Footnote-21145308 -Ref: Ranges and Locales-Footnote-31145543 -Node: Contributors1145764 -Node: History summary1151709 -Node: Installation1153089 -Node: Gawk Distribution1154033 -Node: Getting1154517 -Node: Extracting1155480 -Node: Distribution contents1157118 -Node: Unix Installation1163598 -Node: Quick Installation1164280 -Node: Shell Startup Files1166694 -Node: Additional Configuration Options1167783 -Node: Configuration Philosophy1169948 -Node: Non-Unix Installation1172317 -Node: PC Installation1172777 -Node: PC Binary Installation1173615 -Node: PC Compiling1174050 -Node: PC Using1175167 -Node: Cygwin1178212 -Node: MSYS1178982 -Node: VMS Installation1179483 -Node: VMS Compilation1180274 -Ref: VMS Compilation-Footnote-11181503 -Node: VMS Dynamic Extensions1181561 -Node: VMS Installation Details1183246 -Node: VMS Running1185499 -Node: VMS GNV1189778 -Node: VMS Old Gawk1190513 -Node: Bugs1190984 -Node: Bug address1191647 -Node: Usenet1194439 -Node: Maintainers1195216 -Node: Other Versions1196477 -Node: Installation summary1203239 -Node: Notes1204441 -Node: Compatibility Mode1205306 -Node: Additions1206088 -Node: Accessing The Source1207013 -Node: Adding Code1208450 -Node: New Ports1214669 -Node: Derived Files1219157 -Ref: Derived Files-Footnote-11224803 -Ref: Derived Files-Footnote-21224838 -Ref: Derived Files-Footnote-31225436 -Node: Future Extensions1225550 -Node: Implementation Limitations1226208 -Node: Extension Design1227391 -Node: Old Extension Problems1228545 -Ref: Old Extension Problems-Footnote-11230063 -Node: Extension New Mechanism Goals1230120 -Ref: Extension New Mechanism Goals-Footnote-11233484 -Node: Extension Other Design Decisions1233673 -Node: Extension Future Growth1235786 -Node: Old Extension Mechanism1236622 -Node: Notes summary1238385 -Node: Basic Concepts1239567 -Node: Basic High Level1240248 -Ref: figure-general-flow1240530 -Ref: figure-process-flow1241215 -Ref: Basic High Level-Footnote-11244516 -Node: Basic Data Typing1244701 -Node: Glossary1248029 -Node: Copying1279867 -Node: GNU Free Documentation License1317406 -Node: Index1342524 +Ref: Setting the rounding mode-Footnote-1939872 +Node: Arbitrary Precision Integers940051 +Ref: Arbitrary Precision Integers-Footnote-1943226 +Node: Checking for MPFR943375 +Node: POSIX Floating Point Problems944849 +Ref: POSIX Floating Point Problems-Footnote-1948720 +Node: Floating point summary948758 +Node: Dynamic Extensions950948 +Node: Extension Intro952501 +Node: Plugin License953767 +Node: Extension Mechanism Outline954564 +Ref: figure-load-extension955003 +Ref: figure-register-new-function956568 +Ref: figure-call-new-function957660 +Node: Extension API Description959722 +Node: Extension API Functions Introduction961364 +Node: General Data Types966904 +Ref: General Data Types-Footnote-1975265 +Node: Memory Allocation Functions975564 +Ref: Memory Allocation Functions-Footnote-1979774 +Node: Constructor Functions979873 +Node: Registration Functions983459 +Node: Extension Functions984144 +Node: Exit Callback Functions989359 +Node: Extension Version String990609 +Node: Input Parsers991272 +Node: Output Wrappers1003993 +Node: Two-way processors1008505 +Node: Printing Messages1010770 +Ref: Printing Messages-Footnote-11011941 +Node: Updating ERRNO1012094 +Node: Requesting Values1012833 +Ref: table-value-types-returned1013570 +Node: Accessing Parameters1014506 +Node: Symbol Table Access1015741 +Node: Symbol table by name1016253 +Node: Symbol table by cookie1018042 +Ref: Symbol table by cookie-Footnote-11022227 +Node: Cached values1022291 +Ref: Cached values-Footnote-11025827 +Node: Array Manipulation1025980 +Ref: Array Manipulation-Footnote-11027071 +Node: Array Data Types1027108 +Ref: Array Data Types-Footnote-11029766 +Node: Array Functions1029858 +Node: Flattening Arrays1034356 +Node: Creating Arrays1041332 +Node: Redirection API1046099 +Node: Extension API Variables1048932 +Node: Extension Versioning1049643 +Ref: gawk-api-version1050072 +Node: Extension GMP/MPFR Versioning1051803 +Node: Extension API Informational Variables1053431 +Node: Extension API Boilerplate1054504 +Node: Changes from API V11058478 +Node: Finding Extensions1060050 +Node: Extension Example1060609 +Node: Internal File Description1061407 +Node: Internal File Ops1065487 +Ref: Internal File Ops-Footnote-11076838 +Node: Using Internal File Ops1076978 +Ref: Using Internal File Ops-Footnote-11079361 +Node: Extension Samples1079635 +Node: Extension Sample File Functions1081164 +Node: Extension Sample Fnmatch1088813 +Node: Extension Sample Fork1090300 +Node: Extension Sample Inplace1091518 +Node: Extension Sample Ord1094735 +Node: Extension Sample Readdir1095571 +Ref: table-readdir-file-types1096460 +Node: Extension Sample Revout1097265 +Node: Extension Sample Rev2way1097854 +Node: Extension Sample Read write array1098594 +Node: Extension Sample Readfile1100536 +Node: Extension Sample Time1101631 +Node: Extension Sample API Tests1102979 +Node: gawkextlib1103471 +Node: Extension summary1105927 +Node: Extension Exercises1109629 +Node: Language History1111127 +Node: V7/SVR3.11112783 +Node: SVR41114935 +Node: POSIX1116369 +Node: BTL1117749 +Node: POSIX/GNU1118478 +Node: Feature History1124256 +Node: Common Extensions1140115 +Node: Ranges and Locales1141398 +Ref: Ranges and Locales-Footnote-11146014 +Ref: Ranges and Locales-Footnote-21146041 +Ref: Ranges and Locales-Footnote-31146276 +Node: Contributors1146497 +Node: History summary1152442 +Node: Installation1153822 +Node: Gawk Distribution1154766 +Node: Getting1155250 +Node: Extracting1156213 +Node: Distribution contents1157851 +Node: Unix Installation1164331 +Node: Quick Installation1165013 +Node: Shell Startup Files1167427 +Node: Additional Configuration Options1168516 +Node: Configuration Philosophy1170681 +Node: Non-Unix Installation1173050 +Node: PC Installation1173510 +Node: PC Binary Installation1174348 +Node: PC Compiling1174783 +Node: PC Using1175900 +Node: Cygwin1178945 +Node: MSYS1179715 +Node: VMS Installation1180216 +Node: VMS Compilation1181007 +Ref: VMS Compilation-Footnote-11182236 +Node: VMS Dynamic Extensions1182294 +Node: VMS Installation Details1183979 +Node: VMS Running1186232 +Node: VMS GNV1190511 +Node: VMS Old Gawk1191246 +Node: Bugs1191717 +Node: Bug address1192380 +Node: Usenet1195172 +Node: Maintainers1195949 +Node: Other Versions1197210 +Node: Installation summary1203972 +Node: Notes1205174 +Node: Compatibility Mode1206039 +Node: Additions1206821 +Node: Accessing The Source1207746 +Node: Adding Code1209183 +Node: New Ports1215402 +Node: Derived Files1219890 +Ref: Derived Files-Footnote-11225536 +Ref: Derived Files-Footnote-21225571 +Ref: Derived Files-Footnote-31226169 +Node: Future Extensions1226283 +Node: Implementation Limitations1226941 +Node: Extension Design1228124 +Node: Old Extension Problems1229278 +Ref: Old Extension Problems-Footnote-11230796 +Node: Extension New Mechanism Goals1230853 +Ref: Extension New Mechanism Goals-Footnote-11234217 +Node: Extension Other Design Decisions1234406 +Node: Extension Future Growth1236519 +Node: Old Extension Mechanism1237355 +Node: Notes summary1239118 +Node: Basic Concepts1240300 +Node: Basic High Level1240981 +Ref: figure-general-flow1241263 +Ref: figure-process-flow1241948 +Ref: Basic High Level-Footnote-11245249 +Node: Basic Data Typing1245434 +Node: Glossary1248762 +Node: Copying1280600 +Node: GNU Free Documentation License1318139 +Node: Index1343257 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index ba042aae..61b232ea 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -64,9 +64,9 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH October, 2017 +@set UPDATE-MONTH January, 2018 @set VERSION 4.2 -@set PATCHLEVEL 0 +@set PATCHLEVEL 1 @set GAWKINETTITLE TCP/IP Internetworking with @command{gawk} @ifset FOR_PRINT @@ -284,13 +284,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2017 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2018 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2017 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2018 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -32028,6 +32028,7 @@ $ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 1/10) @}'} @node Setting the rounding mode @subsection Setting the Rounding Mode +@cindex @code{ROUNDMODE} variable The @code{ROUNDMODE} variable provides program-level control over the rounding mode. The correspondence between @code{ROUNDMODE} and the IEEE @@ -32100,6 +32101,71 @@ distributes upward and downward rounds of exact halves, which might cause any accumulating round-off error to cancel itself out. This is the default rounding mode for IEEE 754 computing functions and operators. +@c January 2018. Thanks to nethox@gmail.com for the example. +@cindex sidebar, Rounding Modes and Conversion +@ifdocbook +@docbook +<sidebar><title>Rounding Modes and Conversion</title> +@end docbook + +It's important to understand that, along with @code{CONVFMT} and +@code{OFMT}, the rounding mode affects how numbers are converted to strings. +For example, consider the following program: + +@example +BEGIN @{ + pi = 3.1416 + OFMT = "%.f" # Print value as integer + print pi # ROUNDMODE = "N" by default. + ROUNDMODE = "U" # Now change ROUNDMODE + print pi +@} +@end example + +@noindent +Running this program produces this output: + +@example +$ @kbd{gawk -M -f roundmode.awk} +@print{} 3 +@print{} 4 +@end example + +@docbook +</sidebar> +@end docbook +@end ifdocbook + +@ifnotdocbook +@cartouche +@center @b{Rounding Modes and Conversion} + + +It's important to understand that, along with @code{CONVFMT} and +@code{OFMT}, the rounding mode affects how numbers are converted to strings. +For example, consider the following program: + +@example +BEGIN @{ + pi = 3.1416 + OFMT = "%.f" # Print value as integer + print pi # ROUNDMODE = "N" by default. + ROUNDMODE = "U" # Now change ROUNDMODE + print pi +@} +@end example + +@noindent +Running this program produces this output: + +@example +$ @kbd{gawk -M -f roundmode.awk} +@print{} 3 +@print{} 4 +@end example +@end cartouche +@end ifnotdocbook + The other rounding modes are rarely used. Rounding toward positive infinity (@code{roundTowardPositive}) and toward negative infinity (@code{roundTowardNegative}) are often used to implement interval @@ -32398,11 +32464,14 @@ BEGIN @{ if (! adequate_math_precision(fpbits)) @{ print("Error: insufficient computation precision available.\n" \ "Try again with the -M argument?") > "/dev/stderr" + # Note: you may need to set a flag here to bail out of END rules exit 1 @} @} @end example +Please be aware that @code{exit} will jump to the @code{END} rules, if present (@pxref{Exit Statement}). + @node POSIX Floating Point Problems @section Standards Versus Existing Practice @@ -40336,13 +40405,6 @@ The people maintaining the various @command{gawk} ports are: If your bug is also reproducible under Unix, send a copy of your report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well. -@c 7/2017, Juan Guerrero has taken over the DJGPP port. -@ignore -The DJGPP port is no longer supported; it will remain in the code base -for a while in case a volunteer wishes to take it over. If this does -not happen, then eventually code for this port will be removed. -@end ignore - @node Other Versions @appendixsec Other Freely Available @command{awk} Implementations @cindex @command{awk}, implementations diff --git a/doc/gawktexi.in b/doc/gawktexi.in index dab833d4..6c4e3b29 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -59,9 +59,9 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH October, 2017 +@set UPDATE-MONTH January, 2018 @set VERSION 4.2 -@set PATCHLEVEL 0 +@set PATCHLEVEL 1 @set GAWKINETTITLE TCP/IP Internetworking with @command{gawk} @ifset FOR_PRINT @@ -279,13 +279,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2017 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2018 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2017 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2018 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -31041,6 +31041,7 @@ $ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 1/10) @}'} @node Setting the rounding mode @subsection Setting the Rounding Mode +@cindex @code{ROUNDMODE} variable The @code{ROUNDMODE} variable provides program-level control over the rounding mode. The correspondence between @code{ROUNDMODE} and the IEEE @@ -31113,6 +31114,32 @@ distributes upward and downward rounds of exact halves, which might cause any accumulating round-off error to cancel itself out. This is the default rounding mode for IEEE 754 computing functions and operators. +@c January 2018. Thanks to nethox@gmail.com for the example. +@sidebar Rounding Modes and Conversion +It's important to understand that, along with @code{CONVFMT} and +@code{OFMT}, the rounding mode affects how numbers are converted to strings. +For example, consider the following program: + +@example +BEGIN @{ + pi = 3.1416 + OFMT = "%.f" # Print value as integer + print pi # ROUNDMODE = "N" by default. + ROUNDMODE = "U" # Now change ROUNDMODE + print pi +@} +@end example + +@noindent +Running this program produces this output: + +@example +$ @kbd{gawk -M -f roundmode.awk} +@print{} 3 +@print{} 4 +@end example +@end sidebar + The other rounding modes are rarely used. Rounding toward positive infinity (@code{roundTowardPositive}) and toward negative infinity (@code{roundTowardNegative}) are often used to implement interval @@ -31411,11 +31438,14 @@ BEGIN @{ if (! adequate_math_precision(fpbits)) @{ print("Error: insufficient computation precision available.\n" \ "Try again with the -M argument?") > "/dev/stderr" + # Note: you may need to set a flag here to bail out of END rules exit 1 @} @} @end example +Please be aware that @code{exit} will jump to the @code{END} rules, if present (@pxref{Exit Statement}). + @node POSIX Floating Point Problems @section Standards Versus Existing Practice @@ -39349,13 +39379,6 @@ The people maintaining the various @command{gawk} ports are: If your bug is also reproducible under Unix, send a copy of your report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well. -@c 7/2017, Juan Guerrero has taken over the DJGPP port. -@ignore -The DJGPP port is no longer supported; it will remain in the code base -for a while in case a volunteer wishes to take it over. If this does -not happen, then eventually code for this port will be removed. -@end ignore - @node Other Versions @appendixsec Other Freely Available @command{awk} Implementations @cindex @command{awk}, implementations @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -308,6 +308,9 @@ set_record(const char *buf, int cnt, const awk_fieldwidth_info_t *fw) n->valref = 1; n->type = Node_val; n->stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + n->strndmode = MPFR_round_mode; +#endif n->flags = (STRING|STRCUR|USER_INPUT); /* do not set MALLOC */ fields_arr[0] = n; if (fw != api_fw) { @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2012-2017 the Free Software Foundation, Inc. + * Copyright (C) 2012-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -925,6 +925,9 @@ api_sym_update_scalar(awk_ext_id_t id, r->stfmt = STFMT_UNUSED; r->stptr = value->str_value.str; r->stlen = value->str_value.len; +#ifdef HAVE_MPFR + r->strndmode = MPFR_round_mode; +#endif return awk_true; } break; diff --git a/interpret.h b/interpret.h index 4b140c28..2ee68112 100644 --- a/interpret.h +++ b/interpret.h @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -735,6 +735,9 @@ mod: /* configure as a string as in make_str_node */ t1->flags |= (MALLOC|STRING|STRCUR); t1->stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + t1->strndmode = MPFR_round_mode; +#endif if ((t1->flags & WSTRCUR) != 0 && (t2->flags & WSTRCUR) != 0) { size_t wlen = t1->wstlen + t2->wstlen; @@ -1892,6 +1892,210 @@ strictopen: return openfd; } +/* push_pty_line_disciplines --- push line disciplines if we work that way */ + +// Factors out common code for the two versions of fork_and_open_slave_pty(). + +static void +push_pty_line_disciplines(int slave) +{ +#ifdef I_PUSH + /* + * Push the necessary modules onto the slave to + * get terminal semantics. Check that they aren't + * already there to avoid hangs on said "limited" systems. + */ +#ifdef I_FIND + if (ioctl(slave, I_FIND, "ptem") == 0) +#endif + ioctl(slave, I_PUSH, "ptem"); +#ifdef I_FIND + if (ioctl(slave, I_FIND, "ldterm") == 0) +#endif + ioctl(slave, I_PUSH, "ldterm"); +#endif +} + +/* set_slave_pty_attributes --- set terminal attributes for slave pty */ + +// Factors out common code for the two versions of fork_and_open_slave_pty(). + +static void +set_slave_pty_attributes(int slave) +{ +#ifdef HAVE_TERMIOS_H + struct termios st; + + tcgetattr(slave, & st); + st.c_iflag &= ~(ISTRIP | IGNCR | INLCR | IXOFF); + st.c_iflag |= (ICRNL | IGNPAR | BRKINT | IXON); + st.c_oflag &= ~OPOST; + st.c_cflag &= ~CSIZE; + st.c_cflag |= CREAD | CS8 | CLOCAL; + st.c_lflag &= ~(ECHO | ECHOE | ECHOK | NOFLSH | TOSTOP); + st.c_lflag |= ISIG; + + /* Set some control codes to default values */ +#ifdef VINTR + st.c_cc[VINTR] = '\003'; /* ^c */ +#endif +#ifdef VQUIT + st.c_cc[VQUIT] = '\034'; /* ^| */ +#endif +#ifdef VERASE + st.c_cc[VERASE] = '\177'; /* ^? */ +#endif +#ifdef VKILL + st.c_cc[VKILL] = '\025'; /* ^u */ +#endif +#ifdef VEOF + st.c_cc[VEOF] = '\004'; /* ^d */ +#endif + tcsetattr(slave, TCSANOW, & st); +#endif /* HAVE_TERMIOS_H */ +} + + +/* fork_and_open_slave_pty --- handle forking the child and slave pty setup */ + +/* + * January, 2018: + * This is messy. AIX and HP-UX require that the slave pty be opened and + * set up in the child. Everything else wants it to be done in the parent, + * before the fork. Thus we have two different versions of the routine that + * do the same thing, but in different orders. This is not pretty, but it + * seems to be the simplest thing to do. + */ + +#if defined _AIX || defined __hpux +static bool +fork_and_open_slave_pty(const char *slavenam, int master, const char *command, pid_t *pid) +{ + int slave; + int save_errno; + + /* + * We specifically open the slave only in the child. This allows + * certain, er, "limited" systems to work. The open is specifically + * without O_NOCTTY in order to make the slave become the controlling + * terminal. + */ + + switch (*pid = fork()) { + case 0: + /* Child process */ + setsid(); + + if ((slave = open(slavenam, O_RDWR)) < 0) { + close(master); + fatal(_("could not open `%s', mode `%s'"), + slavenam, "r+"); + } + + push_pty_line_disciplines(slave); + set_slave_pty_attributes(slave); + + if (close(master) == -1) + fatal(_("close of master pty failed (%s)"), strerror(errno)); + if (close(1) == -1) + fatal(_("close of stdout in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 1) + fatal(_("moving slave pty to stdout in child failed (dup: %s)"), strerror(errno)); + if (close(0) == -1) + fatal(_("close of stdin in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 0) + fatal(_("moving slave pty to stdin in child failed (dup: %s)"), strerror(errno)); + if (close(slave)) + fatal(_("close of slave pty failed (%s)"), strerror(errno)); + + /* stderr does NOT get dup'ed onto child's stdout */ + + set_sigpipe_to_default(); + + execl("/bin/sh", "sh", "-c", command, NULL); + _exit(errno == ENOENT ? 127 : 126); + + case -1: + save_errno = errno; + close(master); + errno = save_errno; + return false; + + default: + return true; + } +} +#else +#ifndef VMS +static bool +fork_and_open_slave_pty(const char *slavenam, int master, const char *command, pid_t *pid) +{ + int slave; + int save_errno; + + if ((slave = open(slavenam, O_RDWR)) < 0) { + close(master); + fatal(_("could not open `%s', mode `%s'"), + slavenam, "r+"); + } + + push_pty_line_disciplines(slave); + set_slave_pty_attributes(slave); + + switch (*pid = fork()) { + case 0: + /* Child process */ + setsid(); + +#ifdef TIOCSCTTY + ioctl(slave, TIOCSCTTY, 0); +#endif + + if (close(master) == -1) + fatal(_("close of master pty failed (%s)"), strerror(errno)); + if (close(1) == -1) + fatal(_("close of stdout in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 1) + fatal(_("moving slave pty to stdout in child failed (dup: %s)"), strerror(errno)); + if (close(0) == -1) + fatal(_("close of stdin in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 0) + fatal(_("moving slave pty to stdin in child failed (dup: %s)"), strerror(errno)); + if (close(slave)) + fatal(_("close of slave pty failed (%s)"), strerror(errno)); + + /* stderr does NOT get dup'ed onto child's stdout */ + + signal(SIGPIPE, SIG_DFL); + + execl("/bin/sh", "sh", "-c", command, NULL); + _exit(errno == ENOENT ? 127 : 126); + + case -1: + save_errno = errno; + close(master); + close(slave); + errno = save_errno; + return false; + + } + + /* parent */ + if (close(slave) != 0) { + close(master); + (void) kill(*pid, SIGKILL); + fatal(_("close of slave pty failed (%s)"), strerror(errno)); + } + + return true; +} +#endif +#endif + /* two_way_open --- open a two way communications channel */ static int @@ -1955,11 +2159,8 @@ two_way_open(const char *str, struct redirect *rp, int extfd) char slavenam[32]; char c; int master, dup_master; - int slave; - int save_errno; pid_t pid; struct stat statb; - struct termios st; /* Use array of chars to avoid ASCII / EBCDIC issues */ static char pty_chars[] = "pqrstuvwxyzabcdefghijklmno"; int i; @@ -2046,104 +2247,9 @@ two_way_open(const char *str, struct redirect *rp, int extfd) got_the_pty: - /* - * We specifically open the slave only in the child. This allows - * certain, er, "limited" systems to work. The open is specifically - * without O_NOCTTY in order to make the slave become the controlling - * terminal. - */ - - switch (pid = fork()) { - case 0: - /* Child process */ - setsid(); - - if ((slave = open(slavenam, O_RDWR)) < 0) { - close(master); - fatal(_("could not open `%s', mode `%s'"), - slavenam, "r+"); - } - -#ifdef I_PUSH - /* - * Push the necessary modules onto the slave to - * get terminal semantics. Check that they aren't - * already there to avoid hangs on said "limited" systems. - */ -#ifdef I_FIND - if (ioctl(slave, I_FIND, "ptem") == 0) -#endif - ioctl(slave, I_PUSH, "ptem"); -#ifdef I_FIND - if (ioctl(slave, I_FIND, "ldterm") == 0) -#endif - ioctl(slave, I_PUSH, "ldterm"); -#endif - tcgetattr(slave, & st); - - st.c_iflag &= ~(ISTRIP | IGNCR | INLCR | IXOFF); - st.c_iflag |= (ICRNL | IGNPAR | BRKINT | IXON); - st.c_oflag &= ~OPOST; - st.c_cflag &= ~CSIZE; - st.c_cflag |= CREAD | CS8 | CLOCAL; - st.c_lflag &= ~(ECHO | ECHOE | ECHOK | NOFLSH | TOSTOP); - st.c_lflag |= ISIG; - - /* Set some control codes to default values */ -#ifdef VINTR - st.c_cc[VINTR] = '\003'; /* ^c */ -#endif -#ifdef VQUIT - st.c_cc[VQUIT] = '\034'; /* ^| */ -#endif -#ifdef VERASE - st.c_cc[VERASE] = '\177'; /* ^? */ -#endif -#ifdef VKILL - st.c_cc[VKILL] = '\025'; /* ^u */ -#endif -#ifdef VEOF - st.c_cc[VEOF] = '\004'; /* ^d */ -#endif - -#ifdef TIOCSCTTY - /* - * This may not necessary anymore given that we - * open the slave in the child, but it doesn't hurt. - */ - ioctl(slave, TIOCSCTTY, 0); -#endif - tcsetattr(slave, TCSANOW, & st); - - if (close(master) == -1) - fatal(_("close of master pty failed (%s)"), strerror(errno)); - if (close(1) == -1) - fatal(_("close of stdout in child failed (%s)"), - strerror(errno)); - if (dup(slave) != 1) - fatal(_("moving slave pty to stdout in child failed (dup: %s)"), strerror(errno)); - if (close(0) == -1) - fatal(_("close of stdin in child failed (%s)"), - strerror(errno)); - if (dup(slave) != 0) - fatal(_("moving slave pty to stdin in child failed (dup: %s)"), strerror(errno)); - if (close(slave)) - fatal(_("close of slave pty failed (%s)"), strerror(errno)); - - /* stderr does NOT get dup'ed onto child's stdout */ - - set_sigpipe_to_default(); - - execl("/bin/sh", "sh", "-c", str, NULL); - _exit(errno == ENOENT ? 127 : 126); - - case -1: - save_errno = errno; - close(master); - errno = save_errno; - return false; - - } + /* this is the parent */ + if (! fork_and_open_slave_pty(slavenam, master, str, & pid)) + fatal(_("could not create child process or open pty")); rp->pid = pid; rp->iop = iop_alloc(master, str, 0); @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2017 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -24,7 +24,7 @@ */ /* FIX THIS BEFORE EVERY RELEASE: */ -#define UPDATE_YEAR 2017 +#define UPDATE_YEAR 2018 #include "awk.h" #include "getopt.h" @@ -3,7 +3,8 @@ */ /* - * Copyright (C) 2012, 2013, 2015, 2017, the Free Software Foundation, Inc. + * Copyright (C) 2012, 2013, 2015, 2017, 2018, + * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -27,6 +28,8 @@ #ifdef HAVE_MPFR +int MPFR_round_mode = 'N'; // default value + #if !defined(MPFR_VERSION_MAJOR) || MPFR_VERSION_MAJOR < 3 typedef mp_exp_t mpfr_exp_t; #endif @@ -373,6 +376,7 @@ mpg_format_val(const char *format, int index, NODE *s) efree(s->stptr); s->stptr = r->stptr; s->flags |= STRCUR; + s->strndmode = MPFR_round_mode; freenode(r); /* Do not unref(r)! We want to keep s->stptr == r->stpr. */ free_wstr(s); return s; @@ -596,6 +600,7 @@ set_ROUNDMODE() if (rndm != -1) { mpfr_set_default_rounding_mode(rndm); ROUND_MODE = rndm; + MPFR_round_mode = n->stptr[0]; } else warning(_("RNDMODE value `%.*s' is invalid"), (int) n->stlen, n->stptr); } @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003-2015, 2017, + * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003-2015, 2017, 2018, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -252,6 +252,9 @@ r_format_val(const char *format, int index, NODE *s) if ((s->flags & (MALLOC|STRCUR)) == (MALLOC|STRCUR)) efree(s->stptr); s->stptr = r->stptr; +#ifdef HAVE_MPFR + s->strndmode = MPFR_round_mode; +#endif freenode(r); /* Do not unref(r)! We want to keep s->stptr == r->stpr. */ goto no_malloc; @@ -273,6 +276,9 @@ r_format_val(const char *format, int index, NODE *s) s->flags &= ~(INTIND|NUMBER); s->flags |= STRING; } +#ifdef HAVE_MPFR + s->strndmode = MPFR_round_mode; +#endif } if ((s->flags & (MALLOC|STRCUR)) == (MALLOC|STRCUR)) efree(s->stptr); @@ -377,6 +383,9 @@ make_str_node(const char *s, size_t len, int flags) r->flags = (MALLOC|STRING|STRCUR); r->valref = 1; r->stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + r->strndmode = MPFR_round_mode; +#endif r->wstptr = NULL; r->wstlen = 0; diff --git a/pc/ChangeLog b/pc/ChangeLog index 4f081b4a..e4b6c028 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,7 @@ +2018-01-10 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.tst: Initial sync against test/Makefile.in. + 2017-11-19 Juan Manuel Guerrero <juan.guerrero@gmx.de> * pc/Makefile (default): Add lines for the djgpp-readline-mpfr diff --git a/pc/Makefile.tst b/pc/Makefile.tst index 3bbfcd7e..b7622df8 100644 --- a/pc/Makefile.tst +++ b/pc/Makefile.tst @@ -175,7 +175,8 @@ BASIC_TESTS = \ regexpbrack regexpbrack2 regexprange regrange reindops reparse resplit \ rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 rstest3 \ rstest4 rstest5 rswhite \ - scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr \ + scalar sclforin sclifin setrec0 setrec1 \ + sigpipe1 sortempty sortglos splitargv splitarr \ splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \ tradanch tweakfld \ @@ -207,7 +208,7 @@ GAWK_EXT_TESTS = \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \ procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \ - profile7 profile8 profile9 profile10 pty1 \ + profile7 profile8 profile9 profile10 pty1 pty2 \ rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline rsglstdin \ rsstart1 rsstart2 rsstart3 rstest6 \ shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit split_after_fpat \ @@ -221,7 +222,7 @@ ARRAYDEBUG_TESTS = arrdbg EXTRA_TESTS = inftest regtest ignrcas3 INET_TESTS = inetdayu inetdayt inetechu inetecht MACHINE_TESTS = double1 double2 fmtspcl intformat -MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrieee +MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrrndeval mpfrieee LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ @@ -1021,6 +1022,10 @@ mpfrrnd: @$(AWK) -M -vPREC=53 -f "$(srcdir)"/$@.awk > _$@ 2>&1 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mpfrrndeval: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ mpfrnegzero: @echo $@ @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 @@ -1353,13 +1358,21 @@ watchpoint1: pty1: @echo $@ - @echo Expect pty1 to fail with DJGPP and MinGW. + @echo Expect $@ to fail with DJGPP and MinGW. @-case `uname` in \ *[Oo][Ss]/390*) : ;; \ *) AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ; \ $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ esac +pty2: + @echo $@ + @echo Expect $@ to fail with DJGPP and MinGW. + @-case `uname` in \ + *[Oo][Ss]/390*) : ;; \ + *) AWKPATH="$(srcdir)" $(AWK) -f $@.awk | od -c >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ; \ + $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ + esac rscompat: @echo $@ @AWKPATH="$(srcdir)" $(AWK) --traditional -f $@.awk "$(srcdir)/$@.in" >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -2293,6 +2306,16 @@ sclifin: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +setrec0: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +setrec1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + sigpipe1: @case `uname` in \ *MS-DOS*) echo This test fails on DJGPP --- skipping $@ ;; \ @@ -3160,17 +3183,7 @@ diffout: # convenient way to scan valgrind results for errors valgrind-scan: @echo "Scanning valgrind log files for problems:" - @$(AWK) '\ - function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \ - printf "\t%s\n",$$0}; \ - {$$1 = ""}; \ - $$2 == "Command:" {incmd = 1; $$2 = ""; cmd = $$0; next}; \ - incmd {if (/Parent PID:/) incmd = 0; else {cmd = (cmd $$0); next}}; \ - /ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \ - /definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ - /possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ - / suppressed:/ && !/: 0 bytes in 0 blocks/ {show()}; \ - ' log.[0-9]* + @$(AWK) -f "$(srcdir)"/valgrind.awk log.[0-9]* # This target is for testing with electric fence. efence: diff --git a/str_array.c b/str_array.c index 8d6d2b01..bc6584d2 100644 --- a/str_array.c +++ b/str_array.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2013, 2016, 2017, + * Copyright (C) 1986, 1988, 1989, 1991-2013, 2016, 2017, 2018, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -444,7 +444,7 @@ str_kilobytes(NODE *symbol) bucket_cnt = symbol->table_size; - /* This does not include extra memory for indices with stfmt != -1 */ + /* This does not include extra memory for indices with stfmt != STFMT_UNUSED */ kb = (((AWKNUM) bucket_cnt) * sizeof (BUCKET) + ((AWKNUM) symbol->array_size) * sizeof (BUCKET *)) / 1024.0; return kb; @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2015, 2017, + * Copyright (C) 1986, 1988, 1989, 1991-2015, 2017, 2018, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -653,6 +653,9 @@ check_param_names(void) n.type = Node_val; n.flags = STRING|STRCUR; n.stfmt = STFMT_UNUSED; +#ifdef HAVE_MPFR + n.strndmode = MPFR_round_mode; +#endif /* * assoc_list() returns an array with two elements per awk array diff --git a/test/ChangeLog b/test/ChangeLog index 26fd2d48..7ad48010 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,17 @@ +2018-01-04 Arnold D. Robbins <arnold@skeeve.com> + + Thanks to Andrew Schorr for the basics of this test. + + * Makefile.am (pty2): New test. + * pty2.awk, pty2.ok: New files. + +2018-01-02 Arnold D. Robbins <arnold@skeeve.com> + + Thanks to Nethox <nethox@gmail.com> for this test. + + * Makefile.am (mpfrrndeval): New test. + * mpfrrndeval.awk, mpfrrndeval.ok: New files. + 2017-12-28 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (EXTRA_DIST): Add numstr1 files. diff --git a/test/Makefile.am b/test/Makefile.am index 0fa74b2c..f49cbdc9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -666,6 +666,8 @@ EXTRA_DIST = \ mpfrrem.ok \ mpfrrnd.awk \ mpfrrnd.ok \ + mpfrrndeval.awk \ + mpfrrndeval.ok \ mpfrsort.awk \ mpfrsort.ok \ mpfrsqrt.awk \ @@ -880,6 +882,8 @@ EXTRA_DIST = \ prtoeval.ok \ pty1.awk \ pty1.ok \ + pty2.awk \ + pty2.ok \ rand-mpfr.ok \ rand.awk \ rand.ok \ @@ -1269,7 +1273,7 @@ GAWK_EXT_TESTS = \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \ procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \ - profile7 profile8 profile9 profile10 pty1 \ + profile7 profile8 profile9 profile10 pty1 pty2 \ rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline rsglstdin \ rsstart1 rsstart2 rsstart3 rstest6 \ shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit split_after_fpat \ @@ -1287,7 +1291,7 @@ INET_TESTS = inetdayu inetdayt inetechu inetecht MACHINE_TESTS = double1 double2 fmtspcl intformat -MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrieee +MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrrndeval mpfrieee mpfrexprange mpfrsort mpfrsqrt mpfrbigint mpfrstrtonum mpgforcenum LOCALE_CHARSET_TESTS = \ @@ -2075,6 +2079,11 @@ mpfrrnd: @$(AWK) -M -vPREC=53 -f "$(srcdir)"/$@.awk > _$@ 2>&1 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mpfrrndeval: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + mpfrnegzero: @echo $@ @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 @@ -2399,6 +2408,14 @@ pty1: $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ esac +pty2: + @echo $@ + @-case `uname` in \ + *[Oo][Ss]/390*) : ;; \ + *) AWKPATH="$(srcdir)" $(AWK) -f $@.awk | od -c >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ; \ + $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ + esac + rscompat: @echo $@ @AWKPATH="$(srcdir)" $(AWK) --traditional -f $@.awk "$(srcdir)/$@.in" >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Makefile.in b/test/Makefile.in index 493bf9fa..47ca0371 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -924,6 +924,8 @@ EXTRA_DIST = \ mpfrrem.ok \ mpfrrnd.awk \ mpfrrnd.ok \ + mpfrrndeval.awk \ + mpfrrndeval.ok \ mpfrsort.awk \ mpfrsort.ok \ mpfrsqrt.awk \ @@ -1138,6 +1140,8 @@ EXTRA_DIST = \ prtoeval.ok \ pty1.awk \ pty1.ok \ + pty2.awk \ + pty2.ok \ rand-mpfr.ok \ rand.awk \ rand.ok \ @@ -1526,7 +1530,7 @@ GAWK_EXT_TESTS = \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \ procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \ - profile7 profile8 profile9 profile10 pty1 \ + profile7 profile8 profile9 profile10 pty1 pty2 \ rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline rsglstdin \ rsstart1 rsstart2 rsstart3 rstest6 \ shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit split_after_fpat \ @@ -1540,7 +1544,7 @@ ARRAYDEBUG_TESTS = arrdbg EXTRA_TESTS = inftest regtest ignrcas3 INET_TESTS = inetdayu inetdayt inetechu inetecht MACHINE_TESTS = double1 double2 fmtspcl intformat -MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrieee +MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrrndeval mpfrieee LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ @@ -2514,6 +2518,11 @@ mpfrrnd: @$(AWK) -M -vPREC=53 -f "$(srcdir)"/$@.awk > _$@ 2>&1 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mpfrrndeval: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + mpfrnegzero: @echo $@ @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 @@ -2837,6 +2846,14 @@ pty1: $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ esac +pty2: + @echo $@ + @-case `uname` in \ + *[Oo][Ss]/390*) : ;; \ + *) AWKPATH="$(srcdir)" $(AWK) -f $@.awk | od -c >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ; \ + $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ;; \ + esac + rscompat: @echo $@ @AWKPATH="$(srcdir)" $(AWK) --traditional -f $@.awk "$(srcdir)/$@.in" >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/mpfrrndeval.awk b/test/mpfrrndeval.awk new file mode 100644 index 00000000..12010052 --- /dev/null +++ b/test/mpfrrndeval.awk @@ -0,0 +1,35 @@ +# Tests side effects (like caching) on the evaluation (formatting and +# rounding) of MPFR variables vs literals. +BEGIN { + pi = 3.1416 + e = 2.7183 + golden = 1.6180 + + # Evaluated as number with (default) OFMT. + print pi + print e + print golden + printf "\n" + + # Evaluated as number with (custom) OFMT. + OFMT = "%.f" + ROUNDMODE = "U"; print "Variable pi U:", pi + ROUNDMODE = "D"; print "Variable pi D:", pi + ROUNDMODE = "U"; print "Literal pi U:", 3.1416 + ROUNDMODE = "D"; print "Literal pi D:", 3.1416 + printf "\n" + + # Evaluated as string with (custom) CONVFMT. Absent comma. + CONVFMT = "%.f" + ROUNDMODE = "D"; print "Variable e D: " e + ROUNDMODE = "U"; print "Variable e U: " e + ROUNDMODE = "D"; print "Literal e D: " 2.7183 + ROUNDMODE = "U"; print "Literal e U: " 2.7183 + printf "\n" + + # Evaluated as number with (hardcoded) printf conversion. + ROUNDMODE = "N"; printf "Variable golden N: %.f\n", golden + ROUNDMODE = "Z"; printf "Variable golden Z: %.f\n", golden + ROUNDMODE = "N"; printf "Literal golden N: %.f\n", 1.6180 + ROUNDMODE = "Z"; printf "Literal golden Z: %.f\n", 1.6180 +} diff --git a/test/mpfrrndeval.ok b/test/mpfrrndeval.ok new file mode 100644 index 00000000..034b21e0 --- /dev/null +++ b/test/mpfrrndeval.ok @@ -0,0 +1,18 @@ +3.1416 +2.7183 +1.618 + +Variable pi U: 4 +Variable pi D: 3 +Literal pi U: 4 +Literal pi D: 3 + +Variable e D: 2 +Variable e U: 3 +Literal e D: 2 +Literal e U: 3 + +Variable golden N: 2 +Variable golden Z: 1 +Literal golden N: 2 +Literal golden Z: 1 diff --git a/test/pty2.awk b/test/pty2.awk new file mode 100644 index 00000000..c2eedbd0 --- /dev/null +++ b/test/pty2.awk @@ -0,0 +1,9 @@ +BEGIN { + cmd = "tr '[A-Z]' '[a-z]' 2> /dev/null" + PROCINFO[cmd, "pty"] = 1 + input = "ABCD" + print input |& cmd + cmd |& getline x + print x +# close(cmd) +} diff --git a/test/pty2.ok b/test/pty2.ok new file mode 100644 index 00000000..fb0f6221 --- /dev/null +++ b/test/pty2.ok @@ -0,0 +1,2 @@ +0000000 a b c d \n +0000005 diff --git a/vms/ChangeLog b/vms/ChangeLog index ad1f5737..27958653 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,3 +1,7 @@ +2018-01-08 John E. Malmberg <wb8tyw@qsl.net> + + * vmstest.com: New tests: numstr1, setrec0, setrec1. + 2017-10-19 Arnold D. Robbins <arnold@skeeve.com> * 4.2.0: Release tar ball made. diff --git a/vms/vmstest.com b/vms/vmstest.com index 23741a83..9f50b2ba 100644 --- a/vms/vmstest.com +++ b/vms/vmstest.com @@ -66,12 +66,15 @@ $! 4.1.3.i: New tests $! basic: ofmtstrnum $! extra: ignrcas3 $! -$! 4.1.3+: New tests +$! 4.2.0: New tests $! basic: aryunasgn, concat5, memleak $! ext: fpat5, fpat6, fwtest5, fwtest6, fwtest7, fwtest8, $! sourcesplit $! charset: mbprintf5 $! +$! 4.2+: New tests +$! basic: numstr1, setrec0, setrec1 +$! $ echo = "write sys$output" $ cmp = "diff/Output=_NL:/Maximum=1" $ delsym = "delete/symbol/local/nolog" @@ -217,7 +220,8 @@ $ gosub list_of_tests $ list = "nasty nasty2 negexp negrange nested nfldstr" - + " nfloop nfneg nfset nlfldsep nlinstr nlstrina" - + " noeffect nofile nofmtch noloop1 noloop2 nonl" - - + " noparms nors nulinsrc nulrsend numindex numsubstr" - + + " noparms nors nulinsrc nulrsend numindex numstr1" - + + " numsubstr" - + " octsub ofmt ofmtbig ofmtfidl" - + " ofmta ofmts ofs1 onlynl opasnidx opasnslf $ gosub list_of_tests @@ -232,7 +236,8 @@ $ list = "rand range1 rebrackloc rebt8b1 redfilnm regeq" - + " resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2" - + " rstest1 rstest2 rstest3 rstest4 rstest5 rswhite" $ gosub list_of_tests -$ list = "scalar sclforin sclifin sigpipe1 sortempty sortglos" - +$ list = "scalar sclforin sclifin setrec0 setrec1 sigpipe1" - + + " sortempty sortglos" - + " splitargv splitarr splitdef splitvar splitwht" - + " strcat1 strtod strnum1 subamp subback subi18n subsepnm" - + " subslash substr swaplns synerr1 synerr2" @@ -420,6 +425,7 @@ $reindops: $reparse: $rsnul1nl: $rswhite: +$setrec0: $sortglos: $splitargv: $splitvar: @@ -660,6 +666,7 @@ $memleak: $minusstr: $negrange: $nulinsrc: +$numstr1: $nlstrina: $octsub: $ofmtstrnum: @@ -671,6 +678,7 @@ $prt1eval: $rebt8b1: $regexprange: $regrange: +$setrec1: $splitdef: $splitwht: $strnum1: |