1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Date: Thu, 27 Apr 2006 20:59:03 +0100
# From: Lee Haywood <ljhaywood2@googlemail.com>
# Subject: gawk multi-byte support bugs, assertion bug and fix.
# To: bug-gawk@gnu.org
# Message-id: <60962be00604271259na0d8fdayb9d0c69a853216e8@mail.gmail.com>
# MIME-version: 1.0
# Content-type: multipart/alternative;
# boundary="----=_Part_10136_920879.1146167943492"
# Status: RO
#
# ------=_Part_10136_920879.1146167943492
# Content-Type: text/plain; charset=ISO-8859-1
# Content-Transfer-Encoding: quoted-printable
# Content-Disposition: inline
#
#
# Firstly, I have been getting the following error from version 3.1.5.
#
# awk: node.c:515: unref: Assertion `(tmp->flags & 4096) !=3D 0' failed.
#
# In mk_number() in node.c the MBS_SUPPORT code is inside the GAWKDEBUG
# section - moving it outside explicitly clears the string values, which
# prevents the assertion error from occurring. The corrected version is
# shown at the end of this message.
#
# As an aside, I also noticed that n->wstptr is not cleared by
# set_field() and set_record() in field.c when the flags are set to
# exclude WSTRCUR. However, I do not have a test case to show if
# changing them makes any difference.
#
# A second problem also occurs when gawk 3.1.5 is compiled with
# multi-byte character support (MBS_SUPPORT). The following code should
# change the index of the substring "bc" from 2 to 3, but it gets
# reported as 2 in both cases - which is obviously disastrous.
#
# awk 'BEGIN {
# Value =3D "abc"
#
# print "Before <" Value "> ",
# index( Value, "bc" )
#
# sub( /bc/, "bbc", Value )
#
# print "After <" Value ">",
# index( Value, "bc" )
# }'
#
# Compiling with MBS_SUPPORT undefined makes these problems go away.
#
# /* mk_number --- allocate a node with defined number */
#
# NODE *
# mk_number(AWKNUM x, unsigned int flags)
# {
# register NODE *r;
#
# getnode(r);
# r->type =3D Node_val;
# r->numbr =3D x;
# r->flags =3D flags;
# #if defined MBS_SUPPORT
# r->wstptr =3D NULL;
# r->wstlen =3D 0;
# #endif /* MBS_SUPPORT */
# #ifdef GAWKDEBUG
# r->stref =3D 1;
# r->stptr =3D NULL;
# r->stlen =3D 0;
# #if defined MBS_SUPPORT
# r->flags &=3D ~WSTRCUR;
# #endif /* MBS_SUPPORT */
# #endif /* GAWKDEBUG */
# return r;
# }
#
# Thanks.
#
# --
# Lee Haywood.
BEGIN {
Value = "abc"
print "Before <" Value "> ", index( Value, "bc" )
sub( /bc/, "bbc", Value )
print "After <" Value ">", index( Value, "bc" )
}
|