gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-1807-gd85154


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-1807-gd851540
Date: Mon, 30 May 2016 21:08:02 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  d851540e8611be939ac01a4f6c87ade351d6ad0b (commit)
      from  bda71a2e22997e09f82d4ea33ccef03c0afc667b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=d851540e8611be939ac01a4f6c87ade351d6ad0b

commit d851540e8611be939ac01a4f6c87ade351d6ad0b
Author: Arnold D. Robbins <address@hidden>
Date:   Mon May 30 17:07:46 2016 -0400

    Allow extension functions to get more arguments than expected.

diff --git a/ChangeLog b/ChangeLog
index 36ca97e..edf3d8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-05-30         Andrew J. Schorr     <address@hidden>
+
+       * gawkapi.h (awk_ext_func_t): Rename num_expected_args to
+       max_expected_args, and explain in the comment that it doesn't really
+       matter.
+       * ext.c (make_builtin): Replace num_expected_args with
+       max_expected_args.
+       (get_argument): Do not check whether the argument number exceeds
+       the maximum expected by the function.
+
 2016-05-30         Arnold D. Robbins     <address@hidden>
 
        * main.c (arg_assign): Fully bracket ifdefs around call
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 3210661..7251f6a 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-30         Andrew J. Schorr     <address@hidden>
+
+       * gawktexi.in: Replace num_expected_args with max_expected_args.
+       Explain what it's used for.
+
 2016-05-25         Manuel Collado        <address@hidden>.
 
        * gawktexi.in: Document new 'nonfatal' API function.
diff --git a/doc/gawk.info b/doc/gawk.info
index 29eee6b..8aa8422 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -23699,7 +23699,7 @@ Extension functions are described by the following 
record:
      typedef struct awk_ext_func {
          const char *name;
          awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-         size_t num_expected_args;
+         size_t max_expected_args;
      } awk_ext_func_t;
 
    The fields are:
@@ -23726,11 +23726,17 @@ Extension functions are described by the following 
record:
      The function must return the value of 'result'.  This is for the
      convenience of the calling code inside 'gawk'.
 
-'size_t num_expected_args;'
-     This is the number of arguments the function expects to receive.
-     Each extension function may decide what to do if the number of
-     arguments isn't what it expected.  As with real 'awk' functions, it
-     is likely OK to ignore extra arguments.
+'size_t max_expected_args;'
+     This is the maximum number of arguments the function expects to
+     receive.  Each extension function may decide what to do if the
+     number of arguments isn't what it expected.  As with real 'awk'
+     functions, it is likely OK to ignore extra arguments.  This value
+     does not affect actual program execution.
+
+     Extension functions should compare this value to the number of
+     actual arguments passed and possibly issue a lint warning if there
+     is an undesirable mismatch.  Of course, if '--lint=fatal' is used,
+     this would cause the program to exit.
 
    Once you have a record representing your extension function, you
 register it with 'gawk' using this API function:
@@ -35691,134 +35697,134 @@ Ref: Memory Allocation Functions-Footnote-1960024
 Node: Constructor Functions960123
 Node: Registration Functions961868
 Node: Extension Functions962553
