Debian Codegraph @

test/regnul2.awk

raw
1 # From [email protected] Thu May 29 09:10:18 IDT 2014
2 # Article: 8408 of comp.lang.awk
3 # X-Received: by 10.182.128.166 with SMTP id np6mr93689obb.16.1401289466734;
4 # Wed, 28 May 2014 08:04:26 -0700 (PDT)
5 # X-Received: by 10.140.36.6 with SMTP id o6mr4939qgo.26.1401289466607; Wed, 28
6 # May 2014 08:04:26 -0700 (PDT)
7 # Path: eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c1no19185457igq.0!news-out.google.com!qf4ni13600igc.0!nntp.google.com!c1no19185454igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
8 # Newsgroups: comp.lang.awk
9 # Date: Wed, 28 May 2014 08:04:26 -0700 (PDT)
10 # In-Reply-To: <[email protected]>
11 # Complaints-To: [email protected]
12 # Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.131.35.51; posting-account=zNhVLgoAAACsg-WfVe_or2VV7loUhx8H
13 # NNTP-Posting-Host: 82.131.35.51
14 # References: <[email protected]>
15 # <[email protected]> <[email protected]>
16 # <[email protected]>
17 # User-Agent: G2/1.0
18 # MIME-Version: 1.0
19 # Message-ID: <[email protected]>
20 # Subject: Re: \0 character can't be implement inside regexp in some cases?
21 # From: Denis Shirokov <[email protected]>
22 # Injection-Date: Wed, 28 May 2014 15:04:26 +0000
23 # Content-Type: text/plain; charset=ISO-8859-1
24 # Xref: news.eternal-september.org comp.lang.awk:8408
25 #
26 #
27 # All of the other use-cases just cluttered up your posting.
28 #
29 # oh, really?
30 #
31 # 1. where in the Janis code the case with the `switch-case'?
32 # 2. how do you know about that there is only two cases? may be you know it because my code contains the other test cases?
33 # 3. fine. do you know what situation with the dynamic regexps? no?
34 # 4. do you know what situation with RS,FS and /.../ in the middle-area? how you can say that there is only two cases if you absolutely do not know it?
35 #
36 # i'm asking: WHO will perform testing other cases? You? gawk-team? the God?
37 # what is that point of view: that it will be enough to say:
38 # Oh! my match(t,/^\0$/) is matching "\x00" but t~/^\0$/ is not. why oh why?
39 #
40 # where is the test cover? or you think that other peoples will doing its instead of You? instead of Me?
41 #
42 # and the second point: guys you are screaming about two levels of stack. really, you kidding? =)
43 #
44 # however, i'm attaching some additional information about dynrexp:
45 #
46 func _chmd(t,r) {
47 _ch("match()",match(t,r))
48 _ch("split()",split(t,A,r)>1)
49 _ch("patsplit()",patsplit(t,A,r))
50 _ch("gsub()",gsub(r,"&",t))
51 t2=t; _ch("sub()",sub(r,"&",t2))
52 _ch("gensub()",!gensub(r,"","G",t))
53 _ch("str~/rexp/",t~r)
54 # switch-case is not applicable with dynrxp
55 _conline() }
56
57 func _ch(fn,bool) {
58 print substr(fn ": ",1,16) (bool ? "+" : "-") }
59
60 func _conline() {
61 print "__________________________"; print }
62
63 BEGIN{ _chmd("\x01","^\1$") #testing that all doings right; all match
64 _chmd("\x00","^\1$") #testing that all doings right; all not match
65 _chmd("\x00","^\0$") #tesing dynrexp
66 }
67 #
68 # output:
69 #
70 # match(): +
71 # split(): +
72 # patsplit(): +
73 # gsub(): +
74 # sub(): +
75 # gensub(): +
76 # str~/rexp/: +
77 # __________________________
78 #
79 # match(): -
80 # split(): -
81 # patsplit(): -
82 # gsub(): -
83 # sub(): -
84 # gensub(): -
85 # str~/rexp/: -
86 # __________________________
87 #
88 # match(): +
89 # split(): +
90 # patsplit(): +
91 # gsub(): +
92 # sub(): +
93 # gensub(): +
94 # str~/rexp/: -
95 #
96 # it's looks like with the dynamic regexp the same story.
97 #
98 # i found another one moment that is possible near with the reason of this issue:
99 #
100 # i was testing what characters can be present in doublestring and regexp "directly" (just as the character) and what characters must be present as escape sequence (\qqq)
101 #
102 # so, i found the following:
103 #
104 # t="abc"
105 # if ( match(t,/^abc[NUL]def/) ) ... - where [NUL] is the character \x00
106 #
107 # it's seems that in that case the regular expression is processed until [NUL]character and the other part is ignored because the example above gives TRUE
108 #
109 # friendship
110 # Denis Shirokov
111 #
112 #