1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#do_includes): replace

also locally defined modules.

* ext/iconv/iconv.c: rdocified.

* ext/strscan/strscan.c: moved misplaced rdoc.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-03-04 10:40:09 +00:00
parent 0992f6c472
commit 49af08e188
4 changed files with 237 additions and 223 deletions

View file

@ -1,3 +1,12 @@
Fri Mar 4 19:39:55 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#do_includes): replace
also locally defined modules.
* ext/iconv/iconv.c: rdocified.
* ext/strscan/strscan.c: moved misplaced rdoc.
Fri Mar 4 16:11:20 2005 NAKAMURA Usaku <usa@ruby-lang.org> Fri Mar 4 16:11:20 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* eval.c (rb_exec_recursive): matched the declaration to prototype. * eval.c (rb_exec_recursive): matched the declaration to prototype.
@ -47,7 +56,7 @@ Fri Mar 4 08:09:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
Thu Mar 4 07:07:00 2005 NARUSE, Yui <naruse@ruby-lang.org> Thu Mar 4 07:07:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow nkf 1.63 * ext/nkf/nkf-utf8/nkf.c: follow nkf 1.63
Thu Mar 3 23:24:00 2005 NARUSE, Yui <naruse@ruby-lang.org> Thu Mar 3 23:24:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
@ -418,7 +427,7 @@ Wed Feb 16 02:47:45 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
Tue Feb 15 22:14:34 2005 sheepman <sheepman@tcn.zaq.ne.jp> Tue Feb 15 22:14:34 2005 sheepman <sheepman@tcn.zaq.ne.jp>
* ext/readline/readline.c (Readline.readline): use rl_outstream * ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699] and rl_instream. [ruby-dev:25699]
Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org> Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org>
@ -3403,7 +3412,7 @@ Thu Oct 21 21:32:30 2004 IWATSUKI Hiroyuki <don@na.rim.or.jp>
* lib/pstore.rb (PStore#transaction): Use the empty content when a * lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561] file is not found. [ruby-dev:24561]
Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io): * lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):

View file

