aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--awk.h9
-rw-r--r--builtin.c2
-rw-r--r--configh.in3
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/awkforai.txt158
-rw-r--r--doc/gawk.info423
-rw-r--r--doc/gawk.texi3
-rw-r--r--eval.c22
-rw-r--r--io.c17
-rw-r--r--main.c4
13 files changed, 497 insertions, 171 deletions
diff --git a/ChangeLog b/ChangeLog
index edcd7706..48f69dce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-12-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ Clean up BINMODE to use symbolic values.
+
+ * awk.h (enum binmode_values): New enum.
+ * eval.c (set_BINMODE): Use them.
+ * io.c (binmode, close_rp, gawk_popen): Ditto.
+ * main.c (main): Ditto.
+ * builtin.c (do_system): Ditto.
+
+ Unrelated:
+
+ * configure.ac: Look for posix_openpt
+ * io.c (two_way_open): Use posix_openpt if it's available.
+ Thanks to Christian Weisgerber <naddy@mips.inka.de> for
+ the changes.
+
2012-12-07 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y (tokentab): `fflush()' is now in POSIX, remove the
diff --git a/awk.h b/awk.h
index a35484f0..b521b9d2 100644
--- a/awk.h
+++ b/awk.h
@@ -921,6 +921,15 @@ struct redirect {
awk_output_buf_t output;
};
+/* values for BINMODE, used as bit flags */
+
+enum binmode_values {
+ TEXT_TRANSLATE = 0, /* usual \r\n ---> \n translation */
+ BINMODE_INPUT = 1, /* no translation for input files */
+ BINMODE_OUTPUT = 2, /* no translation for output files */
+ BINMODE_BOTH = 3 /* no translation for either */
+};
+
/*
* structure for our source, either a command line string or a source file.
*/
diff --git a/builtin.c b/builtin.c
index f736898e..e883fbcc 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2034,7 +2034,7 @@ do_system(int nargs)
ret = system(cmd);
if (ret != -1)
ret = WEXITSTATUS(ret);
- if ((BINMODE & 1) != 0)
+ if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
cmd[tmp->stlen] = save;
diff --git a/configh.in b/configh.in
index 4a16adf4..350aac5f 100644
--- a/configh.in
+++ b/configh.in
@@ -159,6 +159,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
+/* Define to 1 if you have the `posix_openpt' function. */
+#undef HAVE_POSIX_OPENPT
+
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
diff --git a/configure b/configure
index 0e1998e8..2d9b228b 100755
--- a/configure
+++ b/configure
@@ -9962,7 +9962,7 @@ esac
for ac_func in atexit btowc fmod getgrent getgroups grantpt \
isascii iswctype iswlower iswupper mbrlen \
memcmp memcpy memcpy_ulong memmove memset \
- memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
+ memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \
strerror strftime strncasecmp strcoll strtod strtoul \
system tmpfile towlower towupper tzset usleep wcrtomb \
wcscoll wctype
diff --git a/configure.ac b/configure.ac
index bda69198..b7d59f0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -275,7 +275,7 @@ esac
AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \
isascii iswctype iswlower iswupper mbrlen \
memcmp memcpy memcpy_ulong memmove memset \
- memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
+ memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \
strerror strftime strncasecmp strcoll strtod strtoul \
system tmpfile towlower towupper tzset usleep wcrtomb \
wcscoll wctype)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 402757f7..5e780c07 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkforai.txt: Changed content to be pointers to the article
+ to avoid copyright issues.
+ * gawk.texi: Updated description of awkforai.txt.
+
2012-12-07 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi (I/O Functions): Document that fflush() is now part
diff --git a/doc/awkforai.txt b/doc/awkforai.txt
index 3fca3204..2908da56 100644
--- a/doc/awkforai.txt
+++ b/doc/awkforai.txt
@@ -1,150 +1,18 @@
-Draft for ACM SIGPLAN Patterns (Language Trends)
+Sun Dec 9 11:58:23 IST 2012
+============================
-1996
+The original of this file was a draft of an article written in 1996 by
+Ronald P. Lui for an ACM Sigplan publication, explaining why he used
+gawk for teaching introductory Artificial Intelligence courses.
-Why GAWK for AI?
+Since it was not clear as to copying permissions and so on, it has been
+removed from the gawk distribution.
-Ronald P. Loui
+A quick web search shows that this same draft is available at
+http://www.cs.wustl.edu/~loui/sigplan and the final article is available
+from the ACM: http://dl.acm.org/citation.cfm?id=242908
-Most people are surprised when I tell them what language we use in our
-undergraduate AI programming class. That's understandable. We use
-GAWK. GAWK, Gnu's version of Aho, Weinberger, and Kernighan's old
-pattern scanning language isn't even viewed as a programming language by
-most people. Like PERL and TCL, most prefer to view it as a "scripting
-language." It has no objects; it is not functional; it does no built-in
-logic programming. Their surprise turns to puzzlement when I confide
-that (a) while the students are allowed to use any language they want;
-(b) with a single exception, the best work consistently results from
-those working in GAWK. (footnote: The exception was a PASCAL
-programmer who is now an NSF graduate fellow getting a Ph.D. in
-mathematics at Harvard.) Programmers in C, C++, and LISP haven't even
-been close (we have not seen work in PROLOG or JAVA).
+The article itself is recommended reading.
-Why GAWK?
-
-There are some quick answers that have to do with the pragmatics of
-undergraduate programming. Then there are more instructive answers that
-might be valuable to those who debate programming paradigms or to those
-who study the history of AI languages. And there are some deep
-philosophical answers that expose the nature of reasoning and symbolic
-AI. I think the answers, especially the last ones, can be even more
-surprising than the observed effectiveness of GAWK for AI.
-
-First it must be confessed that PERL programmers can cobble together AI
-projects well, too. Most of GAWK's attractiveness is reproduced in
-PERL, and the success of PERL forebodes some of the success of GAWK.
-Both are powerful string-processing languages that allow the programmer
-to exploit many of the features of a UNIX environment. Both provide
-powerful constructions for manipulating a wide variety of data in
-reasonably efficient ways. Both are interpreted, which can reduce
-development time. Both have short learning curves. The GAWK manual can
-be consumed in a single lab session and the language can be mastered by
-the next morning by the average student. GAWK's automatic
-initialization, implicit coercion, I/O support and lack of pointers
-forgive many of the mistakes that young programmers are likely to make.
-Those who have seen C but not mastered it are happy to see that GAWK
-retains some of the same sensibilities while adding what must be
-regarded as spoonsful of syntactic sugar. Some will argue that
-PERL has superior functionality, but for quick AI applications, the
-additional functionality is rarely missed. In fact, PERL's terse syntax
-is not friendly when regular expressions begin to proliferate and
-strings contain fragments of HTML, WWW addresses, or shell commands.
-PERL provides new ways of doing things, but not necessarily ways of
-doing new things.
-
-In the end, despite minor difference, both PERL and GAWK minimize
-programmer time. Neither really provides the programmer the setting in
-which to worry about minimizing run-time.
-
-There are further simple answers. Probably the best is the fact that
-increasingly, undergraduate AI programming is involving the Web. Oren
-Etzioni (University of Washington, Seattle) has for a while been arguing
-that the "softbot" is replacing the mechanical engineers' robot as the
-most glamorous AI testbed. If the artifact whose behavior needs to be
-controlled in an intelligent way is the software agent, then a language
-that is well-suited to controlling the software environment is the
-appropriate language. That would imply a scripting language. If the
-robot is KAREL, then the right language is "turn left; turn right." If
-the robot is Netscape, then the right language is something that can
-generate "netscape -remote 'openURL(http://cs.wustl.edu/~loui)'" with
-elan.
-
-Of course, there are deeper answers. Jon Bentley found two pearls in
-GAWK: its regular expressions and its associative arrays. GAWK asks
-the programmer to use the file system for data organization and the
-operating system for debugging tools and subroutine libraries. There is
-no issue of user-interface. This forces the programmer to return to the
-question of what the program does, not how it looks. There is no time
-spent programming a binsort when the data can be shipped to /bin/sort
-in no time. (footnote: I am reminded of my IBM colleague Ben Grosof's
-advice for Palo Alto: Don't worry about whether it's highway 101 or 280.
-Don't worry if you have to head south for an entrance to go north. Just
-get on the highway as quickly as possible.)
-
-There are some similarities between GAWK and LISP that are illuminating.
-Both provided a powerful uniform data structure (the associative array
-implemented as a hash table for GAWK and the S-expression, or list of
-lists, for LISP). Both were well-supported in their environments (GAWK
-being a child of UNIX, and LISP being the heart of lisp machines). Both
-have trivial syntax and find their power in the programmer's willingness
-to use the simple blocks to build a complex approach.
-
-Deeper still, is the nature of AI programming. AI is about
-functionality and exploratory programming. It is about bottom-up design
-and the building of ambitions as greater behaviors can be demonstrated.
-Woe be to the top-down AI programmer who finds that the bottom-level
-refinements, "this subroutine parses the sentence," cannot actually be
-implemented. Woe be to the programmer who perfects the data structures
-for that heapsort when the whole approach to the high-level problem
-needs to be rethought, and the code is sent to the junkheap the next day.
-
-AI programming requires high-level thinking. There have always been a few
-gifted programmers who can write high-level programs in assembly language.
-Most however need the ambient abstraction to have a higher floor.
-
-Now for the surprising philosophical answers. First, AI has discovered
-that brute-force combinatorics, as an approach to generating intelligent
-behavior, does not often provide the solution. Chess, neural nets, and
-genetic programming show the limits of brute computation. The
-alternative is clever program organization. (footnote: One might add
-that the former are the AI approaches that work, but that is easily
-dismissed: those are the AI approaches that work in general, precisely
-because cleverness is problem-specific.) So AI programmers always want
-to maximize the content of their program, not optimize the efficiency
-of an approach. They want minds, not insects. Instead of enumerating
-large search spaces, they define ways of reducing search, ways of
-bringing different knowledge to the task. A language that maximizes
-what the programmer can attempt rather than one that provides tremendous
-control over how to attempt it, will be the AI choice in the end.
-
-Second, inference is merely the expansion of notation. No matter whether
-the logic that underlies an AI program is fuzzy, probabilistic, deontic,
-defeasible, or deductive, the logic merely defines how strings can be
-transformed into other strings. A language that provides the best
-support for string processing in the end provides the best support for
-logic, for the exploration of various logics, and for most forms of
-symbolic processing that AI might choose to call "reasoning" instead of
-"logic." The implication is that PROLOG, which saves the AI programmer
-from having to write a unifier, saves perhaps two dozen lines of GAWK
-code at the expense of strongly biasing the logic and representational
-expressiveness of any approach.
-
-I view these last two points as news not only to the programming language
-community, but also to much of the AI community that has not reflected on
-the past decade's lessons.
-
-In the puny language, GAWK, which Aho, Weinberger, and Kernighan thought
-not much more important than grep or sed, I find lessons in AI's trends,
-AI's history, and the foundations of AI. What I have found not only
-surprising but also hopeful, is that when I have approached the AI
-people who still enjoy programming, some of them are not the least bit
-surprised.
-
-
-R. Loui (loui@ai.wustl.edu) is Associate Professor of Computer Science,
-at Washington University in St. Louis. He has published in AI Journal,
-Computational Intelligence, ACM SIGART, AI Magazine, AI and Law, the ACM
-Computing Surveys Symposium on AI, Cognitive Science, Minds and
-Machines, Journal of Philosophy, and is on this year's program
-committees for AAAI (National AI conference) and KR (Knowledge
-Representation and Reasoning).
+Arnold Robbins
+arnold@skeeve.com
diff --git a/doc/gawk.info b/doc/gawk.info
index f28ba411..8378fd94 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -25563,8 +25563,9 @@ Various `.c', `.y', and `.h' files
does not.
`doc/awkforai.txt'
- A short article describing why `gawk' is a good language for
- Artificial Intelligence (AI) programming.
+ Pointers to the original draft of a short article describing why
+ `gawk' is a good language for Artificial Intelligence (AI)
+ programming.
`doc/bc_notes'
A brief description of `gawk''s "byte code" internals.
@@ -31538,7 +31539,7 @@ Index
* testbits.awk program: Bitwise Functions. (line 70)
* Texinfo <1>: Adding Code. (line 99)
* Texinfo <2>: Distribution contents.
- (line 79)
+ (line 80)
* Texinfo <3>: Extract Program. (line 12)
* Texinfo <4>: Dupword Program. (line 17)
* Texinfo <5>: Library Functions. (line 22)
@@ -31773,6 +31774,7 @@ Index

Tag Table:
Node: Top1352
+<<<<<<< HEAD
Node: Foreword40138
Node: Preface44483
Ref: Preface-Footnote-147536
@@ -32284,5 +32286,420 @@ Node: Glossary1095479
Node: Copying1120790
Node: GNU Free Documentation License1158347
Node: Index1183484
+=======
+Node: Foreword30282
+Node: Preface34627
+Ref: Preface-Footnote-137680
+Ref: Preface-Footnote-237786
+Node: History38018
+Node: Names40409
+Ref: Names-Footnote-141886
+Node: This Manual41958
+Ref: This Manual-Footnote-146905
+Node: Conventions47005
+Node: Manual History49139
+Ref: Manual History-Footnote-152409
+Ref: Manual History-Footnote-252450
+Node: How To Contribute52524
+Node: Acknowledgments53668
+Node: Getting Started57999
+Node: Running gawk60378
+Node: One-shot61564
+Node: Read Terminal62789
+Ref: Read Terminal-Footnote-164439
+Ref: Read Terminal-Footnote-264715
+Node: Long64886
+Node: Executable Scripts66262
+Ref: Executable Scripts-Footnote-168131
+Ref: Executable Scripts-Footnote-268233
+Node: Comments68780
+Node: Quoting71247
+Node: DOS Quoting75870
+Node: Sample Data Files76545
+Node: Very Simple79577
+Node: Two Rules84176
+Node: More Complex86323
+Ref: More Complex-Footnote-189253
+Node: Statements/Lines89338
+Ref: Statements/Lines-Footnote-193800
+Node: Other Features94065
+Node: When94993
+Node: Invoking Gawk97140
+Node: Command Line98525
+Node: Options99308
+Ref: Options-Footnote-1112852
+Node: Other Arguments112877
+Node: Naming Standard Input115535
+Node: Environment Variables116629
+Node: AWKPATH Variable117073
+Ref: AWKPATH Variable-Footnote-1119670
+Node: Other Environment Variables119930
+Node: Exit Status122270
+Node: Include Files122945
+Node: Obsolete126430
+Node: Undocumented127116
+Node: Regexp127357
+Node: Regexp Usage128746
+Node: Escape Sequences130772
+Node: Regexp Operators136535
+Ref: Regexp Operators-Footnote-1143915
+Ref: Regexp Operators-Footnote-2144062
+Node: Bracket Expressions144160
+Ref: table-char-classes146050
+Node: GNU Regexp Operators148573
+Node: Case-sensitivity152296
+Ref: Case-sensitivity-Footnote-1155264
+Ref: Case-sensitivity-Footnote-2155499
+Node: Leftmost Longest155607
+Node: Computed Regexps156808
+Node: Reading Files160218
+Node: Records162159
+Ref: Records-Footnote-1171083
+Node: Fields171120
+Ref: Fields-Footnote-1174153
+Node: Nonconstant Fields174239
+Node: Changing Fields176441
+Node: Field Separators182422
+Node: Default Field Splitting185051
+Node: Regexp Field Splitting186168
+Node: Single Character Fields189510
+Node: Command Line Field Separator190569
+Node: Field Splitting Summary194010
+Ref: Field Splitting Summary-Footnote-1197202
+Node: Constant Size197303
+Node: Splitting By Content201887
+Ref: Splitting By Content-Footnote-1205613
+Node: Multiple Line205653
+Ref: Multiple Line-Footnote-1211500
+Node: Getline211679
+Node: Plain Getline213907
+Node: Getline/Variable215996
+Node: Getline/File217137
+Node: Getline/Variable/File218459
+Ref: Getline/Variable/File-Footnote-1220058
+Node: Getline/Pipe220145
+Node: Getline/Variable/Pipe222705
+Node: Getline/Coprocess223812
+Node: Getline/Variable/Coprocess225055
+Node: Getline Notes225769
+Node: Getline Summary228556
+Ref: table-getline-variants228899
+Node: Command line directories229755
+Node: Printing230380
+Node: Print232011
+Node: Print Examples233348
+Node: Output Separators236132
+Node: OFMT237892
+Node: Printf239250
+Node: Basic Printf240156
+Node: Control Letters241695
+Node: Format Modifiers245507
+Node: Printf Examples251516
+Node: Redirection254231
+Node: Special Files261215
+Node: Special FD261748
+Ref: Special FD-Footnote-1265373
+Node: Special Network265447
+Node: Special Caveats266297
+Node: Close Files And Pipes267093
+Ref: Close Files And Pipes-Footnote-1274116
+Ref: Close Files And Pipes-Footnote-2274264
+Node: Expressions274414
+Node: Values275546
+Node: Constants276222
+Node: Scalar Constants276902
+Ref: Scalar Constants-Footnote-1277761
+Node: Nondecimal-numbers277943
+Node: Regexp Constants281002
+Node: Using Constant Regexps281477
+Node: Variables284532
+Node: Using Variables285187
+Node: Assignment Options286911
+Node: Conversion288783
+Ref: table-locale-affects294159
+Ref: Conversion-Footnote-1294783
+Node: All Operators294892
+Node: Arithmetic Ops295522
+Node: Concatenation298027
+Ref: Concatenation-Footnote-1300820
+Node: Assignment Ops300940
+Ref: table-assign-ops305928
+Node: Increment Ops307336
+Node: Truth Values and Conditions310806
+Node: Truth Values311889
+Node: Typing and Comparison312938
+Node: Variable Typing313727
+Ref: Variable Typing-Footnote-1317624
+Node: Comparison Operators317746
+Ref: table-relational-ops318156
+Node: POSIX String Comparison321705
+Ref: POSIX String Comparison-Footnote-1322661
+Node: Boolean Ops322799
+Ref: Boolean Ops-Footnote-1326877
+Node: Conditional Exp326968
+Node: Function Calls328700
+Node: Precedence332294
+Node: Locales335963
+Node: Patterns and Actions337052
+Node: Pattern Overview338106
+Node: Regexp Patterns339775
+Node: Expression Patterns340318
+Node: Ranges344003
+Node: BEGIN/END346969
+Node: Using BEGIN/END347731
+Ref: Using BEGIN/END-Footnote-1350462
+Node: I/O And BEGIN/END350568
+Node: BEGINFILE/ENDFILE352850
+Node: Empty355743
+Node: Using Shell Variables356059
+Node: Action Overview358344
+Node: Statements360701
+Node: If Statement362555
+Node: While Statement364054
+Node: Do Statement366098
+Node: For Statement367254
+Node: Switch Statement370406
+Node: Break Statement372503
+Node: Continue Statement374493
+Node: Next Statement376286
+Node: Nextfile Statement378676
+Node: Exit Statement381317
+Node: Built-in Variables383733
+Node: User-modified384828
+Ref: User-modified-Footnote-1392854
+Node: Auto-set392916
+Ref: Auto-set-Footnote-1402207
+Node: ARGC and ARGV402412
+Node: Arrays406263
+Node: Array Basics407768
+Node: Array Intro408594
+Node: Reference to Elements412912
+Node: Assigning Elements415182
+Node: Array Example415673
+Node: Scanning an Array417405
+Node: Controlling Scanning419719
+Ref: Controlling Scanning-Footnote-1424652
+Node: Delete424968
+Ref: Delete-Footnote-1427733
+Node: Numeric Array Subscripts427790
+Node: Uninitialized Subscripts429973
+Node: Multi-dimensional431601
+Node: Multi-scanning434695
+Node: Arrays of Arrays436286
+Node: Functions440931
+Node: Built-in441753
+Node: Calling Built-in442831
+Node: Numeric Functions444819
+Ref: Numeric Functions-Footnote-1448651
+Ref: Numeric Functions-Footnote-2449008
+Ref: Numeric Functions-Footnote-3449056
+Node: String Functions449325
+Ref: String Functions-Footnote-1472822
+Ref: String Functions-Footnote-2472951
+Ref: String Functions-Footnote-3473199
+Node: Gory Details473286
+Ref: table-sub-escapes474965
+Ref: table-sub-posix-92476319
+Ref: table-sub-proposed477662
+Ref: table-posix-sub479012
+Ref: table-gensub-escapes480558
+Ref: Gory Details-Footnote-1481765
+Ref: Gory Details-Footnote-2481816
+Node: I/O Functions481967
+Ref: I/O Functions-Footnote-1489072
+Node: Time Functions489219
+Ref: Time Functions-Footnote-1500111
+Ref: Time Functions-Footnote-2500179
+Ref: Time Functions-Footnote-3500337
+Ref: Time Functions-Footnote-4500448
+Ref: Time Functions-Footnote-5500560
+Ref: Time Functions-Footnote-6500787
+Node: Bitwise Functions501053
+Ref: table-bitwise-ops501611
+Ref: Bitwise Functions-Footnote-1505771
+Node: Type Functions505955
+Node: I18N Functions506425
+Node: User-defined508052
+Node: Definition Syntax508856
+Ref: Definition Syntax-Footnote-1513766
+Node: Function Example513835
+Node: Function Caveats516429
+Node: Calling A Function516850
+Node: Variable Scope517965
+Node: Pass By Value/Reference519940
+Node: Return Statement523380
+Node: Dynamic Typing526361
+Node: Indirect Calls527096
+Node: Internationalization536781
+Node: I18N and L10N538207
+Node: Explaining gettext538893
+Ref: Explaining gettext-Footnote-1543959
+Ref: Explaining gettext-Footnote-2544143
+Node: Programmer i18n544308
+Node: Translator i18n548508
+Node: String Extraction549301
+Ref: String Extraction-Footnote-1550262
+Node: Printf Ordering550348
+Ref: Printf Ordering-Footnote-1553132
+Node: I18N Portability553196
+Ref: I18N Portability-Footnote-1555645
+Node: I18N Example555708
+Ref: I18N Example-Footnote-1558343
+Node: Gawk I18N558415
+Node: Advanced Features559032
+Node: Nondecimal Data560545
+Node: Array Sorting562128
+Node: Controlling Array Traversal562825
+Node: Array Sorting Functions571062
+Ref: Array Sorting Functions-Footnote-1574736
+Ref: Array Sorting Functions-Footnote-2574829
+Node: Two-way I/O575023
+Ref: Two-way I/O-Footnote-1580455
+Node: TCP/IP Networking580525
+Node: Profiling583369
+Node: Library Functions590843
+Ref: Library Functions-Footnote-1593850
+Node: Library Names594021
+Ref: Library Names-Footnote-1597492
+Ref: Library Names-Footnote-2597712
+Node: General Functions597798
+Node: Strtonum Function598751
+Node: Assert Function601681
+Node: Round Function605007
+Node: Cliff Random Function606550
+Node: Ordinal Functions607566
+Ref: Ordinal Functions-Footnote-1610636
+Ref: Ordinal Functions-Footnote-2610888
+Node: Join Function611097
+Ref: Join Function-Footnote-1612868
+Node: Gettimeofday Function613068
+Node: Data File Management616783
+Node: Filetrans Function617415
+Node: Rewind Function621554
+Node: File Checking622941
+Node: Empty Files624035
+Node: Ignoring Assigns626265
+Node: Getopt Function627818
+Ref: Getopt Function-Footnote-1639122
+Node: Passwd Functions639325
+Ref: Passwd Functions-Footnote-1648300
+Node: Group Functions648388
+Node: Walking Arrays656472
+Node: Sample Programs658041
+Node: Running Examples658706
+Node: Clones659434
+Node: Cut Program660658
+Node: Egrep Program670503
+Ref: Egrep Program-Footnote-1678276
+Node: Id Program678386
+Node: Split Program682002
+Ref: Split Program-Footnote-1685521
+Node: Tee Program685649
+Node: Uniq Program688452
+Node: Wc Program695881
+Ref: Wc Program-Footnote-1700147
+Ref: Wc Program-Footnote-2700347
+Node: Miscellaneous Programs700439
+Node: Dupword Program701627
+Node: Alarm Program703658
+Node: Translate Program708407
+Ref: Translate Program-Footnote-1712794
+Ref: Translate Program-Footnote-2713022
+Node: Labels Program713156
+Ref: Labels Program-Footnote-1716527
+Node: Word Sorting716611
+Node: History Sorting720495
+Node: Extract Program722334
+Ref: Extract Program-Footnote-1729817
+Node: Simple Sed729945
+Node: Igawk Program733007
+Ref: Igawk Program-Footnote-1748164
+Ref: Igawk Program-Footnote-2748365
+Node: Anagram Program748503
+Node: Signature Program751571
+Node: Debugger752671
+Node: Debugging753582
+Node: Debugging Concepts753995
+Node: Debugging Terms755851
+Node: Awk Debugging758474
+Node: Sample dgawk session759366
+Node: dgawk invocation759858
+Node: Finding The Bug761040
+Node: List of Debugger Commands767526
+Node: Breakpoint Control768837
+Node: Dgawk Execution Control772473
+Node: Viewing And Changing Data775824
+Node: Dgawk Stack779161
+Node: Dgawk Info780621
+Node: Miscellaneous Dgawk Commands784569
+Node: Readline Support789997
+Node: Dgawk Limitations790835
+Node: Language History793024
+Node: V7/SVR3.1794536
+Node: SVR4796857
+Node: POSIX798299
+Node: BTL799307
+Node: POSIX/GNU800112
+Node: Common Extensions805263
+Node: Ranges and Locales806322
+Ref: Ranges and Locales-Footnote-1810940
+Ref: Ranges and Locales-Footnote-2810967
+Ref: Ranges and Locales-Footnote-3811227
+Node: Contributors811448
+Node: Installation815710
+Node: Gawk Distribution816604
+Node: Getting817088
+Node: Extracting817914
+Node: Distribution contents819606
+Node: Unix Installation824867
+Node: Quick Installation825484
+Node: Additional Configuration Options827446
+Node: Configuration Philosophy828923
+Node: Non-Unix Installation831265
+Node: PC Installation831723
+Node: PC Binary Installation833022
+Node: PC Compiling835037
+Node: PC Testing837981
+Node: PC Using839157
+Node: Cygwin843342
+Node: MSYS844342
+Node: VMS Installation844856
+Node: VMS Compilation845459
+Ref: VMS Compilation-Footnote-1846466
+Node: VMS Installation Details846524
+Node: VMS Running848159
+Node: VMS Old Gawk849766
+Node: Bugs850240
+Node: Other Versions854092
+Node: Notes859373
+Node: Compatibility Mode860065
+Node: Additions860848
+Node: Accessing The Source861660
+Node: Adding Code863085
+Node: New Ports869052
+Node: Dynamic Extensions873165
+Node: Internals874541
+Node: Plugin License883644
+Node: Sample Library884278
+Node: Internal File Description884964
+Node: Internal File Ops888679
+Ref: Internal File Ops-Footnote-1893460
+Node: Using Internal File Ops893600
+Node: Future Extensions895977
+Node: Basic Concepts898481
+Node: Basic High Level899238
+Ref: Basic High Level-Footnote-1903273
+Node: Basic Data Typing903458
+Node: Floating Point Issues907983
+Node: String Conversion Precision909066
+Ref: String Conversion Precision-Footnote-1910766
+Node: Unexpected Results910875
+Node: POSIX Floating Point Problems912701
+Ref: POSIX Floating Point Problems-Footnote-1916406
+Node: Glossary916444
+Node: Copying941619
+Node: GNU Free Documentation License979176
+Node: Index1004313
+>>>>>>> gawk-4.0-stable

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 63dfcb9d..ab26df28 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -33113,7 +33113,8 @@ as a list of things that the POSIX standard should describe but does not.
@cindex artificial intelligence@comma{} @command{gawk} and
@item doc/awkforai.txt
-A short article describing why @command{gawk} is a good language for
+Pointers to the original draft of
+a short article describing why @command{gawk} is a good language for
Artificial Intelligence (AI) programming.
@item doc/bc_notes
diff --git a/eval.c b/eval.c
index 2db2a7dc..9ec1e4c3 100644
--- a/eval.c
+++ b/eval.c
@@ -732,15 +732,15 @@ set_BINMODE()
lintwarn(_("`BINMODE' is a gawk extension"));
}
if (do_traditional)
- BINMODE = 0;
+ BINMODE = TEXT_TRANSLATE;
else if ((v->flags & NUMBER) != 0) {
(void) force_number(v);
BINMODE = get_number_si(v);
/* Make sure the value is rational. */
- if (BINMODE < 0)
- BINMODE = 0;
- else if (BINMODE > 3)
- BINMODE = 3;
+ if (BINMODE < TEXT_TRANSLATE)
+ BINMODE = TEXT_TRANSLATE;
+ else if (BINMODE > BINMODE_BOTH)
+ BINMODE = BINMODE_BOTH;
} else if ((v->flags & STRING) != 0) {
p = v->stptr;
@@ -760,13 +760,13 @@ set_BINMODE()
BINMODE = p[0] - '0';
break;
case 'r':
- BINMODE = 1;
+ BINMODE = BINMODE_INPUT;
break;
case 'w':
- BINMODE = 2;
+ BINMODE = BINMODE_OUTPUT;
break;
default:
- BINMODE = 3;
+ BINMODE = BINMODE_BOTH;
goto bad_value;
break;
}
@@ -774,21 +774,21 @@ set_BINMODE()
case 2:
switch (p[0]) {
case 'r':
- BINMODE = 3;
+ BINMODE = BINMODE_BOTH;
if (p[1] != 'w')
goto bad_value;
break;
case 'w':
- BINMODE = 3;
+ BINMODE = BINMODE_BOTH;
if (p[1] != 'r')
goto bad_value;
break;
+ }
break;
default:
bad_value:
lintwarn(_("BINMODE value `%s' is invalid, treated as 3"), p);
break;
- }
}
} else
BINMODE = 3; /* shouldn't happen */
diff --git a/io.c b/io.c
index b5c25f54..5dbeadf7 100644
--- a/io.c
+++ b/io.c
@@ -290,12 +290,12 @@ binmode(const char *mode)
{
switch (mode[0]) {
case 'r':
- if ((BINMODE & 1) != 0)
+ if ((BINMODE & BINMODE_INPUT) != 0)
mode = "rb";
break;
case 'w':
case 'a':
- if ((BINMODE & 2) != 0)
+ if ((BINMODE & BINMODE_OUTPUT) != 0)
mode = (mode[0] == 'w' ? "wb" : "ab");
break;
}
@@ -1114,7 +1114,7 @@ close_rp(struct redirect *rp, two_way_close_type how)
} else if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) {
/* write to pipe */
status = pclose(rp->output.fp);
- if ((BINMODE & 1) != 0)
+ if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
rp->output.fp = NULL;
@@ -1697,7 +1697,7 @@ two_way_open(const char *str, struct redirect *rp)
if (! no_ptys && pty_vs_pipe(str)) {
static bool initialized = false;
static char first_pty_letter;
-#ifdef HAVE_GRANTPT
+#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT)
static int have_dev_ptmx;
#endif
char slavenam[32];
@@ -1714,7 +1714,7 @@ two_way_open(const char *str, struct redirect *rp)
if (! initialized) {
initialized = true;
-#ifdef HAVE_GRANTPT
+#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT)
have_dev_ptmx = (stat("/dev/ptmx", & statb) >= 0);
#endif
i = 0;
@@ -1729,8 +1729,13 @@ two_way_open(const char *str, struct redirect *rp)
}
#ifdef HAVE_GRANTPT
+#ifdef HAVE_POSIX_OPENPT
+ {
+ master = posix_openpt(O_RDWR|O_NOCTTY);
+#else
if (have_dev_ptmx) {
master = open("/dev/ptmx", O_RDWR);
+#endif
if (master >= 0) {
char *tem;
@@ -2255,7 +2260,7 @@ gawk_popen(const char *cmd, struct redirect *rp)
os_restore_mode(fileno(stdin));
current = popen(cmd, binmode("r"));
- if ((BINMODE & 1) != 0)
+ if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
if (current == NULL)
return NULL;
diff --git a/main.c b/main.c
index 6174dd93..d054ec1a 100644
--- a/main.c
+++ b/main.c
@@ -628,10 +628,10 @@ out:
if (preassigns != NULL)
efree(preassigns);
- if ((BINMODE & 1) != 0)
+ if ((BINMODE & BINMODE_INPUT) != 0)
if (os_setbinmode(fileno(stdin), O_BINARY) == -1)
fatal(_("can't set binary mode on stdin (%s)"), strerror(errno));
- if ((BINMODE & 2) != 0) {
+ if ((BINMODE & BINMODE_OUTPUT) != 0) {
if (os_setbinmode(fileno(stdout), O_BINARY) == -1)
fatal(_("can't set binary mode on stdout (%s)"), strerror(errno));
if (os_setbinmode(fileno(stderr), O_BINARY) == -1)