gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, feature/regex-to-api, updated. gawk-4.1.


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, feature/regex-to-api, updated. gawk-4.1.0-2357-g1b66a15
Date: Wed, 30 Nov 2016 19:24:18 +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, feature/regex-to-api has been updated
       via  1b66a15c2eec9b48008e018e526b333cdeb56338 (commit)
      from  bf847b770dec8fd2e364a56abc8618987b9de917 (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=1b66a15c2eec9b48008e018e526b333cdeb56338

commit 1b66a15c2eec9b48008e018e526b333cdeb56338
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Nov 30 21:23:50 2016 +0200

    Add doc on API changes for typed regexes. Improve test.

diff --git a/ChangeLog b/ChangeLog
index 2194823..403967e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-11-30         Arnold D. Robbins     <address@hidden>
+
+       * gawkapi.h (make_regex): New function.
+
 2016-11-29         Arnold D. Robbins     <address@hidden>
 
        Add support for typed regex variables to the API.
diff --git a/doc/ChangeLog b/doc/ChangeLog
index c948bcd..ea02455 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-30         Arnold D. Robbins     <address@hidden>
+
+       * gawktexi.in: Document typed regex changes as relates to API.
+       Still stuff left to do.
+
 2016-11-21         Arnold D. Robbins     <address@hidden>
 
        * gawktexi.in: Finish off discussion of strongly typed regexp
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 857be3a..c79cda3 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -31571,7 +31571,8 @@ multibyte encoding.
 @itemx @ @ @ @ AWK_STRING,
 @itemx @ @ @ @ AWK_ARRAY,
 @itemx @ @ @ @ AWK_SCALAR,@ @ @ @ @ @ @ @ @ /* opaque access to a variable */
address@hidden @ @ @ @ AWK_VALUE_COOKIE@ @ @ @ /* for updating a previously 
created value */
address@hidden @ @ @ @ AWK_VALUE_COOKIE,@ @ @ /* for updating a previously 
created value */
address@hidden @ @ @ @ AWK_REGEX
 @itemx @} awk_valtype_t;
 This @code{enum} indicates the type of a value.
 It is used in the following @code{struct}.
@@ -31591,6 +31592,7 @@ The @code{val_type} member indicates what kind of value 
the
 @code{union} holds, and each member is of the appropriate type.
 
 @item #define str_value@ @ @ @ @ @ u.s
address@hidden #define regex_value@ @ @ @ str_value
 @itemx #define num_value@ @ @ @ @ @ u.d
 @itemx #define array_cookie@ @ @ u.a
 @itemx #define scalar_cookie@ @ u.scl
@@ -31611,7 +31613,7 @@ and in more detail in @ref{Cached values}.
 
 @end table
 
-Scalar values in @command{awk} are either numbers or strings. The
+Scalar values in @command{awk} are numbers, strings, or typed regexps. The
 @code{awk_value_t} struct represents values.  The @code{val_type} member
 indicates what is in the @code{union}.
 
@@ -31620,6 +31622,12 @@ require more work. Because @command{gawk} allows 
embedded @sc{nul} bytes
 in string values, a string must be represented as a pair containing a
 data pointer and length. This is the @code{awk_string_t} type.
 
+Typed regexp values (@pxref{Strong Regexp Constants}) are not of
+much use to extension functions.  Extension functions can tell that
+they've received them, and create them for scalar values. Otherwise,
+they can examine the text of the regexp through @code{regex_value.str}
+and @code{regex_value.len}.
+
 Identifiers (i.e., the names of global variables) can be associated
 with either scalar values or with arrays.  In addition, @command{gawk}
 provides true arrays of arrays, where any given array element can
@@ -31786,6 +31794,11 @@ It returns @code{result}.
 @itemx make_number(double num, awk_value_t *result);
 This function simply creates a numeric value in the @code{awk_value_t} variable
 pointed to by @code{result}.
+
address@hidden static inline awk_value_t *
address@hidden make_regex(const char *string, size_t length, awk_value_t 
*result);
+This function creates a strongly typed regexp value.
address@hidden is the regular expression of length @code{len}.
 @end table
 
 @node Registration Functions
@@ -32412,6 +32425,7 @@ value type, as appropriate.  This behavior is 
summarized in
 
 @float Table,table-value-types-returned
 @caption{API value types returned}