@ -10,28 +10,10 @@
All the files in this distribution are covered under the Ruby's All the files in this distribution are covered under the Ruby's
license (see the file COPYING). license (see the file COPYING).
Documentation by Yukihiro Matsumoto and Gavin Sinclair.
**********************************************************************/ **********************************************************************/
/*
=begin
= Summary
Ruby extension for codeset conversion.
= Abstract
Iconv is a wrapper class for UNIX 95 (({iconv()})) function family, which
translates string between various coding systems.
See ((<Open Group|URL:http://www.opengroup.org/>))'s on-line documents for more details.
* ((<iconv.h|URL:http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html>))
* ((<iconv_open()|URL:http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_open.html>))
* ((<iconv()|URL:http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html>))
* ((<iconv_close()|URL:http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_close.html>))
Which coding systems are available, it depends on the platform.
=end
*/
#include "ruby.h" #include "ruby.h"
#include <errno.h> #include <errno.h>
#include <iconv.h> #include <iconv.h>
@ -39,6 +21,54 @@ Which coding systems are available, it depends on the platform.
#include "st.h" #include "st.h"
#include "intern.h" #include "intern.h"
/*
* Document-class: Iconv
*
* == Summary
*
* Ruby extension for charset conversion.
*
* == Abstract
*
* Iconv is a wrapper class for the UNIX 95 <tt>iconv()</tt> function family,
* which translates string between various encoding systems.
*
* See Open Group's on-line documents for more details.
* * <tt>iconv.h</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html
* * <tt>iconv_open()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_open.html
* * <tt>iconv()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html
* * <tt>iconv_close()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_close.html
*
* Which coding systems are available is platform-dependent.
*
* == Examples
*
* 1. Instantiate a new Iconv and use method Iconv#iconv.
*
* cd = Iconv.new(to, from)
* begin
* input.each { |s| output << cd.iconv(s) }
* output << cd.iconv(nil) # Don't forget this!
* ensure
* cd.close
* end
*
* 2. Invoke Iconv.open with a block.
*
* Iconv.open(to, from) do |cd|
* input.each { |s| output << cd.iconv(s) }
* output << cd.iconv(nil)
* end
*
* 3. Shorthand for (2).
*
* Iconv.iconv(to, from, *input.to_a)
*
* 4. Simple conversion between two charsets.
*
* converted_text = Iconv.new('iso-8859-15', 'utf-8').iconv(text)
*/
/* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is /* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is
big enough to keep iconv_t */ big enough to keep iconv_t */
#define VALUE2ICONV(v) ((iconv_t)((VALUE)(v) ^ -1)) #define VALUE2ICONV(v) ((iconv_t)((VALUE)(v) ^ -1))
@ -80,18 +110,6 @@ static VALUE iconv_init_state _((VALUE cd));
static VALUE iconv_finish _((VALUE self)); static VALUE iconv_finish _((VALUE self));
static VALUE iconv_iconv _((int argc, VALUE *argv, VALUE self)); static VALUE iconv_iconv _((int argc, VALUE *argv, VALUE self));
/*
=begin
= Classes & Modules
=end
*/
/*
=begin
== Iconv
=end
*/
static VALUE charset_map; static VALUE charset_map;
static VALUE charset_map_get _((void)) static VALUE charset_map_get _((void))
@ -465,36 +483,6 @@ iconv_convert
return ret; return ret;
} }
/*
=begin
=== Class methods
=end
*/
/*
=begin
--- Iconv.new(to, from) {|cd| ...}
Creates new code converter from a coding-system designated with ((|from|))
to another one designated with ((|to|)).
:Parameters
:((|to|))
coding-system name for destination.
:((|from|))
coding-system name for source.
:Exceptions
:(({TypeError}))
if ((|to|)) or ((|from|)) aren't String
:(({ArgumentError}))
if designated converter couldn't find out.
:(({SystemCallError}))
when (({iconv_open(3)})) failed.
--- Iconv.open(to, from)
Equivalents to ((<Iconv.new>)) except with in the case of called
with a block, yields with the new instance and closes it, and
returns the result which returned from the block.
=end
*/
static VALUE static VALUE
iconv_s_allocate iconv_s_allocate
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -507,6 +495,24 @@ iconv_s_allocate
return Data_Wrap_Struct(klass, 0, ICONV_FREE, 0); return Data_Wrap_Struct(klass, 0, ICONV_FREE, 0);
} }
/*
* Document-method: new
* call-seq: Iconv.new(to, from)
*
* Creates new code converter from a coding-system designated with +from+
* to another one designated with +to+.
*
* === Parameters
*
* +to+:: encoding name for destination
* +from+:: encoding name for source
*
* === Exceptions
*
* TypeError:: if +to+ or +from+ aren't String
* ArgumentError:: if designated converter couldn't find out
* SystemCallError:: if <tt>iconv_open3</tt> fails
*/
static VALUE static VALUE
iconv_initialize iconv_initialize
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -524,6 +530,14 @@ iconv_initialize
return self; return self;
} }
/*
* Document-method: open
* call-seq: Iconv.open(to, from) { |iconv| ... }
*
* Equivalent to Iconv.new except that when it is called with a block, it
* yields with the new instance and closes it, and returns the result which
* returned from the block.
*/
static VALUE static VALUE
iconv_s_open iconv_s_open
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -546,22 +560,6 @@ iconv_s_open
} }
} }
/*
=begin
--- Iconv.iconv(to, from, *strs)
Shorthand for
Iconv.open(to, from) {|cd| (strs + [nil]).collect {|s| cd.iconv(s)}}
:Parameters
:((|to|)), ((|from|))
see ((<Iconv.new>)).
:((|strs|))
strings to be converted.
:Exceptions
exceptions thrown by ((<Iconv.new>)), ((<Iconv.open>)) and
((<Iconv#iconv>)).
=end
*/
static VALUE static VALUE
iconv_s_convert iconv_s_convert
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -587,6 +585,24 @@ iconv_s_convert
return env->ret; return env->ret;
} }
/*
* Document-method: iconv
* call-seq: Iconv.iconv(to, from, *strs)
*
* Shorthand for
* Iconv.open(to, from) { |cd|
* (strs + [nil]).collect { |s| cd.iconv(s) }
* }
*
* === Parameters
*
* <tt>to, from</tt>:: see Iconv.new
* <tt>strs</tt>:: strings to be converted
*
* === Exceptions
*
* Exceptions thrown by Iconv.new, Iconv.open and Iconv#iconv.
*/
static VALUE static VALUE
iconv_s_iconv iconv_s_iconv
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -612,14 +628,13 @@ iconv_s_iconv
} }
/* /*
=begin * Document-method: Iconv::conv
--- Iconv.conv(to, from, str) * call-seq: Iconv.iconv(to, from, *strs)
Shorthand for *
Iconv.iconv(to, from, str).join * Shorthand for
see ((<Iconv.iconv>)) * Iconv.iconv(to, from, str).join
=end * See Iconv.iconv ???
*/ */
static VALUE static VALUE
iconv_s_conv iconv_s_conv
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -640,10 +655,10 @@ iconv_s_conv
} }
/* /*
=begin * Document-method: list
--- Iconv.list {|*aliases| ... } * call-seq: Iconv.list {|*aliases| ... }
Iterates each alias sets. *
=end * Iterates each alias sets.
*/ */
#ifdef HAVE_ICONVLIST #ifdef HAVE_ICONVLIST
@ -716,22 +731,16 @@ iconv_s_list _((void))
return Qnil; return Qnil;
} }
/* /*
=begin * Document-method: close
=== Instance methods *
=end * Finishes conversion.
*/ *
/* * After calling this, calling Iconv#iconv will cause an exception, but
=begin * multiple calls of #close are guaranteed to end successfully.
--- Iconv#close *
Finishes conversion. * Returns a string containing the byte sequence to change the output buffer to
* After calling this, invoking method ((<Iconv#iconv>)) will cause * its initial shift state. <i>???</i>
exception, but multiple calls of (({close})) are guaranteed to
end successfully.
* Returns a string contains the byte sequence to change the
output buffer to its initial shift state.
=end
*/ */
static VALUE static VALUE
iconv_init_state iconv_init_state
@ -763,29 +772,31 @@ iconv_finish
} }
/* /*
=begin * Document-method: iconv
--- Iconv#iconv(str, [ start = 0, [ length = -1 ] ]) * call-seq: iconv(str, start=0, length=-1)
Converts string and returns converted one. *
* In the case of ((|str|)) is (({String})), converts (({str[start, length]})). * Converts string and returns the result.
Returns converted string. * * If +str+ is a String, converts <tt>str[start, length]</tt> and returns the converted string.
* In the case of ((|str|)) is (({nil})), places ((|converter|)) * * If +str+ is +nil+, places converter itself into initial shift state and
itself into initial shift state and just returns a string contains * just returns a string containing the byte sequence to change the output
the byte sequence to change the output buffer to its initial shift * buffer to its initial shift state.
state. * * Otherwise, raises an exception.
* Otherwise, causes exception. *
:Parameters * === Parameters
:((|str|)) *
string to be converted or (({nil})). * str:: string to be converted, or nil
:((|start|)) * start:: starting offset
starting offset. * length:: conversion length; nil or -1 means whole the string from start
:((|length|)) *
conversion length, * === Exceptions
(({nil})) or (({-1})) means whole string from (({start})). *
:Exceptions * * IconvIllegalSequence
* ((<Iconv::IllegalSequence>)) * * IconvInvalidCharacter
* ((<Iconv::InvalidCharacter>)) * * IconvOutOfRange
* ((<Iconv::OutOfRange>)) *
=end * === Examples
*
* See the Iconv documentation.
*/ */
static VALUE static VALUE
iconv_iconv iconv_iconv
@ -806,33 +817,31 @@ iconv_iconv
return iconv_convert(VALUE2ICONV(cd), str, return iconv_convert(VALUE2ICONV(cd), str,
NIL_P(n1) ? 0 : NUM2INT(n1), NIL_P(n1) ? 0 : NUM2INT(n1),
NIL_P(n2) ? -1 : NUM2INT(n2), NIL_P(n2) ? -1 : NUM2INT(n2),
NULL); NULL);
} }
/* /*
=begin * Document-class: Iconv::Failure
= Exceptions *
=end * Base attributes for Iconv exceptions.
*/ *
/* * === Iconv::Failure#success
=begin *
== Iconv::Failure * Returns string(s) translated successfully until the exception occurred.
Base exceptional attributes from ((<Iconv>)). * * In the case of failure occurred within Iconv.iconv, returned
* value is an array of strings translated successfully preceding
=== Instance methods * failure and the last element is string on the way.
=end *
*/ * === Iconv::Failure#failed
/* *
=begin * Returns substring of the original string passed to Iconv that starts at the
--- Iconv::Failure#success * character caused the exception.
Returns string(s) translated successfully until the exception occurred. *
* In the case of failure occurred within ((<Iconv.iconv>)), returned * === Iconv::Failure#inspect
value is an array of strings translated successfully preceding *
failure and the last element is string on the way. * Returns inspected string like as: #<_class_: _success_, _failed_>
=end */
*/
static VALUE static VALUE
iconv_failure_success iconv_failure_success
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -846,12 +855,8 @@ iconv_failure_success
} }
/* /*
=begin * Comment!
--- Iconv::Failure#failed */
Returns substring of the original string passed to ((<Iconv>)) that
starts at the character caused the exception.
=end
*/
static VALUE static VALUE
iconv_failure_failed iconv_failure_failed
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -864,12 +869,6 @@ iconv_failure_failed
return rb_attr_get(self, rb_failed); return rb_attr_get(self, rb_failed);
} }
/*
=begin
--- Iconv::Failure#inspect
Returns inspected string like as: #<(({type})): "(({success}))", "(({failed}))">
=end
*/
static VALUE static VALUE
iconv_failure_inspect iconv_failure_inspect
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
@ -891,34 +890,49 @@ iconv_failure_inspect
} }
/* /*
Hmmm, I don't like to write RD inside of function :-<. * Document-class: Iconv::IllegalSequence
*
* Input conversion stopped due to an input byte that does not belong to
* the input codeset, or the output codeset does not contain the
* character.
*
* === Superclass
*
* ArgumentError
*
* === Included Modules
*
* Iconv::Failure
*/
=begin /*
== Iconv::IllegalSequence * Document-class: Iconv::InvalidCharacter
Input conversion stopped due to an input byte that does not belong to *
the input codeset, or the output codeset does not contain the * Input conversion stopped due to an incomplete character or shift
character. * sequence at the end of the input buffer.
=== Superclass *
(({ArgumentError})) * === Superclass
=== Included Modules *
((<Iconv::Failure>)) * ArgumentError
*
* === Included Modules
*
* Iconv::Failure
*/
== Iconv::InvalidCharacter /*
Input conversion stopped due to an incomplete character or shift * Document-class: Iconv::OutOfRange
sequence at the end of the input buffer. *
=== Superclass * Iconv library internal error. Must not occur.
(({ArgumentError})) *
=== Included Modules * === Superclass
((<Iconv::Failure>)) *
* RuntimeError
== Iconv::OutOfRange *
Iconv library internal error. Must not occur. * === Included Modules
=== Superclass *
(({RuntimeError})) * Iconv::Failure
=== Included Modules */
((<Iconv::Failure>))
=end
*/
void void
Init_iconv _((void)) Init_iconv _((void))
@ -956,24 +970,3 @@ Init_iconv _((void))
rb_define_singleton_method(rb_cIconv, "charset_map", charset_map_get, 0); rb_define_singleton_method(rb_cIconv, "charset_map", charset_map_get, 0);
} }
/*
=begin
== Example
(1) Instantiate a new ((<Iconv>)), use method ((<Iconv#iconv>)).
cd = Iconv.new(to, from)
begin
input.each {|s| output << cd.iconv(s)}
output << cd.iconv(nil) # don't forget this
ensure
cd.close
end
(2) Invoke ((<Iconv.open>)) with a block.
Iconv.open(to, from) do |cd|
input.each {|s| output << cd.iconv(s)}
output << cd.iconv(nil)
end
(3) Shorthand for (2).
Iconv.iconv(to, from, *input.to_a)
=end
*/