-Node: Exit Callback Functions964852
-Node: Extension Version String966102
-Node: Input Parsers966765
-Node: Output Wrappers976650
-Node: Two-way processors981162
-Node: Printing Messages983426
-Ref: Printing Messages-Footnote-1984597
-Node: Updating ERRNO984750
-Node: Requesting Values985489
-Ref: table-value-types-returned986226
-Node: Accessing Parameters987109
-Node: Symbol Table Access988344
-Node: Symbol table by name988856
-Node: Symbol table by cookie990877
-Ref: Symbol table by cookie-Footnote-1995026
-Node: Cached values995090
-Ref: Cached values-Footnote-1998591
-Node: Array Manipulation998682
-Ref: Array Manipulation-Footnote-1999773
-Node: Array Data Types999810
-Ref: Array Data Types-Footnote-11002468
-Node: Array Functions1002560
-Node: Flattening Arrays1006418
-Node: Creating Arrays1013326
-Node: Redirection API1018095
-Node: Extension API Variables1020926
-Node: Extension Versioning1021559
-Ref: gawk-api-version1021996
-Node: Extension API Informational Variables1023752
-Node: Extension API Boilerplate1024816
-Node: Finding Extensions1028630
-Node: Extension Example1029189
-Node: Internal File Description1029987
-Node: Internal File Ops1034067
-Ref: Internal File Ops-Footnote-11045829
-Node: Using Internal File Ops1045969
-Ref: Using Internal File Ops-Footnote-11048352
-Node: Extension Samples1048626
-Node: Extension Sample File Functions1050155
-Node: Extension Sample Fnmatch1057804
-Node: Extension Sample Fork1059291
-Node: Extension Sample Inplace1060509
-Node: Extension Sample Ord1063719
-Node: Extension Sample Readdir1064555
-Ref: table-readdir-file-types1065444
-Node: Extension Sample Revout1066249
-Node: Extension Sample Rev2way1066838
-Node: Extension Sample Read write array1067578
-Node: Extension Sample Readfile1069520
-Node: Extension Sample Time1070615
-Node: Extension Sample API Tests1071963
-Node: gawkextlib1072455
-Node: Extension summary1074902
-Node: Extension Exercises1078604
-Node: Language History1080101
-Node: V7/SVR3.11081757
-Node: SVR41083909
-Node: POSIX1085343
-Node: BTL1086722
-Node: POSIX/GNU1087451
-Node: Feature History1093313
-Node: Common Extensions1107683
-Node: Ranges and Locales1108966
-Ref: Ranges and Locales-Footnote-11113582
-Ref: Ranges and Locales-Footnote-21113609
-Ref: Ranges and Locales-Footnote-31113844
-Node: Contributors1114065
-Node: History summary1119634
-Node: Installation1121014
-Node: Gawk Distribution1121958
-Node: Getting1122442
-Node: Extracting1123403
-Node: Distribution contents1125041
-Node: Unix Installation1131135
-Node: Quick Installation1131817
-Node: Shell Startup Files1134231
-Node: Additional Configuration Options1135309
-Node: Configuration Philosophy1137114
-Node: Non-Unix Installation1139483
-Node: PC Installation1139941
-Node: PC Binary Installation1141261
-Node: PC Compiling1143113
-Ref: PC Compiling-Footnote-11146137
-Node: PC Testing1146246
-Node: PC Using1147426
-Node: Cygwin1151540
-Node: MSYS1152310
-Node: VMS Installation1152811
-Node: VMS Compilation1153602
-Ref: VMS Compilation-Footnote-11154831
-Node: VMS Dynamic Extensions1154889
-Node: VMS Installation Details1156574
-Node: VMS Running1158827
-Node: VMS GNV1163106
-Node: VMS Old Gawk1163841
-Node: Bugs1164312
-Node: Other Versions1168509
-Node: Installation summary1175093
-Node: Notes1176151
-Node: Compatibility Mode1177016
-Node: Additions1177798
-Node: Accessing The Source1178723
-Node: Adding Code1180158
-Node: New Ports1186377
-Node: Derived Files1190865
-Ref: Derived Files-Footnote-11196350
-Ref: Derived Files-Footnote-21196385
-Ref: Derived Files-Footnote-31196983
-Node: Future Extensions1197097
-Node: Implementation Limitations1197755
-Node: Extension Design1198938
-Node: Old Extension Problems1200092
-Ref: Old Extension Problems-Footnote-11201610
-Node: Extension New Mechanism Goals1201667
-Ref: Extension New Mechanism Goals-Footnote-11205031
-Node: Extension Other Design Decisions1205220
-Node: Extension Future Growth1207333
-Node: Old Extension Mechanism1208169
-Node: Notes summary1209932
-Node: Basic Concepts1211114
-Node: Basic High Level1211795
-Ref: figure-general-flow1212077
-Ref: figure-process-flow1212762
-Ref: Basic High Level-Footnote-11216063
-Node: Basic Data Typing1216248
-Node: Glossary1219576
-Node: Copying1251522
-Node: GNU Free Documentation License1289061
-Node: Index1314179
+Node: Exit Callback Functions965176
+Node: Extension Version String966426
+Node: Input Parsers967089
+Node: Output Wrappers976974
+Node: Two-way processors981486
+Node: Printing Messages983750
+Ref: Printing Messages-Footnote-1984921
+Node: Updating ERRNO985074
+Node: Requesting Values985813
+Ref: table-value-types-returned986550
+Node: Accessing Parameters987433
+Node: Symbol Table Access988668
+Node: Symbol table by name989180
+Node: Symbol table by cookie991201
+Ref: Symbol table by cookie-Footnote-1995350
+Node: Cached values995414
+Ref: Cached values-Footnote-1998915
+Node: Array Manipulation999006
+Ref: Array Manipulation-Footnote-11000097
+Node: Array Data Types1000134
+Ref: Array Data Types-Footnote-11002792
+Node: Array Functions1002884
+Node: Flattening Arrays1006742
+Node: Creating Arrays1013650
+Node: Redirection API1018419
+Node: Extension API Variables1021250
+Node: Extension Versioning1021883
+Ref: gawk-api-version1022320
+Node: Extension API Informational Variables1024076
+Node: Extension API Boilerplate1025140
+Node: Finding Extensions1028954
+Node: Extension Example1029513
+Node: Internal File Description1030311
+Node: Internal File Ops1034391
+Ref: Internal File Ops-Footnote-11046153
+Node: Using Internal File Ops1046293
+Ref: Using Internal File Ops-Footnote-11048676
+Node: Extension Samples1048950
+Node: Extension Sample File Functions1050479
+Node: Extension Sample Fnmatch1058128
+Node: Extension Sample Fork1059615
+Node: Extension Sample Inplace1060833
+Node: Extension Sample Ord1064043
+Node: Extension Sample Readdir1064879
+Ref: table-readdir-file-types1065768
+Node: Extension Sample Revout1066573
+Node: Extension Sample Rev2way1067162
+Node: Extension Sample Read write array1067902
+Node: Extension Sample Readfile1069844
+Node: Extension Sample Time1070939
+Node: Extension Sample API Tests1072287
+Node: gawkextlib1072779
+Node: Extension summary1075226
+Node: Extension Exercises1078928
+Node: Language History1080425
+Node: V7/SVR3.11082081
+Node: SVR41084233
+Node: POSIX1085667
+Node: BTL1087046
+Node: POSIX/GNU1087775
+Node: Feature History1093637
+Node: Common Extensions1108007
+Node: Ranges and Locales1109290
+Ref: Ranges and Locales-Footnote-11113906
+Ref: Ranges and Locales-Footnote-21113933
+Ref: Ranges and Locales-Footnote-31114168
+Node: Contributors1114389
+Node: History summary1119958
+Node: Installation1121338
+Node: Gawk Distribution1122282
+Node: Getting1122766
+Node: Extracting1123727
+Node: Distribution contents1125365
+Node: Unix Installation1131459
+Node: Quick Installation1132141
+Node: Shell Startup Files1134555
+Node: Additional Configuration Options1135633
+Node: Configuration Philosophy1137438
+Node: Non-Unix Installation1139807
+Node: PC Installation1140265
+Node: PC Binary Installation1141585
+Node: PC Compiling1143437
+Ref: PC Compiling-Footnote-11146461
+Node: PC Testing1146570
+Node: PC Using1147750
+Node: Cygwin1151864
+Node: MSYS1152634
+Node: VMS Installation1153135
+Node: VMS Compilation1153926
+Ref: VMS Compilation-Footnote-11155155
+Node: VMS Dynamic Extensions1155213
+Node: VMS Installation Details1156898
+Node: VMS Running1159151
+Node: VMS GNV1163430
+Node: VMS Old Gawk1164165
+Node: Bugs1164636
+Node: Other Versions1168833
+Node: Installation summary1175417
+Node: Notes1176475
+Node: Compatibility Mode1177340
+Node: Additions1178122
+Node: Accessing The Source1179047
+Node: Adding Code1180482
+Node: New Ports1186701
+Node: Derived Files1191189
+Ref: Derived Files-Footnote-11196674
+Ref: Derived Files-Footnote-21196709
+Ref: Derived Files-Footnote-31197307
+Node: Future Extensions1197421
+Node: Implementation Limitations1198079
+Node: Extension Design1199262
+Node: Old Extension Problems1200416
+Ref: Old Extension Problems-Footnote-11201934
+Node: Extension New Mechanism Goals1201991
+Ref: Extension New Mechanism Goals-Footnote-11205355
+Node: Extension Other Design Decisions1205544
+Node: Extension Future Growth1207657
+Node: Old Extension Mechanism1208493
+Node: Notes summary1210256
+Node: Basic Concepts1211438
+Node: Basic High Level1212119
+Ref: figure-general-flow1212401
+Ref: figure-process-flow1213086
+Ref: Basic High Level-Footnote-11216387
+Node: Basic Data Typing1216572
+Node: Glossary1219900
+Node: Copying1251846
+Node: GNU Free Documentation License1289385
+Node: Index1314503
 
 End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 47eec4b..e23230b 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -32484,7 +32484,7 @@ Extension functions are described by the following 
