Forum: Ruby StringScanner::search_full documentation error - ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D15a45a973443d4562051eb675b60474?d=identicon&s=25 Tom Cloyd (Guest)
on 2009-01-01 14:59
(Received via mailing list)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Meager as my Ruby skills are, I hesitate to claim to have found a
documentation error, but I'm not sure what else to call it. I've looked
for a ruby documentation list to report this to, and haven't found one,
so I send it here.<br>
<br>
At <a class="moz-txt-link-freetext"
href="http://ruby-doc.org/core/">http://ruby-doc.org/cor...,
documentation for
StringScanner::search_full reads -<br>
<br>
<div class="method-heading">"<a
 href="http://ruby-doc.org/core/classes/StringScanner.src...
 target="Code" class="method-signature"
 onclick="popupCode('StringScanner.src/M002050.html');return
false;"><span
 class="method-name">search_full(pattern, return_string_p,
advance_pointer_p)<br>
</span> </a> </div>
<div class="m-description">
<p>Scans the <a
 href="http://ruby-doc.org/core/classes/StringScanner.htm...
<em>until</em>
the <tt>pattern</tt> is <a
 href="http://ruby-doc.org/core/classes/StringScanner.htm....
Returns the <a
 href="http://ruby-doc.org/core/classes/StringScanner.htm...
<a
href="http://ruby-doc.org/core/classes/StringScanner.htm...
if <tt>return_string_p</tt> is
true, otherwise returns the number of bytes advanced. Advances the <a
 href="http://ruby-doc.org/core/classes/StringScanner.htm...
<a
href="http://ruby-doc.org/core/classes/StringScanner.htm...
if
<tt>advance_pointer_p</tt>, otherwise not. This method does affect the
match register."<br>
</p>
<p>But consider these (edited) results...<br>
</p>
<p>irb(main):005:0&gt; a='abc .r def
.n'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
=&gt; "abc .r def .n"&nbsp; <br>
irb(main):009:0&gt; aa=StringScanner.new(a)<br>
=&gt; #&lt;StringScanner 0/13 @ "abc ...."&gt; <br>
irb(main):014:0&gt; aa.search_full(/\.r /,true,false)<br>
=&gt; 7<br>
irb(main):016:0&gt; aa.pos<br>
=&gt; 7<br>
</p>
<p>[comment: these results are the opposite of what I expected - I did
NOT get back the matched string, and the pointer WAS advanced.] <br>
</p>
<p>irb(main):021:0&gt; aa.reset<br>
=&gt; #&lt;StringScanner 0/13 @ "abc ...."&gt;<br>
irb(main):022:0&gt; aa.search_full(/\.r /,false,true)<br>
=&gt; "abc .r "<br>
irb(main):023:0&gt; aa.pos<br>
=&gt; 0<br>
</p>
<p>[comment: again - this is the opposite of what I expected, given the
documentation.]<br>
</p>
<p>irb(main):025:0&gt; a<br>
=&gt; "abc .r def .n"<br>
</p>
<p><br>
Environment:<br>
OS: Kubuntu Linux 8.10 Intrepid Ibix<br>
/$ ruby -v<br>
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]<br>
</p>
</div>
I've stared at these results for some minutes and don't yet see an
"pilot error".<br>
<br>
All comments welcome.<br>
<br>
Tom<br>
<pre class="moz-signature" cols="72">--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
&lt;&lt; <a class="moz-txt-link-abbreviated"
href="mailto:tc@tomcloyd.com">tc@tomcloyd.com</a> &gt;&gt; (email)
&lt;&lt; TomCloyd.com &gt;&gt; (website)
&lt;&lt; sleightmind.wordpress.com &gt;&gt; (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</pre>
</body>
</html>
This topic is locked and can not be replied to.