address@hidden FIXME: This needs doing.
 @docbook
 <informaltable>
 <tgroup cols="6">
@@ -32487,6 +32501,7 @@ value type, as appropriate.  This behavior is 
summarized in
 </informaltable>
 @end docbook
 
address@hidden FIXME: This needs doing.
 @ifnotplaintext
 @ifnotdocbook
 @multitable @columnfractions .50 .50
@@ -32509,27 +32524,29 @@ value type, as appropriate.  This behavior is 
summarized in
 @end ifnotplaintext
 @ifplaintext
 @example
-                        +-------------------------------------------------+
-                        |                Type of Actual Value:            |
-                        +------------+------------+-----------+-----------+
-                        |   String   |   Number   | Array     | Undefined |
-+-----------+-----------+------------+------------+-----------+-----------+
-|           | String    |   String   |   String   | False     | False     |
-|           |-----------+------------+------------+-----------+-----------+
-|           | Number    | Number if  |   Number   | False     | False     |
-|           |           | can be     |            |           |           |
-|           |           | converted, |            |           |           |
-|           |           | else false |            |           |           |
-|           |-----------+------------+------------+-----------+-----------+
-|   Type    | Array     |   False    |   False    | Array     | False     |
-| Requested |-----------+------------+------------+-----------+-----------+
-|           | Scalar    |   Scalar   |   Scalar   | False     | False     |
-|           |-----------+------------+------------+-----------+-----------+
-|           | Undefined |  String    |   Number   | Array     | Undefined |
-|           |-----------+------------+------------+-----------+-----------+
-|           | Value     |   False    |   False    | False     | False     |
-|           | cookie    |            |            |           |           |
-+-----------+-----------+------------+------------+-----------+-----------+
+                        
+-------------------------------------------------------------+
+                        |                    Type of Actual Value:             
       |
+                        
+------------+------------+-----------+-----------+-----------+
+                        |   String   |   Number   | Regex     | Array     | 
Undefined |
++-----------+-----------+------------+------------+-----------+-----------+-----------+
+|           | String    |   String   |   String   | String    | false     | 
false     |
+|           
+-----------+------------+------------+-----------+-----------+-----------+
+|           | Number    | Number if  |   Number   | false     | false     | 
false     |
+|           |           | can be     |            |           |           |    
       |
+|           |           | converted, |            |           |           |    
       |
+|           |           | else false |            |           |           |    
       |
+|           
+-----------+------------+------------+-----------+-----------+-----------+
+|           | Regex     |   false    |   false    |  Regex    | false     | 
false     |
+|           
+-----------+------------+------------+-----------+-----------+-----------+
+|   Type    | Array     |   false    |   false    |  false    | Array     | 
false     |
+| Requested 
+-----------+------------+------------+-----------+-----------+-----------+
+|           | Scalar    |   Scalar   |   Scalar   |  Scalar   | false     | 
false     |
+|           
+-----------+------------+------------+-----------+-----------+-----------+
+|           | Undefined |  String    |   Number   |  Regex    | Array     | 
Undefined |
+|           
+-----------+------------+------------+-----------+-----------+-----------+
+|           | Value     |   false    |   false    |  false    | false     | 
false     |
+|           | Cookie    |            |            |           |           |    
       |
++-----------+-----------+------------+------------+-----------+-----------+-----------+
 @end example
 @end ifplaintext
 @end float
@@ -32636,7 +32653,7 @@ Return false if the value cannot be retrieved.
 
 @item awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);
 Update the value associated with a scalar cookie.  Return false if
-the new value is not of type @code{AWK_STRING} or @code{AWK_NUMBER}.
+the new value is not of type @code{AWK_STRING}, @code{AWK_REGEX}, or 
@code{AWK_NUMBER}.
 Here too, the predefined variables may not be updated.
 @end table
 
@@ -32757,7 +32774,7 @@ is what the routines in this @value{SECTION} let you 
do.  The functions are as f
 @table @code
 @item awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);
 Create a cached string or numeric value from @code{value} for