record:
 typedef struct awk_ext_func @{
 @ @ @ @ const char *name;
 @ @ @ @ awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-@ @ @ @ size_t num_expected_args;
+@ @ @ @ size_t max_expected_args;
 @} awk_ext_func_t;
 @end example
 
@@ -32516,11 +32516,17 @@ actual parameters were passed from the calling 
@command{awk} code.
 The function must return the value of @code{result}.
 This is for the convenience of the calling code inside @command{gawk}.
 
address@hidden size_t num_expected_args;
-This is the number of arguments the function expects to receive.
address@hidden size_t max_expected_args;
+This is the maximum number of arguments the function expects to receive.
 Each extension function may decide what to do if the number of
 arguments isn't what it expected.  As with real @command{awk} functions, it
-is likely OK to ignore extra arguments.
+is likely OK to ignore extra arguments.  This value does not affect
+actual program execution.
+
+Extension functions should compare this value to the number of actual
+arguments passed and possibly issue a lint warning if there is an
+undesirable mismatch.  Of course, if
address@hidden is used, this would cause the program to exit.
 @end table
 
 Once you have a record representing your extension function, you register
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index d77e476..a0692e2 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -31575,7 +31575,7 @@ Extension functions are described by the following 
record:
 typedef struct awk_ext_func @{
 @ @ @ @ const char *name;
 @ @ @ @ awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-@ @ @ @ size_t num_expected_args;
+@ @ @ @ size_t max_expected_args;
 @} awk_ext_func_t;
 @end example
 
