aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-12-22 18:30:05 +0200
committerArnold D. Robbins <arnold@skeeve.com>2016-12-22 18:30:05 +0200
commitaf31a6de1bd15d4d5f5520ebfcb1d24239b9a683 (patch)
tree988513e4b333829ae6b541802eb52546a2bdb6fe
parent1f05c34b1b0d8b0a0c561ce38570d4ed8774f54a (diff)
downloadegawk-af31a6de1bd15d4d5f5520ebfcb1d24239b9a683.tar.gz
egawk-af31a6de1bd15d4d5f5520ebfcb1d24239b9a683.tar.bz2
egawk-af31a6de1bd15d4d5f5520ebfcb1d24239b9a683.zip
Doc cleanups after merge. Totally break binary compat in the API.
-rw-r--r--ChangeLog13
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawk.info305
-rw-r--r--doc/gawk.texi31
-rw-r--r--doc/gawktexi.in31
-rw-r--r--extension/ChangeLog4
-rw-r--r--extension/testext.c2
-rw-r--r--gawkapi.c66
-rw-r--r--gawkapi.h33
9 files changed, 267 insertions, 223 deletions
diff --git a/ChangeLog b/ChangeLog
index c29c85ec..b8c45122 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,19 @@
regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h,
regexec.c, verify.h, xalloc.h: Moved to support.
+ Unrelated: Totally break binary compatibility in the API
+ after merging in API min/max changes and REGEX and STRNUM
+ support in the API:
+
+ * gawkapi.c (valtype2str): New function.
+ (node_to_awk_value): Minor simplification in a switch.
+ (api_flatten_array): Removed.
+ (api_flatten_array_typed): Use valtype2str in error message.
+ (api_impl): Reorder functions to group related ones together again.
+ * gawkapi.h (awk_valtype_t): Reorder enum values.
+ (struct gawk_api): Remove api_flatten_array field. Reorder
+ functions to group related ones together again.
+
2016-12-17 Arnold D. Robbins <arnold@skeeve.com>
* gawkapi.h (api_add_ext_func): Add comment about point to
diff --git a/doc/ChangeLog b/doc/ChangeLog
index d3e974c7..3a4978d9 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Minor edits after merging branches and some
+ additional work in the code.
+
2016-12-17 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Further API clarifications and edits, add a
diff --git a/doc/gawk.info b/doc/gawk.info
index 696c8c3e..3169ff0c 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -23625,11 +23625,11 @@ use them.
' AWK_UNDEFINED,'
' AWK_NUMBER,'
' AWK_STRING,'
+' AWK_REGEX,'
+' AWK_STRNUM,'
' AWK_ARRAY,'
' AWK_SCALAR, /* opaque access to a variable */'
-' AWK_VALUE_COOKIE, /* for updating a previously created value */'
-' AWK_REGEX,'
-' AWK_STRNUM'
+' AWK_VALUE_COOKIE /* for updating a previously created value */'
'} awk_valtype_t;'
This 'enum' indicates the type of a value. It is used in the
following 'struct'.
@@ -23680,9 +23680,9 @@ and length. This is the 'awk_string_t' type.
A strnum (numeric string) value is represented as a string and
consists of user input data that appears to be numeric. When an
-extension attempts to create a strnum value, a string flagged as user
-input is created. Subsequent parsing will determine whether it looks
-like a number and should be treated as a strnum or a regular string.
+extension creates a strnum value, the result is a string flagged as user
+input. Subsequent parsing by 'gawk' then determines whether it looks
+like a number and should be treated as a strnum, or as a regular string.
Typed regexp values (*note Strong Regexp Constants::) are not of much
use to extension functions. Extension functions can tell that they've
@@ -23851,13 +23851,13 @@ code would use them:
'static inline awk_value_t *'
'make_const_user_input(const char *string, size_t length, awk_value_t *result);'
- This function is identical to 'make_const_string', but the string
+ This function is identical to 'make_const_string()', but the string
is flagged as user input that should be treated as a strnum value
if the contents of the string are numeric.
'static inline awk_value_t *'
'make_malloced_user_input(const char *string, size_t length, awk_value_t *result);'
- This function is identical to 'make_malloced_string', but the
+ This function is identical to 'make_malloced_string()', but the
string is flagged as user input that should be treated as a strnum
value if the contents of the string are numeric.
@@ -24979,8 +24979,9 @@ The following functions relate to individual array elements:
For the array represented by 'a_cookie', create an
'awk_flat_array_t' structure and fill it in with 'AWK_STRING'
indices and 'AWK_UNDEFINED' values. This is superseded by
- 'flatten_array_typed' and retained only for legacy binary
- compatibility.
+ 'flatten_array_typed()'. It is provided as a macro, and remains
+ convenience and for source code compatibility with the previous
+ version of the API.
'awk_bool_t release_flattened_array(awk_array_t a_cookie,'
' awk_flat_array_t *data);'
@@ -28191,6 +28192,12 @@ to different non-Unix operating systems:
Various '.c', '.y', and '.h' files
These files contain the actual 'gawk' source code.
+'support/*'
+ C header and source files for routines that 'gawk' uses, but that
+ are not part of its core functionality. For example, argument
+ parsing, regular expression matching, and random number generating
+ routines are all kept here.
+
'ABOUT-NLS'
A file containing information about GNU 'gettext' and translations.
@@ -32715,7 +32722,7 @@ Index
* arrays, unassigned elements: Reference to Elements.
(line 18)
* artificial intelligence, gawk and: Distribution contents.
- (line 52)
+ (line 58)
* ASCII: Ordinal Functions. (line 45)
* ASCII <1>: Glossary. (line 196)
* asort: String Functions. (line 42)
@@ -35194,7 +35201,7 @@ Index
* Texinfo <2>: Dupword Program. (line 17)
* Texinfo <3>: Extract Program. (line 12)
* Texinfo <4>: Distribution contents.
- (line 77)
+ (line 83)
* Texinfo <5>: Adding Code. (line 100)
* Texinfo, chapter beginnings in files: Regexp Operators. (line 22)
* Texinfo, extracting programs from source files: Extract Program.
@@ -35856,142 +35863,142 @@ Ref: figure-call-new-function948497
Node: Extension API Description950559
Node: Extension API Functions Introduction952201
Node: General Data Types957512
-Ref: General Data Types-Footnote-1964227
-Node: Memory Allocation Functions964526
-Ref: Memory Allocation Functions-Footnote-1967371
-Node: Constructor Functions967470
-Node: Registration Functions970465
-Node: Extension Functions971150
-Node: Exit Callback Functions976348
-Node: Extension Version String977598
-Node: Input Parsers978261
-Node: Output Wrappers988143
-Node: Two-way processors992655
-Node: Printing Messages994920
-Ref: Printing Messages-Footnote-1996091
-Node: Updating ERRNO996244
-Node: Requesting Values996983
-Ref: table-value-types-returned997720
-Node: Accessing Parameters998603
-Node: Symbol Table Access999838
-Node: Symbol table by name1000350
-Node: Symbol table by cookie1002139
-Ref: Symbol table by cookie-Footnote-11006324
-Node: Cached values1006388
-Ref: Cached values-Footnote-11009924
-Node: Array Manipulation1010015
-Ref: Array Manipulation-Footnote-11011106
-Node: Array Data Types1011143
-Ref: Array Data Types-Footnote-11013801
-Node: Array Functions1013893
-Node: Flattening Arrays1018207
-Node: Creating Arrays1025148
-Node: Redirection API1029917
-Node: Extension API Variables1032748
-Node: Extension Versioning1033381
-Ref: gawk-api-version1033818
-Node: Extension API Informational Variables1035546
-Node: Extension API Boilerplate1036610
-Node: Changes from API V11040472
-Node: Finding Extensions1041132
-Node: Extension Example1041691
-Node: Internal File Description1042489
-Node: Internal File Ops1046569
-Ref: Internal File Ops-Footnote-11057969
-Node: Using Internal File Ops1058109
-Ref: Using Internal File Ops-Footnote-11060492
-Node: Extension Samples1060766
-Node: Extension Sample File Functions1062295
-Node: Extension Sample Fnmatch1069944
-Node: Extension Sample Fork1071431
-Node: Extension Sample Inplace1072649
-Node: Extension Sample Ord1075859
-Node: Extension Sample Readdir1076695
-Ref: table-readdir-file-types1077584
-Node: Extension Sample Revout1078389
-Node: Extension Sample Rev2way1078978
-Node: Extension Sample Read write array1079718
-Node: Extension Sample Readfile1081660
-Node: Extension Sample Time1082755
-Node: Extension Sample API Tests1084103
-Node: gawkextlib1084595
-Node: Extension summary1087042
-Node: Extension Exercises1090744
-Node: Language History1092242
-Node: V7/SVR3.11093898
-Node: SVR41096050
-Node: POSIX1097484
-Node: BTL1098863
-Node: POSIX/GNU1099592
-Node: Feature History1105454
-Node: Common Extensions1119824
-Node: Ranges and Locales1121107
-Ref: Ranges and Locales-Footnote-11125723
-Ref: Ranges and Locales-Footnote-21125750
-Ref: Ranges and Locales-Footnote-31125985
-Node: Contributors1126206
-Node: History summary1131766
-Node: Installation1133146
-Node: Gawk Distribution1134090
-Node: Getting1134574
-Node: Extracting1135535
-Node: Distribution contents1137173
-Node: Unix Installation1143258
-Node: Quick Installation1143940
-Node: Shell Startup Files1146354
-Node: Additional Configuration Options1147432
-Node: Configuration Philosophy1149237
-Node: Non-Unix Installation1151606
-Node: PC Installation1152066
-Node: PC Binary Installation1152904
-Node: PC Compiling1153339
-Node: PC Using1154456
-Node: Cygwin1157501
-Node: MSYS1158271
-Node: VMS Installation1158772
-Node: VMS Compilation1159563
-Ref: VMS Compilation-Footnote-11160792
-Node: VMS Dynamic Extensions1160850
-Node: VMS Installation Details1162535
-Node: VMS Running1164788
-Node: VMS GNV1169067
-Node: VMS Old Gawk1169802
-Node: Bugs1170273
-Node: Bug address1170936
-Node: Usenet1173333
-Node: Maintainers1174108
-Node: Other Versions1175484
-Node: Installation summary1182068
-Node: Notes1183103
-Node: Compatibility Mode1183968
-Node: Additions1184750
-Node: Accessing The Source1185675
-Node: Adding Code1187110
-Node: New Ports1193329
-Node: Derived Files1197817
-Ref: Derived Files-Footnote-11203302
-Ref: Derived Files-Footnote-21203337
-Ref: Derived Files-Footnote-31203935
-Node: Future Extensions1204049
-Node: Implementation Limitations1204707
-Node: Extension Design1205890
-Node: Old Extension Problems1207044
-Ref: Old Extension Problems-Footnote-11208562
-Node: Extension New Mechanism Goals1208619
-Ref: Extension New Mechanism Goals-Footnote-11211983
-Node: Extension Other Design Decisions1212172
-Node: Extension Future Growth1214285
-Node: Old Extension Mechanism1215121
-Node: Notes summary1216884
-Node: Basic Concepts1218066
-Node: Basic High Level1218747
-Ref: figure-general-flow1219029
-Ref: figure-process-flow1219714
-Ref: Basic High Level-Footnote-11223015
-Node: Basic Data Typing1223200
-Node: Glossary1226528
-Node: Copying1258475
-Node: GNU Free Documentation License1296014
-Node: Index1321132
+Ref: General Data Types-Footnote-1964235
+Node: Memory Allocation Functions964534
+Ref: Memory Allocation Functions-Footnote-1967379
+Node: Constructor Functions967478
+Node: Registration Functions970477
+Node: Extension Functions971162
+Node: Exit Callback Functions976360
+Node: Extension Version String977610
+Node: Input Parsers978273
+Node: Output Wrappers988155
+Node: Two-way processors992667
+Node: Printing Messages994932
+Ref: Printing Messages-Footnote-1996103
+Node: Updating ERRNO996256
+Node: Requesting Values996995
+Ref: table-value-types-returned997732
+Node: Accessing Parameters998615
+Node: Symbol Table Access999850
+Node: Symbol table by name1000362
+Node: Symbol table by cookie1002151
+Ref: Symbol table by cookie-Footnote-11006336
+Node: Cached values1006400
+Ref: Cached values-Footnote-11009936
+Node: Array Manipulation1010027
+Ref: Array Manipulation-Footnote-11011118
+Node: Array Data Types1011155
+Ref: Array Data Types-Footnote-11013813
+Node: Array Functions1013905
+Node: Flattening Arrays1018300
+Node: Creating Arrays1025241
+Node: Redirection API1030010
+Node: Extension API Variables1032841
+Node: Extension Versioning1033474
+Ref: gawk-api-version1033911
+Node: Extension API Informational Variables1035639
+Node: Extension API Boilerplate1036703
+Node: Changes from API V11040565
+Node: Finding Extensions1041225
+Node: Extension Example1041784
+Node: Internal File Description1042582
+Node: Internal File Ops1046662
+Ref: Internal File Ops-Footnote-11058062
+Node: Using Internal File Ops1058202
+Ref: Using Internal File Ops-Footnote-11060585
+Node: Extension Samples1060859
+Node: Extension Sample File Functions1062388
+Node: Extension Sample Fnmatch1070037
+Node: Extension Sample Fork1071524
+Node: Extension Sample Inplace1072742
+Node: Extension Sample Ord1075952
+Node: Extension Sample Readdir1076788
+Ref: table-readdir-file-types1077677
+Node: Extension Sample Revout1078482
+Node: Extension Sample Rev2way1079071
+Node: Extension Sample Read write array1079811
+Node: Extension Sample Readfile1081753
+Node: Extension Sample Time1082848
+Node: Extension Sample API Tests1084196
+Node: gawkextlib1084688
+Node: Extension summary1087135
+Node: Extension Exercises1090837
+Node: Language History1092335
+Node: V7/SVR3.11093991
+Node: SVR41096143
+Node: POSIX1097577
+Node: BTL1098956
+Node: POSIX/GNU1099685
+Node: Feature History1105547
+Node: Common Extensions1119917
+Node: Ranges and Locales1121200
+Ref: Ranges and Locales-Footnote-11125816
+Ref: Ranges and Locales-Footnote-21125843
+Ref: Ranges and Locales-Footnote-31126078
+Node: Contributors1126299
+Node: History summary1131859
+Node: Installation1133239
+Node: Gawk Distribution1134183
+Node: Getting1134667
+Node: Extracting1135628
+Node: Distribution contents1137266
+Node: Unix Installation1143608
+Node: Quick Installation1144290
+Node: Shell Startup Files1146704
+Node: Additional Configuration Options1147782
+Node: Configuration Philosophy1149587
+Node: Non-Unix Installation1151956
+Node: PC Installation1152416
+Node: PC Binary Installation1153254
+Node: PC Compiling1153689
+Node: PC Using1154806
+Node: Cygwin1157851
+Node: MSYS1158621
+Node: VMS Installation1159122
+Node: VMS Compilation1159913
+Ref: VMS Compilation-Footnote-11161142
+Node: VMS Dynamic Extensions1161200
+Node: VMS Installation Details1162885
+Node: VMS Running1165138
+Node: VMS GNV1169417
+Node: VMS Old Gawk1170152
+Node: Bugs1170623
+Node: Bug address1171286
+Node: Usenet1173683
+Node: Maintainers1174458
+Node: Other Versions1175834
+Node: Installation summary1182418
+Node: Notes1183453
+Node: Compatibility Mode1184318
+Node: Additions1185100
+Node: Accessing The Source1186025
+Node: Adding Code1187460
+Node: New Ports1193679
+Node: Derived Files1198167
+Ref: Derived Files-Footnote-11203652
+Ref: Derived Files-Footnote-21203687
+Ref: Derived Files-Footnote-31204285
+Node: Future Extensions1204399
+Node: Implementation Limitations1205057
+Node: Extension Design1206240
+Node: Old Extension Problems1207394
+Ref: Old Extension Problems-Footnote-11208912
+Node: Extension New Mechanism Goals1208969
+Ref: Extension New Mechanism Goals-Footnote-11212333
+Node: Extension Other Design Decisions1212522
+Node: Extension Future Growth1214635
+Node: Old Extension Mechanism1215471
+Node: Notes summary1217234
+Node: Basic Concepts1218416
+Node: Basic High Level1219097
+Ref: figure-general-flow1219379
+Ref: figure-process-flow1220064
+Ref: Basic High Level-Footnote-11223365
+Node: Basic Data Typing1223550
+Node: Glossary1226878
+Node: Copying1258825
+Node: GNU Free Documentation License1296364
+Node: Index1321482

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 414fa14d..2a7f1c58 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -32557,11 +32557,11 @@ multibyte encoding.
@itemx @ @ @ @ AWK_UNDEFINED,
@itemx @ @ @ @ AWK_NUMBER,
@itemx @ @ @ @ AWK_STRING,
+@itemx @ @ @ @ AWK_REGEX,
+@itemx @ @ @ @ AWK_STRNUM,
@itemx @ @ @ @ AWK_ARRAY,
@itemx @ @ @ @ AWK_SCALAR,@ @ @ @ @ @ @ @ @ /* opaque access to a variable */
-@itemx @ @ @ @ AWK_VALUE_COOKIE,@ @ @ /* for updating a previously created value */
-@itemx @ @ @ @ AWK_REGEX,
-@itemx @ @ @ @ AWK_STRNUM
+@itemx @ @ @ @ AWK_VALUE_COOKIE@ @ @ @ /* for updating a previously created value */
@itemx @} awk_valtype_t;
This @code{enum} indicates the type of a value.
It is used in the following @code{struct}.
@@ -32614,9 +32614,9 @@ data pointer and length. This is the @code{awk_string_t} type.
A strnum (numeric string) value is represented as a string and consists
of user input data that appears to be numeric.
-When an extension attempts to create a strnum value, a string flagged
-as user input is created. Subsequent parsing will determine whether it
-looks like a number and should be treated as a strnum or a regular string.
+When an extension creates a strnum value, the result is a string flagged
+as user input. Subsequent parsing by @command{gawk} then determines whether it
+looks like a number and should be treated as a strnum, or as a regular string.
Typed regexp values (@pxref{Strong Regexp Constants}) are not of
much use to extension functions. Extension functions can tell that
@@ -32793,13 +32793,13 @@ pointed to by @code{result}.
@item static inline awk_value_t *
@itemx make_const_user_input(const char *string, size_t length, awk_value_t *result);
-This function is identical to @code{make_const_string}, but the string is
+This function is identical to @code{make_const_string()}, but the string is
flagged as user input that should be treated as a strnum value if the contents
of the string are numeric.
@item static inline awk_value_t *
@itemx make_malloced_user_input(const char *string, size_t length, awk_value_t *result);
-This function is identical to @code{make_malloced_string}, but the string is
+This function is identical to @code{make_malloced_string()}, but the string is
flagged as user input that should be treated as a strnum value if the contents
of the string are numeric.
@@ -34068,7 +34068,8 @@ statement (@pxref{Delete}).
@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, awk_flat_array_t **data, awk_valtype_t index_type, awk_valtype_t value_type);
For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
-structure and fill it in with indices and values of the requested types. Set the pointer whose address is passed as @code{data}
+structure and fill it in with indices and values of the requested types.
+Set the pointer whose address is passed as @code{data}
to point to this structure.
Return true upon success, or false otherwise.
@ifset FOR_PRINT
@@ -34083,8 +34084,10 @@ flatten an array and work with it.
@item awk_bool_t flatten_array(awk_array_t a_cookie, awk_flat_array_t **data);
For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
structure and fill it in with @code{AWK_STRING} indices and
-@code{AWK_UNDEFINED} values. This is superseded by @code{flatten_array_typed}
-and retained only for legacy binary compatibility.
+@code{AWK_UNDEFINED} values.
+This is superseded by @code{flatten_array_typed()}.
+It is provided as a macro, and remains convenience and for source code
+compatibility with the previous version of the API.
@item awk_bool_t release_flattened_array(awk_array_t a_cookie,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_flat_array_t *data);
@@ -38246,6 +38249,12 @@ These files contain the actual @command{gawk} source code.
@end table
@table @file
+@item support/*
+C header and source files for routines that @command{gawk}
+uses, but that are not part of its core functionality.
+For example, argument parsing, regular expression matching,
+and random number generating routines are all kept here.
+
@item ABOUT-NLS
A file containing information about GNU @command{gettext} and translations.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index c1674c11..c8c66d2d 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -31571,11 +31571,11 @@ multibyte encoding.
@itemx @ @ @ @ AWK_UNDEFINED,
@itemx @ @ @ @ AWK_NUMBER,
@itemx @ @ @ @ AWK_STRING,
+@itemx @ @ @ @ AWK_REGEX,
+@itemx @ @ @ @ AWK_STRNUM,
@itemx @ @ @ @ AWK_ARRAY,
@itemx @ @ @ @ AWK_SCALAR,@ @ @ @ @ @ @ @ @ /* opaque access to a variable */
-@itemx @ @ @ @ AWK_VALUE_COOKIE,@ @ @ /* for updating a previously created value */
-@itemx @ @ @ @ AWK_REGEX,
-@itemx @ @ @ @ AWK_STRNUM
+@itemx @ @ @ @ AWK_VALUE_COOKIE@ @ @ @ /* for updating a previously created value */
@itemx @} awk_valtype_t;
This @code{enum} indicates the type of a value.
It is used in the following @code{struct}.
@@ -31628,9 +31628,9 @@ data pointer and length. This is the @code{awk_string_t} type.
A strnum (numeric string) value is represented as a string and consists
of user input data that appears to be numeric.
-When an extension attempts to create a strnum value, a string flagged
-as user input is created. Subsequent parsing will determine whether it
-looks like a number and should be treated as a strnum or a regular string.
+When an extension creates a strnum value, the result is a string flagged
+as user input. Subsequent parsing by @command{gawk} then determines whether it
+looks like a number and should be treated as a strnum, or as a regular string.
Typed regexp values (@pxref{Strong Regexp Constants}) are not of
much use to extension functions. Extension functions can tell that
@@ -31807,13 +31807,13 @@ pointed to by @code{result}.
@item static inline awk_value_t *
@itemx make_const_user_input(const char *string, size_t length, awk_value_t *result);
-This function is identical to @code{make_const_string}, but the string is
+This function is identical to @code{make_const_string()}, but the string is
flagged as user input that should be treated as a strnum value if the contents
of the string are numeric.
@item static inline awk_value_t *
@itemx make_malloced_user_input(const char *string, size_t length, awk_value_t *result);
-This function is identical to @code{make_malloced_string}, but the string is
+This function is identical to @code{make_malloced_string()}, but the string is
flagged as user input that should be treated as a strnum value if the contents
of the string are numeric.
@@ -33082,7 +33082,8 @@ statement (@pxref{Delete}).
@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, awk_flat_array_t **data, awk_valtype_t index_type, awk_valtype_t value_type);
For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
-structure and fill it in with indices and values of the requested types. Set the pointer whose address is passed as @code{data}
+structure and fill it in with indices and values of the requested types.
+Set the pointer whose address is passed as @code{data}
to point to this structure.
Return true upon success, or false otherwise.
@ifset FOR_PRINT
@@ -33097,8 +33098,10 @@ flatten an array and work with it.
@item awk_bool_t flatten_array(awk_array_t a_cookie, awk_flat_array_t **data);
For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
structure and fill it in with @code{AWK_STRING} indices and
-@code{AWK_UNDEFINED} values. This is superseded by @code{flatten_array_typed}
-and retained only for legacy binary compatibility.
+@code{AWK_UNDEFINED} values.
+This is superseded by @code{flatten_array_typed()}.
+It is provided as a macro, and remains convenience and for source code
+compatibility with the previous version of the API.
@item awk_bool_t release_flattened_array(awk_array_t a_cookie,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_flat_array_t *data);
@@ -37260,6 +37263,12 @@ These files contain the actual @command{gawk} source code.
@end table
@table @file
+@item support/*
+C header and source files for routines that @command{gawk}
+uses, but that are not part of its core functionality.
+For example, argument parsing, regular expression matching,
+and random number generating routines are all kept here.
+
@item ABOUT-NLS
A file containing information about GNU @command{gettext} and translations.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 9c647f05..20834b01 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,7 @@
+2016-12-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * testext.c (valrep2str): Update for new API types.
+
2016-12-16 Arnold D. Robbins <arnold@skeeve.com>
* filefuncs.c: Update func_table again.
diff --git a/extension/testext.c b/extension/testext.c
index bf342182..d23ad368 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -70,6 +70,8 @@ valrep2str(const awk_value_t *value)
case AWK_VALUE_COOKIE:
strcpy(buf, "<value-cookie>");
break;
+ case AWK_REGEX:
+ case AWK_STRNUM:
case AWK_STRING:
if (value->str_value.len < size)
size = value->str_value.len;
diff --git a/gawkapi.c b/gawkapi.c
index 72797e0c..4c6a2f8f 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -31,6 +31,7 @@ extern INSTRUCTION *main_beginfile;
extern int currule;
static awk_bool_t node_to_awk_value(NODE *node, awk_value_t *result, awk_valtype_t wanted);
+static char *valtype2str(awk_valtype_t type);
/*
* api_get_argument --- get the count'th paramater, zero-based.
@@ -515,9 +516,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted)
break;
case NUMBER:
(void) force_string(node);
- assign_string(node, val, AWK_STRNUM);
- ret = awk_true;
- break;
+ /* fall through */
case NUMBER|USER_INPUT:
assign_string(node, val, AWK_STRNUM);
ret = awk_true;
@@ -1090,7 +1089,7 @@ api_clear_array(awk_ext_id_t id, awk_array_t a_cookie)
return awk_true;
}
-/* api_flatten_array --- flatten out an array so that it can be looped over easily. */
+/* api_flatten_array_typed --- flatten out an array so that it can be looped over easily. */
static awk_bool_t
api_flatten_array_typed(awk_ext_id_t id,
@@ -1128,35 +1127,22 @@ api_flatten_array_typed(awk_ext_id_t id,
index = list[i];
value = list[i + 1]; /* number or string or subarray */
- /* Convert index and value to ext types. */
+ /* Convert index and value to API types. */
if (! node_to_awk_value(index,
& (*data)->elements[j].index, index_type)) {
- fatal(_("api_flatten_array_typed: could not convert index %d to %d\n"),
- (int) i, (int) index_type);
+ fatal(_("api_flatten_array_typed: could not convert index %d to %s\n"),
+ (int) i, valtype2str(index_type));
}
if (! node_to_awk_value(value,
& (*data)->elements[j].value, value_type)) {
- fatal(_("api_flatten_array_typed: could not convert value %d to %d\n"),
- (int) i, (int) value_type);
+ fatal(_("api_flatten_array_typed: could not convert value %d to %s\n"),
+ (int) i, valtype2str(value_type));
}
}
return awk_true;
}
/*
- * api_flatten_array -- replaced by api_flatten_array_typed. This function
- * is retained only for binary compatibility.
- */
-
-static awk_bool_t
-api_flatten_array(awk_ext_id_t id,
- awk_array_t a_cookie,
- awk_flat_array_t **data)
-{
- return api_flatten_array_typed(id, a_cookie, data, AWK_STRING, AWK_UNDEFINED);
-}
-
-/*
* api_release_flattened_array --- release array memory,
* delete any marked elements. Count must match what
* gawk thinks the size is.
@@ -1375,6 +1361,7 @@ gawk_api_t api_impl = {
api_fatal,
api_warning,
api_lintwarn,
+ api_nonfatal,
/* updating ERRNO */
api_update_ERRNO_int,
@@ -1404,7 +1391,7 @@ gawk_api_t api_impl = {
api_del_array_element,
api_create_array,
api_clear_array,
- api_flatten_array, /* for legacy binary compatibility */
+ api_flatten_array_typed,
api_release_flattened_array,
/* Memory allocation */
@@ -1415,12 +1402,6 @@ gawk_api_t api_impl = {
/* Find/open a file */
api_get_file,
-
- /* Print nonfatal error message */
- api_nonfatal,
-
- /* New array flattening function */
- api_flatten_array_typed,
};
/* init_ext_api --- init the extension API */
@@ -1455,3 +1436,30 @@ print_ext_versions(void)
for (p = vi_head; p != NULL; p = p->next)
printf("%s\n", p->version);
}
+
+/* valtype2str --- return a printable representation of a value type */
+
+static char *
+valtype2str(awk_valtype_t type)
+{
+ static char buf[100];
+
+ // Important: keep in same order as in gawkapi.h!
+ static char *values[] = {
+ "AWK_UNDEFINED",
+ "AWK_NUMBER",
+ "AWK_STRING",
+ "AWK_REGEX",
+ "AWK_STRNUM",
+ "AWK_ARRAY",
+ "AWK_SCALAR",
+ "AWK_VALUE_COOKIE",
+ };
+
+ if (AWK_UNDEFINED <= type && type <= AWK_VALUE_COOKIE)
+ return values[(int) type];
+
+ sprintf(buf, "unknown type! (%d)", (int) type);
+
+ return buf;
+}
diff --git a/gawkapi.h b/gawkapi.h
index 384fbe81..5071adce 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -306,11 +306,11 @@ typedef enum {
AWK_UNDEFINED,
AWK_NUMBER,
AWK_STRING,
+ AWK_REGEX,
+ AWK_STRNUM,
AWK_ARRAY,
AWK_SCALAR, /* opaque access to a variable */
- AWK_VALUE_COOKIE, /* for updating a previously created value */
- AWK_REGEX,
- AWK_STRNUM
+ AWK_VALUE_COOKIE /* for updating a previously created value */
} awk_valtype_t;
/*
@@ -473,6 +473,7 @@ typedef struct gawk_api {
void (*api_fatal)(awk_ext_id_t id, const char *format, ...);
void (*api_warning)(awk_ext_id_t id, const char *format, ...);
void (*api_lintwarn)(awk_ext_id_t id, const char *format, ...);
+ void (*api_nonfatal)(awk_ext_id_t id, const char *format, ...);
/* Functions to update ERRNO */
void (*api_update_ERRNO_int)(awk_ext_id_t id, int errno_val);
@@ -686,15 +687,14 @@ typedef struct gawk_api {
awk_bool_t (*api_clear_array)(awk_ext_id_t id, awk_array_t a_cookie);
/*
- * Flatten out an array so that it can be looped over easily.
- * This function returns all indices as strings and values as
- * the native type one would get from an AWK_UNDEFINED request.
- * Please use api_flatten_array_typed for more control over the
- * type conversions.
+ * Flatten out an array with type conversions as requested.
+ * This supersedes the api_flatten_array function that did not allow
+ * the caller to specify the requested types.
*/
- awk_bool_t (*api_flatten_array)(awk_ext_id_t id,
+ awk_bool_t (*api_flatten_array_typed)(awk_ext_id_t id,
awk_array_t a_cookie,
- awk_flat_array_t **data);
+ awk_flat_array_t **data,
+ awk_valtype_t index_type, awk_valtype_t value_type);
/* When done, delete any marked elements, release the memory. */
awk_bool_t (*api_release_flattened_array)(awk_ext_id_t id,
@@ -744,19 +744,6 @@ typedef struct gawk_api {
const awk_input_buf_t **ibufp,
const awk_output_buf_t **obufp);
- /* Print nonfatal error message */
- void (*api_nonfatal)(awk_ext_id_t id, const char *format, ...);
-
- /*
- * Flatten out an array with type conversions as requested.
- * This supersedes the api_flatten_array function that did not allow
- * the caller to specify the requested types.
- */
- awk_bool_t (*api_flatten_array_typed)(awk_ext_id_t id,
- awk_array_t a_cookie,
- awk_flat_array_t **data,
- awk_valtype_t index_type, awk_valtype_t value_type);
-
} gawk_api_t;
#ifndef GAWK /* these are not for the gawk code itself! */