-efficient later assignment.  Only values of type @code{AWK_NUMBER}
+efficient later assignment.  Only values of type @code{AWK_NUMBER}, 
@code{AWK_REGEX},
 and @code{AWK_STRING} are allowed.  Any other type is rejected.
 @code{AWK_UNDEFINED} could be allowed, but doing so would result in
 inferior performance.
@@ -33500,10 +33517,10 @@ debugging:
 
 @float Table,gawk-api-version
 @caption{gawk API version constants}
address@hidden @columnfractions .33 .33 .33
address@hidden API Version @tab C preprocessor define @tab enum constant
address@hidden Major @tab gawk_api_major_version @tab GAWK_API_MAJOR_VERSION
address@hidden Minor @tab gawk_api_minor_version @tab GAWK_API_MINOR_VERSION
address@hidden @columnfractions .20 .33 .33
address@hidden API Version @tab C Preprocessor Define @tab enum constant
address@hidden Major @tab @code{gawk_api_major_version} @tab 
@code{GAWK_API_MAJOR_VERSION}
address@hidden Minor @tab @code{gawk_api_minor_version} @tab 
@code{GAWK_API_MINOR_VERSION}
 @end multitable
 @end float
 
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 5d5fb93..dc0373f 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-30         Arnold D. Robbins     <address@hidden>
+
+       * rwarray.c: Restore read comparion of major and minor versions
+       to use !=.
+
 2016-11-29         Arnold D. Robbins     <address@hidden>
 
        * rwarray.c: Adjust to read and write regexes also.
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 037fd87..ad77b68 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -305,7 +305,7 @@ do_reada(int nargs, awk_value_t *result)
        }
        major = ntohl(major);
 
-       if (major < MAJOR) {
+       if (major != MAJOR) {
                errno = EBADF;
                goto done1;
        }
@@ -316,7 +316,7 @@ do_reada(int nargs, awk_value_t *result)
        }
 
        minor = ntohl(minor);
-       if (minor < MINOR) {
+       if (minor != MINOR) {
                errno = EBADF;
                goto done1;
        }
diff --git a/gawkapi.h b/gawkapi.h
index 89a997b..9220b09 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -883,6 +883,18 @@ make_number(double num, awk_value_t *result)
        return result;
 }
 
+/* make_regex --- make a regex value in result */
+
+static inline awk_value_t *
+make_regex(const char *string, size_t length, awk_value_t *result)
+{
+       make_const_string(str, len, result);
+       result->val_type = AWK_REGEX;
+
+       return result;
+}
+
+
 /*
  * Each extension must define a function with this prototype:
  *
diff --git a/test/ChangeLog b/test/ChangeLog
index fa12aef..a2dbdc5 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-30         Arnold D. Robbins     <address@hidden>
+
+       * rwarray.awk: Use typeof() to verify that typed regex is
+       created correctly upon reading.
+
 2016-11-29         Arnold D. Robbins     <address@hidden>
 
        * rwarray.awk: Add a typed regex into the array before
diff --git a/test/rwarray.awk b/test/rwarray.awk
index 83c3ccd..70809b6 100644
--- a/test/rwarray.awk
+++ b/test/rwarray.awk
@@ -4,7 +4,8 @@ BEGIN {
        while ((getline word) > 0)
                dict[word] = word word
 
-       dict["/typed-regex/"] = @/search me/
+       re_sub = "/typed-regex/"
+       dict[re_sub] = @/search me/
 
        n = asorti(dict, dictindices)
        for (i = 1; i <= n; i++)
@@ -38,4 +39,8 @@ BEGIN {
                if (ret == 0 && !("KEEPIT" in ENVIRON))
                        system("rm -f orig.bin orig.out new.out")
        }
+
+       if (typeof(dict[re_sub]) != "regexp")
+               printf("dict[\"%s\"] should be regexp, is %s\n",
+                       re_sub, typeof(dict[re_sub]));
 }

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

Summary of changes:
 ChangeLog           |    4 +++
 doc/ChangeLog       |    5 ++++
 doc/gawktexi.in     |   75 +++++++++++++++++++++++++++++++--------------------
 extension/ChangeLog |    5 ++++
 extension/rwarray.c |    4 +--
 gawkapi.h           |   12 +++++++++
 test/ChangeLog      |    5 ++++
 test/rwarray.awk    |    7 ++++-
 8 files changed, 85 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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