@@ -31607,11 +31607,17 @@ actual parameters were passed from the calling 
@command{awk} code.
 The function must return the value of @code{result}.
 This is for the convenience of the calling code inside @command{gawk}.
 
address@hidden size_t num_expected_args;
-This is the number of arguments the function expects to receive.
address@hidden size_t max_expected_args;
+This is the maximum number of arguments the function expects to receive.
 Each extension function may decide what to do if the number of
 arguments isn't what it expected.  As with real @command{awk} functions, it
-is likely OK to ignore extra arguments.
+is likely OK to ignore extra arguments.  This value does not affect
+actual program execution.
+
+Extension functions should compare this value to the number of actual
+arguments passed and possibly issue a lint warning if there is an
+undesirable mismatch.  Of course, if
address@hidden is used, this would cause the program to exit.
 @end table
 
 Once you have a record representing your extension function, you register
diff --git a/ext.c b/ext.c
index c16ab60..c0d6f15 100644
--- a/ext.c
+++ b/ext.c
@@ -99,7 +99,7 @@ make_builtin(const awk_ext_func_t *funcinfo)
        const char *sp;
        char c;
        const char *name = funcinfo->name;
-       int count = funcinfo->num_expected_args;
+       int count = funcinfo->max_expected_args;
 
        sp = name;
        if (sp == NULL || *sp == '\0')
@@ -156,10 +156,9 @@ get_argument(int i)
        INSTRUCTION *pc;
        
        pc = TOP()->code_ptr;           /* Op_ext_builtin instruction */
-       pcount = (pc + 1)->expr_count;  /* max # of arguments */
        arg_count = pc->expr_count;     /* # of arguments supplied */
 
-       if (i < 0 || i >= pcount || i >= arg_count)
+       if (i < 0 || i >= arg_count)
                return NULL;
 
        t = PEEK(arg_count - i);
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 1da8981..06e8f6a 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-26         Andrew J. Schorr     <address@hidden>
+
+       * filefuncs.c (func_table): Update "stat" to indicate that the
+       max # of expected args is 3, not 2.
+
 2016-01-27         Arnold D. Robbins     <address@hidden>
 
        * filefuncs.c (do_statvfs): Define out f_fsid on AIX.
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index b33fcf1..00387cf 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -929,7 +929,7 @@ out:
 
 static awk_ext_func_t func_table[] = {
        { "chdir",      do_chdir, 1 },
-       { "stat",       do_stat, 2 },
+       { "stat",       do_stat, 3 },
 #ifndef __MINGW32__
        { "fts",        do_fts, 3 },
 #endif
diff --git a/gawkapi.h b/gawkapi.h
index 514b123..f024460 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -374,11 +374,15 @@ typedef struct awk_flat_array {
  * Each extension function may decide what to do if the number of
  * arguments isn't what it expected.  Following awk functions, it
  * is likely OK to ignore extra arguments.
+
+ * Note that the 'max_expected_args' value should be used by the
+ * extension function itself only to trigger a lint warning if more
+ * arguments are passed to the function.
  */
 typedef struct awk_ext_func {
        const char *name;
        awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-       size_t num_expected_args;
+       size_t max_expected_args;
 } awk_ext_func_t;
 
 typedef void *awk_ext_id_t;    /* opaque type for extension id */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   10 ++
 doc/ChangeLog         |    5 +
 doc/gawk.info         |  276 +++++++++++++++++++++++++------------------------
 doc/gawk.texi         |   14 ++-
 doc/gawktexi.in       |   14 ++-
 ext.c                 |    5 +-
 extension/ChangeLog   |    5 +
 extension/filefuncs.c |    2 +-
 gawkapi.h             |    6 +-
 9 files changed, 189 insertions(+), 148 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]