View file

@ -303,7 +303,8 @@ strscan_terminate(self)
} }
/* /*
* Returns the string being scanned. * Equivalent to #terminate.
* This method is obsolete; use #terminate instead.
*/ */
static VALUE static VALUE
strscan_clear(self) strscan_clear(self)
@ -313,6 +314,9 @@ strscan_clear(self)
return strscan_terminate(self); return strscan_terminate(self);
} }
/*
* Returns the string being scanned.
*/
static VALUE static VALUE
strscan_get_string(self) strscan_get_string(self)
VALUE self; VALUE self;
@ -744,6 +748,10 @@ strscan_get_byte(self)
p->prev + p->regs.end[0]); p->prev + p->regs.end[0]);
} }
/*
* Equivalent to #get_byte.
* This method is obsolete; use #get_byte instead.
*/
static VALUE static VALUE
strscan_getbyte(self) strscan_getbyte(self)
VALUE self; VALUE self;
@ -781,6 +789,18 @@ strscan_peek(self, vlen)
return extract_beg_len(p, p->curr, len); return extract_beg_len(p, p->curr, len);
} }
/*
* Equivalent to #peek.
* This method is obsolete; use #peek instead.
*/
static VALUE
strscan_peep(self, vlen)
VALUE self, vlen;
{
rb_warning("StringScanner#peep is obsolete; use #peek instead");
return strscan_peek(self, vlen);
}
/* /*
* Set the scan pointer to the previous position. Only one previous position is * Set the scan pointer to the previous position. Only one previous position is
* remembered, and it changes with each scanning operation. * remembered, and it changes with each scanning operation.
@ -792,14 +812,6 @@ strscan_peek(self, vlen)
* s.scan(/\d/) # => nil * s.scan(/\d/) # => nil
* s.unscan # ScanError: can't unscan: prev match had failed * s.unscan # ScanError: can't unscan: prev match had failed
*/ */
static VALUE
strscan_peep(self, vlen)
VALUE self, vlen;
{
rb_warning("StringScanner#peep is obsolete; use #peek instead");
return strscan_peek(self, vlen);
}
static VALUE static VALUE
strscan_unscan(self) strscan_unscan(self)
VALUE self; VALUE self;

View file

@ -596,7 +596,7 @@ module RDoc
def do_includes def do_includes
@body.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m| @body.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
if cls = @classes[c] if cls = @classes[c]
m = KNOWN_CLASSES[m] || m m = @known_classes[m] || m
cls.add_include(Include.new(m, "")) cls.add_include(Include.new(m, ""))
end end
end end