summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-20 04:59:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-20 04:59:39 +0000
commit62e648e148b3cb9f96dcce808c55c02b7ccb4486 (patch)
tree9708892ece92e860d81559ab55e6b1f9400d7ffc
parentaeb049c573be4dc24dd20650f40e4777e0f698cf (diff)
ruby 1.3 cycle
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--COPYING358
-rw-r--r--ChangeLog2354
-rw-r--r--MANIFEST64
-rw-r--r--Makefile.in102
-rw-r--r--README42
-rw-r--r--README.EXT499
-rw-r--r--README.EXT.jp1147
-rw-r--r--README.jp38
-rw-r--r--ToDo41
-rw-r--r--array.c1037
-rw-r--r--bignum.c568
-rw-r--r--class.c268
-rw-r--r--compar.c48
-rw-r--r--config.guess485
-rw-r--r--config.sub156
-rw-r--r--config_h.dj64
-rw-r--r--config_s.dj51
-rw-r--r--configure1325
-rw-r--r--configure.bat3
-rw-r--r--configure.in249
-rw-r--r--defines.h24
-rw-r--r--dir.c155
-rw-r--r--dln.c298
-rw-r--r--dln.h14
-rw-r--r--enum.c141
-rw-r--r--env.h11
-rw-r--r--error.c656
-rw-r--r--eval.c4790
-rw-r--r--ext/Setup1
-rw-r--r--ext/Win32API/MANIFEST7
-rw-r--r--ext/Win32API/Win32API.c223
-rw-r--r--ext/Win32API/extconf.rb7
-rw-r--r--ext/Win32API/getch.rb5
-rw-r--r--ext/Win32API/point.rb18
-rw-r--r--ext/aix_ld.rb2
-rw-r--r--ext/curses/curses.c107
-rw-r--r--ext/curses/extconf.rb5
-rw-r--r--ext/curses/hello.rb4
-rw-r--r--ext/curses/view.rb1
-rw-r--r--ext/cygwin32_ld.rb90
-rw-r--r--ext/dbm/dbm.c175
-rw-r--r--ext/dbm/extconf.rb6
-rw-r--r--ext/etc/etc.c91
-rw-r--r--ext/etc/extconf.rb24
-rw-r--r--ext/extmk.rb.in235
-rw-r--r--ext/extmk.rb.nt6
-rw-r--r--ext/fcntl/fcntl.c2
-rw-r--r--ext/kconv/kconv.c89
-rw-r--r--ext/md5/md5init.c14
-rw-r--r--ext/socket/depend2
-rw-r--r--ext/socket/extconf.rb12
-rw-r--r--ext/socket/socket.c829
-rw-r--r--ext/tcltklib/extconf.rb114
-rw-r--r--ext/tcltklib/lib/tcltk.rb287
-rw-r--r--ext/tcltklib/tcltklib.c293
-rw-r--r--ext/tk/MANIFEST25
-rw-r--r--ext/tk/depend1
-rw-r--r--ext/tk/extconf.rb2
-rw-r--r--ext/tk/lib/tk.rb2499
-rw-r--r--ext/tk/lib/tkafter.rb296
-rw-r--r--ext/tk/lib/tkbgerror.rb17
-rw-r--r--ext/tk/lib/tkcanvas.rb829
-rw-r--r--ext/tk/lib/tkclass.rb38
-rw-r--r--ext/tk/lib/tkdialog.rb141
-rw-r--r--ext/tk/lib/tkentry.rb73
-rw-r--r--ext/tk/lib/tkfont.rb944
-rw-r--r--ext/tk/lib/tkmenubar.rb137
-rw-r--r--ext/tk/lib/tkmngfocus.rb27
-rw-r--r--ext/tk/lib/tkpalette.rb48
-rw-r--r--ext/tk/lib/tkscrollbox.rb27
-rw-r--r--ext/tk/lib/tktext.rb797
-rw-r--r--ext/tk/lib/tkvirtevent.rb66
-rw-r--r--ext/tk/sample/tkbiff.rb149
-rw-r--r--ext/tk/sample/tkbrowse.rb79
-rw-r--r--ext/tk/sample/tkdialog.rb62
-rw-r--r--ext/tk/sample/tkfrom.rb132
-rw-r--r--ext/tk/sample/tkhello.rb10
-rw-r--r--ext/tk/sample/tkline.rb45
-rw-r--r--ext/tk/sample/tktimer.rb50
-rw-r--r--ext/tk/tkutil.c45
-rw-r--r--file.c905
-rw-r--r--fnmatch.c83
-rw-r--r--gc.c496
-rw-r--r--glob.c119
-rw-r--r--hash.c921
-rw-r--r--inits.c10
-rw-r--r--instruby.rb54
-rw-r--r--intern.h484
-rw-r--r--io.c1562
-rw-r--r--keywords2
-rw-r--r--lex.c44
-rw-r--r--lib/Env.rb31
-rw-r--r--lib/README61
-rw-r--r--lib/base64.rb45
-rw-r--r--lib/cgi-lib.rb39
-rw-r--r--lib/complex.rb14
-rw-r--r--lib/date.rb91
-rw-r--r--lib/date2.rb219
-rw-r--r--lib/debug.rb12
-rw-r--r--lib/delegate.rb100
-rw-r--r--lib/e2mmap.rb77
-rw-r--r--lib/eregex.rb11
-rw-r--r--lib/final.rb41
-rw-r--r--lib/finalize.rb66
-rw-r--r--lib/find.rb4
-rw-r--r--lib/ftools.rb31
-rw-r--r--lib/ftplib.rb1123
-rw-r--r--lib/getoptlong.rb473
-rw-r--r--lib/getopts.rb3
-rw-r--r--lib/importenv.rb15
-rw-r--r--lib/jcode.rb23
-rw-r--r--lib/mailread.rb5
-rw-r--r--lib/mathn.rb5
-rw-r--r--lib/matrix.rb239
-rw-r--r--lib/mkmf.rb144
-rw-r--r--lib/monitor.rb325
-rw-r--r--lib/mutex_m.rb60
-rw-r--r--lib/observer.rb8
-rw-r--r--lib/open3.rb55
-rw-r--r--lib/parsearg.rb5
-rw-r--r--lib/parsedate.rb81
-rw-r--r--lib/ping.rb33
-rw-r--r--lib/profile.rb53
-rw-r--r--lib/pstore.rb39
-rw-r--r--lib/rational.rb9
-rw-r--r--lib/readbytes.rb36
-rw-r--r--lib/shellwords.rb16
-rw-r--r--lib/singleton.rb37
-rw-r--r--lib/sync.rb13
-rw-r--r--lib/telnet.rb439
-rw-r--r--lib/tempfile.rb91
-rw-r--r--lib/thread.rb163
-rw-r--r--lib/thwait.rb113
-rw-r--r--lib/timeout.rb42
-rw-r--r--lib/tracer.rb147
-rw-r--r--lib/weakref.rb39
-rw-r--r--main.c1
-rw-r--r--marshal.c289
-rw-r--r--math.c74
-rw-r--r--misc/README5
-rw-r--r--misc/inf-ruby.el316
-rw-r--r--misc/ruby-mode.el699
-rw-r--r--misc/rubydb2x.el104
-rw-r--r--misc/rubydb3x.el104
-rw-r--r--missing/dir.h126
-rw-r--r--missing/file.h1
-rw-r--r--missing/memcmp.c21
-rw-r--r--missing/strchr.c45
-rw-r--r--missing/vsnprintf.c1153
-rw-r--r--missing/x68.c24
-rw-r--r--mkconfig.rb4
-rw-r--r--node.h231
-rw-r--r--numeric.c1066
-rw-r--r--object.c871
-rw-r--r--pack.c407
-rw-r--r--parse.y2025
-rw-r--r--process.c410
-rw-r--r--random.c122
-rw-r--r--range.c174
-rw-r--r--re.c705
-rw-r--r--re.h16
-rw-r--r--regex.h205
-rw-r--r--ruby.1216
-rw-r--r--ruby.c393
-rw-r--r--ruby.h428
-rw-r--r--rubyio.h60
-rw-r--r--rubysig.h54
-rw-r--r--rubytest.rb2
-rw-r--r--sample/README60
-rw-r--r--sample/cal.rb118
-rw-r--r--sample/fib.py10
-rw-r--r--sample/fib.scm4
-rw-r--r--sample/freq.rb8
-rw-r--r--sample/from.rb36
-rw-r--r--sample/goodfriday.rb48
-rw-r--r--sample/mkproto.rb8
-rw-r--r--sample/observ.rb15
-rw-r--r--sample/occur.rb8
-rw-r--r--sample/rbc.rb257
-rw-r--r--sample/sieve.rb3
-rw-r--r--sample/test.rb218
-rw-r--r--sample/trojan.rb4
-rw-r--r--sample/tsvr.rb2
-rw-r--r--signal.c141
-rw-r--r--sprintf.c463
-rw-r--r--string.c2015
-rw-r--r--struct.c414
-rw-r--r--time.c405
-rw-r--r--top.sed96
-rw-r--r--util.c353
-rw-r--r--util.h26
-rw-r--r--variable.c613
-rw-r--r--version.c12
-rw-r--r--version.h4
-rw-r--r--win32/Makefile31
-rw-r--r--win32/config.h12
-rw-r--r--win32/ruby.def469
-rw-r--r--win32/sdbm.c2
198 files changed, 36559 insertions, 13179 deletions
diff --git a/COPYING b/COPYING
index 3c68f02..eeb586b 100644
--- a/COPYING
+++ b/COPYING
@@ -1,37 +1,40 @@
GNU GENERAL PUBLIC LICENSE
- Version 1, February 1989
+ Version 2, June 1991
- Copyright (C) 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
- The license agreements of most software companies try to keep users
-at the mercy of those companies. By contrast, our General Public
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
When we speak of free software, we are referring to freedom, not
-price. Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
- For example, if you distribute copies of a such a program, whether
+ For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
-source code. And you must tell them their rights.
+source code. And you must show them these terms so they know their
+rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
@@ -44,120 +47,207 @@ want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License. The
-"Program", below, refers to any such program or work, and a "work based
-on the Program" means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications. Each
-licensee is addressed as "you".
-
- 1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program. You may charge a fee for the physical act of
-transferring a copy.
-
- 2. You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
-
- a) cause the modified files to carry prominent notices stating that
- you changed the files and the date of any change; and
-
- b) cause the whole of any work that you distribute or publish, that
- in whole or in part contains the Program or any part thereof, either
- with or without modifications, to be licensed at no charge to all
- third parties under the terms of this General Public License (except
- that you may choose to grant warranty protection to some or all
- third parties, at your option).
-
- c) If the modified program normally reads commands interactively when
- run, you must cause it, when started running for such interactive use
- in the simplest and most usual way, to print or display an
- announcement including an appropriate copyright notice and a notice
- that there is no warranty (or else, saying that you provide a
- warranty) and that users may redistribute the program under these
- conditions, and telling the user how to view a copy of this General
- Public License.
-
- d) You may charge a fee for the physical act of transferring a
- copy, and you may at your option offer warranty protection in
- exchange for a fee.
-
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
- 3. You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
-
- a) accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- b) accompany it with a written offer, valid for at least three
- years, to give any third party free (except for a nominal charge
- for the cost of distribution) a complete machine-readable copy of the
- corresponding source code, to be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- c) accompany it with the information you received as to where the
- corresponding source code may be obtained. (This alternative is
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
- received the program in object code or executable form alone.)
-
-Source code for a work means the preferred form of the work for making
-modifications to it. For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
-
- 4. You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License. However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
-
- 5. By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions. You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
- 7. The Free Software Foundation may publish revised and/or new versions
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
-specifies a version number of the license which applies to it and "any
+specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
+this License, you may choose any version ever published by the Free Software
Foundation.
- 8. If you wish to incorporate parts of the Program into other free
+ 10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
@@ -167,7 +257,7 @@ of promoting the sharing and reuse of software generally.
NO WARRANTY
- 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
@@ -177,7 +267,7 @@ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
- 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
@@ -189,25 +279,24 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
- Appendix: How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
-possible use to humanity, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
- To do so, attach the following notices to the program. It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -216,33 +305,36 @@ the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) 19xx name of author
+ Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here a sample; alter the names:
+necessary. Here is a sample; alter the names:
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- program `Gnomovision' (a program to direct compilers to make passes
- at assemblers) written by James Hacker.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
-That's all there is to it!
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ChangeLog b/ChangeLog
index 029e200..6a317e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,2355 @@
+Wed Jan 20 03:39:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yycompile): rb_in_compile renamed to ruby_in_compile.
+
+ * ruby.c (load_file): define DATA iff __END__ appeared in script.
+
+Tue Jan 19 14:57:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): need to protect lex_lastline.
+
+ * parse.y (yylex): disable %//, %'', %``.
+
+Tue Jan 19 05:01:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * array.c (beg_len): round range value too much.
+
+Mon Jan 18 13:02:27 1999 Kuroda Jun <jkuro@dwe.co.j>
+
+ * hash.c (env_keys): strchr() may return NULL.
+
+Mon Jan 18 17:51:47 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * instruby.rb (wdir): install libruby.a in archdir.
+
+ * lib/ftools.rb (install): removes file before installing.
+
+Mon Jan 18 16:55:31 1999 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * eval.c (rb_callcc): experimental continuation support.
+
+Sun Jan 17 19:45:37 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * pack.c (pack_pack): nil packing caused SEGV.
+
+Sat Jan 16 13:18:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_concat): character (fixnum) can be append to
+ strings
+
+ * array.c (rb_ary_unshift): unshift returns array.
+
+Sat Jan 16 01:39:19 1999 Yoshida Masato <yoshidam@tau.bekkoame.ne.jp>
+
+ * string.c (rb_str_split_method): UTF-8 support.
+
+ * regex.c: UTF-8 support.
+
+Thu Jan 14 00:42:55 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_gsub_bang): forget to add offset for null match.
+
+ * eval.c (rb_thread_local_aset): can't modify in tainted mode.
+
+ * hash.c (env_each_key): avoid generating temporary array.
+
+Wed Jan 13 23:58:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_f_setenv): name and value can be tainted.
+
+Wed Jan 6 02:42:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (Init_Bignum): forgot to define Bignum#===.
+
+ * gc.c (gc_sweep): if add_heap() is called during GC, objects on
+ allocated heap page(s) are not marked, should not be recycled.
+
+ * gc.c (gc_sweep): should refer latest freelist.
+
+ * gc.c (id2ref): modified to support performance patch.
+
+ * object.c (rb_obj_id): performance patch (no bignum for id).
+
+Tue Jan 5 01:56:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * config.guess: merge up-to-date from autoconf 2.12.
+
+ * array.c (rb_ary_join): avoid calling rb_protect_inspect() till
+ it is really needed.
+
+ * object.c (rb_obj_inspect): show detailed information for the
+ instance variables (infinite loop can avoid now).
+
+ * struct.c (rb_struct_inspect): avoid infinite loop.
+
+Sun Jan 3 01:37:58 1999 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+
+ * misc/ruby-mode.el (ruby-end-of-defun): moved too much.
+
+ * misc/ruby-mode.el (ruby-mode-variables): set paragraph-separator
+ for the mode.
+
+ * misc/ruby-mode.el: proper font-lock for `def' and `nil' etc.
+
+Sat Jan 2 17:09:06 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_jump_tag): new api to invoke JUMP_TAG. tag values
+ can obtained from rb_eval_string_protect()/rb_load_protect().
+
+ * eval.c (rb_rescue): now catches all exceptions but SystemExit.
+
+ * eval.c (rb_eval_string_protect): eval string with protection.
+
+ * eval.c (rb_load_protect): load file with protection.
+
+ * io.c (rb_io_puts): avoid infinite loop for cyclic arrays.
+
+ * eval.c (rb_thread_local_aref): thread local hash tables.
+
+ * object.c (rb_equal): check exact equal before calling `=='.
+
+Thu Dec 31 22:28:53 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * eval.c (rb_f_require): feature names should be provided with
+ DLEXT extension.
+
+ * marshal.c (Init_marshal): need to provide `marshal.so'.
+
+Wed Dec 30 02:29:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (classname): do not call rb_ivar_set().
+
+ * eval.c (ruby_run): finalizers were called too early.
+
+Fri Dec 25 12:19:30 1998 Fukuda Masaki <fukuda@wni.co.jp>
+
+ * gc.c (rb_gc_mark): should not return on FL_EXIVAR.
+
+Fri Dec 25 11:56:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (gc_mark): proper scanning for temporary region.
+
+ * eval.c (TMP_ALLOC): protection for C_ALLOCA was broken.
+
+Thu Dec 24 18:26:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * development version 1.3 released.
+
+Thu Dec 24 00:17:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_load): top self should be set properly.
+
+ * variable.c (classname): check __classpath__ iff it is defined.
+
+ * variable.c (classname): invalid warning at -v with static linked
+ ruby interpreter.
+
+ * eval.c (is_defined): modified for expr::Const support.
+
+ * eval.c (rb_eval): invoke method expr::Const if expr is not class
+ nor module.
+
+ * parse.y (primary): enable expr::identifier as method
+ invocation.
+
+Wed Dec 23 03:04:36 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): avoid too many loop pops for (?:..).
+
+Tue Dec 22 18:01:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental version 1.1d1 released.
+
+Mon Dec 21 01:33:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (TMP_PROTECT): add volatile to ensure GC protection.
+
+ * string.c (rb_str_gsub_bang): calculate buffer size properly.
+
+ * parse.y (lex_get_str): needed to return Qnil at EOS.
+
+ * eval.c (find_file): check policy modified, raise exception
+ immediately for tainted load_path.
+
+ * hash.c (rb_f_setenv): do not depend on setenv() nor putenv().
+
+Thu Dec 17 06:29:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/tk/tkutil.c (tk_s_new): use rb_obj_instance_eval(), instead
+ of rb_yield_0().
+
+ * eval.c (rb_f_require): forgot to call find_file in some cases.
+
+ * eval.c (rb_f_require): `require "feature.so"' to load dynamic
+ libraries. old `require "feature.o"' is still OK.
+
+ * eval.c (rb_eval): yield without value dumped core.
+
+Wed Dec 16 16:28:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental version 1.1d0 (pre1.2) released.
+
+Wed Dec 16 10:43:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): bound check before calling re_match().
+
+Tue Dec 15 13:59:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (exc_to_s): returns class name for unset mesg.
+
+ * error.c (exc_initialize): do not initialize @mesg by "".
+
+ * parse.y (nextc): __END__ should handle CR+LF newlines.
+
+Wed Dec 9 13:37:12 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * pack.c (encodes): use buffering for B-encoding.
+
+ * pack.c (pack_pack): Q-encoding by 'M'.
+
+Tue Dec 8 14:10:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (generic_ivar_get): any object can have instance
+ variables now. great improvement.
+
+ * variable.c (rb_name_class): do not set __classpath__ by default,
+ use __classid__ instead.
+
+Mon Dec 7 22:08:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (struct RFile): IO objects can have instance variables now.
+
+ * parse.y (primary): allows `def obj::foo; .. end'.
+
+Mon Dec 7 18:24:50 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ruby.c (set_arg0): $0 supprt for HP-UX.
+
+Mon Dec 7 01:30:28 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (dln_strerror): better error messages on win32.
+
+Sat Dec 5 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): indentable here-doc delimiter by
+ `<<-'. Proposed by Clemens <c.hintze@gmx.net>. Thanks.
+
+Thu Dec 3 16:50:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/extmk.rb.in (realclean): trouble on install.
+
+Sun Nov 29 22:25:39 1998 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * process.c (f_exec): check number of argument.
+
+Thu Nov 26 17:27:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c9 released.
+
+Wed Nov 25 13:07:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dup): do not copy additional data (STR_NO_ORIG).
+
+ * parse.y (yycompile): reduce known memory leak (hard to remove).
+
+Wed Nov 25 03:41:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (st_init_table_with_size): round size up to prime number.
+
+Sat Nov 21 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_aset): reduce copying key strings.
+
+ * gc.c (looks_pointerp): declare as inline function if possible.
+
+ * st.c (PTR_NOT_EQUAL): compare hash values first before calling
+ comparing function.
+
+ * st.c (ADD_DIRECT): save hash value in entries to reduce hash
+ calculation.
+
+ * string.c (rb_str_gsub_bang): avoid rb_scan_args() to speed-up.
+
+ * string.c (rb_str_sub_bang): ditto.
+
+Sat Nov 21 18:44:06 1998 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * time.c (time_s_now): had memory leak.
+
+ * ext/md5/md5init.c (md5_new): had memory leak.
+
+ * ext/md5/md5init.c (md5_clone): ditto.
+
+Fri Nov 20 23:23:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/delegate.rb: do not propagate hash and eql?.
+
+Thu Nov 19 01:40:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/ruby-mode.el (ruby-expr-beg): failed to find reserved
+ word boundary.
+
+ * eval.c (rb_eval): avoid calling `concat' method. calls
+ rb_ary_concat() directly for efficiency.
+
+ * eval.c (rb_eval): actual rest arguments extended arrays too much.
+
+Wed Nov 18 14:30:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (rb_define_global_function): global functions now be
+ module function of the Kernel.
+
+Wed Nov 18 10:48:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (read_all): SEGV on large files.
+
+Tue Nov 17 18:11:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c8 released.
+
+Tue Nov 17 16:58:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): assignment to attribute name start with capital
+ should be allowed.
+
+ * eval.c (thread_alloc): needed to mark terminated threads too.
+
+Tue Nov 17 12:33:48 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * ext/extmk.rb.in (create_makefile): Set `libdir' to `@libdir@',
+ Set `pkglibdir' to `$libdir/$(RUBY_INSTALL_NAME)'.
+
+Tue Nov 17 10:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): %l%%c -> %%l%c
+
+Tue Nov 17 01:08:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (ret_args): distinguish `a' and `*a' for the arguments
+ of yield and return.
+
+ * eval.c (rb_eval): flip3 should work like sed.
+
+ * eval.c (rb_eval): flip{2,3} now have independent state for each
+ scope to work fine with thread.
+
+Mon Nov 16 23:26:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (primary): exec else clause if no exception raised.
+
+Sun Nov 15 15:44:07 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ext/extmk.rb.in (install): bug in target.
+
+Sat Nov 14 11:02:05 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * Makefile.in (install): Give the argument `$(DESTDIR)' to
+ `instruby.rb'.
+ * instruby.rb: Recognize ARG[0] as `destdir'.
+ * instruby.rb: Give the argument `destdir' to `extmk.rb'.
+ * ext/extmk.rb.in: Recognize ARG[1] as `$destdir'.
+
+ * instruby.rb: Create the installation directories (bindir, libdir,
+ archdir, pkglibdir, archdir, and mandir) under `destdir', and
+ install all files under there.
+ * ext/extmk.rb.in: Likewise.
+
+Sat Nov 14 10:56:55 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * instruby.rb: Add the variable `pkglibdir'.
+ * instruby.rb: Set the variable `libdir' to `$(libdir)', not
+ `$(libdir)/$(ruby_install_name)'. `libruby.so' and `libruby.so.LIB'
+ are installed at `libdir'.
+ * instruby.rb: Set the variable `archdir' to `$(pkglibdir)/$(arch)'.
+
+Fri Nov 13 19:43:29 1998 KIMURA Koichi <kbk@kt.rim.or.jp>
+
+ * missing/nt.c (SafeFree): wrong free offset.
+
+Thu Nov 12 20:11:53 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sample/ruby-mode.el: wrong highlight.
+
+ * parse.y (parse_regx): newline in regexp was ignored.
+
+Wed Nov 11 10:54:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): <<'FOO' should not escape anything.
+
+ * parse.y (here_document): bare << here-doc available, even though
+ it's deprecated.
+
+ * file.c (rb_file_s_readlink): return value should be tainted.
+
+ * ext/etc/etc.c (setup_passwd): information (eg. GCOS name) should
+ be tainted (modified at Perl Conference).
+
+Tue Nov 10 00:22:11 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: elf supprt for FreeBSD 3.x
+
+Tue Nov 10 00:05:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): here document available in eval.
+
+Mon Nov 9 17:55:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c7 released.
+
+Fri Nov 6 19:25:27 1998 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+
+ * sample/ruby-mode.el: font-lock patch.
+
+Thu Nov 5 15:42:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/README, lib/README: simple description for each file.
+
+Wed Nov 4 18:14:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): attribute assignment should be called as public.
+
+Tue Nov 3 23:36:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dump): dumps core for negative char value.
+
+ * regex.c (re_compile_pattern): out of boundary access for empty
+ regexp.
+
+Mon Nov 2 22:54:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_aset): `str[str]' replaces first match.
+
+Mon Nov 2 18:24:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_create): was accessing modified status.
+
+Sun Nov 1 01:18:52 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * gc.c (xrealloc): size 0 needs round up to 1.
+
+Sat Oct 31 23:18:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_split_method): negative LIMIT means number of
+ splitted fields are unlimited, as in perl.
+
+ * string.c (rb_str_split_method): if LIMIT is unspecified,
+ trailing null fields are stripped.
+
+Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
+
+ * string.c (str_aref): regexp index SEGVed.
+
+Fri Oct 30 14:33:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_match): returns nil for unmatch.
+
+ * dir.c (dir_entries): new method.
+
+ * eval.c (block_pass): do not push block, substitute it.
+
+Fri Oct 30 01:28:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * range.c (range_check): avoid <=> check for Fixnums.
+
+ * array.c (rb_ary_aset): accept negative index.
+
+Wed Oct 28 22:00:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): access out of boundary fixed.
+
+Wed Oct 28 11:37:42 1998 TAMITO <tommy@valley.ne.jp>
+
+ * io.c (f_select): fd number comparison bug.
+
+Tue Oct 27 23:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/ruby-mode.el (ruby-parse-region): forgot to support %w()
+ style array literal.
+
+ * eval.c (rb_eval): unused block raises warning.
+
+Mon Oct 26 09:37:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (dvar_asgn_push): dvar pushed too many times if
+ variable-in-block first appear in loops.
+
+Sun Oct 25 22:59:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (set_list_bits): was using wrong offset.
+
+Thu Oct 22 00:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_obj_method): method retrieved from tainted object
+ should be tainted too.
+
+ * eval.c (method_call): safe_level should be restored during
+ Method#call.
+
+Wed Oct 21 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (Init_IO): new constants IO::SEEK_{SET,CUR,END}.
+
+ * io.c (rb_f_ungetc): ungetc pushes a char back into STDIN.
+
+Mon Oct 19 11:50:00 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * ext/extmk.rb: Load '@top_srcdir@/lib/find.rb', not
+ '../lib/find.rb'.
+ * ext/extmk.rb: Distinguish between `top_srcdir' and `topdir'.
+ * Makefile.in (CFLAGS): Add `-I.'.
+ * Makefile.in (lex.c): Give `@srcdir@/keywords' to gperf, not
+ `keywords'.
+ * instruby.rb: Use `CONFIG["bindir"]', instead of `prefix + "/bin"'.
+ * instruby.rb: Use `CONFIG["libdir"]', instead of `prefix + "/lib"'.
+ * instruby.rb Use `CONFIG["mandir"]', instead of `prefix + "/man"'.
+ * instruby.rb (wdir): Add the variable to preserve the current
+ working directory.
+ * instruby.rb: Chdir to wdir before install `config.h' and
+ `rbconfig.rb'.
+
+Mon Oct 19 10:07:01 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * eval.c (rb_eval): reduce recursive calls to rb_eval().
+
+Fri Oct 16 15:31:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_new_internal): timeval must be positive.
+
+Thu Oct 15 13:54:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): local variabls can be accessed within right side
+ expression in assignment, notably in blocks.
+
+Wed Oct 14 00:18:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (Init_Array): Array#=== is now for equal check, not
+ inclusion check.
+
+ * parse.y (when_args): `when a, *b' style new syntax for array
+ expansion in `case'.
+
+Tue Oct 13 14:30:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_obj_untaint): taint marks can be unset.
+
+ * eval.c (rb_eval): taint propagation for embedded strings.
+
+Mon Oct 12 13:27:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call0): check stack depth more frequently.
+
+Mon Oct 12 08:08:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_p): can print even in secure mode.
+
+Sun Oct 11 22:50:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_const_set): taint check for modification.
+
+ * variable.c (rb_ivar_set): taint check for modification.
+
+ * string.c (rb_str_modify): taint check for modification.
+
+ * hash.c (rb_hash_modify): taint check for modification.
+
+ * array.c (rb_ary_modify): taint check for modification.
+
+ * ruby.h (FL_TAINT): taint for all objects, not only strings.
+
+Fri Oct 9 17:01:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (read_all): read() returns "" at immediate EOF.
+
+ * io.c (io_read): read(nil) read all until EOF.
+
+Thu Oct 8 13:32:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_dump): marshal can dump Time object now.
+
+ * marshal.c (Init_marshal): rename marshal methods `_dump_to' to
+ `_dump', `_load_from' to `_load'.
+
+ * parse.y (rb_intern): "+=".intern generates proper symbol.
+
+Mon Oct 5 18:31:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c6 released.
+
+Fri Oct 2 14:22:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): `/\s*(--)$/ =~ "- --"' did not match,
+ because of wrong optimize condition.
+
+Mon Oct 1 01:55:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rb_intern): should not raise exceptions.
+
+ * parse.y (yylex): symbol like `:foo?=' should not be allowed.
+
+ * ext/extmk.rb.in: makes *.a for static link modules.
+
+Wed Sep 30 14:13:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_start): supports making a subclass of the
+ Thread class.
+
+Tue Sep 29 17:46:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_join): join is now an instance method.
+
+Fri Sep 25 12:01:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `@foo!' should be an error.
+
+Thu Sep 24 14:55:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/etc/etc.c (Init_etc): wrong field definition.
+
+Thu Sep 17 17:09:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_reopen): was creating FILE* for wrong fd.
+
+Tue Sep 15 05:28:11 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_compile_pattern): forgot to fixup for the pattern
+ like (?=(A)|(B)).
+
+Tue Sep 15 01:06:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_gets_internal): do not set $_ by default, only
+ gets/readline set the variable.
+
+ * eval.c (rb_f_load): load toplevel class is set to anonymous
+ module if safe_level >= 5, to encapsulate modification.
+
+ * eval.c (rb_f_load): set frame properly.
+
+ * string.c (rb_str_each_line): do not set $_.
+
+Mon Sep 14 14:42:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): beginning and end of the string, do not
+ automatically match `\b'.
+
+ * string.c (scan_once): comsume at leaset on character.
+
+ * regex.c (re_search): wrong behavior for negative range.
+
+Sat Sep 12 21:21:26 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_search): range value should be maintained.
+
+Thu Sep 10 10:55:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (backref_error): yyerror does not understand formats.
+
+Tue Sep 8 18:05:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c5 released.
+
+Tue Sep 8 10:03:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_each_line): wrong line splitting with newline at
+ top of the string.
+
+ * string.c: non bang methods return copied string.
+
+ * eval.c (f_END): needed to initialize frame->argc;
+
+Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (bigadd): proper sign combination.
+
+ * regex.c (re_search): wrong return value for \A.
+
+>>>>>>> 1.1.1.2.2.154
+Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c4 released.
+
+Tue Sep 1 10:47:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (slow_search): do not compare llen and blen. llen may
+ be longer than blen, if little contains 0xff.
+
+ * regex.c (mbctab_euc): set 0x8e as multibyte character.
+
+ * string.c (str_inspect): mask character for octal output.
+
+Mon Aug 31 15:32:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): use calculated offset if exactn is the
+ first opcode in the compiled regexp.
+
+ * regex.c (bm_search): use Boyer-Moore search for simple search.
+
+ * regex.c (must_instr): wrong length check if pattern includes
+ byte escape by 0xff.
+
+ * regex.c (re_compile_pattern): need not to check current_mbctype.
+
+Sat Aug 29 16:31:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_check_safe_str): avoid calling rb_id2name() in normal
+ cases to speed-up.
+
+ * eval.c (thread_raise): do not save context of terminated thread.
+
+ * regex.c (re_compile_pattern): mask \nnn over 256.
+
+Sat Aug 29 02:09:46 1998 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sprintf.c (f_sprintf): wrong buffer size check.
+
+Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+
+Fri Aug 28 12:25:33 1998 Hiroshi Igarashi <igarashi@ueda.info.waseda.ac.jp>
+
+ * ruby.c (ruby_require_modules): load modules in appearing order.
+
+Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+
+Thu Aug 27 12:54:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c3 released.
+
+Wed Aug 26 14:40:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): check whether ruby_class is properly set,
+ before accessing it.
+
+ * eval.c (rb_obj_instance_eval): ruby_class should be Qnil for
+ special objects like Fixnums.
+
+ * ext/tkutil/tkutil.c (Init_tkutil): removes calls to
+ rb_yield_0(). used instance_eval() instead in the tk.rb.
+
+Wed Aug 26 11:47:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): pop non-greedy stack elements on success.
+
+Wed Aug 26 09:25:35 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.h: add #define environ for cygwin32.
+
+Tue Aug 25 08:57:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_sort_bang): temporarily freeze sorting array.
+
+Mon Aug 24 18:46:44 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (dln_find_1): path check was too strict.
+
+Mon Aug 24 15:28:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * parse.y (f_arglist): opt_nl added after f_args.
+
+Fri Aug 21 01:06:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c: grand renaming on socket.c.
+
+ * ext/socket/socket.c (inet_aton): supply inet_aton for those
+ systems that do not have it.
+
+ * ext/socket/socket.c (setipaddr): use inet_aton instead of
+ inet_addr.
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): new method: works
+ like Socket.gethostbyname but returning array contains ip-addrs
+ as octet decimal string format like "127.0.0.1".
+
+ * ext/socket/socket.c (mkhostent): return format changed to
+ [host, aliases, type, ipaddr..] as documented.
+
+Wed Aug 19 00:31:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_ctl): forgot to place TRAP_END at right position.
+
+Fri Aug 14 11:01:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_trace_func): save __FILE__, __LINE__ before
+ executing trace_func, since trace function should not corrupt
+ line number information.
+
+Thu Aug 13 15:09:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_s_new): was marking unallocated region on GC.
+
+Tue Aug 11 11:57:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c2 released.
+
+Mon Aug 10 14:05:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * process.c (f_system): removed fflush(stdin).
+
+Fri Aug 7 17:44:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (err_snprintf): replace sprintf for fixed sized buffer,
+ with snprintf to avoid buffer over-run. For systems which does
+ dot provide snprintf, missing/snprintf.c added.
+
+Wed Aug 5 00:47:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_search): recycle match object.
+
+Mon Aug 3 09:17:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_gsub_bang): do not allocate temporary string.
+
+ * string.c (rb_str_sub_bang): use inline replace.
+
+Wed Jul 29 00:36:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_s_new): the default value can be specified.
+
+ * hash.c (hash_default): method to set the default value.
+
+ * hash.c (hash_aref): now returns the default value.
+
+Tue Jul 28 13:03:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_s_new): argument to specify initial value is added.
+
+ * array.c (ary_s_new): specifies size, not capacity.
+
+Mon Jul 27 12:39:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_replace): zero fill for expansion gap.
+
+ * regex.c (mbctab_euc): set flags on for 0xA1-0xFE. suggested by
+ <inaba@st.rim.or.jp>.
+
+ * string.c (str_inspect): consider current_mbctype.
+
+Sun Jul 26 15:37:11 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_s_new): Array.new(1<<30) dumps core.
+
+Fri Jul 24 13:40:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c1 released.
+
+Fri Jul 24 02:10:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_bytes2): allocated buffer size was too short.
+
+ * marshal.c (w_object): saves all options, not only casefold flag.
+
+ * re.c (reg_clone): now copies options properly.
+
+ * re.c (reg_get_kcode): code number was wrong.
+
+Thu Jul 23 13:11:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_attr): argument should be symbol or string.
+
+Wed Jul 22 11:59:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (calculate_must_string): wrong offset added.
+
+Wed Jul 22 11:59:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (rehash): still had a GC problem. fixed.
+
+Tue Jul 21 13:19:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (gc_mark_threads): crashed on GC before thread allocation.
+
+ * st.c (rehash): GC during rehash caused SEGV.
+
+Tue Jul 21 01:25:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): integer formatter totally re-written.
+
+ * sprintf.c (remove_sign_bits): support uppercase hexadecimal.
+
+Sat Jul 18 00:14:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): proper sign position for %X and %O.
+
+Fri Jul 17 14:10:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c0 released.
+
+Fri Jul 17 08:01:49 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * process.c (f_exec): Check_SafeStr() added.
+
+ * process.c (f_system): Check_SafeStr() moved before fork().
+
+Thu Jul 16 22:58:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (scan_once): substrings to the block should not be
+ tainted. use reg_nth_match(), not str_substr().
+
+ * string.c (str_substr): needed to transfer taint.
+
+Thu Jul 16 16:15:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (xmalloc): object allocation count added to GC trigger.
+
+ * eval.c (thread_save_context): avoid marking uninitialized stack
+ in thread_mark. GC may be triggered by REALLOC_N().
+
+Wed Jul 15 15:11:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_31.
+
+Wed Jul 15 15:05:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_create): exit() and abort() in threads now
+ forwarded to main_thread.
+
+Tue Jul 14 14:03:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (obj_instance_variables): list names that is not
+ instance variables.
+
+ * gc.c (GC_MALLOC_LIMIT): choose smaller limit value.
+
+Mon Jul 13 12:39:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (str2cstr): should not return NULL.
+
+Fri Jul 10 11:51:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (gettable): needed to add dyna_in_block() check.
+
+Thu Jul 9 17:38:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_30.
+
+Thu Jul 9 16:01:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (fmt_setup): format specifier for long needed.
+
+ * sprintf.c (f_sprintf): ditto.
+
+ * numeric.c (fix2str): ditto.
+
+ * eval.c (thread_create): no more ITIMER_REAL.
+
+ * eval.c (thread_create): thread finalization needed before
+ aborting thread if thread_abort is set.
+
+Wed Jul 8 18:17:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (big_pow): abandon power by bignum (too big).
+
+Tue Jul 7 13:58:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_catch): add C level catch/throw feature.
+
+Mon Jul 6 15:18:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): proper return values for `||=' and `&&='.
+
+Fri Jul 3 16:05:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_29.
+
+Fri Jul 3 11:20:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_byte): byte should not extend sign bit.
+
+ * numeric.c (fix_mul): use FIX2LONG() instead of FIX2INT() for
+ 64bit architectures.
+
+ * marshal.c (r_bytes): remove weird casting bwetween pointer and int.
+
+ * process.c (proc_setsid): new method Process#setsid().
+
+Thu Jul 2 12:49:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (w_object): remove `write_bignum' label for 64bit
+ architectures.
+
+ * marshal.c (r_bytes): needs int, not long.
+
+Wed Jul 1 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (flo_plus): should not allow addition with strings.
+
+Wed Jul 1 13:09:01 1998 Keiju ISHITSUKA <keiju@rational.com>
+
+ * numeric.c (num_uminus): wrong coerce direction.
+
+Tue Jun 30 10:13:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (f_p): accepts arbitrary number of arguments.
+
+ * eval.c (rb_yield_0): there's some case that iterator_p() returns
+ true even if the_block was not set. check added.
+
+Tue Jun 30 01:05:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (BEGIN_CALLARGS): adjust the_block before evaluating the
+ receiver's value and the arguments.
+
+Fri Jun 26 18:02:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_28.
+
+Fri Jun 26 11:01:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_aset_method): needed to convert to string.
+
+Thu Jun 25 02:05:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): optimize for `.*' at beginning of the
+ pattern.
+
+ * regex.c (re_search): optimize for character class repeat at
+ beginning of the pattern.
+
+ * regex.c (re_compile_pattern): detect optimization potential for
+ the compiled patterns.
+
+Thu Jun 25 00:02:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * re.c (reg_s_new): flag value was wrong.
+
+Wed Jun 24 23:45:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): wrong anchor handling for reverse search.
+
+Wed Jun 24 02:18:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (mlhs): `((a,b)),c = [[1,2]],3' assigns a=1,b=2,c=3.
+
+Tue Jun 23 11:46:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `&&=' and `||=' added.
+
+Sat Jun 20 02:53:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assignable): nesting local variables should have higher
+ priority than normal local variables for assignment too.
+
+Fri Jun 19 18:28:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_27.
+
+Fri Jun 19 14:34:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): support hack for nested multiple assignment.
+
+ * parse.y (mlhs): nested multiple assignment.
+
+ * eval.c (rb_eval): in-block variables now honors static scope.
+
+ * configure.in: RSHIFT check moved to configure.
+
+Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_26.
+
+Thu Jun 18 13:37:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (file_s_ftype): uses lstat(2) instead of stat(2).
+
+ * dir.c (dir_s_glob): there can be buffer overrun, check added.
+
+ * eval.c (f_binding): handles in-block variables declared after
+ binding's generation.
+
+ * numeric.c (flo_floor): floor, ceil, round added to Float.
+
+Wed Jun 17 11:20:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (gettable): nesting local variables should have higher
+ priority than normal local variables.
+
+Tue Jun 16 12:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (str2inum): handles `+ddd'.
+
+ * struct.c (make_struct): name parameter can be nil for unnamed
+ structures.
+
+Mon Jun 15 16:30:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (class_s_inherited): prohibiting to make subclass of
+ class Class.
+
+ * object.c (module_s_new): support for making subclass of Module.
+
+ * parse.y (yycompile): clear eval_tree before compiling.
+
+Fri Jun 12 17:58:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (eval): write back the_dyna_var into the block.
+
+Thu Jun 11 18:19:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_25.
+
+ * eval.c (dvar_add_compiling): register dyna_var at compile time.
+
+ * regex.c (re_compile_pattern): RE_DUP_MAX iteration is too big.
+
+Wed Jun 10 15:12:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_eof): do not block other threads.
+
+ * signal.c (trap): reserve SIGALRM for thread.
+
+ * eval.c (thread_create): use ITIMER_REAL also to avoid system
+ call blocking.
+
+ * io.c (f_syscall): add TRAP_BEG, TRAP_END around system calls.
+
+ * io.c (io_ctl): add TRAP_BEG, TRAP_END around system calls.
+
+ * enum.c (enum_collect): did not collect false values.
+
+ * array.c (ary_new2): forgot to initialize capa field.
+
+Tue Jun 9 18:36:15 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_split_method): split dumped core for "\xff".
+
+Tue Jun 9 16:22:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_24.
+
+Tue Jun 9 16:04:07 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/kconv/kconv.c (kconv_guess): more precise decision for EUC,
+ using jless algorithm (3 sequential EUC hiragana characters).
+
+Tue Jun 9 15:12:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/kconv/kconv.c (kconv_guess): wrong guess for EUC as SJIS in
+ some cases (0xe0 - 0xef).
+
+ * gc.c (xmalloc): insert size check for big (negative in signed)
+ allocation size.
+
+Tue Jun 9 02:54:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/parsedate.rb: wday moved to the last in the return values.
+
+Mon Jun 8 10:40:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_split_method): split dumped core for "\0".
+
+Sat Jun 6 22:50:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (calculate_must_string): wrong condition for
+ {start,stop}_nowidth.
+
+ * regex.c (re_match): various features imported from GNU regex.c
+ 0.12, such as nested grouping, avoiding infinite loop with empty
+ match, etc.
+
+ * regex.c (register_info_type): now use union.
+
+ * regex.c (re_search): more precise anchor(^) check.
+
+Wed Jun 3 18:07:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_raise): check rb_in_compile, not rb_in_eval.
+
+Mon Jun 1 05:26:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * string.c (trnext): casting to signed char* needed.
+
+Tue Jun 2 16:00:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (udp_addrsetup): error check enhanced.
+
+ * ext/socket/socket.c (sock_s_getservbyaname): use strtoul(), if
+ possible.
+
+Sat May 30 07:10:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_prepare_re): no more needless regular expression
+ recompile on casefold conditions.
+
+Thu May 28 18:02:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (nil_plus): no more `+' method for nil.
+
+Wed May 27 17:33:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_fetch): new method.
+
+ * regex.c (re_search): check whether translate table is set.
+
+Tue May 26 11:39:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_23.
+
+ * parse.y (yylex): no UPLUS/UMINUS for 1st argument if
+ parenthesises are omitted.
+
+Tue May 26 01:09:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): (?XI) for turns off the
+ corresponding option.
+
+Mon May 25 12:38:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): inline i option (?i).
+
+ * regex.c (re_compile_pattern): inline x option (?x).
+
+ * regex.c (re_compile_pattern): x option for regexp.
+
+ * dir.c (dir_s_open): returns block's evaluated value.
+
+ * io.c (f_open): returns block's evaluated value.
+
+ * ext/curses/curses.c (curses_addstr): nil argument caused SEGV.
+
+Fri May 22 11:52:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): push mark on (?:), so that
+ laststart check for {a,b} can be done.
+
+Thu May 21 17:31:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): wrong match (too non-greedy) for `{a,b}?'.
+
+ * io.c (io_lineno): new method IO#lineno, IO#lineno=.
+
+Wed May 20 06:04:43 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * BeOS patch.
+
+Wed May 20 16:32:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (BIGDN): use RSHIFT(), instead of mere `>>'.
+
+Tue May 19 16:36:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_22.
+
+Tue May 19 16:31:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assignable): specification changed for in-block
+ variable definition.
+
+ * eval.c (dyna_var_asgn): error in in-block variables' compile
+ time definition.
+
+ * parse.y (str_extend): wrong nesting detection.
+
+Tue May 19 09:47:55 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * numeric.c (num2int): re-defined (extensions may use this).
+
+Mon May 18 16:40:50 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * error.c (get_syserr): BeOS support.
+
+ * configure.in: modified for BeOS.
+
+ * string.c (str_dump): do not call isascii().
+
+ * sprintf.c (remove_sign_bits): forgot to initialize end pointer.
+
+ * glob.c: #include <alloca.h> added.
+
+Mon May 18 14:52:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_21.
+
+Mon May 18 03:27:57 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * file.c (file_s_expand_path): optional second argument
+ `default_directory' added.
+
+Sat May 16 22:06:52 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * error.c (RAISE_ERROR): wrong error message
+
+Fri May 15 14:43:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_20.
+
+Thu May 14 14:44:21 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * sun4 cc patches for intern.h and regex.h.
+
+Thu May 14 14:03:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (RANDOM_MAX): guessing proper maximum value for random
+ numbers.
+
+ * random.c (f_rand): use drand48 if possible.
+
+Wed May 13 19:05:20 1998 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * BeOS patches for io.c, error.c and config.guess.
+
+Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_19.
+
+ * most of the Mac and BeOS patches merged, except path separators.
+
+ * error.c (err_append): generated SyntaxError was String.
+
+ * ruby.h: xxx2INT, xxx2UINT checks values as int, not long.
+
+ * ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT.
+
+Tue May 12 17:38:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_18.
+
+Tue May 12 11:38:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (syserr_errno): returns errno of the SystemCallError.
+
+ * error.c (rb_sys_fail): saves errno in the Exception.
+
+ * error.c (set_syserr): no need to protect syserr_list.
+
+ * error.c (rb_sys_fail): no more bufsize limit.
+
+ * error.c (set_syserr): integer value of errno can be accessed by
+ Errno::EXXX::Errno.
+
+Sun May 10 03:10:33 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * io.c (io_tell etc.): moved from File class to IO class.
+
+Fri May 8 12:26:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): should be unsigned int (was signed int).
+
+Thu May 7 16:34:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_pack): `V', `N' uses newly created NUM2UINT().
+
+ * ruby.h (NUM2UINT): new macro.
+
+ * bignum.c (big2uint): try to convert bignum into UINT.
+
+ * re.c (reg_match): needed to return false for match with nil.
+
+ * gc.c (obj_free): wrong condition to free string.
+
+Wed May 6 21:08:08 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (ruby_process_options): modified for DJGPP.
+
+Wed May 6 15:48:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_17.
+
+Wed May 6 01:37:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c: remove global variable `errat'.
+
+ * eval.c (rb_longjmp): embed error position information in the
+ exception object.
+
+Sat May 2 12:20:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_search): supports reverse search.
+
+ * string.c (str_index_method): does update $~ etc.
+
+ * eval.c (f_load): needed to clear the_dyna_vars.
+
+ * eval.c (dyna_var_asgn): do not push dyna_var, which is id == 0.
+
+ * error.c (Init_Exception): NotImplementError is no longer
+ StandardError, which is not handled by default rescue.
+
+Fri May 1 00:35:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (proc_options): `-d' turns on verbose flag too.
+
+ * error.c (exception): last argument may be the superclass of the
+ defining exception(s).
+
+ * io.c (Init_IO): EOFError is now subclass of the IOError.
+
+ * io.c (Init_IO): forgot to define IOError.
+
+ * error.c (Init_Exception): old Exception class renamed to
+ StandardError. Exception now replaces old GlobalExit.
+
+ * error.c (Init_Exception): Exception is now the root of the
+ Global Exits. There's no longer GlobalExit class.
+
+ * util.c (ruby_mktemp): check TMP, TMPDIR first.
+
+Thu Apr 30 01:08:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/tk.rb: call 'unknown', if proc not defined.
+
+ * eval.c (handle_rescue): default rescue handles `Exceptional' not
+ only the instance of the `Exception's.
+
+ * eval.c (f_raise): exception can be any object.
+
+ * time.c (time_gm_or_local): call time_gmtime or time_localtime.
+
+ * eval.c (f_raise): raises TypeError if the class which is not a
+ subclass of String is specified (checked in exc_new()).
+
+ * error.c (exc_new): need to check whether invalid class (not a
+ subclass of String) is specified.
+
+Wed Apr 29 21:05:44 1998 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ruby.c (proc_options): option '-e' via tempfile.
+
+Tue Apr 28 15:27:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_16.
+
+Tue Apr 28 00:07:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_is_proc): type check predicate.
+
+ * eval.c (obj_is_block): ditto.
+
+Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/gtk/gtk.c (Init_gtk): use timeout, not idle to avoid
+ comsuming CPU too much.
+
+ * lib/tk.rb: use tcltklib#_invoke instead of `_eval'.
+
+Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_sort): use dup, not clone.
+
+Mon Apr 27 13:46:27 1998 Tadahiro Maebashi <maebashi@iij.ad.jp>
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): invoke tcl command
+ directly. need not worry about escaping tcl characters.
+
+Mon Apr 27 12:04:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (f_rand): do not call srand() implicitly.
+
+Fri Apr 24 14:35:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_15.
+
+ * parse.y (assignable): dyna_var_asgn actually defines nested
+ local variables in outer context.
+
+ * random.c (f_rand): call srand(), if it has not called yet.
+
+ * random.c (f_srand): use tv_usec as the default seed.
+
+ * eval.c (rb_eval): values of nested local variables should be
+ independent.
+
+ * eval.c (rb_yield_0): local variables wrong nested conditions.
+
+Wed Apr 22 23:27:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (select_get_io): get IO object by `to_io'.
+
+ * io.c (io_to_io): method to retrieve IO object, from delegating
+ object for example.
+
+Wed Apr 22 16:52:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_14.
+
+ * string.c (str_modify): check for embedded pointer reference.
+
+ * gc.c (obj_free): ditto.
+
+ * pack.c (pack_pack): p/P template to embed pointers.
+
+Wed Apr 22 00:07:10 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_rindex): embarrassing typo.
+
+Tue Apr 21 12:31:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_13.
+
+ * configure.in (RUBY_LIB): supports --program-{prefix,suffix}.
+
+ * array.c (ary_rindex): new method.
+
+ * io.c (io_binmode): should return self.
+
+Tue Apr 21 08:23:04 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * parse.y (here_document): calling parse_string with wrong
+ arguments.
+
+ * struct.c (struct_aset): problem member assignment with name.
+
+Mon Apr 20 14:47:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_12.
+
+ * time.c (time_arg): args may be string (support for reduced
+ implicit type conversion).
+
+ * lib/base64.rb: changed to use pack/unpack with `m' template.
+
+Mon Apr 20 06:23:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (mod_remove_const): new method.
+
+Sat Apr 18 03:53:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_each_with_index): removed. use Enumerable's
+ each_with_index instead.
+
+ * class.c (rb_include_module): check for super modules, since
+ module's included modules may be changed.
+
+Fri Apr 17 21:50:47 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * marshal.c (r_long): r_byte() may return signed byte.
+
+Fri Apr 17 11:58:30 1998 NAGAI Hidetoshi <nagai@dumbo.ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): thread and interrupt check.
+
+Fri Apr 17 11:06:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (find_file): try to fopen() to check whether file exists.
+
+ * ruby.c (load_file): ditto.
+
+ * struct.c (struct_aset): struct member can be set by member name.
+
+Fri Apr 17 00:47:19 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in: added m68k-human support
+
+ * file.c (LOCK_SH): defines moved.
+
+ * array.c (ary_flatten_bang): simplified loop.
+
+Thu Apr 16 16:52:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_11.
+
+ * lib/tk.rb: thread support (experimental - maybe slow).
+
+ * eval.c (rb_longjmp): trace event on exception in raising
+ context, just before raising exception.
+
+ * struct.c (struct_s_members): forgot to check singletons.
+
+ * struct.c (struct_aref): members can be accessed by names too.
+
+ * array.c (ary_flatten): new method.
+
+ * eval.c (rb_longjmp): prints exception information with `-d'.
+
+ * object.c (any_to_s): remove class name restriction.
+
+Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (thread_flock): do not block other threads.
+
+ * eval.c (thread_trap_eval): signals are now delivered to the
+ current thread again. In case that the current thread is dead,
+ signals are forwarded to the main thread.
+
+ * string.c (str_new4): need not to duplicate frozen strings.
+
+Wed Apr 15 08:33:47 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_inspect): remove restriction for struct names.
+
+Wed Apr 15 02:55:02 1998 Kazuya 'Sharl' Masuda <sharl@www.ufo.co.jp>
+
+ * x68 patches to config.sub, ext/extmk.rb.in
+
+Wed Apr 15 01:22:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_dup_frozen): do not duplicate frozen strings.
+
+ * parse.y (yylex): allow nested parenthesises.
+
+ * io.c (obj_displayln): prints newline after `display'ing the
+ receiver.
+
+ * io.c (io_puts): avoid generating "\n" each time. use RS_default
+ instead.
+
+ * io.c (f_p): ditto.
+
+Tue Apr 14 22:18:17 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_aref): should not subtract negative index.
+
+Tue Apr 14 11:34:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_10.
+
+ * parse.y: token names prefixed by `t'.
+
+ * struct.c (struct_s_def): supports subclassing of Struct.
+
+ * io.c (io_s_new): supports subclassing of IO.
+
+Mon Apr 13 11:07:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_binding): need to restore method name.
+
+ * eval.c (rb_call0): raises SystemStackError, not Fatal.
+
+ * io.c (obj_display): same as `print self'.
+
+ * io.c (f_p): can now be called in the method form.
+
+ * re.c (reg_regsub): needed to be mbchar aware.
+
+Mon Apr 13 13:18:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_trap_eval): all signals delivered to main_thread.
+
+Mon Apr 13 12:47:03 1998 TAKAHASHI Masayoshi <maki@inac.co.jp>
+
+ * re.c (kcode_set_option): did not set SJIS on SJIS condition.
+
+Sun Apr 12 22:14:07 1998 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
+
+ * array.c (ary_uniq_bang): should be `==', not `='. embarrassing.
+
+Sat Apr 11 02:13:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_subseq): SEGVed for `[][1,1]'.
+
+Fri Apr 10 21:29:06 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_subseq): add check for beg larger than array length.
+
+Wed Apr 8 17:24:11 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * dir.c (dir_s_open): can be called with block (like IO#open).
+
+ * dir.c (dir_s_chdir): print directory path on error.
+
+ * dir.c (dir_s_chroot): ditto
+
+ * dir.c (Init_Dir): needed to override `new'.
+
+Thu Apr 9 18:24:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_09.
+
+ * string.c (str_cmp): do not depend on sentinel at the end of the
+ strings.
+
+ * string.c (str_chomp_bang): forgot to set the sentinel.
+
+Wed Apr 8 00:59:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (big2int): converted int may be too big to fit in
+ signed int.
+
+ * parse.y (arg): `foo += 1' should not cause an error.
+
+ * variable.c (rb_const_defined): returned false even if the
+ constant is defined at the top level.
+
+ * eval.c (f_local_variables): dyna_var->id may be null. should
+ have checked before calling str_new2().
+
+Tue Apr 7 01:15:15 1998 Kaneko Naoshi <wbs01621@mail.wbs.or.jp>
+
+ * re.c (reg_regsub): need to check string boundary.
+
+Tue Apr 7 19:19:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_cmp): returns either 1, 0, -1.
+
+ * array.c (ary_cmp): should check array length, too
+
+Tue Apr 7 18:50:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_08.
+
+Tue Apr 7 18:31:27 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * instruby.rb (mandir): dll installation for cygwin32
+
+Tue Apr 7 01:16:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * config.sub (maybe_os): TOWNS support?
+
+ * config.guess: too strict check for libc versions on linuxes.
+
+ * experimental release 1.1b9_07.
+
+ * array.c (ary_cmp): compare each element using `<=>'.
+
+ * hash.c (hash_each_with_index): yields [value, key] pair.
+
+ * class.c (class_protected_instance_methods): list protected
+ method names.
+
+ * class.c (ins_methods_i): exclude protected methods.
+
+ * eval.c (PUSH_BLOCK): dynamic variables can be accessed from
+ eval() with bindings.
+
+Mon Apr 6 14:49:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_yield): must return evaluated value.
+
+Fri Apr 3 13:07:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_schedule): context switch bypassed on wrong
+ conditions.
+
+ * variable.c (rb_name_class): set classname by id before String
+ class is initialized (1.0 behavior restored).
+
+Fri Apr 3 11:25:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (num2int): no implicit conversion from string.
+
+ * numeric.c (num2int): check whether `to_i' returns an Integer.
+
+ * numeric.c (num_zero_p): new method.
+
+ * numeric.c (num_nonzero_p): new method. returns the receiver if
+ it's not zero.
+
+ * eval.c (obj_instance_eval): the_class should be the object's
+ singleton class.
+
+ * error.c (exc_s_new): message is converted into a string.
+
+Thu Apr 2 18:31:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_call_init): every object call `initialize'.
+
+Wed Apr 1 08:51:53 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * parse.y (stmt): UNTIL_MOD should be for stmt, not only for expr.
+
+Wed Apr 1 01:20:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (true_and): boolean operators &, | and ^.
+
+Tue Mar 31 13:23:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_compact_bang): returns nil, if it does not modify
+ the array like String's bang methods.
+
+ * array.c (ary_uniq_bang): new method to remove duplicate items.
+
+ * eval.c (bind_s_new): new method.
+
+ * numeric.c (num2int): raise exception if Fixnums too big to
+ convert into `int' in case that sizeof(int) < sizeof(INT).
+
+ * string.c (str_center): SEGV on negative width.
+
+ * eval.c (eval): forgot to set sourcefile.
+
+Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (f_test): raises exception for unkown command.
+
+ * eval.c (Init_eval): `class_eval': alias to the module_eval.
+
+Mon Mar 30 18:50:42 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * string.c (str_capitalize_bang): did not check string modification.
+
+ * string.c (str_delete_bang): wrong conversion.
+
+ * string.c (str_intern): typo in error message.
+
+Mon Mar 30 01:44:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_instance_eval): accepts block as evaluation body.
+ No compilation needed each time.
+
+ * eval.c (mod_module_eval): ditto
+
+ * file.c (file_s_umask): umask did not return old values, if no
+ argument given.
+
+Sun Mar 29 00:54:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_throw): nil returned always.
+
+Sat Mar 28 20:40:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_06.
+
+Sat Mar 28 16:07:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_closed): should not cause exception fot closed IO.
+
+ * string.c (str_tr): returned nil for success.
+
+Sat Mar 28 00:47:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_local_variables): new method to return an array of
+ local variable names.
+
+ * variable.c (obj_instance_variables): now returns an array of
+ variable names, as described in the reference.
+
+ * eval.c (rb_attr): honors default method visibility of the
+ current scope.
+
+Fri Mar 27 13:49:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_05.
+
+ * ruby.c (ruby_prog_init): `site_ruby' added to load_path.
+
+ * ruby.c (ruby_prog_init): load-path order changed. Paths in
+ the RUBYLIB environment variable comes first in non-tainted
+ mode.
+
+Thu Mar 26 11:51:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call): new feature: `protected' methods.
+
+ * string.c (str_dump): new method.
+
+ * eval.c (block_pass): block argument can be nil, which means no
+ block is supplied for the method.
+
+Wed Mar 25 21:20:13 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * string.c (str_reverse_bang): string copied to wrong place.
+
+Wed Mar 25 08:12:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (flo_modulo): caused SEGV if left operand is not a
+ float value.
+
+ * eval.c (f_eval): optional third and fourth argument to specify
+ file-name and line-number.
+
+ * eval.c (eval): file-name and line-number set properly.
+
+ * parse.y (assign_in_cond): literal assignment is now warning, not
+ compile error.
+
+ * error.c (Warn): Warn() always print message, OTOH Waring()
+ prints when verbose flag is set.
+
+Tue Mar 24 12:50:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (ruby_prog_init): `.' should come last in the load-path.
+
+ * eval.c (Init_eval): `__send__', alias for `send'.
+
+Mon Mar 23 12:44:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_chomp_bang): now takes `rs' as an argument.
+
+ * eval.c (thread_free): main_thread should not be freed.
+
+Fri Mar 20 16:40:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_chomp_bang): chomp! (and other ! methods) returns
+ nil if it does not modify the string.
+
+ * string.c (str_sub_iter_s): should check last pattern since it
+ may be matched to null.
+
+Thu Mar 19 13:48:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_04.
+
+ * parse.y (yylex): `10e0.9' should cause syntax error.
+
+Wed Mar 18 17:46:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (load_file): new file object constant DATA. Only
+ available for the script from the file.
+
+ * regex.c (re_match): forwading failure point popped too much.
+
+Tue Mar 17 18:23:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * math.c (math_frexp): newly added.
+
+ * math.c (math_ldexp): ditto.
+
+ * bignum.c (bigdivmod): calculates modulo.
+
+ * numeric.c (fix_remainder): returns reminder, formerly introduced
+ as modulo.
+
+ * numeric.c (fix_modulo): calculates proper `modulo'.
+
+ * bignum.c (bigdivmod): wrong sign for reminder.
+
+Mon Mar 16 17:07:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_03.
+
+Mon Mar 16 16:33:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (pipe_finalize): needed to add pipe_finalize to pipes on
+ cygwin32.
+
+Mon Mar 16 14:11:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (ins_methods_i): needed to consider NOEX_UNDEF.
+
+Mon Mar 16 13:23:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_check_closed): check for `fptr->f2 == NULL'.
+
+ * io.c (io_fptr_close): ditto.
+
+Mon Mar 16 11:49:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (pipe_atexit): free()ing referencing pipe_list.
+
+ * range.c (range_length): returns zero, if the first is greater
+ than the last.
+
+ * signal.c (trap_restore_mask): restore signal mask before raising
+ exceptions and throws.
+
+Fri Mar 13 13:49:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_02.
+
+ * object.c (mod_clone): need to dups constants and instance
+ variables.
+
+ * eval.c (rb_eval): forgot to initialize body for NODE_DEFS.
+
+ * eval.c (rb_eval): retrieve self from calling frame, since self
+ changes sometimes.
+
+ * env.h (FRAME): need to save self in the calling frame.
+
+ * io.c (f_gets_method): rs should be initialized by RS.
+
+Thu Mar 12 15:33:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_01.
+
+ * range.c (range_s_new): check values by `first <= last'.
+
+ * parse.y (lastline_set): fixed offset for $_ and $~ in the local
+ variable space.
+
+Wed Mar 11 02:14:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_gets): handle normal case specially for speed.
+
+ * eval.c (rb_disable_super): function to disable superclass's
+ method explicitly.
+
+ * eval.c (rb_eval): inherits previous method definition's
+ NOEX_UNDEF-ness, if exists.
+
+ * class.c (rb_define_method): disables superclass's overriding
+ method by default.
+
+Wed Mar 11 01:40:48 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * numeric.c (flo_gt,etc.): do not depend on `<=>', to handle NaN.
+
+Tue Mar 10 00:03:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (load_file): understands multiple options in #! line.
+
+ * regex.c (re_compile_pattern): support for [:alpha:] etc.
+
+Mon Mar 9 16:53:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.h (GetOpenFile): embed io_check_closed in GetOpenFile.
+
+ * sprintf.c (f_sprintf): zero padding failed for negative
+ integers.
+
+ * sprintf.c (remove_sign_bits): failed to remove some bits.
+
+Sat Mar 7 21:51:46 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * class.c (ins_methods_i): body may be NULL for some case.
+
+Fri Mar 6 17:23:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (mbcinit): table driven mbchar detection.
+
+ * object.c (obj_alloc): check for allocating instance for the
+ primitive classes (mostly perfect).
+
+ * ext/curses/curses.c (curses_finalize): restore original state at
+ interpreter temination.
+
+ * ext/curses/curses.c (curses_addstr): forgot to check argument
+ type (caused SEGV). now uses STR2CSTR() macro.
+
+Thu Mar 5 13:47:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (block_pass): accepts method object as block args.
+
+ * eval.c (f_missing): use any_to_s() for stringify.
+
+Wed Mar 4 01:39:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (block_arg): new syntax - block argument in the
+ calling arglist.
+
+ * eval.c (rb_call): no module search. simplified a lot.
+
+ * eval.c (rb_eval): block arg support.
+
+ * parse.y (f_block_arg): new syntax - block argument in the
+ formal arglist.
+
+Tue Mar 3 14:20:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_method): returns bound method object.
+
+ * eval.c (rb_call): argument check for empty methods.
+
+ * ruby.h (NUM2CHR): new macro, originally from curses module.
+
+Tue Mar 3 13:03:35 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * io.c (io_putc): new method.
+
+Tue Mar 3 11:21:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_inspect): more strict charcode detection.
+
+ * eval.c (thread_stop): stopping only thread raises ThreadError
+ exception.
+
+Tue Mar 3 08:04:56 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_alloc): imcomplete struct initialization made
+ GC to access unallocated addresses.
+
+Mon Mar 2 16:28:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_stop_method): remove Thread#stop.
+
+Fri Feb 27 18:16:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b9 released.
+
+Fri Feb 27 09:36:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_delete_nil): needed to compare value to nil, since
+ nil is the valid key for hashes.
+
+ * hash.c (hash_foreach_iter): rehashing causes IndexError.
+
+ * hash.c (hash_foreach_iter): rehash check by pointer comparison.
+
+Thu Feb 26 17:22:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (fname): convert reswords into symbols.
+
+ * parse.y (reswords): reserved words are now embedded in the
+ syntax (sigh).
+
+ * parse.y: now reserved words can be method names safely.
+
+Wed Feb 25 15:50:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (mod_module_eval): clear the_scope's PRIVATE flag before
+ calling eval().
+
+ * gc.c (gc_call_finalizer_at_exit): run finalizers before any data
+ object being freed.
+
+ * eval.c (rb_eval): needed to keep prot_tag->retval before
+ evaluating the ensure clause.
+
+Tue Feb 24 11:16:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): reserved words can be appear as method names at
+ right after 'def' and `.'(dot), like foo.next.
+
+ * eval.c (return_check): checks for return out of thread (formerly
+ done in return_value).
+
+ * eval.c (POP_TAG): copy retval to outer level.
+
+ * eval.c (return_value): just set retval, no check, no unwinding.
+
+ * parse.y (nextc): line continuation by backslash at end of line.
+
+ * regex.c (re_compile_pattern): forgot to clear pending_exact on
+ closing parentheses.
+
+ * parse.y (assignable): should not assign dyna_var to true, if it
+ is already defined.
+
+Mon Feb 23 14:35:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (obj_is_kind_of): no longer accepts true/false/nil.
+
+ * object.c ({true,false,nil}_to_i): can be converted into integers.
+
+Mon Feb 23 12:11:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_s_quote): needed to be mbchar aware.
+
+ * eval.c (proc_s_new): wrong iter mark.
+
+Sat Feb 21 22:59:30 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * io.c (f_syscall): no argument check.
+
+Fri Feb 20 10:17:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b8 released.
+
+ * ext/kconv/kconv.c (kconv_kconv): default output code now be
+ determined according to the value of $KCODE.
+
+ * re.c (rb_get_kcode): can retrieve $KCODE from C code.
+
+ * parse.y (stmt): if/unless modifiers returns nil, if condition is
+ not established.
+
+Thu Feb 19 11:06:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/kconv/kconv.c (kconv_kconv): charcode can be specified by
+ code name (JIS, SJIS, EUC like value of $KCODE).
+
+ * regex.c (re_compile_pattern): forgot to fixup_jump for (?:..).
+
+ * regex.c (re_compile_pattern): needed to clear pending_exact on
+ non-registering grouping (?:...).
+
+Wed Feb 18 19:54:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): needed to set lex_state to EXPR_END.
+
+Wed Feb 18 18:45:10 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * patches for cygwin32 applied.
+
+Wed Feb 18 00:41:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_sub_s): needed to be mbchar aware to increment one
+ character.
+
+ * regex.c (re_match): \Z matches newline just before the end of
+ the string.
+
+Tue Feb 17 00:04:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_arg): Time.gm and Time.local now understands
+ Time#to_a format.
+
+ * string.c (str_sub_s): replace happened twice for null pattern.
+
+ * regex.c (re_search): null pattern should not match after newline
+ at the end of string.
+
+ * time.c (time_isdst): now returns boolean value.
+
+ * error.c (rb_check_type): treat special constants in messages.
+
+ * parse.y (yylex): new form `::Const' to see toplevel constants.
+
+ * parse.y (cond): SEGV on `if ()'.
+
+ * gc.c (obj_free): some data needed explicit free().
+
+Mon Feb 16 23:55:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): release duplicated block informations.
+
+ * eval.c (blk_copy_prev): duplicate outer block information into
+ the heap, when proc/binding created.
+
+Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_mon): now 1 for January and so on.
+
+ * time.c (time_year): year in 19xx (no + 1900 needed anymore).
+
+Mon Feb 16 13:28:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): need to fetch mbchar's second byte
+ without translation.
+
+Mon Feb 16 12:29:27 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * eval.c (f_pass_block): pass iterator block to other method.
+
+Fri Feb 13 08:16:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): handle \s before read_escape().
+
+ * parse.y (read_escape): `\s' in strings as space.
+
+Tue Feb 10 17:29:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b7 released.
+
+ * string.c (str_aset): string insertion by `str[n] = str2'.
+
+ * string.c (str_oct): does recognize `0x'.
+
+ * sprintf.c (f_sprintf): use baes 10 for conversion from string to
+ integer.
+
+Mon Feb 9 14:51:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (do_coerce): proper error message.
+
+ * string.c (str_sum): bug - masked by wrong value. (sigh..)
+
+Sat Feb 7 15:11:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_empty): new method
+
+Fri Feb 6 01:42:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_asctime): use asctime(3), not strftime(3).
+
+Thu Feb 5 18:58:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_fptr_close): do not free path on close().
+
+ * array.c (ary_filter): new method.
+
+ * enum.c (enum_each_with_index): new method.
+
+Thu Feb 5 14:10:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (primary): singleton class def can be appeared inside
+ method bodies.
+
+ * hash.c (hash_replace): replace content.
+
+ * string.c (str_replace_method): replace content.
+
+ * array.c (ary_replace_method): replace elements.
+
+ * string.c (str_succ_bang): String#succ!
+
+Thu Feb 5 18:20:30 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_upcase_bang): multi byte character support.
+
+Wed Feb 4 13:55:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_reverse): SEGV on empty array reverse.
+
+Tue Feb 3 12:24:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (match_to_a): non matching element should be nil.
+
+ * ruby.c (ruby_load_script): load script after all initialization.
+
+ * bignum.c (str2inum): need to interpret prefix `0' of `0x'.
+
+Tue Feb 3 10:00:18 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * numeric.c (fix_rshift): use `sizeof(INT)*8' instead of 32.
+
+Mon Feb 2 14:09:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (set_arg0): grab environment region too.
+
+Thu Jan 29 18:36:25 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * process.c (rb_proc_exec): check `sh' to be exist.
+
+Thu Jan 29 18:18:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_stdio_set): assignment to $stdin or $stdout does
+ reopen() as well as $stderr.
+
+Thu Jan 29 14:18:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (mod_ancestors): should not include singleton classes.
+
+ * object.c (obj_type): should not return internal class.
+
+ * io.c (io_reopen): unwillingly closes stdio streams.
+
+Thu Jan 29 11:50:35 1998 Toshihiko SHIMOKAWA <toshi@csce.kyushu-u.ac.jp>
+
+ * ext/socket/socket.c (udp_addrsetup): forgot to use htons().
+
+Tue Jan 27 23:15:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * keywords: __FILE__, __LINE__ are available again.
+
+Fri Jan 23 14:19:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b6 released.
+
+ * object.c (mod_to_s): need to duplicate classpath.
+
+ * error.c (exc_inspect): need to duplicate classpath.
+
+Thu Jan 22 00:37:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (STR2CSTR): new macro to retrieve char*.
+
+ * class.c (rb_define_method): `initialize' should always be
+ private, even if it defined by C extensions.
+
+ * eval.c (rb_eval): `initialize' should always be private.
+
+Thu Jan 22 16:21:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): some singleton class def cause SEGV.
+
+ * eval.c (TMP_ALLOC): replace ALLOCA_N, where thread context
+ switch may happen.
+
+Wed Jan 21 01:43:42 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (PUSH_FRAME): do not use ALLOCA_N(). crash on some
+ platforms that use missing/alloca.c.
+
+ * regex.c (re_compile_pattern): too many pops for non register
+ subexpr.
+
+ * parse.y (yylex): open parentheses after identifiers are argument
+ list, even if whitespaces have seen.
+
+Tue Jan 20 15:19:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (terms): quoted word list by %w(a b c).
+
+ * ext/tcltklib/extconf.rb: more accurate check for tcl/tk libs.
+
+ * file.c (rb_stat): most of the FileTest methods (and function
+ `test') accept File objects as the argument.
+
+Tue Jan 19 18:19:24 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in (install): there should be no newline after install:
+
+ * re.c (MIN): renamed from min(). there's a local variable named
+ min in the file, so that some cpp will raise an error.
+
+Mon Jan 19 16:30:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b5 released.
+
+ * process.c (rb_syswait): no exception raised.
+
Fri Jan 16 00:43:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.h (CLONESETUP): copies its singleton classes too.
@@ -27,6 +2379,8 @@ Tue Jan 13 10:00:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Fri Jan 9 13:19:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * version 1.1b4 released.
+
* eval.c (f_missing): class name omitted from the error message.
* error.c (exc_inspect): description changed.
diff --git a/MANIFEST b/MANIFEST
index 2bdaf29..5c697d6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5,6 +5,7 @@ Makefile.in
README
README.jp
README.EXT
+README.EXT.jp
ToDo
array.c
bignum.c
@@ -13,7 +14,8 @@ compar.c
configure
configure.bat
configure.in
-config.dj
+config_h.dj
+config_s.dj
config.guess
config.sub
defines.h
@@ -36,7 +38,6 @@ install-sh
instruby.rb
intern.h
io.c
-io.h
keywords
lex.c
main.c
@@ -47,6 +48,7 @@ node.h
numeric.c
object.c
pack.c
+parse.c
parse.y
process.c
random.c
@@ -58,8 +60,9 @@ regex.h
ruby.1
ruby.c
ruby.h
+rubyio.h
+rubysig.h
rubytest.rb
-sig.h
signal.c
sprintf.c
st.c
@@ -73,74 +76,89 @@ util.c
variable.c
version.c
version.h
+beos/ruby.def.in
ext/Setup
ext/Setup.dj
ext/Setup.nt
ext/Setup.x68
+ext/aix_ld.rb
+ext/cygwin32_ld.rb
ext/extmk.rb.in
ext/extmk.rb.nt
-ext/aix_ld.rb
lib/English.rb
+lib/Env.rb
+lib/README
lib/base64.rb
lib/cgi-lib.rb
lib/complex.rb
lib/date.rb
+lib/date2.rb
lib/debug.rb
lib/delegate.rb
lib/e2mmap.rb
lib/eregex.rb
lib/find.rb
+lib/final.rb
lib/finalize.rb
lib/ftplib.rb
lib/ftools.rb
lib/getopts.rb
+lib/getoptlong.rb
lib/importenv.rb
lib/jcode.rb
lib/mailread.rb
lib/mathn.rb
lib/matrix.rb
lib/mkmf.rb
+lib/monitor.rb
lib/mutex_m.rb
lib/observer.rb
+lib/open3.rb
lib/ostruct.rb
lib/parsearg.rb
lib/parsedate.rb
lib/ping.rb
+lib/profile.rb
lib/pstore.rb
lib/rational.rb
+lib/readbytes.rb
lib/shellwords.rb
+lib/singleton.rb
lib/sync.rb
+lib/telnet.rb
+lib/tempfile.rb
lib/thread.rb
lib/thwait.rb
-lib/tk.rb
-lib/tkcanvas.rb
-lib/tkclass.rb
-lib/tkdialog.rb
-lib/tkentry.rb
-lib/tkscrollbox.rb
-lib/tktext.rb
+lib/timeout.rb
lib/tracer.rb
lib/weakref.rb
+misc/README
+misc/inf-ruby.el
+misc/ruby-mode.el
+misc/rubydb2x.el
+misc/rubydb3x.el
missing/alloca.c
missing/crypt.c
missing/dir.h
missing/dup2.c
missing/file.h
missing/flock.c
+missing/memcmp.c
missing/memmove.c
missing/mkdir.c
-missing/nt.c
-missing/nt.h
-missing/setenv.c
missing/strcasecmp.c
+missing/strchr.c
missing/strdup.c
missing/strerror.c
missing/strftime.c
missing/strstr.c
missing/strtol.c
missing/strtoul.c
+missing/vsnprintf.c
missing/x68.c
+sample/README
sample/biorhythm.rb
+sample/cal.rb
sample/cbreak.rb
sample/clnt.rb
sample/dbmtest.rb
@@ -151,44 +169,38 @@ sample/exyacc.rb
sample/fact.rb
sample/fib.awk
sample/fib.pl
+sample/fib.py
sample/fib.rb
sample/fib.scm
sample/freq.rb
sample/from.rb
sample/fullpath.rb
sample/getopts.test
+sample/goodfriday.rb
sample/less.rb
sample/list.rb
sample/list2.rb
sample/list3.rb
-sample/mrshtest.rb
+sample/mine.rb
sample/mkproto.rb
sample/mpart.rb
+sample/mrshtest.rb
sample/observ.rb
sample/occur.pl
sample/occur.rb
sample/occur2.rb
sample/philos.rb
sample/pi.rb
+sample/rename.rb
sample/rbc.rb
sample/rcs.awk
sample/rcs.dat
sample/rcs.rb
sample/regx.rb
-sample/ruby-mode.el
-sample/rubydb2x.el
-sample/rubydb3x.el
sample/sieve.rb
sample/svr.rb
sample/test.rb
sample/time.rb
-sample/tkbiff.rb
-sample/tkbrowse.rb
-sample/tkdialog.rb
-sample/tkfrom.rb
-sample/tkhello.rb
-sample/tkline.rb
-sample/tktimer.rb
sample/trojan.rb
sample/tsvr.rb
sample/uumerge.rb
@@ -198,6 +210,8 @@ win32/ntsetup.bat
win32/ruby.def
win32/sdbm.c
win32/sdbm.h
+win32/win32.c
+win32/win32.h
x68/fconvert.c
x68/select.c
x68/_dtos18.c
diff --git a/Makefile.in b/Makefile.in
index 3c616d9..628b0e0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -8,19 +8,26 @@ VPATH = @srcdir@:@srcdir@/missing
CC = @CC@
YACC = @YACC@
PURIFY =
+AUTOCONF = autoconf
@SET_MAKE@
-CFLAGS = @CFLAGS@ -I@srcdir@
+prefix = @prefix@
+CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
+EXTLIBS =
LIBS = @LIBS@ $(EXTLIBS)
MISSING = @LIBOBJS@ @ALLOCA@
+LDSHARED = @LDSHARED@
+DLDFLAGS = @DLDFLAGS@
+SOLIBS = @SOLIBS@
binsuffix = @binsuffix@
#### End of system configuration section. ####
-LIBRUBY = libruby.a
+LIBRUBY = @LIBRUBY@
+LIBRUBYARG = @LIBRUBYARG@
EXTOBJS =
@@ -42,8 +49,8 @@ OBJS = array.o \
hash.o \
inits.o \
io.o \
- math.o \
marshal.o \
+ math.o \
numeric.o \
object.o \
pack.o \
@@ -66,44 +73,58 @@ OBJS = array.o \
$(MISSING)
all: miniruby$(binsuffix) rbconfig.rb
- @cd ext; ../miniruby$(binsuffix) ./extmk.rb @EXTSTATIC@
+ @./miniruby$(binsuffix) -Xext extmk.rb @EXTSTATIC@
-miniruby$(binsuffix): $(OBJS) $(MAINOBJ) dmyext.o
+miniruby$(binsuffix): libruby.a $(MAINOBJ) dmyext.o
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(OBJS) dmyext.o $(LIBS) -o miniruby
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.o libruby.a $(LIBS) -o $@
ruby$(binsuffix): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o ruby
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
-$(LIBRUBY): $(OBJS) dmyext.o
- @AR@ rcu $(LIBRUBY) $(OBJS) dmyext.o
- @-@RANLIB@ $(LIBRUBY) 2> /dev/null || true
+libruby.a: $(OBJS) dmyext.o
+ @AR@ rcu $@ $(OBJS) dmyext.o
+ @-@RANLIB@ $@ 2> /dev/null || true
+
+libruby.so: $(OBJS) dmyext.o
+ $(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.o -o $@
install: rbconfig.rb
- ./miniruby$(binsuffix) $(srcdir)/instruby.rb
+ ./miniruby$(binsuffix) $(srcdir)/instruby.rb $(DESTDIR)
clean:; @rm -f $(OBJS) $(LIBRUBY) $(MAINOBJ) rbconfig.rb
@rm -f ext/extinit.c ext/extinit.o dmyext.o
- @if test -f ./miniruby; then cd ext; ../miniruby ./extmk.rb clean; fi
-
-realclean: clean
- @rm -f Makefile ext/extmk.rb ext/config.cache
- @rm -f config.cache config.h config.log config.status
- @rm -f parse.c lex.c *~ core *.core gmon.out
+ @if test -f ./miniruby$(binsuffix); then \
+ ./miniruby$(binsuffix) -Xext extmk.rb clean; \
+ fi
+
+distclean: clean
+ @rm -f Makefile ext/extmk.rb config.h
+ @rm -f ext/config.cache config.cache config.log config.status
+ @rm -f parse.c *~ core *.core gmon.out y.tab.c y.output
@rm -f ruby$(binsuffix) miniruby$(binsuffix)
+realclean: distclean
+ @rm -f lex.c
+
test: miniruby$(binsuffix)
@./miniruby$(binsuffix) $(srcdir)/rubytest.rb
rbconfig.rb: config.status miniruby$(binsuffix)
@./miniruby$(binsuffix) $(srcdir)/mkconfig.rb rbconfig.rb
+config.status: $(srcdir)/configure
+ $(SHELL) ./config.status --recheck
+
+$(srcdir)/configure: $(srcdir)/configure.in
+ cd $(srcdir) && $(AUTOCONF)
+
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
lex.c: keywords
- gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ keywords > lex.c
+ gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ @srcdir@/keywords > lex.c
parse.c: parse.y
$(YACC) $<
@@ -121,24 +142,30 @@ dup2.o: @srcdir@/missing/dup2.c
flock.o: @srcdir@/missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/flock.c
+memcmp.o: @srcdir@/missing/memcmp.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memcmp.c
+
memmove.o: @srcdir@/missing/memmove.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memmove.c
mkdir.o: @srcdir@/missing/mkdir.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/mkdir.c
-setenv.o: @srcdir@/missing/setenv.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/setenv.c
+vsnprintf.o: @srcdir@/missing/vsnprintf.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/vsnprintf.c
strcasecmp.o: @srcdir@/missing/strcasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strcasecmp.c
-strerror.o: @srcdir@/missing/strerror.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strerror.c
+strchr.o: @srcdir@/missing/strchr.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strchr.c
strdup.o: @srcdir@/missing/strdup.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strdup.c
+strerror.o: @srcdir@/missing/strerror.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strerror.c
+
strftime.o: @srcdir@/missing/strftime.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strftime.c
@@ -160,40 +187,43 @@ x68.o: @srcdir@/missing/x68.c
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
-parse.o : parse.y ruby.h defines.h config.h intern.h env.h node.h st.h regex.h lex.c
+parse.o: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
array.o: array.c ruby.h config.h defines.h intern.h
bignum.o: bignum.c ruby.h config.h defines.h intern.h
class.o: class.c ruby.h config.h defines.h intern.h node.h st.h
compar.o: compar.c ruby.h config.h defines.h intern.h
dir.o: dir.c ruby.h config.h defines.h intern.h
-dln.o: dln.c config.h defines.h dln.h st.h
+dln.o: dln.c config.h defines.h dln.h
dmyext.o: dmyext.c
enum.o: enum.c ruby.h config.h defines.h intern.h
error.o: error.c ruby.h config.h defines.h intern.h env.h
-eval.o: eval.c ruby.h config.h defines.h intern.h env.h node.h sig.h st.h dln.h
-file.o: file.c ruby.h config.h defines.h intern.h io.h sig.h
-gc.o: gc.c ruby.h config.h defines.h intern.h env.h sig.h st.h node.h re.h regex.h
-hash.o: hash.c ruby.h config.h defines.h intern.h st.h
+eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
+file.o: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+fnmatch.o: fnmatch.c config.h fnmatch.h
+gc.o: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
+glob.o: config.h glob.c fnmatch.h
+hash.o: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h
inits.o: inits.c ruby.h config.h defines.h intern.h
-io.o: io.c ruby.h config.h defines.h intern.h io.h sig.h
-main.o: main.c
-marshal.o: marshal.c ruby.h config.h defines.h intern.h io.h sig.h st.h
+io.o: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+main.o: main.c ruby.h config.h defines.h intern.h
+marshal.o: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
math.o: math.c ruby.h config.h defines.h intern.h
numeric.o: numeric.c ruby.h config.h defines.h intern.h
object.o: object.c ruby.h config.h defines.h intern.h st.h
pack.o: pack.c ruby.h config.h defines.h intern.h
-process.o: process.c ruby.h config.h defines.h intern.h sig.h st.h
+process.o: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
random.o: random.c ruby.h config.h defines.h intern.h
range.o: range.c ruby.h config.h defines.h intern.h
re.o: re.c ruby.h config.h defines.h intern.h re.h regex.h
-ruby.o: ruby.c ruby.h config.h defines.h intern.h re.h regex.h dln.h
-signal.o: signal.c ruby.h config.h defines.h intern.h sig.h
+regex.o: regex.c config.h regex.h util.h
+ruby.o: ruby.c ruby.h config.h defines.h intern.h dln.h util.h
+signal.o: signal.c ruby.h config.h defines.h intern.h rubysig.h
sprintf.o: sprintf.c ruby.h config.h defines.h intern.h
st.o: st.c config.h st.h
string.o: string.c ruby.h config.h defines.h intern.h re.h regex.h
struct.o: struct.c ruby.h config.h defines.h intern.h
time.o: time.c ruby.h config.h defines.h intern.h
-util.o: util.c defines.h intern.h config.h util.h
-variable.o: variable.c ruby.h config.h defines.h intern.h env.h st.h
+util.o: util.c ruby.h config.h defines.h intern.h util.h
+variable.o: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
version.o: version.c ruby.h config.h defines.h intern.h version.h
diff --git a/README b/README
index d41fb9f..dd93c59 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@
Ruby is the interpreted scripting language for quick and
easy object-oriented programming. It has many features to
process text files and to do system management tasks (as in
-perl). It is simple, straight-forward, and extensible.
+Perl). It is simple, straight-forward, and extensible.
* Features of Ruby
@@ -15,7 +15,8 @@ perl). It is simple, straight-forward, and extensible.
+ Iterators and Closures
+ Garbage Collection
+ Dynamic Loading of Object files(on some architecture)
- + Highly Portable(works on many UNIX machines)
+ + Highly Portable(works on many UNIX machines, and on DOS,
+ Windows, Mac, BeOS etc.)
* How to get Ruby
@@ -31,21 +32,26 @@ This is what you need to do to compile and install Ruby:
2. Edit defines.h if you need. Probably this step will not need.
- 3. Remove comment mark(#) before the module names from ext/Setup, if
- you want to link modules statically.
+ 3. Remove comment mark(#) before the module names from ext/Setup (or
+ add module names if not present), if you want to link modules
+ statically.
- If you want to link all the extension modules, remove comment
- mark from the line "#option nodynamic".
+ If you don't want to compile non static extension modules
+ (probably on architectures which does not allow dynamic loading),
+ remove comment mark from the line "#option nodynamic" in
+ ext/Setup.
4. Run make.
- 5. Optionally, run 'make test' to check that the compiled Ruby
- interpreter works well. If you see the message "test succeeded",
- your Ruby works as it should (hopefully).
+ 5. Optionally, run 'make test' to check whether the compiled Ruby
+ interpreter works well. If you see the message "test succeeded",
+ your ruby works as it should (hopefully).
6. Run 'make install'
-If you fail to compile Ruby, please send the detailed error report with
+ You may have to be a super user to install ruby.
+
+If you fail to compile ruby, please send the detailed error report with
the error log and machine/OS type, to help others.
* Copying
@@ -61,12 +67,13 @@ You can redistribute it and/or modify it under either the terms of the GPL
2. You may modify your copy of the software in any way, provided that
you do at least ONE of the following:
- a) place your modifications in the Public Domain or otherwise make them
- Freely Available, such as by posting said modifications to Usenet
- or an equivalent medium, or by allowing the author to include your
- modifications in the software.
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
- b) use the modified software only within your corporation or organization.
+ b) use the modified software only within your corporation or
+ organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided.
@@ -84,8 +91,7 @@ You can redistribute it and/or modify it under either the terms of the GPL
the software.
c) give non-standard executables non-standard names, with
- instructions on where to get the original software
- distribution.
+ instructions on where to get the original software distribution.
d) make other distribution arrangements with the author.
@@ -94,7 +100,7 @@ You can redistribute it and/or modify it under either the terms of the GPL
are not written by the author, so that they are not under this terms.
They are gc.c(partly), utils.c(partly), regex.[ch], fnmatch.[ch],
glob.c, st.[ch] and some files under the ./missing directory. See
- each files for the copying condition.
+ each file for the copying condition.
5. The scripts and library files supplied as input to or produced as
output from the software do not automatically fall under the
diff --git a/README.EXT b/README.EXT
index c2f81d1..f169e54 100644
--- a/README.EXT
+++ b/README.EXT
@@ -1,21 +1,16 @@
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
-This document explains how to make extention modules for ruby.
+This document explains how to make extention modules for Ruby.
1.Basic knowledge
In C, variables have types and data do not have types. In contrast,
-ruby variables do not have static type and data themselves have
+Ruby variables do not have static type and data themselves have
types. So, data need to be converted across the languages.
-Data in ruby represented C type `VALUE'. Each VALUE data have its
+Data in Ruby represented C type `VALUE'. Each VALUE data have its
data-type.
-rubyのデータはVALUEというCの型で表現されます.VALUE型のデー
-タはそのデータタイプを自分で知っています.このデータタイプと
-いうのはデータ(オブジェクト)の実際の構造を意味していて,ruby
-のクラスとはまた違ったものです.
-
To retrieve an C data from the VALUE, you need to:
(1) Identify VALUE's data type
@@ -38,7 +33,7 @@ Ruby interpreter has data-types as below:
T_ARRAY array
T_FIXNUM Fixnum(31bit integer)
T_HASH assosiative array
- T_STRUCT (ruby) structure
+ T_STRUCT (Ruby) structure
T_BIGNUM multi precision integer
T_TRUE true
T_FALSE false
@@ -89,37 +84,28 @@ There are faster check-macros for fixnums and nil.
1.3 Convert VALUE into C data
-データタイプがT_NIL, T_FALSE, T_TRUEである時,データはそれぞ
-れnil, FALSE, TRUEです.このデータタイプのオブジェクトはひと
-つずつしか存在しません.
-
-データタイプがT_FIXNUMの時,これは31bitのサイズを持つ整数で
-す.FIXNUMをCの整数に変換するためにはマクロ「FIX2INT()」を使
-います.それから,FIXNUMに限らずrubyのデータを整数に変換する
-「NUM2INT()」というマクロがあります.このマクロはデータタイ
-プのチェック無しで使えます(整数に変換できない場合には例外が
-発生する).
-
-それ以外のデータタイプは対応するCの構造体があります.対応す
-る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の
-ポインタに変換できます.
+The data for type T_NIL, T_FALSE, T_TRUE are nil, true, false
+respectively. They are singletons for the data type.
-構造体は「struct RXxxxx」という名前でruby.hで定義されていま
-す.例えば文字列は「struct RString」です.実際に使う可能性が
-あるのは文字列と配列くらいだと思います.
+The T_FIXNUM data is the 31bit length fixed integer (63bit length on
+some machines), which can be conver to the C integer by using
+FIX2INT() macro. There also be NUM2INT() which converts any Ruby
+numbers into C integer. The NUM2INT() macro includes type check, so
+the exception will be raised if conversion failed.
-ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
-字にしたもの)という名前で提供されています(例: RSTRING()).
+Other data types have corresponding C structures, e.g. struct RArray
+for T_ARRAY etc. VALUE of the type which has corresponding structure
+can be cast to retrieve the pointer to the struct. The casting macro
+RXXXX for each data type like RARRAY(obj). see "ruby.h".
-例えば,文字列strの長さを得るためには「RSTRING(str)->len」と
-し,文字列strをchar*として得るためには「RSTRING(str)->ptr」
-とします.配列の場合には,それぞれ「RARRAT(str)->len」,
-「RARRAT(str)->ptr」となります.
+For example, `RSTRING(size)->len' is the way to get the size of the
+Ruby String object. The allocated region can be accessed by
+`RSTRING(str)->ptr'. For arrays, `RARRAY(ary)->len' and
+`RARRAY(ary)->ptr' respectively.
-rubyの構造体を直接アクセスする時に気をつけなければならないこ
-とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
-ないことです.直接変更した場合,オブジェクトの内容の整合性が
-とれなくなって,思わぬバグの原因になります.
+Notice: Do not change the value of the structure directly, unless you
+are responsible about the result. It will be the cause of interesting
+bugs.
1.4 Convert C data into VALUE
@@ -137,10 +123,10 @@ VALUEの実際の構造は
うかわかるわけです(ポインタのLSBが立っていないことを仮定して
いる).
-ですから,FIXNUM以外のrubyのオブジェクトの構造体は単にVALUE
+ですから,FIXNUM以外のRubyのオブジェクトの構造体は単にVALUE
にキャストするだけでVALUEに変換出来ます.ただし,任意の構造
体がVALUEにキャスト出来るわけではありません.キャストするの
-はrubyの知っている構造体(ruby.hで定義されているstruct RXxxx
+はRubyの知っている構造体(ruby.hで定義されているstruct RXxxx
のもの)だけにしておいてください.
FIXNUMに関しては変換マクロを経由する必要があります.Cの整数
@@ -153,256 +139,241 @@ FIXNUMに関しては変換マクロを経由する必要があります.Cの整数
INT2NUM()は整数がFIXNUMの範囲に収まらない場合,Bignumに変換
してくれます(が,少し遅い).
-1.5 Manipulate ruby data
+1.5 Manipulate Ruby data
-先程も述べた通り,rubyの構造体をアクセスする時に内容の更新を
-行うことは勧められません.で,rubyのデータを操作する時には
-rubyが用意している関数を用いてください.
-
-ここではもっとも使われるであろう文字列と配列の生成/操作を行
-い関数をあげます(全部ではないです).
+As I already told, it is not recommended to modify object's internal
+structure. To manipulate objects, use functions supplied by Ruby
+interpreter. Useful functions are listed below (not all):
String funtions
- str_new(char *ptr, int len)
+ rb_str_new(char *ptr, int len)
- Creates a new ruby string.
+ Creates a new Ruby string.
- str_new2(char *ptr)
+ rb_str_new2(char *ptr)
- Creates a new ruby string from C string. This is equivalent to
- str_new(ptr, strlen(ptr)).
+ Creates a new Ruby string from C string. This is equivalent to
+ rb_str_new(ptr, strlen(ptr)).
- str_cat(VALUE str, char *ptr, int len)
+ rb_str_cat(VALUE str, char *ptr, int len)
- Appends len bytes data from ptr to the ruby string.
+ Appends len bytes data from ptr to the Ruby string.
Array functions
- ary_new()
+ rb_ary_new()
Creates an array with no element.
- ary_new2(int len)
+ rb_ary_new2(int len)
Creates an array with no element, with allocating internal buffer
for len elements.
- ary_new3(int n, ...)
+ rb_ary_new3(int n, ...)
Creates an n-elements array from arguments.
- ary_new4(int n, VALUE *elts)
+ rb_ary_new4(int n, VALUE *elts)
Creates an n-elements array from C array.
- ary_push(VALUE ary)
- ary_pop(VALUE ary, VALUE val)
- ary_shift(VALUE ary)
- ary_unshift(VALUE ary, VALUE val)
- ary_entry(VALUE ary, int idx)
+ rb_ary_push(VALUE ary, VALUE val)
+ rb_ary_pop(VALUE ary)
+ rb_ary_shift(VALUE ary)
+ rb_ary_unshift(VALUE ary, VALUE val)
+ rb_ary_entry(VALUE ary, int idx)
Array operations. The first argument to each functions must be an
array. They may dump core if other types given.
-2. Extend ruby with C
+2. Extend Ruby with C
-原理的にrubyで書けることはCでも書けます.rubyそのものがCで記
+原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
述されているんですから,当然といえば当然なんですけど.ここで
-はrubyの拡張に使うことが多いだろうと予測される機能を中心に紹
+はRubyの拡張に使うことが多いだろうと予測される機能を中心に紹
介します.
-2.1 Add new features to ruby
+2.1 Add new features to Ruby
-rubyで提供されている関数を使えばrubyインタプリタに新しい機能
-を追加することができます.rubyでは以下の機能を追加する関数が
+Rubyで提供されている関数を使えばRubyインタプリタに新しい機能
+を追加することができます.Rubyでは以下の機能を追加する関数が
提供されています.
- * クラス,モジュール
- * メソッド,特異メソッドなど
- * 定数
+ * Classes, Modules
+ * Methods, Singleton Methods
+ * Constants
では順に紹介します.
2.1.1 Class/module definition
-クラスやモジュールを定義するためには,以下の関数を使います.
+To define class or module, use functions below:
VALUE rb_define_class(char *name, VALUE super)
VALUE rb_define_module(char *name)
-これらの関数は新しく定義されたクラスやモジュールを返します.
-メソッドや定数の定義にこれらの値が必要なので,ほとんどの場合
-は戻り値を変数に格納しておく必要があるでしょう.
+These functions return the newly created class ot module. You may
+want to save this reference into the variable to use later.
2.1.2 Method/singleton method definition
-メソッドや特異メソッドを定義するには以下の関数を使います.
+To define methods or singleton methods, use functions below:
void rb_define_method(VALUE class, char *name,
VALUE (*func)(), int argc)
void rb_define_singleton_method(VALUE object, char *name,
- VALUE (*func)(), int argc)
+ VALUE (*func)(), int argc)
+The `argc' represents the number of the arguments to the C function,
+which must be less than 17. But I believe you don't need that much. :-)
-念のため説明すると「特異メソッド」とは,その特定のオブジェク
-トに対してだけ有効なメソッドです.rubyではよくSmalltalkにお
-けるクラスメソッドとして,クラスに対する特異メソッドが使われ
-ます.
+If `argc' is negative, it specifies calling sequence, not number of
+the arguments.
+
+If argc is -1, the function will be called like:
-これらの関数の argcという引数はCの関数へ渡される引数の数(と
-形式)を決めます.argcが正の時は関数に引き渡す引数の数を意味
-します.16個以上の引数は使えません(が,要りませんよね,そん
-なに).
+ VALUE func(int argc, VALUE *argv, VALUE obj)
-argcが負の時は引数の数ではなく,形式を指定したことになります.
-argcが-1の時は引数を配列に入れて渡されます.argcが-2の時は引
-数はrubyの配列として渡されます.
+where argc is the actual number of arguments, argv is the C array of
+the arguments, and obj is the receiver.
-メソッドを定義する関数はもう二つあります.ひとつはprivateメ
-ソッドを定義する関数で,引数はrb_define_method()と同じです.
+if argc is -2, the arguments are passed in Ruby array. The function
+will be called like:
+
+ VALUE func(VALUE obj, VALUE args)
+
+where obj is the receiver, and args is the Ruby array containing
+actual arguments.
+
+There're two more functions to define method. One is to define
+private method:
void rb_define_private_method(VALUE class, char *name,
VALUE (*func)(), int argc)
-privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ
-ドです.
-
-もうひとつはモジュール関数を定義するものです.モジュール関数
-とはモジュールの特異メソッドであり,同時にprivateメソッドで
-もあるものです.例をあげるとMathモジュールのsqrt()などがあげ
-られます.このメソッドは
+The other is to define module function, which is private AND singleton
+method of the module. For example, sqrt is the module function
+defined in Math module. It can be call in the form like:
Math.sqrt(4)
-という形式でも
+or
include Math
sqrt(4)
-という形式でも使えます.モジュール関数を定義する関数は以下の
-通りです.
+To define module function
void rb_define_module_function(VALUE module, char *name,
VALUE (*func)(), int argc)
-関数的メソッド(Kernelモジュールのprivaet method)を定義するた
-めの関数は以下の通りです.
+Oh, in addition, function-like method, which is private method defined
+in Kernel module, can be defined using:
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
2.1.3 Constant definition
-拡張モジュールが必要な定数はあらかじめ定義しておいた方が良い
-でしょう.定数を定義する関数は二つあります.
+We have 2 functions to define constants:
void rb_define_const(VALUE class, char *name, VALUE val)
void rb_define_global_const(char *name, VALUE val)
-前者は特定のクラス/モジュールに属する定数を定義するもの,後
-者はグローバルな定数を定義するものです.
-
-2.2 Use ruby features from C
+The former is to define constant under specified class/module. The
+latter is to define global constant.
-既に『1.5 rubyのデータを操作する』で一部紹介したような関数を
-使えば,rubyの機能を実現している関数を直接呼び出すことが出来
-ます.
-
-# このような関数の一覧表はいまのところありません.ソースを見
-# るしかないですね.
+2.2 Use Ruby features from C
-それ以外にもrubyの機能を呼び出す方法はいくつかあります.
+There are several ways to invoke Ruby's features from C code.
-2.2.1 rubyのプログラムをevalする
+2.2.1 Evaluate Ruby Program in String
-Cからrubyの機能を呼び出すもっとも簡単な方法として,文字列で
-与えられたrubyのプログラムを評価する関数があります.
+Easiest way to call Ruby's function from C program is to evaluate the
+string as Ruby program. This function will do the job.
VALUE rb_eval_string(char *str)
-この評価は現在の環境で行われます.つまり,現在のローカル変数
-などを受け継ぎます.
+Evaluation is done under current context, thus current local variables
+of the innermost method (which is defined by Ruby) can be accessed.
2.2.2 ID or Symbol
-Cから文字列を経由せずにrubyのメソッドを呼び出すこともできま
-す.その前に,rubyインタプリタ内でメソッドや変数名を指定する
-時に使われているIDについて説明しておきましょう.
-
-IDとは変数名,メソッド名を表す整数です.rubyの中では
+You can invoke methods directly, without parsing the string. First I
+need to explain about symbols (which data type is ID). ID is the
+integer number to represent Ruby's identifiers such as variable names.
+It can be accessed from Ruby in the form like:
- :識別子
+ :Identifier
-でアクセスできます.Cからこの整数を得るためには関数
+You can get the symbol value from string within C code, by using
rb_intern(char *name)
-を使います.また一文字の演算子はその文字コードがそのままシン
-ボルになっています.
+In addition, the symbols for one character operators (e.g +) is the
+code for that character.
-2.2.3 Invoke ruby method from C
+2.2.3 Invoke Ruby method from C
-Cから文字列を経由せずにrubyのメソッドを呼び出すためには以下
-の関数を使います.
+To invoke methods directly, you can use the function below
VALUE rb_funcall(VALUE recv, ID mid, int argc, ...)
-この関数はオブジェクトrecvのmidで指定されるメソッドを呼び出
-します.
+This function invokes the method of the recv, which name is specified
+by the symbol mid.
-2.2.4 変数/定数を参照/更新する
+2.2.4 Accessing the variables and constants
Cから関数を使って参照・更新できるのは,クラス定数,インスタ
ンス変数です.大域変数は一部のものはCの大域変数としてアクセ
スできます.ローカル変数を参照する方法は公開していません.
-オブジェクトのインスタンス変数を参照・更新する関数は以下の通
-りです.
+The functions to access/modify instance variables are below:
VALUE rb_ivar_get(VALUE obj, ID id)
VALUE rb_ivar_set(VALUE obj, ID id, VALUE val)
-idはrb_intern()で得られるものを使ってください.
+id must be the symbol, which can be retrieved by rb_intern().
-クラス定数を参照するには以下の関数を使ってください.
+To access the constants of the class/module:
VALUE rb_const_get(VALUE obj, ID id)
-クラス定数を新しく定義するためには『2.1.3 定数定義』で紹介さ
-れている関数を使ってください.
+See 2.1.3 for defining new constant.
-3. Informatin sharing between ruby and C
+3. Informatin sharing between Ruby and C
-C言語とrubyの間で情報を共有する方法について解説します.
+C言語とRubyの間で情報を共有する方法について解説します.
-3.1 Ruby constant that Cから参照できるrubyの定数
+3.1 Ruby constant that Cから参照できるRubyの定数
-Following ruby constants can be referred from C.
+Following Ruby constants can be referred from C.
- TRUE
- FALSE
+ Qtrue
+ Qfalse
-Boolean values. FALSE is false in the C also (i.e. 0).
+Boolean values. Qfalse is false in the C also (i.e. 0).
Qnil
Ruby nil in C scope.
-3.2 Global variables shared between C and ruby
+3.2 Global variables shared between C and Ruby
-Cとrubyで大域変数を使って情報を共有できます.共有できる大域
+CとRubyで大域変数を使って情報を共有できます.共有できる大域
変数にはいくつかの種類があります.そのなかでもっとも良く使わ
れると思われるのはrb_define_variable()です.
void rb_define_variable(char *name, VALUE *var)
-この関数はrubyとCとで共有する大域変数を定義します.変数名が
+この関数はRubyとCとで共有する大域変数を定義します.変数名が
`$'で始まらない時には自動的に追加されます.この変数の値を変
-更すると自動的にrubyの対応する変数の値も変わります.
+更すると自動的にRubyの対応する変数の値も変わります.
-またruby側からは更新できない変数もあります.このread onlyの
+またRuby側からは更新できない変数もあります.このread onlyの
変数は以下の関数で定義します.
void rb_define_readonly_variable(char *name, VALUE *var)
@@ -421,13 +392,13 @@ setterに0を指定します.
# getterもsetterも0ならばrb_define_variable()と同じになる.
-それから,Cの関数によって実現されるrubyの大域変数を定義する
+それから,Cの関数によって実現されるRubyの大域変数を定義する
関数があります.
void rb_define_virtual_variable(char *name,
VALUE (*getter)(), VALUE (*setter)())
-この関数によって定義されたrubyの大域変数が参照された時には
+この関数によって定義されたRubyの大域変数が参照された時には
getterが,変数に値がセットされた時にはsetterが呼ばれます.
The prototypes of the getter and setter functions are as following:
@@ -435,14 +406,14 @@ The prototypes of the getter and setter functions are as following:
(*getter)(ID id, void *data, struct global_entry* entry);
(*setter)(VALUE val, ID id, void *data, struct global_entry* entry);
-3.3 Encapsulate C data into ruby object
+3.3 Encapsulate C data into Ruby object
-Cの世界で定義されたデータ(構造体)をrubyのオブジェクトとして
+Cの世界で定義されたデータ(構造体)をRubyのオブジェクトとして
取り扱いたい場合がありえます.このような場合には,Dataという
-rubyオブジェクトにCの構造体(へのポインタ)をくるむことでruby
+RubyオブジェクトにCの構造体(へのポインタ)をくるむことでRuby
オブジェクトとして取り扱えるようになります.
-Dataオブジェクトを生成して構造体をrubyオブジェクトにカプセル
+Dataオブジェクトを生成して構造体をRubyオブジェクトにカプセル
化するためには,以下のマクロを使います.
Data_Wrap_Struct(class,mark,free,ptr)
@@ -450,7 +421,7 @@ Dataオブジェクトを生成して構造体をrubyオブジェクトにカプセル
このマクロの戻り値は生成されたDataオブジェクトです.
classはこのDataオブジェクトのクラスです.ptrはカプセル化する
-Cの構造体へのポインタです.markはこの構造体がrubyのオブジェ
+Cの構造体へのポインタです.markはこの構造体がRubyのオブジェ
クトへの参照がある時に使う関数です.そのような参照を含まない
時には0を指定します.
@@ -482,47 +453,38 @@ Cの構造体へのポインタは変数svalに代入されます.
4.Example - Create dbm module
-ここまでの説明でとりあえず拡張モジュールは作れるはずです.
-rubyのextディレクトリにすでに含まれているdbmモジュールを例に
+ここまでの説明でとりあえず拡張ライブラリは作れるはずです.
+Rubyのextディレクトリにすでに含まれているdbmモジュールを例に
して段階的に説明します.
(1) make the directory
% mkdir ext/dbm
-rubyを展開したディレクトリの下,extディレクトリの中に拡張モ
-ジュール用のディレクトリを作ります.名前は適当に選んで構いま
-せん.
+Make a directory for the extension library under ext directory.
(2) create MANIFEST file
% cd ext/dbm
% touch MANIFEST
-拡張モジュールのディレクトリの下にはMANIFESTというファイルが
-必要なので,とりあえず空のファイルを作っておきます.後でこの
-ファイルには必要なファイル一覧が入ることになります.
-
-MANIFESTというファイルは,makeの時にディレクトリが拡張モジュー
-ルを含んでいるかどうか判定するために使われれています.
+There should be MANIFEST file in the directory for the extension
+library. Make empty file now.
(3) design the library
-まあ,当然なんですけど,どういう機能を実現するかどうかまず設
-計する必要があります.どんなクラスをつくるか,そのクラスには
-どんなメソッドがあるか,クラスが提供する定数などについて設計
-します.dbmクラスについてはext/dbm.docを参照してください.
+You need to design the library features, before making it.
(4) write C code.
-拡張モジュール本体となるC言語のソースを書きます.C言語のソー
+拡張ライブラリ本体となるC言語のソースを書きます.C言語のソー
スがひとつの時には「モジュール名.c」を選ぶと良いでしょう.C
言語のソースが複数の場合には逆に「モジュール名.c」というファ
イル名は避ける必要があります.オブジェクトファイルとモジュー
ル生成時に中間的に生成される「モジュール名.o」というファイル
とが衝突するからです.
-rubyは拡張モジュールをロードする時に「Init_モジュール名」と
+Rubyは拡張ライブラリをロードする時に「Init_モジュール名」と
いう関数を自動的に実行します.dbmモジュールの場合「Init_dbm」
です.この関数の中でクラス,モジュール,メソッド,定数などの
定義を行います.dbm.cから一部引用します.
@@ -530,27 +492,25 @@ rubyは拡張モジュールをロードする時に「Init_モジュール名」と
--
Init_dbm()
{
- /* DBMクラスを定義する */
- cDBM = rb_define_class("DBM", cObject);
- /* DBMはEnumerateモジュールをインクルードする */
- rb_include_module(cDBM, mEnumerable);
+ /* define DBM class */
+ cDBM = rb_define_class("DBM", rb_cObject);
+ /* DBM includes Enumerate module */
+ rb_include_module(cDBM, rb_mEnumerable);
- /* DBMクラスのクラスメソッドopen(): 引数はCの配列で受ける */
+ /* DBM has class method open(): arguments are received as C array */
rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
- /* DBMクラスのメソッドclose(): 引数はなし */
+ /* DBM instance method close(): no args */
rb_define_method(cDBM, "close", fdbm_close, 0);
- /* DBMクラスのメソッド[]: 引数は1個 */
+ /* DBM instance method []: 1 argument */
rb_define_method(cDBM, "[]", fdbm_fetch, 1);
:
- /* DBMデータを格納するインスタンス変数名のためのID */
- id_dbm = rb_intern("dbm");
}
--
DBMモジュールはdbmのデータと対応するオブジェクトになるはずで
-すから,Cの世界のdbmをrubyの世界に取り込む必要があります.
+すから,Cの世界のdbmをRubyの世界に取り込む必要があります.
dbm.cではData_Make_Structを以下のように使っています.
@@ -600,7 +560,7 @@ fdbm_delete(obj, keystr)
引数の数が固定のタイプは第1引数がself,第2引数以降がメソッド
の引数となります.
-引数の数が不定のものはCの配列で受けるものとrubyの配列で受け
+引数の数が不定のものはCの配列で受けるものとRubyの配列で受け
るものとがあります.dbmモジュールの中で,Cの配列で受けるもの
はDBMのクラスメソッドであるopen()です.これを実装している関
数fdbm_s_open()はこうなっています.
@@ -634,7 +594,7 @@ fdbm_s_open(argc, argv, class)
で,2つまで許されるという意味になります.省略されている時の
変数の値はnil(C言語のレベルではQnil)になります.
-rubyの配列で引数を受け取るものはindexesがあります.実装はこ
+Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
うです.
--
@@ -647,15 +607,14 @@ fdbm_indexes(obj, args)
}
--
-第1引数はself,第2引数はrubyの配列です.ここではキャストを減
+第1引数はself,第2引数はRubyの配列です.ここではキャストを減
らすため struct RArray* で受けていますが,VALUEでも同じこと
です.
-** 注意事項
+** Notice
-rubyと共有はしないがrubyのオブジェクトを格納する可能性のある
-Cの大域変数は以下の関数を使ってrubyインタプリタに変数の存在
-を教えてあげてください.でないとGCでトラブルを起こします.
+GC should know about global variables which refers Ruby's objects, but
+not exported to the Ruby world. You need to protect them by
void rb_global_variable(VALUE *var)
@@ -665,7 +624,7 @@ Cの大域変数は以下の関数を使ってrubyインタプリタに変数の存在
make時に実行されます.なければ適当にMakefileが生成されます.
extconf.rbはモジュールのコンパイルに必要な条件のチェックなど
-を行うことが目的です.extconf.rbの中では以下のruby関数を使う
+を行うことが目的です.extconf.rbの中では以下のRuby関数を使う
ことが出来ます.
have_library(lib, func): ライブラリの存在チェック
@@ -704,31 +663,31 @@ make時にはMANIFESTの内容は参照しませんので,空のままでも問題
(8) make
-rubyのディレクトリでmakeを実行するとMakefileを生成からmake,
-必要によってはそのモジュールのrubyへのリンクまで自動的に実行
+Rubyのディレクトリでmakeを実行するとMakefileを生成からmake,
+必要によってはそのモジュールのRubyへのリンクまで自動的に実行
してくれます.extconf.rbを書き換えるなどしてMakefileの再生成
-が必要な時はまたrubyディレクトリでmakeしてください.
+が必要な時はまたRubyディレクトリでmakeしてください.
(9) debug
-まあ,デバッグしないと動かないでしょうね.ext/Setupにディレ
-クトリ名を書くと静的にリンクするのでデバッガが使えるようにな
-ります.その分コンパイルが遅くなりますけど.
+You may need to rb_debug the module. The modules can be linked
+statically by adding directory name in the ext/Setup file,
+so that you can inspect the module by the debugger.
-(10) done, now you have the extension module
+(10) done, now you have the extension library
後はこっそり使うなり,広く公開するなり,売るなり,ご自由にお
-使いください.rubyの作者は拡張モジュールに関して一切の権利を
+使いください.Rubyの作者は拡張ライブラリに関して一切の権利を
主張しません.
-Appendix A. rubyのソースコードの分類
+Appendix A. Rubyのソースコードの分類
-rubyのソースはいくつかに分類することが出来ます.このうちクラ
-スライブラリの部分は基本的に拡張モジュールと同じ作り方になっ
+Rubyのソースはいくつかに分類することが出来ます.このうちクラ
+スライブラリの部分は基本的に拡張ライブラリと同じ作り方になっ
ています.これらのソースは今までの説明でほとんど理解できると
思います.
-coore ruby language
+ruby language core
class.c
error.c
@@ -780,13 +739,13 @@ class library
Appendix B. 拡張用関数リファレンス
-C言語からrubyの機能を利用するAPIは以下の通りである.
+C言語からRubyの機能を利用するAPIは以下の通りである.
** 型
VALUE
-rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
+Rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
組み込み型を表現するCの型はruby.hに記述してあるRで始まる構造
体である.VALUE型をこれらにキャストするためにRで始まる構造体
名を全て大文字にした名前のマクロが用意されている.
@@ -797,21 +756,21 @@ rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
const: nil object
- TRUE
+ Qtrue
-const: TRUE object(default true value)
+const: Qtrue object(default true value)
- FALSE
+ Qfalse
-const: FALSE object
+const: Qfalse object
** Cデータのカプセル化
Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
-Cの任意のポインタをカプセル化したrubyオブジェクトを返す.こ
-のポインタがrubyからアクセスされなくなった時,freeで指定した
-関数が呼ばれる.また,このポインタの指すデータが他のrubyオブ
+Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
+のポインタがRubyからアクセスされなくなった時,freeで指定した
+関数が呼ばれる.また,このポインタの指すデータが他のRubyオブ
ジェクトを指している場合,markに指定する関数でマークする必要
がある.
@@ -828,20 +787,20 @@ dataからtype型のポインタを取り出し変数svalに代入するマクロ.
VALUE rb_define_class(char *name, VALUE super)
-superのサブクラスとして新しいrubyクラスを定義する.
+superのサブクラスとして新しいRubyクラスを定義する.
VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
-superのサブクラスとして新しいrubyクラスを定義し,moduleの定
+superのサブクラスとして新しいRubyクラスを定義し,moduleの定
数として定義する.
VALUE rb_define_module(char *name)
-新しいrubyモジュールを定義する.
+新しいRubyモジュールを定義する.
VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
-新しいrubyモジュールを定義し,moduleの定数として定義する.
+新しいRubyモジュールを定義し,moduleの定数として定義する.
void rb_include_module(VALUE class, VALUE module)
@@ -852,61 +811,70 @@ superのサブクラスとして新しいrubyクラスを定義し,moduleの定
オブジェクトをモジュール(で定義されているメソッド)で拡張する.
-** 大域変数定義
+** Defining Global Variables
void rb_define_variable(char *name, VALUE *var)
-rubyとCとで共有するグローバル変数を定義する.変数名が`$'で始
-まらない時には自動的に追加される.nameとしてrubyの識別子とし
-て許されない文字(例えば` ')を含む場合にはrubyプログラムから
-は見えなくなる.
+Defines a global variable which is shared between C and Ruby. If name
+contains the character which is not allowed to be part of the symbol,
+it can't be seen from Ruby programs.
void rb_define_readonly_variable(char *name, VALUE *var)
-rubyとCとで共有するread onlyのグローバル変数を定義する.read
-onlyであること以外はrb_define_variable()と同じ.
+Defines a read-only global variable. Works just like
+rb_define_variable(), except defined variable is read-only.
void rb_define_virtual_variable(char *name,
VALUE (*getter)(), VALUE (*setter)())
-関数によって実現されるruby変数を定義する.変数が参照された時
-にはgetterが,変数に値がセットされた時にはsetterが呼ばれる.
+Defines a virtual variable, whose behavior is defined by pair of C
+functions. The getter function is called when the variable is
+referred. The setter function is called when the value is set to the
+variable. The prototype for getter/setter functions are:
+
+ VALUE getter(ID id)
+ void setter(VALUE val, ID id)
+
+The getter function must return the value for the access.
void rb_define_hooked_variable(char *name, VALUE *var,
VALUE (*getter)(), VALUE (*setter)())
-関数によってhookのつけられたグローバル変数を定義する.変数が
-参照された時にはgetterが,関数に値がセットされた時にはsetter
-が呼ばれる.getterやsetterに0を指定した時にはhookを指定しな
-いのと同じ事になる.
+Defines hooked variable. It's virtual variable with C variable. The
+getter is called as
+
+ VALUE getter(ID id, VALUE *var)
+
+returning new value. The setter is called as
+
+ void setter(VALUE val, ID id, VALUE *var)
+
+GC requires to mark the C global variables which hold Ruby values.
void rb_global_variable(VALUE *var)
-GCのため,rubyプログラムからはアクセスされないが, rubyオブジェ
-クトを含む大域変数をマークする.
+Tells GC to protect these variables.
-** クラス定数
+** Constant Definition
- void rb_define_const(VALUE class, char *name, VALUE val)
+ void rb_define_const(VALUE klass, char *name, VALUE val)
-クラス定数を定義する.
+Defines a new constant under the class/module.
void rb_define_global_const(char *name, VALUE val)
-大域定数を定義する.
+Defines global contant. This is just work as
rb_define_const(cKernal, name, val)
-と同じ意味.
-
-** メソッド定義
+** Method Definition
rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc)
メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2引
数とする形式で与えられる(第3引数はself).argcが-2の時, 第1引
-数がself, 第2引数がargs(argsは引数を含むrubyの配列)という形
+数がself, 第2引数がargs(argsは引数を含むRubyの配列)という形
式で与えられる.
rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc)
@@ -927,7 +895,7 @@ argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
数に対応する引数が与えられていない場合は変数にQnilが代入され
る.
-** rubyメソッド呼び出し
+** Rubyメソッド呼び出し
VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
@@ -939,7 +907,7 @@ argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
VALUE rb_eval_string(char *str)
-文字列をrubyとスクリプトしてコンパイル・実行する.
+文字列をRubyとスクリプトしてコンパイル・実行する.
ID rb_intern(char *name)
@@ -959,7 +927,7 @@ classの名前を返す(デバッグ用).classが名前を持たない時には,
VALUE rb_iv_get(VALUE obj, char *name)
objのインスタンス変数の値を得る.`@'で始まらないインスタンス
-変数は rubyプログラムからアクセスできない「隠れた」インスタ
+変数は Rubyプログラムからアクセスできない「隠れた」インスタ
ンス変数になる.
VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
@@ -993,69 +961,66 @@ valを値としてイテレータブロックを呼び出す.
** 例外・エラー
- void Warning(char *fmt, ...)
+ void rb_warning(char *fmt, ...)
-verbose時に標準エラー出力に警告情報を表示する.引数はprintf()と同じ.
+rb_verbose時に標準エラー出力に警告情報を表示する.引数はprintf()と同じ.
- void Fail(char *fmt, ...)
+ void rb_raise(rb_eRuntimeError, char *fmt, ...)
例外を発生させる.引数はprintf()と同じ.
- void Fatal(char *fmt, ...)
+ void rb_fatal(char *fmt, ...)
致命的例外を発生させる.通常の例外処理は行なわれず, インター
プリタが終了する(ただしensureで指定されたコードは終了前に実
行される).
- void Bug(char *fmt, ...)
+ void rb_bug(char *fmt, ...)
インタープリタなどプログラムのバグでしか発生するはずのない状
況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.例外
処理は一切行なわれない.
-** rubyの初期化・実行
+** Initialize and Starts the Interpreter
-rubyをアプリケーションに埋め込む場合には以下のインタフェース
-を使う.通常の拡張モジュールには必要ない.
+The embedding API are below (not needed for extension libraries):
void ruby_init(int argc, char **argv, char **envp)
-rubyインタプリタの初期化を行なう.
+Initializes the interpreter.
void ruby_run()
-rubyインタプリタを実行する.
+Starts execution of the interpreter.
void ruby_script(char *name)
-rubyのスクリプト名($0)を設定する.
+Specifies the name of the script ($0).
-Appendix B. extconf.rbで使える関数たち
+Appendix B. Functions Available in extconf.rb
extconf.rbの中では利用可能なコンパイル条件チェックの関数は以
下の通りである.
have_library(lib, func)
-関数funcを定義しているライブラリlibの存在をチェックする.ラ
-イブラリが存在する時,TRUEを返す.
+Checks whether library which contains specified function exists.
+Returns true if the library exists.
have_func(func)
-関数funcの存在をチェックする.funcが標準ではリンクされないラ
-イブラリ内のものである時には先にhave_libraryでそのライブラリ
-をチェックしておく事.関数が存在する時TRUEを返す.
+Checks whether func exists. Returns true if the function exists. To
+check functions in the additional library, you need to check that
+library first using have_library().
have_header(header)
-ヘッダファイルの存在をチェックする.ヘッダファイルが存在する
-時TRUEを返す.
+Checks for the header files. Returns true if the header file exists.
create_makefile(target)
-拡張モジュール用のMakefileを生成する.この関数を呼ばなければ
-そのモジュールはコンパイルされない.targetはモジュール名を表
-す.
+Generates the Makefile for the extension library. If you don't invoke
+this method, the compilation will not be done.
/*
* Local variables:
diff --git a/README.EXT.jp b/README.EXT.jp
new file mode 100644
index 0000000..87175be
--- /dev/null
+++ b/README.EXT.jp
@@ -0,0 +1,1147 @@
+.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
+
+Rubyの拡張ライブラリの作り方を説明します.
+
+1.基礎知識
+
+Cの変数には型があり,データには型がありません.ですから,た
+とえばポインタをintの変数に代入すると,その値は整数として取
+り扱われます.逆にRubyの変数には型がなく,データに型がありま
+す.この違いのため,CとRubyは相互に変換しなければ,お互いの
+データをアクセスできません.
+
+RubyのデータはVALUEというCの型で表現されます.VALUE型のデー
+タはそのデータタイプを自分で知っています.このデータタイプと
+いうのはデータ(オブジェクト)の実際の構造を意味していて,Ruby
+のクラスとはまた違ったものです.
+
+VALUEからCにとって意味のあるデータを取り出すためには
+
+ (1) VALUEのデータタイプを知る
+ (2) VALUEをCのデータに変換する
+
+の両方が必要です.(1)を忘れると間違ったデータの変換が行われ
+て,最悪プログラムがcore dumpします.
+
+1.1 データタイプ
+
+Rubyにはユーザが使う可能性のある以下のタイプがあります.
+
+ T_NIL nil
+ T_OBJECT 通常のオブジェクト
+ T_CLASS クラス
+ T_MODULE モジュール
+ T_FLOAT 浮動小数点数
+ T_STRING 文字列
+ T_REGEXP 正規表現
+ T_ARRAY 配列
+ T_FIXNUM Fixnum(31bit長整数)
+ T_HASH 連想配列
+ T_STRUCT (Rubyの)構造体
+ T_BIGNUM 多倍長整数
+ T_FILE 入出力
+ T_TRUE 真
+ T_FALSE 偽
+ T_DATA データ
+
+その他に内部で利用されている以下のタイプがあります.
+
+ T_ICLASS
+ T_MATCH
+ T_VARMAP
+ T_SCOPE
+ T_NODE
+
+ほとんどのタイプはCの構造体で実装されています.
+
+1.2 VALUEのデータタイプをチェックする
+
+ruby.hではTYPE()というマクロが定義されていて,VALUEのデータ
+タイプを知ることが出来ます.TYPE()マクロは上で紹介したT_XXXX
+の形式の定数を返します.VALUEのデータタイプに応じて処理する
+場合には,TYPE()の値で分岐することになります.
+
+ switch (TYPE(obj)) {
+ case T_FIXNUM:
+ /* FIXNUMの処理 */
+ break;
+ case T_STRING:
+ /* 文字列の処理 */
+ break;
+ case T_ARRAY:
+ /* 配列の処理 */
+ break;
+ default:
+ /* 例外を発生させる */
+ TypeError("not valid value");
+ break;
+ }
+
+それとデータタイプをチェックして,正しくなければ例外を発生す
+る関数が用意されています.
+
+ void Check_Type(VALUE value, int type)
+
+この関数はvalueがtypeで無ければ,例外を発生させます.引数と
+して与えられたVALUEのデータタイプが正しいかどうかチェックす
+るためには,この関数を使います.
+
+FIXNUMとNILに関してはより高速な判別マクロが用意されています.
+
+ FIXNUM_P(obj)
+ NIL_P(obj)
+
+1.3 VALUEをCのデータに変換する
+
+データタイプがT_NIL, T_FALSE, T_TRUEである時,データはそれぞ
+れnil, false, trueです.このデータタイプのオブジェクトはひと
+つずつしか存在しません.
+
+データタイプがT_FIXNUMの時,これは31bitのサイズを持つ整数で
+す.FIXNUMをCの整数に変換するためにはマクロ「FIX2INT()」を使
+います.それから,FIXNUMに限らずRubyのデータを整数に変換する
+「NUM2INT()」というマクロがあります.このマクロはデータタイ
+プのチェック無しで使えます(整数に変換できない場合には例外が
+発生する).
+
+同様にチェック無しで使える変換マクロはdoubleを取り出す
+「NUM2DBL()」とchar*を取り出す「STR2CSTR()」があります.
+
+それ以外のデータタイプは対応するCの構造体があります.対応す
+る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の
+ポインタに変換できます.
+
+構造体は「struct RXxxxx」という名前でruby.hで定義されていま
+す.例えば文字列は「struct RString」です.実際に使う可能性が
+あるのは文字列と配列くらいだと思います.
+
+ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
+字にしたもの)という名前で提供されています(例: RSTRING()).
+
+例えば,文字列strの長さを得るためには「RSTRING(str)->len」と
+し,文字列strをchar*として得るためには「RSTRING(str)->ptr」
+とします.配列の場合には,それぞれ「RARRAY(ary)->len」,
+「RARRAY(ary)->ptr」となります.
+
+Rubyの構造体を直接アクセスする時に気をつけなければならないこ
+とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
+ないことです.直接変更した場合,オブジェクトの内容の整合性が
+とれなくなって,思わぬバグの原因になります.
+
+1.4 CのデータをVALUEに変換する
+
+VALUEの実際の構造は
+
+ * FIXNUMの場合
+
+ 1bit右シフトして,LSBを立てる.
+
+ * その他のポインタの場合
+
+ そのままVALUEにキャストする.
+
+となっています.よって,LSBをチェックすればVALUEがFIXNUMかど
+うかわかるわけです(ポインタのLSBが立っていないことを仮定して
+いる).
+
+ですから,FIXNUM以外のRubyのオブジェクトの構造体は単にVALUE
+にキャストするだけでVALUEに変換出来ます.ただし,任意の構造
+体がVALUEにキャスト出来るわけではありません.キャストするの
+はRubyの知っている構造体(ruby.hで定義されているstruct RXxxx
+のもの)だけです.
+
+FIXNUMに関しては変換マクロを経由する必要があります.Cの整数
+からVALUEに変換するマクロは以下のものがあります.必要に応じ
+て使い分けてください.
+
+ INT2FIX() もとの整数が31bit以内に収まる自信がある時
+ INT2NUM() 任意の整数からVALUEへ
+
+INT2NUM()は整数がFIXNUMの範囲に収まらない場合,Bignumに変換
+してくれます(が,少し遅い).
+
+1.5 Rubyのデータを操作する
+
+先程も述べた通り,Rubyの構造体をアクセスする時に内容の更新を
+行うことは勧められません.で,Rubyのデータを操作する時には
+Rubyが用意している関数を用いてください.
+
+ここではもっとも使われるであろう文字列と配列の生成/操作を行
+い関数をあげます(全部ではないです).
+
+ 文字列に対する関数
+
+ rb_str_new(char *ptr, int len)
+
+ 新しいRubyの文字列を生成する.
+
+ rb_str_new2(char *ptr)
+
+ Cの文字列からRubyの文字列を生成する.この関数の機能は
+ rb_str_new(ptr, strlen(ptr))と同等である.
+
+ rb_str_cat(VALUE str, char *ptr, int len)
+
+ Rubyの文字列strにlenバイトの文字列ptrを追加する.
+
+ 配列に対する関数
+
+ rb_ary_new()
+
+ 要素が0の配列を生成する.
+
+ rb_ary_new2(int len)
+
+ 要素が0の配列を生成する.len要素分の領域をあらかじめ割り
+ 当てておく.
+
+ rb_ary_new3(int n, ...)
+
+ 引数で指定したn要素を含む配列を生成する.
+
+ rb_ary_new4(int n, VALUE *elts)
+
+ 配列で与えたn要素の配列を生成する.
+
+ rb_ary_push(VALUE ary, VALUE val)
+ rb_ary_pop(VALUE ary)
+ rb_ary_shift(VALUE ary)
+ rb_ary_unshift(VALUE ary, VALUE val)
+ rb_ary_entry(VALUE ary, int idx)
+
+ Arrayの同名のメソッドと同じ働きをする関数.第1引数は必ず
+ 配列でなければならない.
+
+2.Rubyの機能を使う
+
+原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
+述されているんですから,当然といえば当然なんですけど.ここで
+はRubyの拡張に使うことが多いだろうと予測される機能を中心に紹
+介します.
+
+2.1 Rubyに機能を追加する
+
+Rubyで提供されている関数を使えばRubyインタプリタに新しい機能
+を追加することができます.Rubyでは以下の機能を追加する関数が
+提供されています.
+
+ * クラス,モジュール
+ * メソッド,特異メソッドなど
+ * 定数
+
+では順に紹介します.
+
+2.1.1 クラス/モジュール定義
+
+クラスやモジュールを定義するためには,以下の関数を使います.
+
+ VALUE rb_define_class(char *name, VALUE super)
+ VALUE rb_define_module(char *name)
+
+これらの関数は新しく定義されたクラスやモジュールを返します.
+メソッドや定数の定義にこれらの値が必要なので,ほとんどの場合
+は戻り値を変数に格納しておく必要があるでしょう.
+
+クラスやモジュールを他のクラスの内部にネストして定義する時に
+は以下の関数を使います.
+
+ VALUE rb_define_class(VALUE outer, char *name, VALUE super)
+ VALUE rb_define_module(VALUE outer, char *name)
+
+2.1.2 メソッド/特異メソッド定義
+
+メソッドや特異メソッドを定義するには以下の関数を使います.
+
+ void rb_define_method(VALUE class, char *name,
+ VALUE (*func)(), int argc)
+
+ void rb_define_singleton_method(VALUE object, char *name,
+ VALUE (*func)(), int argc)
+
+
+念のため説明すると「特異メソッド」とは,その特定のオブジェク
+トに対してだけ有効なメソッドです.RubyではよくSmalltalkにお
+けるクラスメソッドとして,クラスに対する特異メソッドが使われ
+ます.
+
+これらの関数の argcという引数はCの関数へ渡される引数の数(と
+形式)を決めます.argcが正の時は関数に引き渡す引数の数を意味
+します.16個以上の引数は使えません(が,要りませんよね,そん
+なに).実際の関数には先頭の引数としてselfが与えられますので,
+指定した数より1多い引数を持つことになります.
+
+argcが負の時は引数の数ではなく,形式を指定したことになります.
+argcが-1の時は引数を配列に入れて渡されます.argcが-2の時は引
+数はRubyの配列として渡されます.
+
+メソッドを定義する関数はもう二つあります.ひとつはprivateメ
+ソッドを定義する関数で,引数はrb_define_method()と同じです.
+
+ void rb_define_private_method(VALUE class, char *name,
+ VALUE (*func)(), int argc)
+
+privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ
+ドです.
+
+もうひとつはモジュール関数を定義するものです.モジュール関数
+とはモジュールの特異メソッドであり,同時にprivateメソッドで
+もあるものです.例をあげるとMathモジュールのsqrt()などがあげ
+られます.このメソッドは
+
+ Math.sqrt(4)
+
+という形式でも
+
+ include Math
+ sqrt(4)
+
+という形式でも使えます.モジュール関数を定義する関数は以下の
+通りです.
+
+ void rb_define_module_function(VALUE module, char *name,
+ VALUE (*func)(), int argc)
+
+関数的メソッド(Kernelモジュールのprivate method)を定義するた
+めの関数は以下の通りです.
+
+ void rb_define_global_function(char *name, VALUE (*func)(), int argc)
+
+
+2.1.3 定数定義
+
+拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い
+でしょう.定数を定義する関数は二つあります.
+
+ void rb_define_const(VALUE class, char *name, VALUE val)
+ void rb_define_global_const(char *name, VALUE val)
+
+前者は特定のクラス/モジュールに属する定数を定義するもの,後
+者はグローバルな定数を定義するものです.
+
+2.2 Rubyの機能をCから呼び出す
+
+既に『1.5 Rubyのデータを操作する』で一部紹介したような関数を
+使えば,Rubyの機能を実現している関数を直接呼び出すことが出来
+ます.
+
+# このような関数の一覧表はいまのところありません.ソースを見
+# るしかないですね.
+
+それ以外にもRubyの機能を呼び出す方法はいくつかあります.
+
+2.2.1 Rubyのプログラムをevalする
+
+CからRubyの機能を呼び出すもっとも簡単な方法として,文字列で
+与えられたRubyのプログラムを評価する関数があります.
+
+ VALUE rb_eval_string(char *str)
+
+この評価は現在の環境で行われます.つまり,現在のローカル変数
+などを受け継ぎます.
+
+2.2.2 IDまたはシンボル
+
+Cから文字列を経由せずにRubyのメソッドを呼び出すこともできま
+す.その前に,Rubyインタプリタ内でメソッドや変数名を指定する
+時に使われているIDについて説明しておきましょう.
+
+IDとは変数名,メソッド名を表す整数です.Rubyの中では
+
+ :識別子
+
+でアクセスできます.Cからこの整数を得るためには関数
+
+ rb_intern(char *name)
+
+を使います.また一文字の演算子はその文字コードがそのままシン
+ボルになっています.Rubyから引数として与えられたシンボル(ま
+たは文字列)をIDに変換するには以下の関数を使います.
+
+ rb_to_id(VALUE symbol)
+
+2.2.3 CからRubyのメソッドを呼び出す
+
+Cから文字列を経由せずにRubyのメソッドを呼び出すためには以下
+の関数を使います.
+
+ VALUE rb_funcall(VALUE recv, ID mid, int argc, ...)
+
+この関数はオブジェクトrecvのmidで指定されるメソッドを呼び出
+します.その他に引数の指定の仕方が違う以下の関数もあります.
+
+ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
+ VALUE rb_apply(VALUE recv, ID mid, VALUE args)
+
+applyには引数としてRubyの配列を与えます.
+
+2.2.4 変数/定数を参照/更新する
+
+Cから関数を使って参照・更新できるのは,定数,インスタンス変
+数です.大域変数は一部のものはCの大域変数としてアクセスでき
+ます.ローカル変数を参照する方法は公開していません.
+
+オブジェクトのインスタンス変数を参照・更新する関数は以下の通
+りです.
+
+ VALUE rb_ivar_get(VALUE obj, ID id)
+ VALUE rb_ivar_set(VALUE obj, ID id, VALUE val)
+
+idはrb_intern()で得られるものを使ってください.
+
+定数を参照するには以下の関数を使ってください.
+
+ VALUE rb_const_get(VALUE obj, ID id)
+
+定数を新しく定義するためには『2.1.3 定数定義』で紹介さ
+れている関数を使ってください.
+
+3.RubyとCとの情報共有
+
+C言語とRubyの間で情報を共有する方法について解説します.
+
+3.1 Cから参照できるRubyの定数
+
+以下のRubyの定数はCのレベルから参照できる.
+
+ Qtrue
+ Qfalse
+
+真偽値.QfalseはC言語でも偽とみなされる(つまり0).
+
+ Qnil
+
+C言語から見た「nil」.
+
+3.2 CとRubyで共有される大域変数
+
+CとRubyで大域変数を使って情報を共有できます.共有できる大域
+変数にはいくつかの種類があります.そのなかでもっとも良く使わ
+れると思われるのはrb_define_variable()です.
+
+ void rb_define_variable(char *name, VALUE *var)
+
+この関数はRubyとCとで共有する大域変数を定義します.変数名が
+`$'で始まらない時には自動的に追加されます.この変数の値を変
+更すると自動的にRubyの対応する変数の値も変わります.
+
+またRuby側からは更新できない変数もあります.このread onlyの
+変数は以下の関数で定義します.
+
+ void rb_define_readonly_variable(char *name, VALUE *var)
+
+これら変数の他にhookをつけた大域変数を定義できます.hook付き
+の大域変数は以下の関数を用いて定義します.hook付き大域変数の
+値の参照や設定はhookで行う必要があります.
+
+ void rb_define_hooked_variable(char *name, VALUE *var,
+ VALUE (*getter)(), VALUE (*setter)())
+
+この関数はCの関数によってhookのつけられた大域変数を定義しま
+す.変数が参照された時には関数getterが,変数に値がセットされ
+た時には関数setterが呼ばれる.hookを指定しない場合はgetterや
+setterに0を指定します.
+
+# getterもsetterも0ならばrb_define_variable()と同じになる.
+
+それから,Cの関数によって実現されるRubyの大域変数を定義する
+関数があります.
+
+ void rb_define_virtual_variable(char *name,
+ VALUE (*getter)(), VALUE (*setter)())
+
+この関数によって定義されたRubyの大域変数が参照された時には
+getterが,変数に値がセットされた時にはsetterが呼ばれます.
+
+getterとsetterの仕様は以下の通りです.
+
+ (*getter)(ID id, void *data, struct global_entry* entry);
+ (*setter)(VALUE val, ID id, void *data, struct global_entry* entry);
+
+3.3 CのデータをRubyオブジェクトにする
+
+Cの世界で定義されたデータ(構造体)をRubyのオブジェクトとして
+取り扱いたい場合がありえます.このような場合には,Dataという
+RubyオブジェクトにCの構造体(へのポインタ)をくるむことでRuby
+オブジェクトとして取り扱えるようになります.
+
+Dataオブジェクトを生成して構造体をRubyオブジェクトにカプセル
+化するためには,以下のマクロを使います.
+
+ Data_Wrap_Struct(class,mark,free,ptr)
+
+このマクロの戻り値は生成されたDataオブジェクトです.
+
+classはこのDataオブジェクトのクラスです.ptrはカプセル化する
+Cの構造体へのポインタです.markはこの構造体がRubyのオブジェ
+クトへの参照がある時に使う関数です.そのような参照を含まない
+時には0を指定します.
+
+# そのような参照は勧められません.
+
+freeはこの構造体がもう不要になった時に呼ばれる関数です.この
+関数がガーベージコレクタから呼ばれます.
+
+Cの構造体の割当とDataオブジェクトの生成を同時に行うマクロと
+して以下のものが提供されています.
+
+ Data_Make_Struct(class, type, mark, free, sval)
+
+このマクロの戻り値は生成されたDataオブジェクトです.
+
+class, mark, freeはData_Wrap_Structと同じ働きをします.type
+は割り当てるC構造体の型です.割り当てられた構造体は変数sval
+に代入されます.この変数の型は (type*) である必要があります.
+
+Dataオブジェクトからポインタを取り出すのは以下のマクロを用い
+ます.
+
+ Data_Get_Struct(obj, type, sval)
+
+Cの構造体へのポインタは変数svalに代入されます.
+
+これらのDataの使い方はちょっと分かりにくいので,後で説明する
+例題を参照してください.
+
+4.例題 - dbmパッケージを作る
+
+ここまでの説明でとりあえず拡張ライブラリは作れるはずです.
+Rubyのextディレクトリにすでに含まれているdbmモジュールを例に
+して段階的に説明します.
+
+(1) ディレクトリを作る
+
+ % mkdir ext/dbm
+
+Ruby 1.1からは任意のディレクトリでダイナミックライブラリを作
+ることができるようになりました.Rubyに静的にリンクする場合に
+はRubyを展開したディレクトリの下,extディレクトリの中に拡張
+モジュール用のディレクトリを作る必要があります.名前は適当に
+選んで構いません.
+
+(2) MANIFESTファイルを作る
+
+ % cd ext/dbm
+ % touch MANIFEST
+
+拡張ライブラリのディレクトリの下にはMANIFESTというファイルが
+必要なので,とりあえず空のファイルを作っておきます.後でこの
+ファイルには必要なファイル一覧が入ることになります.
+
+MANIFESTというファイルは,静的リンクのmakeの時にディレクトリ
+が拡張ライブラリを含んでいるかどうか判定するために使われれて
+います.ダイナミックライブラリを作る場合には必ずしも必要では
+ありません.
+
+(3) 設計する
+
+まあ,当然なんですけど,どういう機能を実現するかどうかまず設
+計する必要があります.どんなクラスをつくるか,そのクラスには
+どんなメソッドがあるか,クラスが提供する定数などについて設計
+します.dbmクラスについてはext/dbm.docを参照してください.
+
+(4) Cコードを書く
+
+拡張ライブラリ本体となるC言語のソースを書きます.C言語のソー
+スがひとつの時には「モジュール名.c」を選ぶと良いでしょう.C
+言語のソースが複数の場合には逆に「モジュール名.c」というファ
+イル名は避ける必要があります.オブジェクトファイルとモジュー
+ル生成時に中間的に生成される「モジュール名.o」というファイル
+とが衝突するからです.
+
+Rubyは拡張ライブラリをロードする時に「Init_モジュール名」と
+いう関数を自動的に実行します.dbmモジュールの場合「Init_dbm」
+です.この関数の中でクラス,モジュール,メソッド,定数などの
+定義を行います.dbm.cから一部引用します.
+
+--
+Init_dbm()
+{
+ /* DBMクラスを定義する */
+ cDBM = rb_define_class("DBM", rb_cObject);
+ /* DBMはEnumerateモジュールをインクルードする */
+ rb_include_module(cDBM, rb_mEnumerable);
+
+ /* DBMクラスのクラスメソッドopen(): 引数はCの配列で受ける */
+ rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
+
+ /* DBMクラスのメソッドclose(): 引数はなし */
+ rb_define_method(cDBM, "close", fdbm_close, 0);
+ /* DBMクラスのメソッド[]: 引数は1個 */
+ rb_define_method(cDBM, "[]", fdbm_fetch, 1);
+ :
+
+ /* DBMデータを格納するインスタンス変数名のためのID */
+ id_dbm = rb_intern("dbm");
+}
+--
+
+DBMモジュールはdbmのデータと対応するオブジェクトになるはずで
+すから,Cの世界のdbmをRubyの世界に取り込む必要があります.
+
+
+dbm.cではData_Make_Structを以下のように使っています.
+
+--
+struct dbmdata {
+ int di_size;
+ DBM *di_dbm;
+};
+
+
+obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp);
+--
+
+ここではdbmstruct構造体へのポインタをDataにカプセル化してい
+ます.DBM*を直接カプセル化しないのはclose()した時の処理を考
+えてのことです.
+
+Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
+に以下のマクロを使っています.
+
+--
+#define GetDBM(obj, dbmp) {\
+ Data_Get_Struct(obj, struct dbmdata, dbmp);\
+ if (dbmp->di_dbm == 0) closed_dbm();\
+}
+--
+
+ちょっと複雑なマクロですが,要するにdbmdata構造体のポインタ
+の取り出しと,closeされているかどうかのチェックをまとめてい
+るだけです.
+
+DBMクラスにはたくさんメソッドがありますが,分類すると3種類の
+引数の受け方があります.ひとつは引数の数が固定のもので,例と
+してはdeleteメソッドがあります.deleteメソッドを実装している
+fdbm_delete()はこのようになっています.
+
+--
+static VALUE
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
+{
+ :
+}
+--
+
+引数の数が固定のタイプは第1引数がself,第2引数以降がメソッド
+の引数となります.
+
+引数の数が不定のものはCの配列で受けるものとRubyの配列で受け
+るものとがあります.dbmモジュールの中で,Cの配列で受けるもの
+はDBMのクラスメソッドであるopen()です.これを実装している関
+数fdbm_s_open()はこうなっています.
+
+--
+static VALUE
+fdbm_s_open(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ :
+ if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ mode = 0666; /* default value */
+ }
+ :
+}
+--
+
+このタイプの関数は第1引数が与えられた引数の数,第2引数が与え
+られた引数の入っている配列になります.selfは第3引数として与
+えられます.
+
+この配列で与えられた引数を解析するための関数がopen()でも使わ
+れているrb_scan_args()です.第3引数に指定したフォーマットに
+従い,第4変数以降に指定した変数に値を代入してくれます.この
+フォーマットは,第1文字目が省略できない引数の数,第2文字目が
+省略できる引数の数,第3文字目が対応する相手が無いあまりの引
+数があるかどうかを示す"*"です.2文字目と3文字目は省略できま
+す.dbm.cの例では,フォーマットは"11"ですから,引数は最低1つ
+で,2つまで許されるという意味になります.省略されている時の
+変数の値はnil(C言語のレベルではQnil)になります.
+
+Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
+うです.
+
+--
+static VALUE
+fdbm_indexes(obj, args)
+ VALUE obj;
+ struct RArray *args;
+{
+ :
+}
+--
+
+第1引数はself,第2引数はRubyの配列です.ここではキャストを減
+らすため struct RArray* で受けていますが,VALUEでも同じこと
+です.
+
+** 注意事項
+
+Rubyと共有はしないがRubyのオブジェクトを格納する可能性のある
+Cの大域変数は以下の関数を使ってRubyインタプリタに変数の存在
+を教えてあげてください.でないとGCでトラブルを起こします.
+
+ void rb_global_variable(VALUE *var)
+
+(5) extconf.rbを用意する
+
+Makefileを作る場合の雛型になるextconf.rbというファイルを作り
+ます.extconf.rbはモジュールのコンパイルに必要な条件のチェッ
+クなどを行うことが目的です.extconf.rbの中では以下のRuby関数
+を使うことが出来ます.
+
+ have_library(lib, func): ライブラリの存在チェック
+ have_func(func): 関数の存在チェック
+ have_header(header): ヘッダファイルの存在チェック
+ create_makefile(target): Makefileの生成
+
+以下の変数を使うことができます.
+
+ $CFLAGS: コンパイル時に追加的に指定するフラグ(-Iなど)
+ $LDFLAGS: リンク時に追加的に指定するフラグ(-Lなど)
+
+モジュールをコンパイルする条件が揃わなず,そのモジュールはコ
+ンパイルしない時にはcreate_makefileを呼ばなければMakefileは
+生成されず,コンパイルも行われません.
+
+モジュールがRuby 1.1専用である場合には
+
+ require 'mkmf'
+
+をextconf.rbの先頭に置くと便利でしょう.
+
+(6) dependを用意する
+
+もし,ディレクトリにdependというファイルが存在すれば,
+Makefileが依存関係をチェックしてくれます.
+
+ % gcc -MM *.c > depend
+
+などで作ることが出来ます.あって損は無いでしょう.
+
+(7) MANIFESTファイルにファイル名を入れる
+
+ % ls > MANIFEST
+ % vi MANIFEST
+
+*.o, *~など不必要なファイル以外はMANIFESTに追加しておきます.
+make時にはMANIFESTの内容は参照しませんので,空のままでも問題
+は起きませんが,パッケージングの時に参照することがあるのと,
+必要なファイルを区別できるので,用意しておいた方が良いでしょ
+う.
+
+(8) Makefileを生成する
+
+Makefileを実際に生成するためには
+
+ ruby extconf.rb
+
+とします.extconf.rbに require 'mkmf' の行がない場合にはエラー
+になりますので,引数を追加して
+
+ ruby -r mkmf extconf.rb
+
+としてください.
+
+ディレクトリをext以下に用意した場合にはRuby全体のmakeの時に
+自動的にMakefileが生成されますので,このステップは不要です.
+
+(9) makeする
+
+動的リンクライブラリを生成する場合にはその場でmakeしてくださ
+い.必要であれば make install でインストールされます.
+
+ext以下にディレクトリを用意した場合は,Rubyのディレクトリで
+makeを実行するとMakefileを生成からmake,必要によってはそのモ
+ジュールのRubyへのリンクまで自動的に実行してくれます.
+extconf.rbを書き換えるなどしてMakefileの再生成が必要な時はま
+たRubyディレクトリでmakeしてください.
+
+動的リンクライブラリはmake installでRubyライブラリのディレク
+トリの下にコピーされます.もしモジュールと協調して使うRubyで
+記述されたプログラムがあり,Rubyライブラリに置きたい場合には,
+拡張ライブラリ用のディレクトリの下に lib というディレクトリ
+を作り,そこに 拡張子 .rb のファイルを置いておけば同時にイン
+ストールされます.
+
+(10) デバッグ
+
+まあ,デバッグしないと動かないでしょうね.ext/Setupにディレ
+クトリ名を書くと静的にリンクするのでデバッガが使えるようにな
+ります.その分コンパイルが遅くなりますけど.
+
+(11) できあがり
+
+後はこっそり使うなり,広く公開するなり,売るなり,ご自由にお
+使いください.Rubyの作者は拡張ライブラリに関して一切の権利を
+主張しません.
+
+Appendix A. Rubyのソースコードの分類
+
+Rubyのソースはいくつかに分類することが出来ます.このうちクラ
+スライブラリの部分は基本的に拡張ライブラリと同じ作り方になっ
+ています.これらのソースは今までの説明でほとんど理解できると
+思います.
+
+Ruby言語のコア
+
+ class.c
+ error.c
+ eval.c
+ gc.c
+ object.c
+ parse.y
+ variable.c
+
+ユーティリティ関数
+
+ dln.c
+ fnmatch.c
+ glob.c
+ regex.c
+ st.c
+ util.c
+
+Rubyコマンドの実装
+
+ dmyext.c
+ inits.c
+ main.c
+ ruby.c
+ version.c
+
+クラスライブラリ
+
+ array.c
+ bignum.c
+ compar.c
+ dir.c
+ enum.c
+ file.c
+ hash.c
+ io.c
+ marshal.c
+ math.c
+ numeric.c
+ pack.c
+ process.c
+ random.c
+ range.c
+ re.c
+ signal.c
+ sprintf.c
+ string.c
+ struct.c
+ time.c
+
+Appendix B. 拡張用関数リファレンス
+
+C言語からRubyの機能を利用するAPIは以下の通りである.
+
+** 型
+
+ VALUE
+
+Rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
+組み込み型を表現するCの型はruby.hに記述してあるRで始まる構造
+体である.VALUE型をこれらにキャストするためにRで始まる構造体
+名を全て大文字にした名前のマクロが用意されている.
+
+** 変数・定数
+
+ Qnil
+
+定数: nilオブジェクト
+
+ Qtrue
+
+定数: trueオブジェクト(真のデフォルト値)
+
+ Qfalse
+
+定数: falseオブジェクト
+
+** Cデータのカプセル化
+
+ Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
+
+Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
+のポインタがRubyからアクセスされなくなった時,freeで指定した
+関数が呼ばれる.また,このポインタの指すデータが他のRubyオブ
+ジェクトを指している場合,markに指定する関数でマークする必要
+がある.
+
+ Data_Make_Struct(class, type, mark, free, sval)
+
+type型のメモリをmallocし,変数svalに代入した後,それをカプセ
+ル化したデータを返すマクロ.
+
+ Data_Get_Struct(data, type, sval)
+
+dataからtype型のポインタを取り出し変数svalに代入するマクロ.
+
+** 型チェック
+
+ TYPE(value)
+ FIXNUM_P(value)
+ NIL_P(value)
+ void Check_Type(VALUE value, int type)
+ void Check_SafeStr(VALUE value)
+
+** 型変換
+
+ FIX2INT(value)
+ INT2FIX(i)
+ NUM2INT(value)
+ INT2NUM(i)
+ NUM2DBL(value)
+ rb_float_new(f)
+ STR2CSTR(value)
+ rb_str_new2(s)
+
+** クラス/モジュール定義
+
+ VALUE rb_define_class(char *name, VALUE super)
+
+superのサブクラスとして新しいRubyクラスを定義する.
+
+ VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
+
+superのサブクラスとして新しいRubyクラスを定義し,moduleの定
+数として定義する.
+
+ VALUE rb_define_module(char *name)
+
+新しいRubyモジュールを定義する.
+
+ VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
+
+新しいRubyモジュールを定義し,moduleの定数として定義する.
+
+ void rb_include_module(VALUE class, VALUE module)
+
+モジュールをインクルードする.classがすでにmoduleをインクルー
+ドしている時には何もしない(多重インクルードの禁止).
+
+ void rb_extend_object(VALUE object, VALUE module)
+
+オブジェクトをモジュール(で定義されているメソッド)で拡張する.
+
+** 大域変数定義
+
+ void rb_define_variable(char *name, VALUE *var)
+
+RubyとCとで共有するグローバル変数を定義する.変数名が`$'で始
+まらない時には自動的に追加される.nameとしてRubyの識別子とし
+て許されない文字(例えば` ')を含む場合にはRubyプログラムから
+は見えなくなる.
+
+ void rb_define_readonly_variable(char *name, VALUE *var)
+
+RubyとCとで共有するread onlyのグローバル変数を定義する.read
+onlyであること以外はrb_define_variable()と同じ.
+
+ void rb_define_virtual_variable(char *name,
+ VALUE (*getter)(), VALUE (*setter)())
+
+関数によって実現されるRuby変数を定義する.変数が参照された時
+にはgetterが,変数に値がセットされた時にはsetterが呼ばれる.
+
+ void rb_define_hooked_variable(char *name, VALUE *var,
+ VALUE (*getter)(), VALUE (*setter)())
+
+関数によってhookのつけられたグローバル変数を定義する.変数が
+参照された時にはgetterが,関数に値がセットされた時にはsetter
+が呼ばれる.getterやsetterに0を指定した時にはhookを指定しな
+いのと同じ事になる.
+
+ void rb_global_variable(VALUE *var)
+
+GCのため,Rubyプログラムからはアクセスされないが, Rubyオブジェ
+クトを含む大域変数をマークする.
+
+** 定数
+
+ void rb_define_const(VALUE klass, char *name, VALUE val)
+
+定数を定義する.
+
+ void rb_define_global_const(char *name, VALUE val)
+
+大域定数を定義する.
+
+ rb_define_const(cKernal, name, val)
+
+と同じ意味.
+
+** メソッド定義
+
+ rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
+関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2引
+数とする形式で与えられる(第3引数はself).argcが-2の時, 第1引
+数がself, 第2引数がargs(argsは引数を含むRubyの配列)という形
+式で与えられる.
+
+ rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+privateメソッドを定義する.引数はrb_define_method()と同じ.
+
+ rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+特異メソッドを定義する.引数はrb_define_method()と同じ.
+
+ rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
+
+argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
+付加引数の数, 残りの引数があるかを指定する文字列で, "数字数
+字*"という形式である. 2 番目の数字と"*"はそれぞれ省略可能で
+ある.必須引数が一つもない場合は0を指定する.第3引数以降は変
+数へのポインタで, 該当する要素がその変数に格納される.付加引
+数に対応する引数が与えられていない場合は変数にQnilが代入され
+る.
+
+** Rubyメソッド呼び出し
+
+ VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
+
+メソッド呼び出し.文字列からmidを得るためにはrb_intern()を使う.
+
+ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
+
+メソッド呼び出し.引数をargc,argv形式で渡す.
+
+ VALUE rb_eval_string(char *str)
+
+文字列をRubyとスクリプトしてコンパイル・実行する.
+
+ ID rb_intern(char *name)
+
+文字列に対応するIDを返す.
+
+ char *rb_id2name(ID id)
+
+IDに対応する文字列を返す(デバッグ用).
+
+ char *rb_class2name(VALUE class)
+
+classの名前を返す(デバッグ用).classが名前を持たない時には,
+祖先を遡って名前を持つクラスの名前を返す.
+
+** インスタンス変数
+
+ VALUE rb_iv_get(VALUE obj, char *name)
+
+objのインスタンス変数の値を得る.`@'で始まらないインスタンス
+変数は Rubyプログラムからアクセスできない「隠れた」インスタ
+ンス変数になる.定数は大文字の名前を持つクラス(またはモジュー
+ル)のインスタンス変数として実装されている.
+
+ VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
+
+objのインスタンス変数をvalにセットする.
+
+** 制御構造
+
+ VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
+
+func2をブロックとして設定し, func1をイテレータとして呼ぶ.
+func1には arg1が引数として渡され, func2には第1引数にイテレー
+タから与えられた値, 第2引数にarg2が渡される.
+
+ VALUE rb_yield(VALUE val)
+
+valを値としてイテレータブロックを呼び出す.
+
+ VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
+
+関数func1をarg1を引数に呼び出す.func1の実行中に例外が発生し
+た時には func2をarg2を引数として呼ぶ.戻り値は例外が発生しな
+かった時はfunc1の戻り値, 例外が発生した時にはfunc2の戻り値で
+ある.
+
+ VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
+
+関数func1をarg1を引数として実行し, 実行終了後(たとえ例外が発
+生しても) func2をarg2を引数として実行する.戻り値はfunc1の戻
+り値である(例外が発生した時は戻らない).
+
+** 例外・エラー
+
+ void rb_warning(char *fmt, ...)
+
+rb_verbose時に標準エラー出力に警告情報を表示する.引数はprintf()と同じ.
+
+ void rb_raise(rb_eRuntimeError, char *fmt, ...)
+
+RuntimeError例外を発生させる.引数はprintf()と同じ.
+
+ void rb_raise(VALUE exception, char *fmt, ...)
+
+exceptionで指定した例外を発生させる.fmt以下の引数はprintf()と同じ.
+
+ void rb_fatal(char *fmt, ...)
+
+致命的例外を発生させる.通常の例外処理は行なわれず, インター
+プリタが終了する(ただしensureで指定されたコードは終了前に実
+行される).
+
+ void rb_bug(char *fmt, ...)
+
+インタープリタなどプログラムのバグでしか発生するはずのない状
+況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.例外
+処理は一切行なわれない.
+
+** Rubyの初期化・実行
+
+Rubyをアプリケーションに埋め込む場合には以下のインタフェース
+を使う.通常の拡張ライブラリには必要ない.
+
+ void ruby_init(int argc, char **argv, char **envp)
+
+Rubyインタプリタの初期化を行なう.
+
+ void ruby_run()
+
+Rubyインタプリタを実行する.
+
+ void ruby_script(char *name)
+
+Rubyのスクリプト名($0)を設定する.
+
+
+Appendix B. extconf.rbで使える関数たち
+
+extconf.rbの中では利用可能なコンパイル条件チェックの関数は以
+下の通りである.
+
+ have_library(lib, func)
+
+関数funcを定義しているライブラリlibの存在をチェックする.ラ
+イブラリが存在する時,trueを返す.
+
+ have_func(func)
+
+関数funcの存在をチェックする.funcが標準ではリンクされないラ
+イブラリ内のものである時には先にhave_libraryでそのライブラリ
+をチェックしておく事.関数が存在する時TRUEを返す.
+
+ have_header(header)
+
+ヘッダファイルの存在をチェックする.ヘッダファイルが存在する
+時trueを返す.
+
+ create_makefile(target)
+
+拡張ライブラリ用のMakefileを生成する.この関数を呼ばなければ
+そのモジュールはコンパイルされない.targetはモジュール名を表
+す.
+
+/*
+ * Local variables:
+ * fill-column: 60
+ * end:
+ */
diff --git a/README.jp b/README.jp
index 00822a3..d137a43 100644
--- a/README.jp
+++ b/README.jp
@@ -5,7 +5,7 @@ Rubyは最初から純粋なオブジェクト指向言語として設計されていま
すから,オブジェクト指向プログラミングを手軽に行う事が出来ま
す.もちろん通常の手続き型のプログラミングも可能です.
-Rubyはテキスト処理関係の能力などに優れ,perlと同じくらい強力
+Rubyはテキスト処理関係の能力などに優れ,Perlと同じくらい強力
です.さらにシンプルな文法と,例外処理やイテレータなどの機構
によって,より分かりやすいプログラミングが出来ます.
@@ -20,7 +20,8 @@ Rubyはテキスト処理関係の能力などに優れ,perlと同じくらい強力
+ イテレータとクロージャ
+ ガーベージコレクタ
+ ダイナミックローディング (アーキテクチャによる)
- + 移植性が高い.多くのUNIX上で動く
+ + 移植性が高い.多くのUNIX上で動くだけでなく,DOSやWindows,
+ Mac,BeOSなどの上でも動く
* 入手法
@@ -41,14 +42,14 @@ Rubyはテキスト処理関係の能力などに優れ,perlと同じくらい強力
です.
-* メイリングリスト
+* メーリングリスト
- Rubyに関わる話題のためのメイリングリストを開設しました.ア
+ Rubyに関わる話題のためのメーリングリストを開設しました.ア
ドレスは
ruby-list@netlab.co.jp
- です.このアドレスにメイルを送れば,自動的に登録されます.
+ です.このアドレスにメールを送れば,自動的に登録されます.
* コンパイル・インストール
@@ -81,6 +82,8 @@ Rubyはテキスト処理関係の能力などに優れ,perlと同じくらい強力
6. make install
+ rootで作業する必要があるかもしれません.
+
もし,コンパイル時にエラーが発生した場合にはエラーのログとマ
シン,OSの種類を含むできるだけ詳しいレポートを作者に送ってく
ださると他の方のためにもなります.
@@ -92,7 +95,7 @@ UNIXであればconfigureがほとんどの差異を吸収してくれるはずで
すが,思わぬ見落としがあった場合(あるに違いない),作者にその
ことをレポートすれば,解決できるかも知れません.
-アークテクチャにもっとも依存するのはGC部です.RubyのGCは対象
+アーキテクチャにもっとも依存するのはGC部です.RubyのGCは対象
のアーキテクチャがsetjmp()によって全てのレジスタを jmp_bufに
格納することと,jmp_bufとスタックが32bitアラインメントされて
いることを仮定しています.特に前者が成立しない場合の対応は非
@@ -120,34 +123,37 @@ Licence)または以下に示す条件でRubyを再配布できます.GPLにつ
由に変更できます.
(a) ネットニューズにポストしたり,作者に変更を送付する
- などの方法で,変更を公開する
+ などの方法で,変更を公開する.
- (b) 変更したRubyを自分の所属する組織内部だけで使う
+ (b) 変更したRubyを自分の所属する組織内部だけで使う.
(c) 変更点を明示したうえ,ソフトウェアの名前を変更する.
- そのソフトウェアを配布する時にはもとのRubyも同時に
- 配布する
+ そのソフトウェアを配布する時には変更前のRubyも同時
+ に配布する.または変更前のRubyのソースの入手法を明
+ 示する.
- (d) その他の変更条件を作者と合意する
+ (d) その他の変更条件を作者と合意する.
3. 以下の条件のいずれかを満たす時にRubyをオブジェクトコー
ドや実行形式でも配布できます.
- (a) バイナリを受け取った人がソースを入手できるようにソー
- スの入手法を明示する
+ (a) バイナリを受け取った人がソースを入手できるように,
+ ソースの入手法を明示する.
- (b) 機械可読なソースコードを添付する
+ (b) 機械可読なソースコードを添付する.
(c) 変更を行ったバイナリは名前を変更したうえ,ソースの
- 入手法を明示する
+ 入手法を明示する.
- (d) その他の配布条件を作者と合意する
+ (d) その他の配布条件を作者と合意する.
4. 他のプログラムへの引用はいかなる目的であれ自由です.た
だし,Rubyに含まれる他の作者によるコードは,それぞれの
作者の意向による制限が加えられます.具体的にはgc.c(一部),
util.c(一部),st.[ch],regex.[ch], fnmatch.[ch], glob.c
および./missingディレクトリ下のファイル群が該当します.
+ それぞれの配布条件などに付いては各ファイルを参照してく
+ ださい.
5. Rubyへの入力となるスクリプトおよび,Rubyからの出力の権
利はRubyの作者ではなく,それぞれの入出力を生成した人に
diff --git a/ToDo b/ToDo
index 3b6edee..3bc7887 100644
--- a/ToDo
+++ b/ToDo
@@ -1,4 +1,37 @@
-* non-blocking open/write for thread
-* パッケージまたは大域変数のアクセス制御
-* format機能
-* re-write regex code for speed and copyright
+Language Spec.
+
+* package or access control for global variables
+* named arguments like foo(nation:="german").
+* multiple return values, yield values. maybe imcompatible
+
+Hacking Interpreter
+
+* non-blocking open (e.g. named pipe) for thread
+* avoid blocking with gethostbyname/gethostbyaddr
+* objectify interpreters
+* remove rb_eval() recursions
+* syntax tree -> bytecode ???
+* scrambled script, or script filter
+* regular expression bug /(?:\s+\d+){2}/ URGENT!!
+
+Extension Libraries
+
+* mod_ruby, FastCGI ruby
+* InterBase module
+* ptk.rb pTk wrapper that is compatible to tk.rb
+
+Ruby Libraries
+
+* CGI.rb
+* httplib.rb, urllib.rb, nttplib.rb, etc.
+* format like perl's
+
+Tools
+
+* extension library maker like XS or SWIG
+* freeze or undump to bundle everything
+
+Misc
+
+* translate README.EXT fully into English
+* publish Ruby books
diff --git a/array.c b/array.c
index 388fb05..8f6c0c2 100644
--- a/array.c
+++ b/array.c
@@ -6,41 +6,55 @@
$Date$
created at: Fri Aug 6 09:46:12 JST 1993
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
+#include "util.h"
-
-VALUE cArray;
+VALUE rb_cArray;
#define ARY_DEFAULT_SIZE 16
void
-memclear(mem, size)
+rb_mem_clear(mem, size)
register VALUE *mem;
- register int size;
+ register size_t size;
{
while (size--) {
*mem++ = Qnil;
}
}
+static void
+memfill(mem, size, val)
+ register VALUE *mem;
+ register size_t size;
+ register VALUE val;
+{
+ while (size--) {
+ *mem++ = val;
+ }
+}
+
#define ARY_FREEZE FL_USER1
+#define ARY_TMPLOCK FL_USER2
static void
-ary_modify(ary)
+rb_ary_modify(ary)
VALUE ary;
{
- rb_secure(5);
- if (FL_TEST(ary, ARY_FREEZE)) {
- TypeError("can't modify frozen array");
- }
+ if (FL_TEST(ary, ARY_FREEZE))
+ rb_raise(rb_eTypeError, "can't modify frozen array");
+ if (FL_TEST(ary, ARY_TMPLOCK))
+ rb_raise(rb_eTypeError, "can't modify array during sort");
+ if (rb_safe_level() >= 4 && !FL_TEST(ary, FL_TAINT))
+ rb_raise(rb_eSecurityError, "Insecure: can't modify array");
}
VALUE
-ary_freeze(ary)
+rb_ary_freeze(ary)
VALUE ary;
{
FL_SET(ary, ARY_FREEZE);
@@ -48,56 +62,68 @@ ary_freeze(ary)
}
static VALUE
-ary_frozen_p(ary)
+rb_ary_frozen_p(ary)
VALUE ary;
{
- if (FL_TEST(ary, ARY_FREEZE))
- return TRUE;
- return FALSE;
+ if (FL_TEST(ary, ARY_FREEZE|ARY_TMPLOCK))
+ return Qtrue;
+ return Qfalse;
}
VALUE
-ary_new2(len)
- int len;
+rb_ary_new2(len)
+ size_t len;
{
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, cArray, T_ARRAY);
+ OBJSETUP(ary, rb_cArray, T_ARRAY);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative array size (or size too big)");
+ }
+ if (len > 0 && len*sizeof(VALUE) <= 0) {
+ rb_raise(rb_eArgError, "array size too big");
+ }
ary->len = 0;
ary->capa = len;
- if (len == 0)
- ary->ptr = 0;
- else {
- ary->ptr = ALLOC_N(VALUE, len);
- memclear(ary->ptr, len);
- }
+ ary->ptr = 0;
+ ary->ptr = ALLOC_N(VALUE, len);
return (VALUE)ary;
}
VALUE
-ary_new()
+rb_ary_new()
{
- return ary_new2(ARY_DEFAULT_SIZE);
+ return rb_ary_new2(ARY_DEFAULT_SIZE);
}
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
VALUE
-ary_new3(n, va_alist)
- int n;
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_ary_new3(size_t n, ...)
+#else
+rb_ary_new3(n, va_alist)
+ size_t n;
va_dcl
+#endif
{
va_list ar;
VALUE ary;
- int i;
+ size_t i;
if (n < 0) {
- IndexError("Negative number of items(%d)", n);
+ rb_raise(rb_eIndexError, "negative number of items(%d)", n);
}
- ary = ary_new2(n<ARY_DEFAULT_SIZE?ARY_DEFAULT_SIZE:n);
+ ary = rb_ary_new2(n<ARY_DEFAULT_SIZE?ARY_DEFAULT_SIZE:n);
- va_start(ar);
+ va_init_list(ar, n);
for (i=0; i<n; i++) {
RARRAY(ary)->ptr[i] = va_arg(ar, VALUE);
}
@@ -108,26 +134,28 @@ ary_new3(n, va_alist)
}
VALUE
-ary_new4(n, elts)
- int n;
+rb_ary_new4(n, elts)
+ size_t n;
VALUE *elts;
{
VALUE ary;
- ary = ary_new2(n);
- MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
+ ary = rb_ary_new2(n);
+ if (elts) {
+ MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
+ }
RARRAY(ary)->len = n;
return ary;
}
VALUE
-assoc_new(car, cdr)
+rb_assoc_new(car, cdr)
VALUE car, cdr;
{
VALUE ary;
- ary = ary_new2(2);
+ ary = rb_ary_new2(2);
RARRAY(ary)->ptr[0] = car;
RARRAY(ary)->ptr[1] = cdr;
RARRAY(ary)->len = 2;
@@ -136,32 +164,49 @@ assoc_new(car, cdr)
}
static VALUE
-ary_s_new(argc, argv, class)
+rb_ary_s_new(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
- VALUE size;
+ size_t len = 0;
+ VALUE size, val;
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, class, T_ARRAY);
+ OBJSETUP(ary, klass, T_ARRAY);
- rb_scan_args(argc, argv, "01", &size);
ary->len = 0;
- ary->capa = NIL_P(size)?ARY_DEFAULT_SIZE:NUM2INT(size);
+ ary->ptr = 0;
+ if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
+ ary->capa = ARY_DEFAULT_SIZE;
+ }
+ else {
+ size_t capa = NUM2UINT(size);
+
+ if (capa < 0) {
+ rb_raise(rb_eArgError, "negative array size");
+ }
+ if (capa > 0 && capa*sizeof(VALUE) <= 0) {
+ rb_raise(rb_eArgError, "array size too big");
+ }
+ ary->capa = capa;
+ len = capa;
+ }
ary->ptr = ALLOC_N(VALUE, ary->capa);
- memclear(ary->ptr, ary->capa);
+ memfill(ary->ptr, len, val);
+ ary->len = len;
+ rb_obj_call_init((VALUE)ary);
return (VALUE)ary;
}
static VALUE
-ary_s_create(argc, argv, class)
+rb_ary_s_create(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, class, T_ARRAY);
+ OBJSETUP(ary, klass, T_ARRAY);
ary->len = argc;
ary->capa = argc;
@@ -177,14 +222,17 @@ ary_s_create(argc, argv, class)
}
void
-ary_store(ary, idx, val)
+rb_ary_store(ary, idx, val)
VALUE ary;
- int idx;
+ size_t idx;
VALUE val;
{
- ary_modify(ary);
+ rb_ary_modify(ary);
if (idx < 0) {
- IndexError("negative index for array");
+ idx = RARRAY(ary)->len + idx;
+ if (idx < 0) {
+ rb_raise(rb_eIndexError, "negative index of array");
+ }
}
if (idx >= RARRAY(ary)->capa) {
@@ -192,7 +240,8 @@ ary_store(ary, idx, val)
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
if (idx > RARRAY(ary)->len) {
- memclear(RARRAY(ary)->ptr+RARRAY(ary)->len, idx-RARRAY(ary)->len+1);
+ rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len,
+ idx-RARRAY(ary)->len+1);
}
if (idx >= RARRAY(ary)->len) {
@@ -202,28 +251,28 @@ ary_store(ary, idx, val)
}
VALUE
-ary_push(ary, item)
+rb_ary_push(ary, item)
VALUE ary;
VALUE item;
{
- ary_store(ary, RARRAY(ary)->len, item);
+ rb_ary_store(ary, RARRAY(ary)->len, item);
return ary;
}
static VALUE
-ary_push_method(argc, argv, ary)
+rb_ary_push_method(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
while (argc--) {
- ary_store(ary, RARRAY(ary)->len, *argv++);
+ rb_ary_store(ary, RARRAY(ary)->len, *argv++);
}
return ary;
}
VALUE
-ary_pop(ary)
+rb_ary_pop(ary)
VALUE ary;
{
if (RARRAY(ary)->len == 0) return Qnil;
@@ -235,7 +284,7 @@ ary_pop(ary)
}
VALUE
-ary_shift(ary)
+rb_ary_shift(ary)
VALUE ary;
{
VALUE top;
@@ -256,10 +305,10 @@ ary_shift(ary)
}
VALUE
-ary_unshift(ary, item)
+rb_ary_unshift(ary, item)
VALUE ary, item;
{
- ary_modify(ary);
+ rb_ary_modify(ary);
if (RARRAY(ary)->len >= RARRAY(ary)->capa) {
RARRAY(ary)->capa+=ARY_DEFAULT_SIZE;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
@@ -269,13 +318,15 @@ ary_unshift(ary, item)
MEMMOVE(RARRAY(ary)->ptr+1, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
RARRAY(ary)->len++;
- return RARRAY(ary)->ptr[0] = item;
+ RARRAY(ary)->ptr[0] = item;
+
+ return ary;
}
VALUE
-ary_entry(ary, offset)
+rb_ary_entry(ary, offset)
VALUE ary;
- int offset;
+ size_t offset;
{
if (RARRAY(ary)->len == 0) return Qnil;
@@ -290,27 +341,27 @@ ary_entry(ary, offset)
}
static VALUE
-ary_subseq(ary, beg, len)
+rb_ary_subseq(ary, beg, len)
VALUE ary;
- int beg, len;
+ size_t beg, len;
{
VALUE ary2;
- if (beg < 0) {
- beg = RARRAY(ary)->len + beg;
- if (beg < 0) beg = 0;
- }
- if (len < 0) {
- IndexError("negative length %d", RARRAY(ary)->len);
+ if (len <= 0) {
+ return rb_ary_new2(0);
}
- if (len == 0) {
- return ary_new2(0);
+ if (beg < 0) {
+ len += beg;
+ beg = 0;
}
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
+ if (len < 0) {
+ len = 0;
+ }
- ary2 = ary_new2(len);
+ ary2 = rb_ary_new2(len);
MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr+beg, VALUE, len);
RARRAY(ary2)->len = len;
@@ -320,80 +371,74 @@ ary_subseq(ary, beg, len)
static VALUE
beg_len(range, begp, lenp, len)
VALUE range;
- int *begp, *lenp;
- int len;
+ size_t *begp, *lenp;
+ size_t len;
{
- int beg, end;
+ size_t beg, end;
+ size_t b, e;
- if (!range_beg_end(range, &beg, &end)) return FALSE;
-
- if ((beg > 0 && end > 0 || beg < 0 && end < 0) && beg > end) {
- IndexError("end smaller than beg [%d..%d]", beg, end);
- }
+ if (!rb_range_beg_end(range, &beg, &end)) return Qfalse;
+ b = beg; e = end;
if (beg < 0) {
beg = len + beg;
- if (beg < 0) beg = 0;
}
+ if (end < 0) {
+ end = len + end;
+ }
+ if (beg > end) {
+ rb_raise(rb_eIndexError, "end smaller than beg [%d..%d]", b, e);
+ }
+
*begp = beg;
if (beg > len) {
*lenp = 0;
}
else {
- if (end < 0) {
- end = len + end;
- if (end < 0) end = -1;
- }
- if (beg > end) {
- *lenp = 0;
- }
- else {
- *lenp = end - beg +1;
- }
+ len = end - beg +1;
+ *lenp = len;
}
- return TRUE;
+ return Qtrue;
}
VALUE
-ary_aref(argc, argv, ary)
+rb_ary_aref(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
VALUE arg1, arg2;
- int beg, len;
+ size_t beg, len;
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
- beg = NUM2INT(arg1);
- len = NUM2INT(arg2);
- if (len <= 0) {
- return ary_new();
+ beg = NUM2UINT(arg1);
+ len = NUM2UINT(arg2);
+ if (beg < 0) {
+ beg = RARRAY(ary)->len + beg;
}
- return ary_subseq(ary, beg, len);
+ return rb_ary_subseq(ary, beg, len);
}
/* special case - speeding up */
if (FIXNUM_P(arg1)) {
- return ary_entry(ary, FIX2INT(arg1));
+ return rb_ary_entry(ary, FIX2UINT(arg1));
}
- else {
- /* check if idx is Range */
- if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
- return ary_subseq(ary, beg, len);
- }
+ else if (TYPE(arg1) == T_BIGNUM) {
+ rb_raise(rb_eIndexError, "index too big");
}
- if (TYPE(arg1) == T_BIGNUM) {
- IndexError("index too big");
+ else if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
+ /* check if idx is Range */
+ return rb_ary_subseq(ary, beg, len);
}
- return ary_entry(ary, NUM2INT(arg1));
+ return rb_ary_entry(ary, NUM2UINT(arg1));
}
static VALUE
-ary_index(ary, val)
+rb_ary_index(ary, val)
VALUE ary;
VALUE val;
{
- int i;
+ size_t i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
@@ -403,59 +448,74 @@ ary_index(ary, val)
}
static VALUE
-ary_indexes(ary, args)
- VALUE ary, args;
+rb_ary_rindex(ary, val)
+ VALUE ary;
+ VALUE val;
{
- VALUE *p, *pend;
- VALUE new_ary;
- int i = 0;
+ size_t i = RARRAY(ary)->len;
- if (!args || NIL_P(args)) {
- return ary_new2(0);
+ while (i--) {
+ if (rb_equal(RARRAY(ary)->ptr[i], val))
+ return INT2FIX(i);
}
+ return Qnil;
+}
- new_ary = ary_new2(RARRAY(args)->len);
+static VALUE
+rb_ary_indexes(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ VALUE new_ary;
+ size_t i;
- p = RARRAY(args)->ptr; pend = p + RARRAY(args)->len;
- while (p < pend) {
- ary_store(new_ary, i++, ary_entry(ary, NUM2INT(*p)));
- p++;
+ new_ary = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ rb_ary_store(new_ary, i, rb_ary_entry(ary, NUM2UINT(argv[i])));
}
+
return new_ary;
}
static void
-ary_replace(ary, beg, len, rpl)
+rb_ary_replace(ary, beg, len, rpl)
VALUE ary, rpl;
- int beg, len;
+ size_t beg, len;
{
- ary_modify(ary);
+ if (len < 0) {
+ rb_raise(rb_eIndexError, "negative length %d", len);
+ }
+
if (TYPE(rpl) != T_ARRAY) {
rpl = rb_Array(rpl);
}
+
+ if (beg + len < 0 || (beg < 0 && beg <= -len)) {
+ rb_raise(rb_eIndexError, "index %d out of range", beg);
+ }
if (beg < 0) {
- beg = RARRAY(ary)->len + beg;
- if (beg < 0) beg = 0;
+ len += beg;
+ beg = 0;
}
+
+ rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
len = beg + RARRAY(rpl)->len;
if (len >= RARRAY(ary)->capa) {
RARRAY(ary)->capa=len;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
- memclear(RARRAY(ary)->ptr+RARRAY(ary)->len, beg-RARRAY(ary)->len);
+ rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len, beg-RARRAY(ary)->len);
MEMCPY(RARRAY(ary)->ptr+beg, RARRAY(rpl)->ptr, VALUE, RARRAY(rpl)->len);
RARRAY(ary)->len = len;
}
else {
- int alen;
+ size_t alen;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
- if (len < 0) {
- IndexError("negative length %d", RARRAY(ary)->len);
- }
alen = RARRAY(ary)->len + RARRAY(rpl)->len - len;
if (alen >= RARRAY(ary)->capa) {
@@ -473,48 +533,49 @@ ary_replace(ary, beg, len, rpl)
}
static VALUE
-ary_aset(argc, argv, ary)
+rb_ary_aset(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
VALUE arg1, arg2, arg3;
- int offset;
- int beg, len;
+ size_t offset;
+ size_t beg, len;
if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
- beg = NUM2INT(arg1);
- len = NUM2INT(arg2);
- ary_replace(ary, beg, len, arg3);
+ beg = NUM2UINT(arg1);
+ len = NUM2UINT(arg2);
+
+ if (beg < 0) {
+ beg = RARRAY(ary)->len + beg;
+ }
+ rb_ary_replace(ary, beg, len, arg3);
return arg3;
}
else if (FIXNUM_P(arg1)) {
- offset = FIX2INT(arg1);
+ offset = FIX2UINT(arg1);
goto fixnum;
}
else if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
/* check if idx is Range */
- ary_replace(ary, beg, len, arg2);
+ rb_ary_replace(ary, beg, len, arg2);
return arg2;
}
if (TYPE(arg1) == T_BIGNUM) {
- IndexError("index too big");
+ rb_raise(rb_eIndexError, "index too big");
}
- offset = NUM2INT(arg1);
+ offset = NUM2UINT(arg1);
fixnum:
- if (offset < 0) {
- offset = RARRAY(ary)->len + offset;
- }
- ary_store(ary, offset, arg2);
+ rb_ary_store(ary, offset, arg2);
return arg2;
}
VALUE
-ary_each(ary)
+rb_ary_each(ary)
VALUE ary;
{
- int i;
+ size_t i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]);
@@ -523,10 +584,10 @@ ary_each(ary)
}
static VALUE
-ary_each_index(ary)
+rb_ary_each_index(ary)
VALUE ary;
{
- int i;
+ size_t i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(INT2FIX(i));
@@ -535,10 +596,10 @@ ary_each_index(ary)
}
static VALUE
-ary_reverse_each(ary)
+rb_ary_reverse_each(ary)
VALUE ary;
{
- int len = RARRAY(ary)->len;
+ size_t len = RARRAY(ary)->len;
while (len--) {
rb_yield(RARRAY(ary)->ptr[len]);
@@ -547,26 +608,26 @@ ary_reverse_each(ary)
}
static VALUE
-ary_length(ary)
+rb_ary_length(ary)
VALUE ary;
{
return INT2FIX(RARRAY(ary)->len);
}
static VALUE
-ary_empty_p(ary)
+rb_ary_empty_p(ary)
VALUE ary;
{
if (RARRAY(ary)->len == 0)
- return TRUE;
- return FALSE;
+ return Qtrue;
+ return Qfalse;
}
static VALUE
-ary_clone(ary)
+rb_ary_clone(ary)
VALUE ary;
{
- VALUE ary2 = ary_new2(RARRAY(ary)->len);
+ VALUE ary2 = rb_ary_new2(RARRAY(ary)->len);
CLONESETUP(ary2, ary);
MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
@@ -575,32 +636,56 @@ ary_clone(ary)
}
static VALUE
-ary_dup(ary)
+rb_ary_dup(ary)
VALUE ary;
{
- return ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
+ return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
}
-extern VALUE OFS;
+static VALUE
+to_ary(ary)
+ VALUE ary;
+{
+ return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
+}
-VALUE
-ary_join(ary, sep)
+extern VALUE rb_output_fs;
+
+static VALUE
+inspect_join(ary, arg)
VALUE ary;
- VALUE sep;
+ VALUE *arg;
{
- int i;
+ return rb_ary_join(arg[0], arg[1]);
+}
+
+VALUE
+rb_ary_join(ary, sep)
+ VALUE ary, sep;
+{
+ size_t i;
VALUE result, tmp;
- if (RARRAY(ary)->len == 0) return str_new(0, 0);
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
- switch (TYPE(RARRAY(ary)->ptr[0])) {
+ tmp = RARRAY(ary)->ptr[0];
+ switch (TYPE(tmp)) {
case T_STRING:
- result = str_dup(RARRAY(ary)->ptr[0]);
+ result = rb_str_dup(tmp);
break;
case T_ARRAY:
- result = ary_join(RARRAY(ary)->ptr[0], sep);
+ if (rb_inspecting_p(tmp)) {
+ result = rb_str_new2("[...]");
+ }
+ else {
+ VALUE args[2];
+
+ args[0] = tmp;
+ args[1] = sep;
+ result = rb_protect_inspect(inspect_join, ary, (VALUE)args);
+ }
break;
default:
- result = obj_as_string(RARRAY(ary)->ptr[0]);
+ result = rb_obj_as_string(tmp);
break;
}
@@ -610,21 +695,30 @@ ary_join(ary, sep)
case T_STRING:
break;
case T_ARRAY:
- tmp = ary_join(tmp, sep);
+ if (rb_inspecting_p(tmp)) {
+ tmp = rb_str_new2("[...]");
+ }
+ else {
+ VALUE args[2];
+
+ args[0] = tmp;
+ args[1] = sep;
+ tmp = rb_protect_inspect(inspect_join, ary, (VALUE)args);
+ }
break;
default:
- tmp = obj_as_string(tmp);
+ tmp = rb_obj_as_string(tmp);
}
- if (!NIL_P(sep)) str_cat(result, RSTRING(sep)->ptr, RSTRING(sep)->len);
- str_cat(result, RSTRING(tmp)->ptr, RSTRING(tmp)->len);
- if (str_tainted(tmp)) str_taint(result);
+ if (!NIL_P(sep)) rb_str_concat(result, sep);
+ rb_str_cat(result, RSTRING(tmp)->ptr, RSTRING(tmp)->len);
+ if (OBJ_TAINTED(tmp)) OBJ_TAINT(result);
}
return result;
}
static VALUE
-ary_join_method(argc, argv, ary)
+rb_ary_join_method(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
@@ -632,57 +726,144 @@ ary_join_method(argc, argv, ary)
VALUE sep;
rb_scan_args(argc, argv, "01", &sep);
- if (NIL_P(sep)) sep = OFS;
- if (!NIL_P(sep)) Check_Type(sep, T_STRING);
-
- return ary_join(ary, sep);
+ if (NIL_P(sep)) sep = rb_output_fs;
+ return rb_ary_join(ary, sep);
}
VALUE
-ary_to_s(ary)
+rb_ary_to_s(ary)
VALUE ary;
{
- VALUE str = ary_join(ary, OFS);
- if (NIL_P(str)) return str_new(0, 0);
+ VALUE str;
+
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
+ str = rb_ary_join(ary, rb_output_fs);
+ if (NIL_P(str)) return rb_str_new(0, 0);
return str;
}
+#ifdef USE_THREAD
+static ID inspect_key;
+#else
+static VALUE inspect_tbl;
+#endif
+
+struct inspect_arg {
+ VALUE (*func)();
+ VALUE arg1, arg2;
+};
+
+VALUE
+inspect_call(arg)
+ struct inspect_arg *arg;
+{
+ return (*arg->func)(arg->arg1, arg->arg2);
+}
+
static VALUE
-ary_inspect(ary)
+inspect_ensure(obj)
+ VALUE obj;
+{
+#ifdef USE_THREAD
+ VALUE inspect_tbl;
+
+ inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+#endif
+ rb_ary_pop(inspect_tbl);
+ return 0;
+}
+
+VALUE
+rb_protect_inspect(func, obj, arg)
+ VALUE (*func)();
+ VALUE obj, arg;
+{
+ struct inspect_arg iarg;
+
+#ifdef USE_THREAD
+ VALUE inspect_tbl;
+
+ if (!inspect_key) {
+ inspect_key = rb_intern("__inspect_key__");
+ }
+ inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+ if (NIL_P(inspect_tbl)) {
+ inspect_tbl = rb_ary_new();
+ rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
+ }
+#else
+ if (!inspect_tbl) {
+ inspect_tbl = rb_ary_new();
+ rb_global_variable(&inspect_tbl);
+ }
+#endif
+ rb_ary_push(inspect_tbl, obj);
+ iarg.func = func;
+ iarg.arg1 = obj;
+ iarg.arg2 = arg;
+ return rb_ensure(inspect_call, (VALUE)&iarg, inspect_ensure, obj);
+}
+
+VALUE
+rb_inspecting_p(obj)
+ VALUE obj;
+{
+#ifdef USE_THREAD
+ VALUE inspect_tbl;
+
+ if (!inspect_key) return Qfalse;
+ inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+ if (NIL_P(inspect_tbl)) return Qfalse;
+#else
+ if (!inspect_tbl) return Qnil;
+#endif
+ return rb_ary_includes(inspect_tbl, obj);
+}
+
+static VALUE
+inspect_ary(ary)
VALUE ary;
{
- int i, len;
+ size_t i = 0;
VALUE s, str;
- if (RARRAY(ary)->len == 0) return str_new2("[]");
- str = str_new2("[");
- len = 1;
+ str = rb_str_new2("[");
for (i=0; i<RARRAY(ary)->len; i++) {
s = rb_inspect(RARRAY(ary)->ptr[i]);
- if (i > 0) str_cat(str, ", ", 2);
- str_cat(str, RSTRING(s)->ptr, RSTRING(s)->len);
- len += RSTRING(s)->len + 2;
+ if (i > 0) rb_str_cat(str, ", ", 2);
+ rb_str_cat(str, RSTRING(s)->ptr, RSTRING(s)->len);
}
- str_cat(str, "]", 1);
+ rb_str_cat(str, "]", 1);
return str;
}
static VALUE
-ary_to_a(ary)
+rb_ary_inspect(ary)
+ VALUE ary;
+{
+ if (RARRAY(ary)->len == 0) return rb_str_new2("[]");
+ if (rb_inspecting_p(ary)) return rb_str_new2("[...]");
+ return rb_protect_inspect(inspect_ary, ary, 0);
+}
+
+static VALUE
+rb_ary_to_a(ary)
VALUE ary;
{
return ary;
}
VALUE
-ary_reverse(ary)
+rb_ary_reverse(ary)
VALUE ary;
{
VALUE *p1, *p2;
VALUE tmp;
+ if (RARRAY(ary)->len == 0) return ary;
+
p1 = RARRAY(ary)->ptr;
p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
@@ -697,10 +878,10 @@ ary_reverse(ary)
}
static VALUE
-ary_reverse_method(ary)
+rb_ary_reverse_method(ary)
VALUE ary;
{
- return ary_reverse(ary_clone(ary));
+ return rb_ary_reverse(rb_ary_dup(ary));
}
static ID cmp;
@@ -709,7 +890,7 @@ static int
sort_1(a, b)
VALUE *a, *b;
{
- VALUE retval = rb_yield(assoc_new(*a, *b));
+ VALUE retval = rb_yield(rb_assoc_new(*a, *b));
return NUM2INT(retval);
}
@@ -722,38 +903,59 @@ sort_2(a, b)
if (FIXNUM_P(*a)) {
if (FIXNUM_P(*b)) return *a - *b;
}
- else if (TYPE(*a) == T_STRING) {
- if (TYPE(*b) == T_STRING) return str_cmp(*a, *b);
+ else if (TYPE(*a) == T_STRING && TYPE(*b) == T_STRING) {
+ return rb_str_cmp(*a, *b);
}
retval = rb_funcall(*a, cmp, 1, *b);
return NUM2INT(retval);
}
+static VALUE
+sort_internal(ary)
+ VALUE ary;
+{
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
+ rb_iterator_p()?sort_1:sort_2);
+ return ary;
+}
+
+static VALUE
+sort_unlock(ary)
+ VALUE ary;
+{
+ FL_UNSET(ary, ARY_TMPLOCK);
+ return ary;
+}
+
VALUE
-ary_sort_bang(ary)
+rb_ary_sort_bang(ary)
VALUE ary;
{
- ary_modify(ary);
- qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), iterator_p()?sort_1:sort_2);
+ if (RARRAY(ary)->len <= 1) return ary;
+
+ rb_ary_modify(ary);
+ FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
+ rb_ensure(sort_internal, ary, sort_unlock, ary);
return ary;
}
VALUE
-ary_sort(ary)
+rb_ary_sort(ary)
VALUE ary;
{
- return ary_sort_bang(ary_clone(ary));
+ if (RARRAY(ary)->len == 0) return ary;
+ return rb_ary_sort_bang(rb_ary_dup(ary));
}
VALUE
-ary_delete(ary, item)
+rb_ary_delete(ary, item)
VALUE ary;
VALUE item;
{
- int i1, i2;
+ size_t i1, i2;
- ary_modify(ary);
+ rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
if (rb_equal(RARRAY(ary)->ptr[i1], item)) continue;
if (i1 != i2) {
@@ -762,7 +964,9 @@ ary_delete(ary, item)
i2++;
}
if (RARRAY(ary)->len == i2) {
- if (iterator_p()) rb_yield(item);
+ if (rb_iterator_p()) {
+ return rb_yield(item);
+ }
return Qnil;
}
else {
@@ -773,15 +977,15 @@ ary_delete(ary, item)
}
VALUE
-ary_delete_at(ary, at)
+rb_ary_delete_at(ary, at)
VALUE ary;
VALUE at;
{
- int i1, i2, pos;
+ size_t i1, i2, pos;
VALUE del = Qnil;
- ary_modify(ary);
- pos = NUM2INT(at);
+ rb_ary_modify(ary);
+ pos = NUM2UINT(at);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
if (i1 == pos) {
del = RARRAY(ary)->ptr[i1];
@@ -798,12 +1002,12 @@ ary_delete_at(ary, at)
}
static VALUE
-ary_delete_if(ary)
+rb_ary_delete_if(ary)
VALUE ary;
{
- int i1, i2;
+ size_t i1, i2;
- ary_modify(ary);
+ rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
if (rb_yield(RARRAY(ary)->ptr[i1])) continue;
if (i1 != i2) {
@@ -816,23 +1020,30 @@ ary_delete_if(ary)
return ary;
}
-#if 0
static VALUE
-ary_replace(ary)
+rb_ary_filter(ary)
VALUE ary;
{
- int i;
+ size_t i;
+ rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
RARRAY(ary)->ptr[i] = rb_yield(RARRAY(ary)->ptr[i]);
}
+ return ary;
+}
+static VALUE
+rb_ary_replace_method(ary, ary2)
+ VALUE ary, ary2;
+{
+ ary2 = to_ary(ary2);
+ rb_ary_replace(ary, 0, RARRAY(ary2)->len, ary2);
return ary;
}
-#endif
static VALUE
-ary_clear(ary)
+rb_ary_clear(ary)
VALUE ary;
{
RARRAY(ary)->len = 0;
@@ -844,32 +1055,28 @@ ary_clear(ary)
}
static VALUE
-ary_fill(argc, argv, ary)
+rb_ary_fill(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
VALUE item, arg1, arg2;
- int beg, len, end;
+ size_t beg, len, end;
VALUE *p, *pend;
- rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
- if (NIL_P(arg2) && beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
+ if (rb_scan_args(argc, argv, "12", &item, &arg1, &arg2) == 2 &&
+ beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
/* beg and len set already */
}
else {
- beg = NUM2INT(arg1);
+ beg = NIL_P(arg1)?0:NUM2UINT(arg1);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- if (!NIL_P(arg2)) {
- len = NUM2INT(arg2);
- }
- else {
- len = RARRAY(ary)->len - beg;
- }
+ len = NIL_P(arg2)?RARRAY(ary)->len - beg:NUM2UINT(arg2);
}
+ rb_ary_modify(ary);
end = beg + len;
if (end > RARRAY(ary)->len) {
if (end >= RARRAY(ary)->capa) {
@@ -877,7 +1084,7 @@ ary_fill(argc, argv, ary)
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
if (beg > RARRAY(ary)->len) {
- memclear(RARRAY(ary)->ptr+RARRAY(ary)->len, end-RARRAY(ary)->len);
+ rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len,end-RARRAY(ary)->len);
}
RARRAY(ary)->len = end;
}
@@ -890,16 +1097,16 @@ ary_fill(argc, argv, ary)
}
VALUE
-ary_plus(x, y)
+rb_ary_plus(x, y)
VALUE x, y;
{
VALUE z;
if (TYPE(y) != T_ARRAY) {
- return ary_plus(x, rb_Array(y));
+ return rb_ary_plus(x, rb_Array(y));
}
- z = ary_new2(RARRAY(x)->len + RARRAY(y)->len);
+ z = rb_ary_new2(RARRAY(x)->len + RARRAY(y)->len);
MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
MEMCPY(RARRAY(z)->ptr+RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
RARRAY(z)->len = RARRAY(x)->len + RARRAY(y)->len;
@@ -907,43 +1114,44 @@ ary_plus(x, y)
}
VALUE
-ary_concat(x, y)
+rb_ary_concat(x, y)
VALUE x, y;
{
VALUE *p, *pend;
if (TYPE(y) != T_ARRAY) {
- return ary_concat(x, rb_Array(y));
+ return rb_ary_concat(x, rb_Array(y));
}
p = RARRAY(y)->ptr;
pend = p + RARRAY(y)->len;
while (p < pend) {
- ary_store(x, RARRAY(x)->len, *p);
+ rb_ary_store(x, RARRAY(x)->len, *p);
p++;
}
return x;
}
static VALUE
-ary_times(ary, times)
+rb_ary_times(ary, times)
VALUE ary;
VALUE times;
{
VALUE ary2;
- int i, len;
+ size_t i, len;
if (TYPE(times) == T_STRING) {
- return ary_join(ary, times);
+ return rb_ary_join(ary, times);
}
- len = NUM2INT(times) * RARRAY(ary)->len;
- ary2 = ary_new2(len);
- RARRAY(ary2)->len = len;
-
+ len = NUM2UINT(times);
if (len < 0) {
- ArgError("negative argument");
+ rb_raise(rb_eArgError, "negative argument");
}
+ len *= RARRAY(ary)->len;
+
+ ary2 = rb_ary_new2(len);
+ RARRAY(ary2)->len = len;
for (i=0; i<len; i+=RARRAY(ary)->len) {
MEMCPY(RARRAY(ary2)->ptr+i, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
@@ -953,7 +1161,7 @@ ary_times(ary, times)
}
VALUE
-ary_assoc(ary, key)
+rb_ary_assoc(ary, key)
VALUE ary;
VALUE key;
{
@@ -971,7 +1179,7 @@ ary_assoc(ary, key)
}
VALUE
-ary_rassoc(ary, value)
+rb_ary_rassoc(ary, value)
VALUE ary;
VALUE value;
{
@@ -989,135 +1197,203 @@ ary_rassoc(ary, value)
}
static VALUE
-ary_equal(ary1, ary2)
+rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
- int i;
+ size_t i;
- if (TYPE(ary2) != T_ARRAY) return FALSE;
- if (RARRAY(ary1)->len != RARRAY(ary2)->len) return FALSE;
+ if (TYPE(ary2) != T_ARRAY) return Qfalse;
+ if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_equal(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
- return FALSE;
+ return Qfalse;
}
- return TRUE;
+ return Qtrue;
}
static VALUE
-ary_eql(ary1, ary2)
+rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
- int i;
+ size_t i;
- if (TYPE(ary2) != T_ARRAY) return FALSE;
+ if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len)
- return FALSE;
+ return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_eql(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
- return FALSE;
+ return Qfalse;
}
- return TRUE;
+ return Qtrue;
}
static VALUE
-ary_hash(ary)
+rb_ary_hash(ary)
VALUE ary;
{
- int h, i;
+ size_t i;
+ int h;
h = RARRAY(ary)->len;
for (i=0; i<RARRAY(ary)->len; i++) {
- h ^= rb_hash(RARRAY(ary)->ptr[i]);
+ int n = rb_hash(RARRAY(ary)->ptr[i]);
+ h ^= NUM2LONG(n);
}
return INT2FIX(h);
}
VALUE
-ary_includes(ary, item)
+rb_ary_includes(ary, item)
VALUE ary;
VALUE item;
{
- int i;
+ size_t i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], item)) {
- return TRUE;
+ return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+static VALUE
+rb_ary_cmp(ary, ary2)
+ VALUE ary;
+ VALUE ary2;
+{
+ size_t i, len;
+
+ ary2 = to_ary(ary2);
+ len = RARRAY(ary)->len;
+ if (len > RARRAY(ary2)->len) {
+ len = RARRAY(ary2)->len;
+ }
+ for (i=0; i<len; i++) {
+ VALUE v = rb_funcall(RARRAY(ary)->ptr[i],cmp,1,RARRAY(ary2)->ptr[i]);
+ if (v != INT2FIX(0)) {
+ return v;
}
}
- return FALSE;
+ len = RARRAY(ary)->len - RARRAY(ary2)->len;
+ if (len == 0) return INT2FIX(0);
+ if (len > 0) return INT2FIX(1);
+ return INT2FIX(-1);
}
static VALUE
-ary_diff(ary1, ary2)
+rb_ary_diff(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- int i;
+ size_t i;
- Check_Type(ary2, T_ARRAY);
- ary3 = ary_new();
+ ary2 = to_ary(ary2);
+ ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (ary_includes(ary2, RARRAY(ary1)->ptr[i])) continue;
- if (ary_includes(ary3, RARRAY(ary1)->ptr[i])) continue;
- ary_push(ary3, RARRAY(ary1)->ptr[i]);
+ if (rb_ary_includes(ary2, RARRAY(ary1)->ptr[i])) continue;
+ if (rb_ary_includes(ary3, RARRAY(ary1)->ptr[i])) continue;
+ rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
}
return ary3;
}
static VALUE
-ary_and(ary1, ary2)
+rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- int i;
+ size_t i;
- Check_Type(ary2, T_ARRAY);
- ary3 = ary_new();
+ ary2 = to_ary(ary2);
+ ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (ary_includes(ary2, RARRAY(ary1)->ptr[i])
- && !ary_includes(ary3, RARRAY(ary1)->ptr[i])) {
- ary_push(ary3, RARRAY(ary1)->ptr[i]);
+ if (rb_ary_includes(ary2, RARRAY(ary1)->ptr[i])
+ && !rb_ary_includes(ary3, RARRAY(ary1)->ptr[i])) {
+ rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
}
}
return ary3;
}
static VALUE
-ary_or(ary1, ary2)
+rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- int i;
+ size_t i;
if (TYPE(ary2) != T_ARRAY) {
- if (ary_includes(ary1, ary2)) return ary1;
- else return ary_plus(ary1, ary2);
+ if (rb_ary_includes(ary1, ary2)) return ary1;
+ else return rb_ary_plus(ary1, ary2);
}
- ary3 = ary_new();
+ ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!ary_includes(ary3, RARRAY(ary1)->ptr[i]))
- ary_push(ary3, RARRAY(ary1)->ptr[i]);
+ if (!rb_ary_includes(ary3, RARRAY(ary1)->ptr[i]))
+ rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
}
for (i=0; i<RARRAY(ary2)->len; i++) {
- if (!ary_includes(ary3, RARRAY(ary2)->ptr[i]))
- ary_push(ary3, RARRAY(ary2)->ptr[i]);
+ if (!rb_ary_includes(ary3, RARRAY(ary2)->ptr[i]))
+ rb_ary_push(ary3, RARRAY(ary2)->ptr[i]);
}
return ary3;
}
static VALUE
-ary_compact_bang(ary)
+rb_ary_uniq_bang(ary)
+ VALUE ary;
+{
+ VALUE *p, *q, *t, *end;
+ VALUE v;
+
+ rb_ary_modify(ary);
+ p = RARRAY(ary)->ptr;
+ end = p + RARRAY(ary)->len;
+
+ while (p < end) {
+ v = *p++;
+ q = t = p;
+ while (q < end) {
+ if (rb_equal(*q, v)) q++;
+ else *t++ = *q++;
+ }
+ end = t;
+ }
+ if (RARRAY(ary)->len == (end - RARRAY(ary)->ptr)) {
+ return Qnil;
+ }
+
+ RARRAY(ary)->len = (end - RARRAY(ary)->ptr);
+
+ return ary;
+}
+
+static VALUE
+rb_ary_uniq(ary)
+ VALUE ary;
+{
+ VALUE v = rb_ary_uniq_bang(rb_ary_dup(ary));
+
+ if (NIL_P(v)) return ary;
+ return v;
+}
+
+static VALUE
+rb_ary_compact_bang(ary)
VALUE ary;
{
VALUE *p, *t, *end;
- ary_modify(ary);
+ rb_ary_modify(ary);
p = t = RARRAY(ary)->ptr;
end = p + RARRAY(ary)->len;
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
+ if (RARRAY(ary)->len == (p - RARRAY(ary)->ptr)) {
+ return Qnil;
+ }
RARRAY(ary)->len = RARRAY(ary)->capa = (p - RARRAY(ary)->ptr);
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
@@ -1125,17 +1401,20 @@ ary_compact_bang(ary)
}
static VALUE
-ary_compact(ary)
+rb_ary_compact(ary)
VALUE ary;
{
- return ary_compact_bang(ary_clone(ary));
+ VALUE v = rb_ary_compact_bang(rb_ary_dup(ary));
+
+ if (NIL_P(v)) return ary;
+ return v;
}
static VALUE
-ary_nitems(ary)
+rb_ary_nitems(ary)
VALUE ary;
{
- int n = 0;
+ size_t n = 0;
VALUE *p, *pend;
p = RARRAY(ary)->ptr;
@@ -1147,74 +1426,108 @@ ary_nitems(ary)
return INT2FIX(n);
}
-extern VALUE mEnumerable;
-
-void
-Init_Array()
+static VALUE
+rb_ary_flatten_bang(ary)
+ VALUE ary;
{
- cArray = rb_define_class("Array", cObject);
- rb_include_module(cArray, mEnumerable);
-
- rb_define_singleton_method(cArray, "new", ary_s_new, -1);
- rb_define_singleton_method(cArray, "[]", ary_s_create, -1);
- rb_define_method(cArray, "to_s", ary_to_s, 0);
- rb_define_method(cArray, "inspect", ary_inspect, 0);
- rb_define_method(cArray, "to_a", ary_to_a, 0);
-
- rb_define_method(cArray, "freeze", ary_freeze, 0);
- rb_define_method(cArray, "frozen?", ary_frozen_p, 0);
-
- rb_define_method(cArray, "==", ary_equal, 1);
- rb_define_method(cArray, "eql?", ary_eql, 1);
- rb_define_method(cArray, "hash", ary_hash, 0);
-
- rb_define_method(cArray, "[]", ary_aref, -1);
- rb_define_method(cArray, "[]=", ary_aset, -1);
- rb_define_method(cArray, "concat", ary_concat, 1);
- rb_define_method(cArray, "<<", ary_push, 1);
- rb_define_method(cArray, "push", ary_push_method, -1);
- rb_define_method(cArray, "pop", ary_pop, 0);
- rb_define_method(cArray, "shift", ary_shift, 0);
- rb_define_method(cArray, "unshift", ary_unshift, 1);
- rb_define_method(cArray, "each", ary_each, 0);
- rb_define_method(cArray, "each_index", ary_each_index, 0);
- rb_define_method(cArray, "reverse_each", ary_reverse_each, 0);
- rb_define_method(cArray, "length", ary_length, 0);
- rb_define_alias(cArray, "size", "length");
- rb_define_method(cArray, "empty?", ary_empty_p, 0);
- rb_define_method(cArray, "index", ary_index, 1);
- rb_define_method(cArray, "indexes", ary_indexes, -2);
- rb_define_method(cArray, "clone", ary_clone, 0);
- rb_define_method(cArray, "dup", ary_dup, 0);
- rb_define_method(cArray, "join", ary_join_method, -1);
- rb_define_method(cArray, "reverse", ary_reverse_method, 0);
- rb_define_method(cArray, "reverse!", ary_reverse, 0);
- rb_define_method(cArray, "sort", ary_sort, 0);
- rb_define_method(cArray, "sort!", ary_sort_bang, 0);
- rb_define_method(cArray, "delete", ary_delete, 1);
- rb_define_method(cArray, "delete_at", ary_delete_at, 1);
- rb_define_method(cArray, "delete_if", ary_delete_if, 0);
-#if 0
- rb_define_method(cArray, "replace", ary_replace, 0);
-#endif
- rb_define_method(cArray, "clear", ary_clear, 0);
- rb_define_method(cArray, "fill", ary_fill, -1);
- rb_define_method(cArray, "include?", ary_includes, 1);
- rb_define_method(cArray, "===", ary_includes, 1);
+ size_t i;
+ int mod = 0;
- rb_define_method(cArray, "assoc", ary_assoc, 1);
- rb_define_method(cArray, "rassoc", ary_rassoc, 1);
+ rb_ary_modify(ary);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ VALUE ary2 = RARRAY(ary)->ptr[i];
+ if (TYPE(ary2) == T_ARRAY) {
+ rb_ary_replace(ary, i--, 1, ary2);
+ mod = 1;
+ }
+ }
+ if (mod == 0) return Qnil;
+ return ary;
+}
- rb_define_method(cArray, "+", ary_plus, 1);
- rb_define_method(cArray, "*", ary_times, 1);
+static VALUE
+rb_ary_flatten(ary)
+ VALUE ary;
+{
+ VALUE v = rb_ary_flatten_bang(rb_ary_dup(ary));
- rb_define_method(cArray, "-", ary_diff, 1);
- rb_define_method(cArray, "&", ary_and, 1);
- rb_define_method(cArray, "|", ary_or, 1);
+ if (NIL_P(v)) return ary;
+ return v;
+}
- rb_define_method(cArray, "compact", ary_compact, 0);
- rb_define_method(cArray, "compact!", ary_compact_bang, 0);
- rb_define_method(cArray, "nitems", ary_nitems, 0);
+void
+Init_Array()
+{
+ rb_cArray = rb_define_class("Array", rb_cObject);
+ rb_include_module(rb_cArray, rb_mEnumerable);
+
+ rb_define_singleton_method(rb_cArray, "new", rb_ary_s_new, -1);
+ rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1);
+ rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0);
+ rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0);
+ rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
+ rb_define_method(rb_cArray, "to_ary", rb_ary_to_a, 0);
+
+ rb_define_method(rb_cArray, "freeze", rb_ary_freeze, 0);
+ rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0);
+
+ rb_define_method(rb_cArray, "==", rb_ary_equal, 1);
+ rb_define_method(rb_cArray, "eql?", rb_ary_eql, 1);
+ rb_define_method(rb_cArray, "hash", rb_ary_hash, 0);
+ rb_define_method(rb_cArray, "===", rb_ary_equal, 1);
+
+ rb_define_method(rb_cArray, "[]", rb_ary_aref, -1);
+ rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
+ rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
+ rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
+ rb_define_method(rb_cArray, "push", rb_ary_push_method, -1);
+ rb_define_method(rb_cArray, "pop", rb_ary_pop, 0);
+ rb_define_method(rb_cArray, "shift", rb_ary_shift, 0);
+ rb_define_method(rb_cArray, "unshift", rb_ary_unshift, 1);
+ rb_define_method(rb_cArray, "each", rb_ary_each, 0);
+ rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
+ rb_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0);
+ rb_define_method(rb_cArray, "length", rb_ary_length, 0);
+ rb_define_alias(rb_cArray, "size", "length");
+ rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0);
+ rb_define_method(rb_cArray, "index", rb_ary_index, 1);
+ rb_define_method(rb_cArray, "rindex", rb_ary_rindex, 1);
+ rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1);
+ rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1);
+ rb_define_method(rb_cArray, "clone", rb_ary_clone, 0);
+ rb_define_method(rb_cArray, "dup", rb_ary_dup, 0);
+ rb_define_method(rb_cArray, "join", rb_ary_join_method, -1);
+ rb_define_method(rb_cArray, "reverse", rb_ary_reverse_method, 0);
+ rb_define_method(rb_cArray, "reverse!", rb_ary_reverse, 0);
+ rb_define_method(rb_cArray, "sort", rb_ary_sort, 0);
+ rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
+ rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
+ rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at, 1);
+ rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
+ rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
+ rb_define_method(rb_cArray, "replace", rb_ary_replace_method, 1);
+ rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
+ rb_define_method(rb_cArray, "fill", rb_ary_fill, -1);
+ rb_define_method(rb_cArray, "include?", rb_ary_includes, 1);
+ rb_define_method(rb_cArray, "<=>", rb_ary_cmp, 1);
+
+ rb_define_method(rb_cArray, "assoc", rb_ary_assoc, 1);
+ rb_define_method(rb_cArray, "rassoc", rb_ary_rassoc, 1);
+
+ rb_define_method(rb_cArray, "+", rb_ary_plus, 1);
+ rb_define_method(rb_cArray, "*", rb_ary_times, 1);
+
+ rb_define_method(rb_cArray, "-", rb_ary_diff, 1);
+ rb_define_method(rb_cArray, "&", rb_ary_and, 1);
+ rb_define_method(rb_cArray, "|", rb_ary_or, 1);
+
+ rb_define_method(rb_cArray, "uniq", rb_ary_uniq, 0);
+ rb_define_method(rb_cArray, "uniq!", rb_ary_uniq_bang, 0);
+ rb_define_method(rb_cArray, "compact", rb_ary_compact, 0);
+ rb_define_method(rb_cArray, "compact!", rb_ary_compact_bang, 0);
+ rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
+ rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, 0);
+ rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
cmp = rb_intern("<=>");
}
diff --git a/bignum.c b/bignum.c
index 17d9c83..770e86a 100644
--- a/bignum.c
+++ b/bignum.c
@@ -9,28 +9,28 @@
************************************************/
#include "ruby.h"
-#include <ctype.h>
#include <math.h>
+#include <ctype.h>
-extern VALUE cInteger;
-VALUE cBignum;
+VALUE rb_cBignum;
+typedef unsigned short USHORT;
#define BDIGITS(x) RBIGNUM(x)->digits
-#define BITSPERDIG (sizeof(USHORT)*CHAR_BIT)
+#define BITSPERDIG (sizeof(short)*CHAR_BIT)
#define BIGRAD (1L << BITSPERDIG)
-#define DIGSPERINT ((UINT)(sizeof(INT)/sizeof(USHORT)))
-#define BIGUP(x) ((UINT)(x) << BITSPERDIG)
-#define BIGDN(x) ((x) >> BITSPERDIG)
-#define BIGLO(x) ((x) & (BIGRAD-1))
+#define DIGSPERINT ((unsigned int)(sizeof(long)/sizeof(short)))
+#define BIGUP(x) ((unsigned long)(x) << BITSPERDIG)
+#define BIGDN(x) (((x)<0) ? ~((~(x))>>BITSPERDIG) : (x)>>BITSPERDIG)
+#define BIGLO(x) ((USHORT)((x) & (BIGRAD-1)))
static VALUE
-bignew_1(class, len, sign)
- VALUE class;
- UINT len;
+bignew_1(klass, len, sign)
+ VALUE klass;
+ size_t len;
char sign;
{
NEWOBJ(big, struct RBignum);
- OBJSETUP(big, cBignum, T_BIGNUM);
+ OBJSETUP(big, klass, T_BIGNUM);
big->sign = sign;
big->len = len;
BDIGITS(big) = ALLOC_N(USHORT, len);
@@ -38,10 +38,10 @@ bignew_1(class, len, sign)
return (VALUE)big;
}
-#define bignew(len,sign) bignew_1(cBignum,len,sign)
+#define bignew(len,sign) bignew_1(rb_cBignum,len,sign)
VALUE
-big_clone(x)
+rb_big_clone(x)
VALUE x;
{
VALUE z = bignew_1(CLASS_OF(x), RBIGNUM(x)->len, RBIGNUM(x)->sign);
@@ -51,22 +51,22 @@ big_clone(x)
}
void
-big_2comp(x) /* get 2's complement */
+rb_big_2comp(x) /* get 2's complement */
VALUE x;
{
- UINT i = RBIGNUM(x)->len;
+ int i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
long num;
while (i--) ds[i] = ~ds[i];
i = 0; num = 1;
do {
- num += (long)ds[i];
+ num += ds[i];
ds[i++] = BIGLO(num);
num = BIGDN(num);
} while (i < RBIGNUM(x)->len);
if (ds[0] == 1 || ds[0] == 0) {
- for (i=1;i<RBIGNUM(x)->len;i++) {
+ for (i=1; i<RBIGNUM(x)->len; i++) {
if (ds[i] != 0) return;
}
REALLOC_N(BDIGITS(x), USHORT, RBIGNUM(x)->len++);
@@ -79,39 +79,39 @@ static VALUE
bignorm(x)
VALUE x;
{
- UINT len = RBIGNUM(x)->len;
+ size_t len = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (len-- && !ds[len]) ;
RBIGNUM(x)->len = ++len;
- if (len*sizeof(USHORT) < sizeof(VALUE) ||
- (len*sizeof(USHORT) == sizeof(VALUE) &&
- ds[sizeof(VALUE)/sizeof(USHORT)-1] <= 0x3fff)) {
+ if (len*sizeof(USHORT) <= sizeof(VALUE)) {
long num = 0;
while (len--) {
num = BIGUP(num) + ds[len];
}
- if (RBIGNUM(x)->sign) {
- if (POSFIXABLE(num)) return INT2FIX(num);
+ if (num >= 0) {
+ if (RBIGNUM(x)->sign) {
+ if (POSFIXABLE(num)) return INT2FIX(num);
+ }
+ else if (NEGFIXABLE(-(long)num)) return INT2FIX(-(long)num);
}
- else if (NEGFIXABLE(-num)) return INT2FIX(-num);
}
return x;
}
VALUE
-big_norm(x)
+rb_big_norm(x)
VALUE x;
{
- return bignorm(RBIGNUM(x));
+ return bignorm(x);
}
VALUE
-uint2big(n)
- UINT n;
+rb_uint2big(n)
+ unsigned long n;
{
- UINT i = 0;
+ unsigned int i = 0;
USHORT *digits;
VALUE big;
@@ -130,17 +130,17 @@ uint2big(n)
}
VALUE
-int2big(n)
- INT n;
+rb_int2big(n)
+ long n;
{
- INT neg = 0;
+ long neg = 0;
VALUE big;
if (n < 0) {
n = -n;
neg = 1;
}
- big = uint2big(n);
+ big = rb_uint2big(n);
if (neg) {
RBIGNUM(big)->sign = 0;
}
@@ -148,34 +148,39 @@ int2big(n)
}
VALUE
-uint2inum(n)
- UINT n;
+rb_uint2inum(n)
+ unsigned long n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
- return uint2big(n);
+ return rb_uint2big(n);
}
VALUE
-int2inum(n)
- INT n;
+rb_int2inum(n)
+ long n;
{
if (FIXABLE(n)) return INT2FIX(n);
- return int2big(n);
+ return rb_int2big(n);
}
VALUE
-str2inum(str, base)
- UCHAR *str;
+rb_str2inum(str, base)
+ char *str;
int base;
{
char sign = 1, c;
unsigned long num;
- UINT len, blen = 1, i;
+ size_t len, blen = 1;
+ int i;
VALUE z;
USHORT *zds;
- while (isspace(*str)) str++;
- if (*str == '-') {
+ while (ISSPACE(*str)) str++;
+
+ if (*str == '+') {
+ str++;
+ }
+ else if (*str == '-') {
str++;
sign = 0;
}
@@ -195,26 +200,30 @@ str2inum(str, base)
base = 10;
}
}
- len = strlen(str);
if (base == 8) {
- len = 3*len*sizeof(char);
+ while (str[0] == '0') str++;
+ len = 3*strlen(str)*sizeof(char);
}
else { /* base == 10 or 16 */
- len = 4*len*sizeof(char);
+ if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
+ str += 2;
+ }
+ while (str[0] == '0') str++;
+ len = 4*strlen(str)*sizeof(char);
}
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
- UINT val = strtoul((char*)str, 0, base);
+ unsigned int val = strtoul((char*)str, 0, base);
if (POSFIXABLE(val)) {
if (sign) return INT2FIX(val);
else {
- INT result = -(INT)val;
+ long result = -(long)val;
return INT2FIX(result);
}
}
else {
- VALUE big = uint2big(val);
+ VALUE big = rb_uint2big(val);
RBIGNUM(big)->sign = sign;
return big;
}
@@ -263,21 +272,21 @@ str2inum(str, base)
static char hexmap[] = "0123456789abcdef";
VALUE
-big2str(x, base)
+rb_big2str(x, base)
VALUE x;
int base;
{
VALUE t;
USHORT *ds;
- UINT i, j, hbase;
+ unsigned int i, j, hbase;
VALUE ss;
- UCHAR *s, c;
+ char *s, c;
if (FIXNUM_P(x)) {
- return fix2str(x, base);
+ return rb_fix2str(x, base);
}
i = RBIGNUM(x)->len;
- if (i == 0) return str_new2("0");
+ if (i == 0) return rb_str_new2("0");
if (base == 10) {
j = (sizeof(USHORT)/sizeof(char)*CHAR_BIT*i*241L)/800+2;
hbase = 10000;
@@ -297,12 +306,12 @@ big2str(x, base)
else {
j = 0;
hbase = 0;
- Fail("bignum cannot treat base %d", base);
+ rb_raise(rb_eArgError, "bignum cannot treat base %d", base);
}
- t = big_clone(x);
+ t = rb_big_clone(x);
ds = BDIGITS(t);
- ss = str_new(0, j);
+ ss = rb_str_new(0, j);
s = RSTRING(ss)->ptr;
s[0] = RBIGNUM(x)->sign ? '+' : '-';
@@ -311,13 +320,13 @@ big2str(x, base)
unsigned long num = 0;
while (k--) {
num = BIGUP(num) + ds[k];
- ds[k] = num / hbase;
+ ds[k] = (USHORT)(num / hbase);
num %= hbase;
}
if (ds[i-1] == 0) i--;
k = 4;
while (k--) {
- c = num % base;
+ c = (char)(num % base);
s[--j] = hexmap[(int)c];
num /= base;
if (i == 0 && num == 0) break;
@@ -332,44 +341,56 @@ big2str(x, base)
}
static VALUE
-big_to_s(x)
+rb_big_to_s(x)
VALUE x;
{
- return big2str(x, 10);
+ return rb_big2str(x, 10);
}
-INT
-big2int(x)
+unsigned long
+rb_big2ulong(x)
VALUE x;
{
- UINT num;
- UINT len = RBIGNUM(x)->len;
+ unsigned long num;
+ size_t len = RBIGNUM(x)->len;
USHORT *ds;
if (len > sizeof(long)/sizeof(USHORT))
- ArgError("Bignum too big to convert into fixnum");
+ rb_raise(rb_eArgError, "bignum too big to convert into `uint'");
ds = BDIGITS(x);
num = 0;
while (len--) {
num = BIGUP(num);
num += ds[len];
}
- if (!RBIGNUM(x)->sign) return -num;
return num;
}
-VALUE
-big_to_i(x)
+long
+rb_big2long(x)
+ VALUE x;
+{
+ unsigned long num = rb_big2ulong(x);
+
+ if ((long)num < 0) {
+ rb_raise(rb_eArgError, "bignum too big to convert into `int'");
+ }
+ if (!RBIGNUM(x)->sign) return -(long)num;
+ return num;
+}
+
+static VALUE
+rb_big_to_i(x)
VALUE x;
{
return bignorm(x);
}
VALUE
-dbl2big(d)
+rb_dbl2big(d)
double d;
{
- UINT i = 0;
+ unsigned int i = 0;
long c;
USHORT *digits;
VALUE z;
@@ -385,18 +406,18 @@ dbl2big(d)
u *= BIGRAD;
c = (long)u;
u -= c;
- digits[i] = c;
+ digits[i] = (USHORT)c;
}
return bignorm(z);
}
double
-big2dbl(x)
+rb_big2dbl(x)
VALUE x;
{
double d = 0.0;
- UINT i = RBIGNUM(x)->len;
+ size_t i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (i--) {
@@ -406,29 +427,29 @@ big2dbl(x)
return d;
}
-VALUE
-big_to_f(x)
+static VALUE
+rb_big_to_f(x)
VALUE x;
{
- return float_new(big2dbl(x));
+ return rb_float_new(rb_big2dbl(x));
}
static VALUE
-big_cmp(x, y)
+rb_big_cmp(x, y)
VALUE x, y;
{
- int xlen = RBIGNUM(x)->len;
+ size_t xlen = RBIGNUM(x)->len;
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
break;
case T_BIGNUM:
break;
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
if (RBIGNUM(x)->sign > RBIGNUM(y)->sign) return INT2FIX(1);
@@ -446,18 +467,18 @@ big_cmp(x, y)
}
static VALUE
-big_eq(x, y)
+rb_big_eq(x, y)
VALUE x, y;
{
- if (big_cmp(x, y) == INT2FIX(0)) return TRUE;
- return FALSE;
+ if (rb_big_cmp(x, y) == INT2FIX(0)) return Qtrue;
+ return Qfalse;
}
static VALUE
-big_uminus(x)
+rb_big_uminus(x)
VALUE x;
{
- VALUE z = big_clone(x);
+ VALUE z = rb_big_clone(x);
RBIGNUM(z)->sign = !RBIGNUM(x)->sign;
@@ -465,16 +486,16 @@ big_uminus(x)
}
static VALUE
-big_neg(x)
+rb_big_neg(x)
VALUE x;
{
- VALUE z = big_clone(x);
- UINT i = RBIGNUM(x)->len;
+ VALUE z = rb_big_clone(x);
+ size_t i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(z);
- if (!RBIGNUM(x)->sign) big_2comp(z);
+ if (!RBIGNUM(x)->sign) rb_big_2comp(z);
while (i--) ds[i] = ~ds[i];
- if (RBIGNUM(x)->sign) big_2comp(z);
+ if (RBIGNUM(x)->sign) rb_big_2comp(z);
RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
return bignorm(z);
@@ -487,7 +508,7 @@ bigsub(x, y)
VALUE z = 0;
USHORT *zds;
long num;
- UINT i;
+ size_t i;
i = RBIGNUM(x)->len;
/* if x is larger than y, swap */
@@ -535,10 +556,11 @@ bigadd(x, y, sign)
{
VALUE z;
long num;
- UINT i, len;
+ size_t i, len;
- if (RBIGNUM(x)->sign == (RBIGNUM(y)->sign ^ sign)) {
- if (RBIGNUM(y)->sign == sign) return bigsub(y, x);
+ sign = (sign == RBIGNUM(y)->sign);
+ if (RBIGNUM(x)->sign != sign) {
+ if (sign) return bigsub(y, x);
return bigsub(x, y);
}
@@ -549,11 +571,11 @@ bigadd(x, y, sign)
else {
len = RBIGNUM(y)->len + 1;
}
- z = bignew(len, sign==RBIGNUM(y)->sign);
+ z = bignew(len, sign);
len = RBIGNUM(x)->len;
for (i = 0, num = 0; i < len; i++) {
- num += (long)(BDIGITS(x)[i] + BDIGITS(y)[i]);
+ num += BDIGITS(x)[i] + BDIGITS(y)[i];
BDIGITS(z)[i] = BIGLO(num);
num = BIGDN(num);
}
@@ -567,72 +589,72 @@ bigadd(x, y, sign)
BDIGITS(z)[i] = BDIGITS(y)[i];
i++;
}
- BDIGITS(z)[i] = num;
+ BDIGITS(z)[i] = (USHORT)num;
return bignorm(z);
}
VALUE
-big_plus(x, y)
+rb_big_plus(x, y)
VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
/* fall through */
case T_BIGNUM:
return bigadd(x, y, 1);
case T_FLOAT:
- return float_new(big2dbl(x) + RFLOAT(y)->value);
+ return rb_float_new(rb_big2dbl(x) + RFLOAT(y)->value);
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
}
VALUE
-big_minus(x, y)
+rb_big_minus(x, y)
VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
/* fall through */
case T_BIGNUM:
return bigadd(x, y, 0);
case T_FLOAT:
- return float_new(big2dbl(x) - RFLOAT(y)->value);
+ return rb_float_new(rb_big2dbl(x) - RFLOAT(y)->value);
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
}
VALUE
-big_mul(x, y)
+rb_big_mul(x, y)
VALUE x, y;
{
- UINT i = 0, j;
+ size_t i, j;
unsigned long n = 0;
VALUE z;
USHORT *zds;
- if (FIXNUM_P(x)) x = int2big(FIX2INT(x));
+ if (FIXNUM_P(x)) x = rb_int2big(FIX2LONG(x));
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
break;
case T_BIGNUM:
break;
case T_FLOAT:
- return float_new(big2dbl(x) * RFLOAT(y)->value);
+ return rb_float_new(rb_big2dbl(x) * RFLOAT(y)->value);
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
j = RBIGNUM(x)->len + RBIGNUM(y)->len + 1;
@@ -658,19 +680,21 @@ big_mul(x, y)
}
static void
-bigdivmod(x, y, div, mod)
+bigdivmod(x, y, div, mod, modulo)
VALUE x, y;
VALUE *div, *mod;
+ int modulo;
{
- UINT nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len, i, j;
- VALUE z;
+ size_t nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
+ int i, j;
+ VALUE yy, z;
USHORT *xds, *yds, *zds, *tds;
- unsigned long t2;
+ size_t t2;
long num;
USHORT dd, q;
yds = BDIGITS(y);
- if (ny == 0 && yds[0] == 0) num_zerodiv();
+ if (ny == 0 && yds[0] == 0) rb_num_zerodiv();
if (nx < ny || nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1]) {
if (div) *div = INT2FIX(0);
if (mod) *mod = bignorm(x);
@@ -679,17 +703,17 @@ bigdivmod(x, y, div, mod)
xds = BDIGITS(x);
if (ny == 1) {
dd = yds[0];
- z = big_clone(x);
+ z = rb_big_clone(x);
zds = BDIGITS(z);
t2 = 0; i = nx;
while (i--) {
t2 = BIGUP(t2) + zds[i];
- zds[i] = t2 / dd;
+ zds[i] = (USHORT)(t2 / dd);
t2 %= dd;
}
if (div) *div = bignorm(z);
if (mod) {
- if (!RBIGNUM(y)->sign) t2 = -t2;
+ if (!RBIGNUM(y)->sign) t2 = -(long)t2;
*mod = INT2FIX(t2);
}
return;
@@ -699,12 +723,12 @@ bigdivmod(x, y, div, mod)
if (nx==ny) zds[nx+1] = 0;
while (!yds[ny-1]) ny--;
if ((dd = BIGRAD/(int)(yds[ny-1]+1)) != 1) {
- y = big_clone(y);
- tds = BDIGITS(y);
+ yy = rb_big_clone(y);
+ tds = BDIGITS(yy);
j = 0;
num = 0;
while (j<ny) {
- num += (unsigned long)yds[j]*dd;
+ num += (long)yds[j]*dd;
tds[j++] = BIGLO(num);
num = BIGDN(num);
}
@@ -712,11 +736,11 @@ bigdivmod(x, y, div, mod)
j = 0;
num = 0;
while (j<nx) {
- num += (unsigned long)xds[j]*dd;
+ num += (long)xds[j]*dd;
zds[j++] = BIGLO(num);
num = BIGDN(num);
}
- zds[j] = num;
+ zds[j] = (USHORT)num;
}
else {
zds[nx] = 0;
@@ -726,12 +750,12 @@ bigdivmod(x, y, div, mod)
j = nx==ny?nx+1:nx;
do {
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
- else q = (BIGUP(zds[j]) + zds[j-1])/yds[ny-1];
+ else q = (USHORT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
if (q) {
i = 0; num = 0; t2 = 0;
do { /* multiply and subtract */
int ee;
- t2 += (unsigned long)yds[i] * q;
+ t2 += (long)yds[i] * q;
ee = num - BIGLO(t2);
num = zds[j - ny + i] + ee;
if (ee) zds[j - ny + i] = BIGLO(num);
@@ -753,7 +777,7 @@ bigdivmod(x, y, div, mod)
zds[j] = q;
} while (--j >= ny);
if (div) { /* move quotient down in z */
- *div = big_clone(z);
+ *div = rb_big_clone(z);
zds = BDIGITS(*div);
j = (nx==ny ? nx+2 : nx+1) - ny;
for (i = 0;i < j;i++) zds[i] = zds[i+ny];
@@ -761,105 +785,130 @@ bigdivmod(x, y, div, mod)
*div = bignorm(*div);
}
if (mod) { /* just normalize remainder */
- *mod = big_clone(z);
+ *mod = rb_big_clone(z);
if (dd) {
zds = BDIGITS(*mod);
t2 = 0; i = ny;
while(i--) {
t2 = BIGUP(t2) + zds[i];
- zds[i] = t2 / dd;
+ zds[i] = (USHORT)(t2 / dd);
t2 %= dd;
}
}
RBIGNUM(*mod)->len = ny;
- RBIGNUM(*mod)->sign = RBIGNUM(y)->sign;
+ RBIGNUM(*mod)->sign = RBIGNUM(x)->sign;
+ if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) {
+ size_t len = ny;
+ zds = BDIGITS(*mod);
+ while (len-- && !zds[len]);
+ if (len > 0) {
+ *mod = bigadd(*mod, y, 1);
+ return;
+ }
+ }
*mod = bignorm(*mod);
}
}
static VALUE
-big_div(x, y)
+rb_big_div(x, y)
VALUE x, y;
{
VALUE z;
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
break;
case T_BIGNUM:
break;
case T_FLOAT:
- return float_new(big2dbl(x) / RFLOAT(y)->value);
+ return rb_float_new(rb_big2dbl(x) / RFLOAT(y)->value);
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
- bigdivmod(x, y, &z, 0);
+ bigdivmod(x, y, &z, 0, 0);
return z;
}
+
static VALUE
-big_mod(x, y)
+rb_big_modulo(x, y, modulo)
VALUE x, y;
+ int modulo;
{
VALUE z;
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
break;
case T_BIGNUM:
break;
case T_FLOAT:
- y = dbl2big(RFLOAT(y)->value);
+ y = rb_dbl2big(RFLOAT(y)->value);
break;
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
- bigdivmod(x, y, 0, &z);
+ bigdivmod(x, y, 0, &z, modulo);
return z;
}
static VALUE
-big_divmod(x, y)
+rb_big_mod(x, y)
+ VALUE x, y;
+{
+ return rb_big_modulo(x, y, 1);
+}
+
+static VALUE
+rb_big_remainder(x, y)
+ VALUE x, y;
+{
+ return rb_big_modulo(x, y, 0);
+}
+
+static VALUE
+rb_big_divmod(x, y)
VALUE x, y;
{
VALUE div, mod;
switch (TYPE(y)) {
case T_FIXNUM:
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
break;
case T_FLOAT:
- y = dbl2big(RFLOAT(y)->value);
+ y = rb_dbl2big(RFLOAT(y)->value);
break;
case T_BIGNUM:
break;
default:
- return num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
- bigdivmod(x, y, &div, &mod);
+ bigdivmod(x, y, &div, &mod, 1);
- return assoc_new(div, mod);;
+ return rb_assoc_new(div, mod);;
}
VALUE
-big_pow(x, y)
+rb_big_pow(x, y)
VALUE x, y;
{
double d;
- VALUE z;
+ long yy;
if (y == INT2FIX(0)) return INT2FIX(1);
switch (TYPE(y)) {
@@ -868,57 +917,59 @@ big_pow(x, y)
break;
case T_BIGNUM:
- if (RBIGNUM(y)->sign) goto pos_big;
- d = big2dbl(y);
+ rb_warn("in a**b, b may be too big");
+ d = rb_big2dbl(y);
break;
case T_FIXNUM:
- if (FIX2INT(y) > 0) goto pos_big;
- d = (double)FIX2INT(y);
+ yy = NUM2LONG(y);
+ if (yy > 0) {
+ VALUE z;
+
+ z = x;
+ for (;;) {
+ yy = yy - 1;
+ if (yy == 0) break;
+ while (yy % 2 == 0) {
+ yy = yy / 2;
+ x = rb_big_mul(x, x);
+ }
+ z = rb_big_mul(z, x);
+ }
+ return z;
+ }
+ d = (double)yy;
break;
default:
- return num_coerce_bin(x, y);
- }
- return float_new(pow(big2dbl(x), d));
-
- pos_big:
- z = x;
- for (;;) {
- y = rb_funcall(y, '-', 1, INT2FIX(1));
- if (y == INT2FIX(0)) break;
- while (rb_funcall(y, '%', 1, INT2FIX(2)) == INT2FIX(0)) {
- y = rb_funcall(y, '/', 1, INT2FIX(2));
- x = big_mul(x, x);
- }
- z = big_mul(z, x);
+ return rb_num_coerce_bin(x, y);
}
- return z;
+ return rb_float_new(pow(rb_big2dbl(x), d));
}
VALUE
-big_and(x, y)
+rb_big_and(x, y)
VALUE x, y;
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ size_t i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
}
else {
Check_Type(y, T_BIGNUM);
}
if (!RBIGNUM(y)->sign) {
- y = big_clone(y);
- big_2comp(y);
+ y = rb_big_clone(y);
+ rb_big_2comp(y);
}
if (!RBIGNUM(x)->sign) {
- x = big_clone(x);
- big_2comp(x);
+ x = rb_big_clone(x);
+ rb_big_2comp(x);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -943,33 +994,33 @@ big_and(x, y)
for (; i<l2; i++) {
zds[i] = sign?0:ds2[i];
}
- if (!RBIGNUM(z)->sign) big_2comp(z);
+ if (!RBIGNUM(z)->sign) rb_big_2comp(z);
return bignorm(z);
}
VALUE
-big_or(x, y)
+rb_big_or(x, y)
VALUE x, y;
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ unsigned int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
}
else {
Check_Type(y, T_BIGNUM);
}
if (!RBIGNUM(y)->sign) {
- y = big_clone(y);
- big_2comp(y);
+ y = rb_big_clone(y);
+ rb_big_2comp(y);
}
if (!RBIGNUM(x)->sign) {
- x = big_clone(x);
- big_2comp(x);
+ x = rb_big_clone(x);
+ rb_big_2comp(x);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -994,34 +1045,34 @@ big_or(x, y)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:(BIGRAD-1);
}
- if (!RBIGNUM(z)->sign) big_2comp(z);
+ if (!RBIGNUM(z)->sign) rb_big_2comp(z);
return bignorm(z);
}
VALUE
-big_xor(x, y)
+rb_big_xor(x, y)
VALUE x, y;
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ unsigned int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
- y = int2big(FIX2INT(y));
+ y = rb_int2big(FIX2LONG(y));
}
else {
Check_Type(y, T_BIGNUM);
}
if (!RBIGNUM(y)->sign) {
- y = big_clone(y);
- big_2comp(y);
+ y = rb_big_clone(y);
+ rb_big_2comp(y);
}
if (!RBIGNUM(x)->sign) {
- x = big_clone(x);
- big_2comp(x);
+ x = rb_big_clone(x);
+ rb_big_2comp(x);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -1048,26 +1099,26 @@ big_xor(x, y)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:~ds2[i];
}
- if (!RBIGNUM(z)->sign) big_2comp(z);
+ if (!RBIGNUM(z)->sign) rb_big_2comp(z);
return bignorm(z);
}
-static VALUE big_rshift();
+static VALUE rb_big_rshift _((VALUE,VALUE));
VALUE
-big_lshift(x, y)
+rb_big_lshift(x, y)
VALUE x, y;
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- UINT s1 = shift/BITSPERDIG;
- UINT s2 = shift%BITSPERDIG;
+ size_t s1 = shift/BITSPERDIG;
+ size_t s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- UINT len, i;
+ size_t len, i;
- if (shift < 0) return big_rshift(x, INT2FIX(-shift));
+ if (shift < 0) return rb_big_rshift(x, INT2FIX(-shift));
xds = BDIGITS(x);
len = RBIGNUM(x)->len;
z = bignew(len+s1+1, RBIGNUM(x)->sign);
@@ -1085,19 +1136,19 @@ big_lshift(x, y)
}
static VALUE
-big_rshift(x, y)
+rb_big_rshift(x, y)
VALUE x, y;
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- UINT s1 = shift/BITSPERDIG;
- UINT s2 = shift%BITSPERDIG;
+ size_t s1 = shift/BITSPERDIG;
+ size_t s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- UINT i = RBIGNUM(x)->len;
- UINT j;
+ size_t i = RBIGNUM(x)->len;
+ size_t j;
- if (shift < 0) return big_lshift(x, INT2FIX(-shift));
+ if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
if (s1 > RBIGNUM(x)->len) {
if (RBIGNUM(x)->sign)
return INT2FIX(0);
@@ -1117,12 +1168,12 @@ big_rshift(x, y)
}
static VALUE
-big_aref(x, y)
+rb_big_aref(x, y)
VALUE x, y;
{
USHORT *xds;
int shift = NUM2INT(y);
- UINT s1, s2;
+ size_t s1, s2;
if (shift < 0) return INT2FIX(0);
s1 = shift/BITSPERDIG;
@@ -1130,8 +1181,8 @@ big_aref(x, y)
if (!RBIGNUM(x)->sign) {
if (s1 >= RBIGNUM(x)->len) return INT2FIX(1);
- x = big_clone(x);
- big_2comp(x);
+ x = rb_big_clone(x);
+ rb_big_2comp(x);
}
else {
if (s1 >= RBIGNUM(x)->len) return INT2FIX(0);
@@ -1143,10 +1194,11 @@ big_aref(x, y)
}
static VALUE
-big_hash(x)
+rb_big_hash(x)
VALUE x;
{
- int i, len, key;
+ size_t i, len;
+ int key;
USHORT *digits;
key = 0; digits = BDIGITS(x);
@@ -1157,27 +1209,29 @@ big_hash(x)
}
static VALUE
-big_coerce(x, y)
+rb_big_coerce(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- return assoc_new(int2big(FIX2INT(y)), x);
+ return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
}
else {
- TypeError("can't coerce %s to Bignum", rb_class2name(CLASS_OF(y)));
+ rb_raise(rb_eTypeError, "can't coerce %s to Bignum",
+ rb_class2name(CLASS_OF(y)));
}
/* not reached */
+ return Qnil;
}
static VALUE
-big_abs(x)
+rb_big_abs(x)
VALUE x;
{
if (!RBIGNUM(x)->sign) {
- x = big_clone(x);
+ x = rb_big_clone(x);
RBIGNUM(x)->sign = 1;
}
- return (VALUE)x;
+ return x;
}
/* !!!warnig!!!!
@@ -1185,11 +1239,11 @@ big_abs(x)
*/
VALUE
-big_rand(max)
+rb_big_rand(max)
VALUE max;
{
struct RBignum *v;
- int len;
+ size_t len;
len = RBIGNUM(max)->len;
v = RBIGNUM(bignew(len,1));
@@ -1201,47 +1255,57 @@ big_rand(max)
#endif
}
- return big_mod(v, max);
+ return rb_big_mod((VALUE)v, max);
}
static VALUE
-big_size(big)
+rb_big_size(big)
VALUE big;
{
return INT2FIX(RBIGNUM(big)->len*sizeof(USHORT));
}
+static VALUE
+rb_big_zero_p(big)
+ VALUE big;
+{
+ return Qfalse;
+}
+
void
Init_Bignum()
{
- cBignum = rb_define_class("Bignum", cInteger);
-
- rb_undef_method(CLASS_OF(cBignum), "new");
-
- rb_define_method(cBignum, "to_s", big_to_s, 0);
- rb_define_method(cBignum, "coerce", big_coerce, 1);
- rb_define_method(cBignum, "-@", big_uminus, 0);
- rb_define_method(cBignum, "+", big_plus, 1);
- rb_define_method(cBignum, "-", big_minus, 1);
- rb_define_method(cBignum, "*", big_mul, 1);
- rb_define_method(cBignum, "/", big_div, 1);
- rb_define_method(cBignum, "%", big_mod, 1);
- rb_define_method(cBignum, "divmod", big_divmod, 1);
- rb_define_method(cBignum, "**", big_pow, 1);
- rb_define_method(cBignum, "&", big_and, 1);
- rb_define_method(cBignum, "|", big_or, 1);
- rb_define_method(cBignum, "^", big_xor, 1);
- rb_define_method(cBignum, "~", big_neg, 0);
- rb_define_method(cBignum, "<<", big_lshift, 1);
- rb_define_method(cBignum, ">>", big_rshift, 1);
- rb_define_method(cBignum, "[]", big_aref, 1);
-
- rb_define_method(cBignum, "<=>", big_cmp, 1);
- rb_define_method(cBignum, "==", big_eq, 1);
- rb_define_method(cBignum, "eql?", big_eq, 1);
- rb_define_method(cBignum, "hash", big_hash, 0);
- rb_define_method(cBignum, "to_i", big_to_i, 0);
- rb_define_method(cBignum, "to_f", big_to_f, 0);
- rb_define_method(cBignum, "abs", big_abs, 0);
- rb_define_method(cBignum, "size", big_size, 0);
+ rb_cBignum = rb_define_class("Bignum", rb_cInteger);
+
+ rb_undef_method(CLASS_OF(rb_cBignum), "new");
+
+ rb_define_method(rb_cBignum, "to_s", rb_big_to_s, 0);
+ rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
+ rb_define_method(rb_cBignum, "-@", rb_big_uminus, 0);
+ rb_define_method(rb_cBignum, "+", rb_big_plus, 1);
+ rb_define_method(rb_cBignum, "-", rb_big_minus, 1);
+ rb_define_method(rb_cBignum, "*", rb_big_mul, 1);
+ rb_define_method(rb_cBignum, "/", rb_big_div, 1);
+ rb_define_method(rb_cBignum, "%", rb_big_mod, 1);
+ rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1);
+ rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
+ rb_define_method(rb_cBignum, "**", rb_big_pow, 1);
+ rb_define_method(rb_cBignum, "&", rb_big_and, 1);
+ rb_define_method(rb_cBignum, "|", rb_big_or, 1);
+ rb_define_method(rb_cBignum, "^", rb_big_xor, 1);
+ rb_define_method(rb_cBignum, "~", rb_big_neg, 0);
+ rb_define_method(rb_cBignum, "<<", rb_big_lshift, 1);
+ rb_define_method(rb_cBignum, ">>", rb_big_rshift, 1);
+ rb_define_method(rb_cBignum, "[]", rb_big_aref, 1);
+
+ rb_define_method(rb_cBignum, "<=>", rb_big_cmp, 1);
+ rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
+ rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
+ rb_define_method(rb_cBignum, "eql?", rb_big_eq, 1);
+ rb_define_method(rb_cBignum, "hash", rb_big_hash, 0);
+ rb_define_method(rb_cBignum, "to_i", rb_big_to_i, 0);
+ rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
+ rb_define_method(rb_cBignum, "abs", rb_big_abs, 0);
+ rb_define_method(rb_cBignum, "size", rb_big_size, 0);
+ rb_define_method(rb_cBignum, "zero?", rb_big_zero_p, 0);
}
diff --git a/class.c b/class.c
index 13c9298..86ac8c5 100644
--- a/class.c
+++ b/class.c
@@ -6,40 +6,41 @@
$Date$
created at: Tue Aug 10 15:05:44 JST 1993
- Copyright (C) 1993-1995 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "node.h"
#include "st.h"
+#include <ctype.h>
-struct st_table *new_idhash();
-extern st_table *rb_class_tbl;
+#ifdef USE_CWGUSI
+#include <stdio.h>
+#endif
-extern VALUE cClass;
-extern VALUE cModule;
+extern st_table *rb_class_tbl;
VALUE
-class_new(super)
+rb_class_new(super)
VALUE super;
{
NEWOBJ(klass, struct RClass);
- OBJSETUP(klass, cClass, T_CLASS);
+ OBJSETUP(klass, rb_cClass, T_CLASS);
klass->super = super;
klass->iv_tbl = 0;
klass->m_tbl = 0; /* safe GC */
- klass->m_tbl = new_idhash();
+ klass->m_tbl = st_init_numtable();
return (VALUE)klass;
}
VALUE
-singleton_class_new(super)
+rb_singleton_class_new(super)
VALUE super;
{
- VALUE klass = class_new(super);
+ VALUE klass = rb_class_new(super);
FL_SET(klass, FL_SINGLETON);
return klass;
@@ -56,7 +57,7 @@ clone_method(mid, body, tbl)
}
VALUE
-singleton_class_clone(klass)
+rb_singleton_class_clone(klass)
VALUE klass;
{
if (!FL_TEST(klass, FL_SINGLETON))
@@ -69,7 +70,7 @@ singleton_class_clone(klass)
clone->super = RCLASS(klass)->super;
clone->iv_tbl = 0;
clone->m_tbl = 0;
- clone->m_tbl = new_idhash();
+ clone->m_tbl = st_init_numtable();
st_foreach(RCLASS(klass)->m_tbl, clone_method, clone->m_tbl);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
@@ -77,7 +78,7 @@ singleton_class_clone(klass)
}
void
-singleton_class_attached(klass, obj)
+rb_singleton_class_attached(klass, obj)
VALUE klass, obj;
{
if (FL_TEST(klass, FL_SINGLETON))
@@ -91,15 +92,15 @@ rb_define_class_id(id, super)
{
VALUE klass;
- if (!super) super = cObject;
- klass = class_new(super);
+ if (!super) super = rb_cObject;
+ klass = rb_class_new(super);
rb_name_class(klass, id);
/* make metaclass */
- RBASIC(klass)->class = singleton_class_new(RBASIC(super)->class);
- singleton_class_attached(RBASIC(klass)->class, klass);
+ RBASIC(klass)->klass = rb_singleton_class_new(RBASIC(super)->klass);
+ rb_singleton_class_attached(RBASIC(klass)->klass, klass);
rb_funcall(super, rb_intern("inherited"), 1, klass);
- return (VALUE)klass;
+ return klass;
}
VALUE
@@ -112,14 +113,15 @@ rb_define_class(name, super)
id = rb_intern(name);
klass = rb_define_class_id(id, super);
+
st_add_direct(rb_class_tbl, id, klass);
return klass;
}
VALUE
-rb_define_class_under(under, name, super)
- VALUE under;
+rb_define_class_under(outer, name, super)
+ VALUE outer;
char *name;
VALUE super;
{
@@ -128,22 +130,22 @@ rb_define_class_under(under, name, super)
id = rb_intern(name);
klass = rb_define_class_id(id, super);
- rb_const_set(under, id, klass);
- rb_set_class_path(klass, under, name);
+ rb_const_set(outer, id, klass);
+ rb_set_class_path(klass, outer, name);
return klass;
}
VALUE
-module_new()
+rb_module_new()
{
NEWOBJ(mdl, struct RClass);
- OBJSETUP(mdl, cModule, T_MODULE);
+ OBJSETUP(mdl, rb_cModule, T_MODULE);
mdl->super = 0;
mdl->iv_tbl = 0;
mdl->m_tbl = 0;
- mdl->m_tbl = new_idhash();
+ mdl->m_tbl = st_init_numtable();
return (VALUE)mdl;
}
@@ -152,9 +154,9 @@ VALUE
rb_define_module_id(id)
ID id;
{
- extern st_table *rb_class_tbl;
- VALUE mdl = module_new();
+ VALUE mdl;
+ mdl = rb_module_new();
rb_name_class(mdl, id);
return mdl;
@@ -175,8 +177,8 @@ rb_define_module(name)
}
VALUE
-rb_define_module_under(under, name)
- VALUE under;
+rb_define_module_under(outer, name)
+ VALUE outer;
char *name;
{
VALUE module;
@@ -184,8 +186,8 @@ rb_define_module_under(under, name)
id = rb_intern(name);
module = rb_define_module_id(id);
- rb_const_set(under, id, module);
- rb_set_class_path(module, under, name);
+ rb_const_set(outer, id, module);
+ rb_set_class_path(module, outer, name);
return module;
}
@@ -195,16 +197,16 @@ include_class_new(module, super)
VALUE module, super;
{
NEWOBJ(klass, struct RClass);
- OBJSETUP(klass, cClass, T_ICLASS);
+ OBJSETUP(klass, rb_cClass, T_ICLASS);
klass->m_tbl = RCLASS(module)->m_tbl;
klass->iv_tbl = RCLASS(module)->iv_tbl;
klass->super = super;
if (TYPE(module) == T_ICLASS) {
- RBASIC(klass)->class = RBASIC(module)->class;
+ RBASIC(klass)->klass = RBASIC(module)->klass;
}
else {
- RBASIC(klass)->class = module;
+ RBASIC(klass)->klass = module;
}
return (VALUE)klass;
@@ -217,61 +219,66 @@ rb_include_module(klass, module)
VALUE p;
if (NIL_P(module)) return;
+ if (klass == module) return;
switch (TYPE(module)) {
case T_MODULE:
case T_CLASS:
+ case T_ICLASS:
break;
default:
Check_Type(module, T_MODULE);
}
- if (klass == module) return;
- rb_clear_cache();
-
while (module) {
/* ignore if the module included already in superclasses */
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS &&
- RCLASS(p)->m_tbl == RCLASS(module)->m_tbl)
+ RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
+ if (RCLASS(module)->super) {
+ rb_include_module(p, RCLASS(module)->super);
+ }
return;
+ }
}
-
RCLASS(klass)->super =
include_class_new(module, RCLASS(klass)->super);
klass = RCLASS(klass)->super;
module = RCLASS(module)->super;
}
+ rb_clear_cache();
}
VALUE
-mod_included_modules(mod)
+rb_mod_included_modules(mod)
VALUE mod;
{
- VALUE ary = ary_new();
+ VALUE ary = rb_ary_new();
VALUE p;
for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
- ary_push(ary, RBASIC(p)->class);
+ rb_ary_push(ary, RBASIC(p)->klass);
}
}
return ary;
}
VALUE
-mod_ancestors(mod)
+rb_mod_ancestors(mod)
VALUE mod;
{
- VALUE ary = ary_new();
+ VALUE ary = rb_ary_new();
VALUE p;
for (p = mod; p; p = RCLASS(p)->super) {
+ if (FL_TEST(p, FL_SINGLETON))
+ continue;
if (BUILTIN_TYPE(p) == T_ICLASS) {
- ary_push(ary, RBASIC(p)->class);
+ rb_ary_push(ary, RBASIC(p)->klass);
}
else {
- ary_push(ary, p);
+ rb_ary_push(ary, p);
}
}
return ary;
@@ -283,19 +290,43 @@ ins_methods_i(key, body, ary)
NODE *body;
VALUE ary;
{
- if (!body->nd_noex) {
- VALUE name = str_new2(rb_id2name(key));
+ if ((body->nd_noex&(NOEX_PRIVATE|NOEX_PROTECTED)) == 0) {
+ VALUE name = rb_str_new2(rb_id2name(key));
- if (!ary_includes(ary, name)) {
+ if (!rb_ary_includes(ary, name)) {
if (!body->nd_body) {
- ary_push(ary, Qnil);
+ rb_ary_push(ary, Qnil);
}
- ary_push(ary, name);
+ rb_ary_push(ary, name);
+ }
+ }
+ else if (body->nd_body && nd_type(body->nd_body) == NODE_ZSUPER) {
+ rb_ary_push(ary, Qnil);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
+ }
+ return ST_CONTINUE;
+}
+
+static int
+ins_methods_prot_i(key, body, ary)
+ ID key;
+ NODE *body;
+ VALUE ary;
+{
+ if (!body->nd_body) {
+ rb_ary_push(ary, Qnil);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
+ }
+ else if (body->nd_noex & NOEX_PROTECTED) {
+ VALUE name = rb_str_new2(rb_id2name(key));
+
+ if (!rb_ary_includes(ary, name)) {
+ rb_ary_push(ary, name);
}
}
else if (nd_type(body->nd_body) == NODE_ZSUPER) {
- ary_push(ary, Qnil);
- ary_push(ary, str_new2(rb_id2name(key)));
+ rb_ary_push(ary, Qnil);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
}
return ST_CONTINUE;
}
@@ -307,19 +338,19 @@ ins_methods_priv_i(key, body, ary)
VALUE ary;
{
if (!body->nd_body) {
- ary_push(ary, Qnil);
- ary_push(ary, str_new2(rb_id2name(key)));
+ rb_ary_push(ary, Qnil);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
}
- else if (body->nd_noex) {
- VALUE name = str_new2(rb_id2name(key));
+ else if (body->nd_noex & NOEX_PRIVATE) {
+ VALUE name = rb_str_new2(rb_id2name(key));
- if (!ary_includes(ary, name)) {
- ary_push(ary, name);
+ if (!rb_ary_includes(ary, name)) {
+ rb_ary_push(ary, name);
}
}
else if (nd_type(body->nd_body) == NODE_ZSUPER) {
- ary_push(ary, Qnil);
- ary_push(ary, str_new2(rb_id2name(key)));
+ rb_ary_push(ary, Qnil);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
}
return ST_CONTINUE;
}
@@ -334,7 +365,7 @@ method_list(mod, option, func)
VALUE klass;
VALUE *p, *q, *pend;
- ary = ary_new();
+ ary = rb_ary_new();
for (klass = mod; klass; klass = RCLASS(klass)->super) {
st_foreach(RCLASS(klass)->m_tbl, func, ary);
if (!option) break;
@@ -352,7 +383,7 @@ method_list(mod, option, func)
}
VALUE
-class_instance_methods(argc, argv, mod)
+rb_class_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
@@ -364,7 +395,19 @@ class_instance_methods(argc, argv, mod)
}
VALUE
-class_private_instance_methods(argc, argv, mod)
+rb_class_protected_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ VALUE option;
+
+ rb_scan_args(argc, argv, "01", &option);
+ return method_list(mod, RTEST(option), ins_methods_prot_i);
+}
+
+VALUE
+rb_class_private_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
@@ -376,14 +419,14 @@ class_private_instance_methods(argc, argv, mod)
}
VALUE
-obj_singleton_methods(obj)
+rb_obj_singleton_methods(obj)
VALUE obj;
{
VALUE ary;
VALUE klass;
VALUE *p, *q, *pend;
- ary = ary_new();
+ ary = rb_ary_new();
klass = CLASS_OF(obj);
while (klass && FL_TEST(klass, FL_SINGLETON)) {
st_foreach(RCLASS(klass)->m_tbl, ins_methods_i, ary);
@@ -409,7 +452,7 @@ rb_define_method_id(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, name, NEW_CFUNC(func, argc), NOEX_PUBLIC);
+ rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC|NOEX_CFUNC);
}
void
@@ -419,15 +462,22 @@ rb_define_method(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PUBLIC);
+ ID id = rb_intern(name);
+
+ rb_add_method(klass, id, NEW_CFUNC(func, argc),
+ ((name[0] == 'i' && id == rb_intern("initialize"))?
+ NOEX_PRIVATE:NOEX_PUBLIC)|NOEX_CFUNC);
}
void
-rb_undef_method(klass, name)
+rb_define_protected_method(klass, name, func, argc)
VALUE klass;
char *name;
+ VALUE (*func)();
+ int argc;
{
- rb_add_method(klass, rb_intern(name), 0, NOEX_PUBLIC);
+ rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc),
+ NOEX_PROTECTED|NOEX_CFUNC);
}
void
@@ -437,7 +487,16 @@ rb_define_private_method(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PRIVATE);
+ rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc),
+ NOEX_PRIVATE|NOEX_CFUNC);
+}
+
+void
+rb_undef_method(klass, name)
+ VALUE klass;
+ char *name;
+{
+ rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
VALUE
@@ -445,14 +504,14 @@ rb_singleton_class(obj)
VALUE obj;
{
if (rb_special_const_p(obj)) {
- TypeError("cannot define singleton");
+ rb_raise(rb_eTypeError, "cannot define singleton");
}
- if (FL_TEST(RBASIC(obj)->class, FL_SINGLETON)) {
- return (VALUE)RBASIC(obj)->class;
+ if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
+ return RBASIC(obj)->klass;
}
- RBASIC(obj)->class = singleton_class_new(RBASIC(obj)->class);
- singleton_class_attached(RBASIC(obj)->class, obj);
- return RBASIC(obj)->class;
+ RBASIC(obj)->klass = rb_singleton_class_new(RBASIC(obj)->klass);
+ rb_singleton_class_attached(RBASIC(obj)->klass, obj);
+ return RBASIC(obj)->klass;
}
void
@@ -476,15 +535,13 @@ rb_define_module_function(module, name, func, argc)
rb_define_singleton_method(module, name, func, argc);
}
-extern VALUE mKernel;
-
void
rb_define_global_function(name, func, argc)
char *name;
VALUE (*func)();
int argc;
{
- rb_define_private_method(mKernel, name, func, argc);
+ rb_define_module_function(rb_mKernel, name, func, argc);
}
void
@@ -496,57 +553,50 @@ rb_define_alias(klass, name1, name2)
}
void
-rb_define_attr(klass, id, read, write)
+rb_define_attr(klass, name, read, write)
VALUE klass;
- ID id;
+ char *name;
int read, write;
{
- char *name;
- char *buf;
- ID attr, attreq, attriv;
-
- name = rb_id2name(id);
- attr = rb_intern(name);
- buf = ALLOCA_N(char,strlen(name)+2);
- sprintf(buf, "%s=", name);
- attreq = rb_intern(buf);
- sprintf(buf, "@%s", name);
- attriv = rb_intern(buf);
- if (read) {
- rb_add_method(klass, attr, NEW_IVAR(attriv), 0);
- }
- if (write) {
- rb_add_method(klass, attreq, NEW_ATTRSET(attriv), 0);
- }
+ rb_attr(klass, rb_intern(name), read, write, Qfalse);
}
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
#include <varargs.h>
-#include <ctype.h>
+#define va_init_list(a,b) va_start(a)
+#endif
int
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
+#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
VALUE *argv;
char *fmt;
va_dcl
+#endif
{
int n, i;
char *p = fmt;
VALUE *var;
va_list vargs;
- va_start(vargs);
+ va_init_list(vargs, fmt);
if (*p == '*') {
var = va_arg(vargs, VALUE*);
- *var = ary_new4(argc, argv);
+ *var = rb_ary_new4(argc, argv);
return argc;
}
- if (isdigit(*p)) {
+ if (ISDIGIT(*p)) {
n = *p - '0';
if (n > argc)
- ArgError("Wrong # of arguments (%d for %d)", argc, n);
+ rb_raise(rb_eArgError, "Wrong # of arguments (%d for %d)", argc, n);
for (i=0; i<n; i++) {
var = va_arg(vargs, VALUE*);
*var = argv[i];
@@ -557,7 +607,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
goto error;
}
- if (isdigit(*p)) {
+ if (ISDIGIT(*p)) {
n = i + *p - '0';
for (; i<n; i++) {
var = va_arg(vargs, VALUE*);
@@ -574,15 +624,15 @@ rb_scan_args(argc, argv, fmt, va_alist)
if(*p == '*') {
var = va_arg(vargs, VALUE*);
if (argc > i) {
- *var = ary_new4(argc-i, argv+i);
+ *var = rb_ary_new4(argc-i, argv+i);
}
else {
- *var = ary_new();
+ *var = rb_ary_new();
}
}
else if (*p == '\0') {
if (argc > i) {
- ArgError("Wrong # of arguments(%d for %d)", argc, i);
+ rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)", argc, i);
}
}
else {
@@ -593,6 +643,6 @@ rb_scan_args(argc, argv, fmt, va_alist)
return argc;
error:
- Fatal("bad scan arg format: %s", fmt);
+ rb_fatal("bad scan arg format: %s", fmt);
return 0;
}
diff --git a/compar.c b/compar.c
index e852fb1..a6212a8 100644
--- a/compar.c
+++ b/compar.c
@@ -6,13 +6,13 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
-VALUE mComparable;
+VALUE rb_mComparable;
static ID cmp;
@@ -23,8 +23,8 @@ cmp_eq(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);
- if (t == 0) return TRUE;
- return FALSE;
+ if (t == 0) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -34,8 +34,8 @@ cmp_gt(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);
- if (t > 0) return TRUE;
- return FALSE;
+ if (t > 0) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -45,8 +45,8 @@ cmp_ge(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);
- if (t >= 0) return TRUE;
- return FALSE;
+ if (t >= 0) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -56,8 +56,8 @@ cmp_lt(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);
- if (t < 0) return TRUE;
- return FALSE;
+ if (t < 0) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -67,8 +67,8 @@ cmp_le(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);
- if (t <= 0) return TRUE;
- return FALSE;
+ if (t <= 0) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -76,25 +76,25 @@ cmp_between(x, min, max)
VALUE x, min, max;
{
VALUE c = rb_funcall(x, cmp, 1, min);
- int t = NUM2INT(c);
- if (t < 0) return FALSE;
+ long t = NUM2LONG(c);
+ if (t < 0) return Qfalse;
c = rb_funcall(x, cmp, 1, max);
- t = NUM2INT(c);
- if (t > 0) return FALSE;
- return TRUE;
+ t = NUM2LONG(c);
+ if (t > 0) return Qfalse;
+ return Qtrue;
}
void
Init_Comparable()
{
- mComparable = rb_define_module("Comparable");
- rb_define_method(mComparable, "==", cmp_eq, 1);
- rb_define_method(mComparable, ">", cmp_gt, 1);
- rb_define_method(mComparable, ">=", cmp_ge, 1);
- rb_define_method(mComparable, "<", cmp_lt, 1);
- rb_define_method(mComparable, "<=", cmp_le, 1);
- rb_define_method(mComparable, "between?", cmp_between, 2);
+ rb_mComparable = rb_define_module("Comparable");
+ rb_define_method(rb_mComparable, "==", cmp_eq, 1);
+ rb_define_method(rb_mComparable, ">", cmp_gt, 1);
+ rb_define_method(rb_mComparable, ">=", cmp_ge, 1);
+ rb_define_method(rb_mComparable, "<", cmp_lt, 1);
+ rb_define_method(rb_mComparable, "<=", cmp_le, 1);
+ rb_define_method(rb_mComparable, "between?", cmp_between, 2);
cmp = rb_intern("<=>");
}
diff --git a/config.guess b/config.guess
index 91dad5e..042d209 100644
--- a/config.guess
+++ b/config.guess
@@ -1,6 +1,6 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -63,11 +63,53 @@ trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
+ cat <<EOF >dummy.s
+ .globl main
+ .ent main
+main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
@@ -78,17 +120,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
amiga:NetBSD:*:*)
echo m68k-cbm-netbsd${UNAME_RELEASE}
exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- Pyramid*:OSx*:*:*)
+ arm32:NetBSD:*:*)
+ echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit 0 ;;
- sun4*:SunOS:5.*:*)
+ NILE:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
i86pc:SunOS:5.*:*)
@@ -112,25 +191,84 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
atari*:NetBSD:*:*)
echo m68k-atari-netbsd${UNAME_RELEASE}
exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
sun3*:NetBSD:*:*)
echo m68k-sun-netbsd${UNAME_RELEASE}
exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
mac68k:NetBSD:*:*)
echo m68k-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:NetBSD:*:*)
+ echo powerpc-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
- mips:*:4*:UMIPS)
- echo mips-mips-riscos4sysv
+ 2020:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
- mips:*:5*:RISCos)
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >dummy.c
+ int main (argc, argv) int argc; char **argv; {
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy \
+ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
@@ -174,10 +312,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit 0 ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i[34]86:AIX:*:*)
+ i?86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
*:AIX:2:3)
@@ -203,7 +341,8 @@ EOF
fi
exit 0 ;;
*:AIX:*:4)
- if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -236,12 +375,44 @@ EOF
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit 0 ;;
- 9000/[3478]??:HP-UX:*:*)
+ 9000/[34678]??:HP-UX:*:*)
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/7?? | 9000/8?[679] ) HP_ARCH=hppa1.1 ;;
- 9000/8?? ) HP_ARCH=hppa1.0 ;;
+ 9000/6?? | 9000/7?? | 9000/80[24] | 9000/8?[13679] | 9000/892 )
+ sed 's/^ //' << EOF >dummy.c
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy`
+ rm -f dummy.c dummy
esac
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
@@ -288,6 +459,13 @@ EOF
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
+ i?86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
@@ -315,18 +493,40 @@ EOF
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE}
exit 0 ;;
- CRAY*C90:*:*:*)
- echo c90-cray-unicos${UNAME_RELEASE}
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
+ F300:UNIX_System_V:*:*)
+ FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ F301:UNIX_System_V:*:*)
+ echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+ exit 0 ;;
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
- i[34]86:BSD/386:*:* | *:BSD/OS:*:*)
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
@@ -340,33 +540,142 @@ EOF
echo i386-pc-bow
exit 0 ;;
i*:CYGWIN*:*)
- echo i386-pc-cygwin32
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
exit 0 ;;
p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin32
+ echo powerpcle-unknown-cygwin
exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
- echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:Linux:*:*)
- echo ${UNAME_MACHINE}-pc-linux
- exit 0 ;;
+ # uname on the ARM produces all sorts of strangeness, and we need to
+ # filter it out.
+ case "$UNAME_MACHINE" in
+ arm* | sa110*) UNAME_MACHINE="arm" ;;
+ esac
+
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us.
+ ld_help_string=`ld --help 2>&1`
+ ld_supported_emulations=`echo $ld_help_string \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ i?86linux) echo "${UNAME_MACHINE}-pc-linux-aout" ; exit 0 ;;
+ i?86coff) echo "${UNAME_MACHINE}-pc-linux-coff" ; exit 0 ;;
+ sparclinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
+ m68klinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
+ elf32ppc) echo "powerpc-unknown-linux" ; exit 0 ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ sed 's/^ //' <<EOF >dummy.s
+ .globl main
+ .ent main
+ main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ LIBC=""
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+
+ objdump --private-headers dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >dummy.c <<EOF
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ else
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ echo ${UNAME_MACHINE}-${VENDOR}-linux
+ exit 0
+ fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
- i[34]86:DYNIX/ptx:4*:*)
+ i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
- i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*)
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- i[34]86:*:3.2:*)
+ i?86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
@@ -380,6 +689,18 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
+ i?86:UnixWare:*:*)
+ if /bin/uname -X 2>/dev/null >/dev/null ; then
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ fi
+ echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION}
+ exit 0 ;;
+ pc:*:*:*)
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
@@ -397,28 +718,36 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
- M680[234]0:*:R3V[567]*:*)
+ M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
- uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4.3 && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- uname -p 2>/dev/null | grep 86 >/dev/null \
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
- m680[234]0:LynxOS:2.[23]*:*)
- echo m68k-lynx-lynxos${UNAME_RELEASE}
+ m68*:LynxOS:2.*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i[34]86:LynxOS:2.[23]*:*)
- echo i386-lynx-lynxos${UNAME_RELEASE}
+ i?86:LynxOS:2.*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- TSUNAMI:LynxOS:2.[23]*:*)
- echo sparc-lynx-lynxos${UNAME_RELEASE}
+ rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- rs6000:LynxOS:2.[23]*:*)
- echo rs6000-lynx-lynxos${UNAME_RELEASE}
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
@@ -431,42 +760,58 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
- X680[02346]0:Human68k:*:*)
- echo m68k-sharp-human
+ news*:NEWS-OS:*:6*)
+ echo mips-sony-newsos6
exit 0 ;;
- R[34]000:*System_V*:*:*)
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
+ echo mips-nec-sysv`echo ${UNAME_RELEASE} | sed -n 's/\([.0-9]*\).*/\1/p'`
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- R[34]???:UNIX_SV:4.?MP:*)
- if [ -x /sbin/uversion ]; then
- UVERSION_RELEASE=`(/sbin/uversion -r) 2>/dev/null` \
- || UVERSION_RELEASE=unknown
- UVERSION_SYSTEM=`(/sbin/uversion -s) 2>/dev/null` \
- || UVERSION_SYSTEM=unknown
- case "${UVERSION_RELEASE}:${UVERSION_SYSTEM}" in
- Release*:EWS4800/*)
- suffix=`echo ${UNAME_RELEASE} | tr '[A-Z]' '[a-z]'`
- suffix=${suffix}r`echo ${UVERSION_RELEASE} | \
- sed -e 's/Release//' -e 's/ Rev.*$//'`
- echo mips-nec-sysv${suffix}
- exit 0 ;;
- esac
- fi;;
- *:machten:*:*)
- echo ${UNAME_MACHINE}-apple-machten
- exit 0 ;;
- powerpc:JCC_BSD+:*:*)
- echo powerpc-jcc-bsd4.4
- exit 0 ;;
DS/90*:*:*:V20*)
- echo sparc-fujitsu-uxpds
+ echo sparc-fujitsu-uxpds
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+
+ *:Rhapsody:*:*)
+ arch=`/usr/bin/arch`
+ case "$arch" in
+ ppc)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ ;;
+ i[3456]86)
+ echo i386-apple-rhapsody${UNAME_RELEASE}
+ ;;
+ *)
+ echo $arch-apple-rhapsody${UNAME_RELEASE}
+ ;;
+ esac
exit 0 ;;
esac
@@ -511,7 +856,11 @@ main ()
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3");
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+
exit (0);
#endif
@@ -567,16 +916,12 @@ main ()
printf ("i860-alliant-bsd\n"); exit (0);
#endif
-#if defined (__human68k__) || defined (HUMAN68K)
- printf ("m68k-sharp-human\n"); exit (0);
-#endif
-
exit (1);
}
EOF
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm -f dummy.c dummy.x dummy && exit 0
-rm -f dummy.c dummy.x dummy
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
# Apollos put the system type in the environment.
diff --git a/config.sub b/config.sub
index 002d408..858aba7 100644
--- a/config.sub
+++ b/config.sub
@@ -1,6 +1,6 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@@ -149,35 +149,43 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
- | arme[lb] | pyramid \
- | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
- | alpha | we32k | ns16k | clipper | i370 | sh \
- | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
- | pdp11 | mips64el | mips64orion | mips64orionel \
- | sparc | sparclet | sparclite | sparc64)
- basic_machine=$basic_machine-unknown
- ;;
+ tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 \
+ | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
+ | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
+ | mips64 | mipsel | mips64el | mips64orion | mips64orionel \
+ | mipstx39 | mipstx39el \
+ | sparc | sparclet | sparclite | sparc64 | v850)
+ basic_machine=$basic_machine-unknown
+ ;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[3456]86)
+ i[34567]86)
basic_machine=$basic_machine-pc
;;
+ i[3456]86-TOWNS*)
+ basic_machine=`echo $basic_machine | sed -e 's/-TOWNS.*/-TOWNS/'`
+ ;;
# Object if more than one company name word.
*-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
- | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
- | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
- | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
- | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-*)
+ vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
+ | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \
+ | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
+ | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mipstx39-* | mipstx39el-* \
+ | f301-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -204,9 +212,9 @@ case $basic_machine in
amiga | amiga-*)
basic_machine=m68k-cbm
;;
- amigados)
+ amigaos | amigados)
basic_machine=m68k-cbm
- os=-amigados
+ os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
@@ -292,10 +300,6 @@ case $basic_machine in
encore | umax | mmax)
basic_machine=ns32k-encore
;;
- ews4800)
- basic_machine=mips-nec
- os=-sysv4
- ;;
fx2800)
basic_machine=i860-alliant
;;
@@ -341,24 +345,27 @@ case $basic_machine in
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
+ hppa-next)
+ os=-nextstep3
+ ;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[3456]86v32)
+ i[34567]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[3456]86v4*)
+ i[34567]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[3456]86v)
+ i[34567]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[3456]86sol2)
+ i[34567]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
@@ -390,6 +397,14 @@ case $basic_machine in
miniframe)
basic_machine=m68000-convergent
;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux
+ ;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
@@ -457,25 +472,23 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5)
- basic_machine=i586-intel
+ pentium | p5 | k5 | nexen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | k6 | 6x86)
+ basic_machine=i686-pc
;;
- pentiumpro | p6)
- basic_machine=i686-intel
+ pentiumii | pentium2)
+ basic_machine=i786-pc
;;
- pentium-* | p5-*)
+ pentium-* | p5-* | k5-* | nexen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-*)
+ pentiumpro-* | p6-* | k6-* | 6x86-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- k5)
- # We don't have specific support for AMD's K5 yet, so just call it a Pentium
- basic_machine=i586-amd
- ;;
- nexen)
- # We don't have specific support for Nexgen yet, so just call it a Pentium
- basic_machine=i586-nexgen
+ pentiumii-* | pentium2-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
@@ -559,6 +572,12 @@ case $basic_machine in
basic_machine=i386-sequent
os=-dynix
;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -578,6 +597,9 @@ case $basic_machine in
basic_machine=vax-dec
os=-vms
;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -605,7 +627,11 @@ case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
mips)
- basic_machine=mips-mips
+ if [ x$os = x-linux ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
;;
romp)
basic_machine=romp-ibm
@@ -634,10 +660,6 @@ case $basic_machine in
orion105)
basic_machine=clipper-highlevel
;;
- human)
- basic_machine=m68k-sharp
- os=-human
- ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -652,6 +674,10 @@ case $basic_machine in
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
+ human)
+ basic_machine=m68k-sharp
+ os=-human
+ ;;
*)
;;
esac
@@ -670,9 +696,12 @@ case $os in
-solaris)
os=-solaris2
;;
- -unixware* | svr4*)
+ -svr4*)
os=-sysv4
;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
@@ -683,15 +712,16 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
- | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
- | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -cygwin32* | -pe* | -psos* | -moss* | -proelf* \
- | -linux* | -bow*)
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux* | -uxpv* | -beos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-sunos5*)
@@ -754,6 +784,9 @@ case $os in
;;
-human)
;;
+ -beos)
+ os=-beos
+ ;;
-none)
;;
*)
@@ -806,6 +839,9 @@ case $basic_machine in
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ *-be)
+ os=-beos
+ ;;
*-ibm)
os=-aix
;;
@@ -819,7 +855,7 @@ case $basic_machine in
os=-sysv
;;
*-cbm)
- os=-amigados
+ os=-amigaos
;;
*-dg)
os=-dgux
@@ -869,6 +905,9 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
+ f301-fujitsu)
+ os=-uxpv
+ ;;
*)
os=-none
;;
@@ -887,9 +926,6 @@ case $basic_machine in
-sunos*)
vendor=sun
;;
- -lynxos*)
- vendor=lynx
- ;;
-aix*)
vendor=ibm
;;
@@ -917,7 +953,7 @@ case $basic_machine in
-ptx*)
vendor=sequent
;;
- -vxworks*)
+ -vxsim* | -vxworks*)
vendor=wrs
;;
-aux*)
diff --git a/config_h.dj b/config_h.dj
new file mode 100644
index 0000000..ebed8c4
--- /dev/null
+++ b/config_h.dj
@@ -0,0 +1,64 @@
+#define USE_THREAD 1
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define SIZEOF_VOIDP 4
+#define HAVE_PROTOTYPES 1
+#define HAVE_STDARG_PROTOTYPES 1
+#define HAVE_ATTR_NORETURN 1
+#define HAVE_DIRENT_H 1
+#define STDC_HEADERS 1
+#define HAVE_STDLIB_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_SYS_FILE_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_PWD_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TIMES_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_STRING_H 1
+#define HAVE_UTIME_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_DIRECT_H 1
+#define HAVE_ST_BLKSIZE 1
+#define HAVE_ST_RDEV 1
+#define GETGROUPS_T gid_t
+#define RETSIGTYPE void
+#define HAVE_ALLOCA 1
+#define vfork fork
+#define HAVE_DUP2 1
+#define HAVE_SETENV 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MKDIR 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRDUP 1
+#define HAVE_FMOD 1
+#define HAVE_RANDOM 1
+#define HAVE_WAITPID 1
+#define HAVE_GETCWD 1
+#define HAVE_TRUNCATE 1
+#define HAVE_CHSIZE 1
+#define HAVE_TIMES 1
+#define HAVE_UTIMES 1
+#define HAVE_FCNTL 1
+/*#define HAVE_SETITIMER 1*/
+#define HAVE_GETGROUPS 1
+#define HAVE_SIGPROCMASK 1
+#define HAVE_SIGACTION 1
+#define HAVE_SETSID 1
+#define POSIX_SIGNAL 1
+#define BSD_SETPGRP setpgrp
+#define RSHIFT(x,y) ((x)>>y)
+#define FILE_COUNT _cnt
+#define DLEXT ".o"
+#define RUBY_LIB "/usr/local/lib/ruby"
+#define RUBY_SITE_LIB "/usr/local/lib/ruby/site_ruby"
+#define RUBY_ARCHLIB "/usr/local/lib/ruby/i386-djgpp"
+#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/site_ruby/i386-djgpp"
+#define RUBY_PLATFORM "i386-djgpp"
diff --git a/config_s.dj b/config_s.dj
new file mode 100644
index 0000000..e172e30
--- /dev/null
+++ b/config_s.dj
@@ -0,0 +1,51 @@
+s%@CFLAGS@%-g -O2%g
+s%@CPPFLAGS@%%g
+s%@CXXFLAGS@%%g
+s%@DEFS@% -DUSE_THREAD=1 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_ATTR_NORETURN=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_PWD_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_TIMES_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_STRING_H=1 -DHAVE_UTIME_H=1 -DHAVE_MEMORY_H=1 -DHAVE_DIRECT_H=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=gid_t -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -Dvfork=fork -DHAVE_DUP2=1 -DHAVE_SETENV=1 -DHAVE_MEMMOVE=1 -DHAVE_MKDIR=1 -DHAVE_STRCASECMP=1 -DHAVE_STRERROR=1 -DHAVE_STRFTIME=1 -DHAVE_STRCHR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOUL=1 -DHAVE_STRDUP=1 -DHAVE_FMOD=1 -DHAVE_RANDOM=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_TRUNCATE=1 -DHAVE_CHSIZE=1 -DHAVE_TIMES=1 -DHAVE_UTIMES=1 -DHAVE_FCNTL=1 -DHAVE_SETITIMER=1 -DHAVE_GETGROUPS=1 -DHAVE_SIGPROCMASK=1 -DHAVE_SIGACTION=1 -DHAVE_SETSID=1 -DPOSIX_SIGNAL=1 -DBSD_SETPGRP=setpgrp -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".so\" -DRUBY_LIB=\"/usr/local/lib/ruby\" -DRUBY_SITE_LIB=\"/usr/local/lib/ruby/site_ruby\" -DRUBY_ARCHLIB=\"/usr/local/lib/ruby/i386-djgpp\" -DRUBY_SITE_ARCHLIB=\"/usr/local/lib/ruby/site_ruby/i386-djgpp\" -DRUBY_PLATFORM=\"i386-djgpp\" %g
+s%@LDFLAGS@%%g
+s%@LIBS@%-lm %g
+s%@exec_prefix@%${prefix}%g
+s%@prefix@%/usr/local%g
+s%@program_transform_name@%s,x,x,%g
+s%@bindir@%${exec_prefix}/bin%g
+s%@sbindir@%${exec_prefix}/sbin%g
+s%@libexecdir@%${exec_prefix}/libexec%g
+s%@datadir@%${prefix}/share%g
+s%@sysconfdir@%${prefix}/etc%g
+s%@sharedstatedir@%${prefix}/com%g
+s%@localstatedir@%${prefix}/var%g
+s%@libdir@%${exec_prefix}/lib%g
+s%@includedir@%${prefix}/include%g
+s%@oldincludedir@%/usr/include%g
+s%@infodir@%${prefix}/info%g
+s%@mandir@%${prefix}/man%g
+s%@host@%i386-pc-djgpp%g
+s%@host_alias@%i386-djgpp%g
+s%@host_cpu@%i386%g
+s%@host_vendor@%pc%g
+s%@host_os@%djgpp%g
+s%@CC@%gcc%g
+s%@CPP@%gcc -E%g
+s%@YACC@%bison -y%g
+s%@RANLIB@%ranlib%g
+s%@AR@%ar%g
+s%@INSTALL_PROGRAM@%${INSTALL}%g
+s%@INSTALL_DATA@%${INSTALL} -m 644%g
+s%@SET_MAKE@%%g
+s%@LIBOBJS@% crypt.o flock.o snprintf.o%g
+s%@ALLOCA@%%g
+s%@DLDFLAGS@%%g
+s%@STATIC@%%g
+s%@CCDLFLAGS@%%g
+s%@LDSHARED@%ld%g
+s%@DLEXT@%o%g
+s%@STRIP@%strip%g
+s%@EXTSTATIC@%%g
+s%@binsuffix@%.exe%g
+s%@setup@%Setup%g
+s%@LIBRUBY@%libruby.a%g
+s%@LIBRUBYARG@%libruby.a%g
+s%@SOLIBS@%%g
+s%@srcdir%.%g
+s%@arch@%i386-djgpp%g
+ac_given_srcdir=.
diff --git a/configure b/configure
index dd18efc..31a40f0 100644
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12
+# Generated automatically using autoconf version 2.12.2
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -16,7 +16,7 @@ ac_help="$ac_help
ac_help="$ac_help
--disable-thread never use user-level thread"
ac_help="$ac_help
---enable-fat-binary build a NeXT Multi Architecture Binary. "
+--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. "
ac_help="$ac_help
--with-dln-a-out use dln_a_out if possible"
ac_help="$ac_help
@@ -59,6 +59,7 @@ mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
@@ -342,7 +343,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12"
+ echo "configure generated by autoconf version 2.12.2"
exit 0 ;;
-with-* | --with-*)
@@ -512,9 +513,11 @@ ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
+ac_exeext=
+ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -562,7 +565,7 @@ fi
if test $rb_thread = yes; then
cat >> confdefs.h <<\EOF
-#define THREAD 1
+#define USE_THREAD 1
EOF
fi
@@ -588,33 +591,32 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:597: checking host system type" >&5
+echo "configure:600: checking host system type" >&5
host_alias=$host
case "$host_alias" in
NONE)
case $nonopt in
NONE)
- if host_alias=`$ac_config_guess`; then :
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
fi ;;
*) host_alias=$nonopt ;;
esac ;;
esac
-host=`$ac_config_sub $host_alias`
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
-
fat_binary=no
# Check whether --enable-fat-binary or --disable-fat-binary was given.
if test "${enable_fat_binary+set}" = set; then
@@ -622,18 +624,38 @@ if test "${enable_fat_binary+set}" = set; then
fat_binary=$enableval
fi
-if test "$fat_binary" = yes ; then
+ if test "$fat_binary" = yes ; then
echo $ac_n "checking target architecture ""... $ac_c" 1>&6
-echo "configure:629: checking target architecture " >&5
+echo "configure:631: checking target architecture " >&5
- if test "$TARGET_ARCHS" = "" ; then
- if test `/usr/bin/arch` = "m68k" ; then
- TARGET_ARCHS="m68k i486"
+ case "$host_os" in
+ rhapsody*)
+ echo -n "MacOS X Server: "
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i386"
+ fi
+ ;;
+ nextstep*|openstep*)
+ echo -n "NeXTSTEP/OPENSTEP: "
+
+ if test "$host_os" = "rhapsody" ; then
+ echo -n "Rhapsody: "
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i486"
+ fi
else
- TARGET_ARCHS="m68k `/usr/bin/arch`"
+ echo -n "NeXTSTEP/OPENSTEP: "
+ if test "$TARGET_ARCHS" = "" ; then
+ if test `/usr/bin/arch` = "m68k" ; then
+ TARGET_ARCHS="m68k i486"
+ else # Black and Native one
+ TARGET_ARCHS="m68k `/usr/bin/arch`"
+ fi
+ fi
fi
- fi
+ ;;
+ esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
for archs in $TARGET_ARCHS
do
@@ -647,7 +669,6 @@ EOF
echo "."
fi
-
if test "$program_transform_name" = s,x,x,; then
program_transform_name=
else
@@ -671,15 +692,16 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x,"
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:675: checking for $ac_word" >&5
+echo "configure:696: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
@@ -700,16 +722,17 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:704: checking for $ac_word" >&5
+echo "configure:726: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
- for ac_dir in $PATH; do
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -744,25 +767,61 @@ else
echo "$ac_t""no" 1>&6
fi
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:777: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:752: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:809: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
-cat > conftest.$ac_ext <<EOF
-#line 762 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 820 "configure"
#include "confdefs.h"
+
main(){return(0);}
EOF
-if { (eval echo configure:766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -776,18 +835,24 @@ else
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:786: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:851: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:791: checking whether we are using GNU C" >&5
+echo "configure:856: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -796,7 +861,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:800: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:865: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -807,11 +872,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:815: checking whether ${CC-cc} accepts -g" >&5
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:884: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -826,20 +895,24 @@ rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
- CFLAGS="-O2"
+ CFLAGS="-g"
fi
else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:843: checking how to run the C preprocessor" >&5
+echo "configure:916: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -854,14 +927,14 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 858 "configure"
+#line 931 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:864: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:937: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -871,14 +944,31 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 875 "configure"
+#line 948 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:954: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 965 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:971: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -891,6 +981,8 @@ fi
rm -f conftest*
fi
rm -f conftest*
+fi
+rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
@@ -901,13 +993,13 @@ echo "$ac_t""$CPP" 1>&6
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:905: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:997: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 911 "configure"
+#line 1003 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -925,7 +1017,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 929 "configure"
+#line 1021 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -951,15 +1043,16 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:955: checking for $ac_word" >&5
+echo "configure:1047: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$YACC"; then
ac_cv_prog_YACC="$YACC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_YACC="$ac_prog"
@@ -983,15 +1076,16 @@ test -n "$YACC" || YACC="yacc"
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:987: checking for $ac_word" >&5
+echo "configure:1080: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_RANLIB="ranlib"
@@ -1015,15 +1109,16 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1019: checking for $ac_word" >&5
+echo "configure:1113: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$AR"; then
ac_cv_prog_AR="$AR" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_AR="$ac_prog"
@@ -1051,28 +1146,30 @@ test -n "$AR" || AR="ar"
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1059: checking for a BSD compatible install" >&5
+echo "configure:1155: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -1102,10 +1199,12 @@ echo "$ac_t""$INSTALL" 1>&6
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1109: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1208: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1135,18 +1234,18 @@ fi
# checks for UNIX variants that set C preprocessor variables
ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:1139: checking for minix/config.h" >&5
+echo "configure:1238: checking for minix/config.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1144 "configure"
+#line 1243 "configure"
#include "confdefs.h"
#include <minix/config.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1149: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -1183,13 +1282,243 @@ EOF
fi
+echo $ac_n "checking size of int""... $ac_c" 1>&6
+echo "configure:1287: checking size of int" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1295 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(int));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_int=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_int=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_int" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+EOF
+
+
+echo $ac_n "checking size of long""... $ac_c" 1>&6
+echo "configure:1326: checking size of long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1334 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+EOF
+
+
+echo $ac_n "checking size of void*""... $ac_c" 1>&6
+echo "configure:1365: checking size of void*" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1373 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(void*));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_voidp=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_voidp=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_voidp" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_VOIDP $ac_cv_sizeof_voidp
+EOF
+
+
+
+echo $ac_n "checking for prototypes""... $ac_c" 1>&6
+echo "configure:1405: checking for prototypes" >&5
+if eval "test \"`echo '$''{'rb_cv_have_prototypes'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1410 "configure"
+#include "confdefs.h"
+int foo(int x) { return 0; }
+int main() {
+return foo(10);
+; return 0; }
+EOF
+if { (eval echo configure:1417: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ rb_cv_have_prototypes=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ rb_cv_have_prototypes=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$rb_cv_have_prototypes" 1>&6
+if test "$rb_cv_have_prototypes" = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PROTOTYPES 1
+EOF
+
+fi
+
+echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
+echo "configure:1438: checking for variable length prototypes and stdarg.h" >&5
+if eval "test \"`echo '$''{'rb_cv_stdarg'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1443 "configure"
+#include "confdefs.h"
+
+#include <stdarg.h>
+int foo(int x, ...) {
+ va_list va;
+ va_start(va, x);
+ va_arg(va, int);
+ va_arg(va, char *);
+ va_arg(va, double);
+ return 0;
+}
+
+int main() {
+return foo(10, "", 3.14);
+; return 0; }
+EOF
+if { (eval echo configure:1460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ rb_cv_stdarg=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ rb_cv_stdarg=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$rb_cv_stdarg" 1>&6
+if test "$rb_cv_stdarg" = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_STDARG_PROTOTYPES 1
+EOF
+
+fi
+
+echo $ac_n "checking for gcc attribute noreturn""... $ac_c" 1>&6
+echo "configure:1481: checking for gcc attribute noreturn" >&5
+if eval "test \"`echo '$''{'rb_cv_have_attr_noreturn'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1486 "configure"
+#include "confdefs.h"
+void exit(int x) __attribute__ ((noreturn));
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1493: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ rb_cv_have_attr_noreturn=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ rb_cv_have_attr_noreturn=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$rb_cv_have_attr_noreturn" 1>&6
+if test "$rb_cv_have_attr_noreturn" = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ATTR_NORETURN 1
+EOF
+
+fi
+
case "$host_os" in
nextstep*) ;;
+openstep*) ;;
+rhapsody*) ;;
human*) ;;
+beos*) ;;
*) LIBS="-lm $LIBS";;
esac
echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:1193: checking for crypt in -lcrypt" >&5
+echo "configure:1522: checking for crypt in -lcrypt" >&5
ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1197,7 +1526,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1201 "configure"
+#line 1530 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1208,7 +1537,7 @@ int main() {
crypt()
; return 0; }
EOF
-if { (eval echo configure:1212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1236,7 +1565,7 @@ else
fi
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:1240: checking for dlopen in -ldl" >&5
+echo "configure:1569: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1244,7 +1573,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1248 "configure"
+#line 1577 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1255,7 +1584,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:1259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1283,7 +1612,7 @@ else
fi
# Dynamic linking for SunOS/Solaris and SYSV
echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:1287: checking for shl_load in -ldld" >&5
+echo "configure:1616: checking for shl_load in -ldld" >&5
ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1291,7 +1620,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldld $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1295 "configure"
+#line 1624 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1302,7 +1631,7 @@ int main() {
shl_load()
; return 0; }
EOF
-if { (eval echo configure:1306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1329,18 +1658,65 @@ else
echo "$ac_t""no" 1>&6
fi
# Dynamic linking for HP-UX
+echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6
+echo "configure:1663: checking for setlocale in -lxpg4" >&5
+ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lxpg4 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1671 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char setlocale();
+
+int main() {
+setlocale()
+; return 0; }
+EOF
+if { (eval echo configure:1682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo xpg4 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lxpg4 $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+ # FreeBSD needs this
ac_header_dirent=no
for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1339: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1715: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1344 "configure"
+#line 1720 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@@ -1348,7 +1724,7 @@ int main() {
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:1352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1728: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@@ -1373,7 +1749,7 @@ done
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1377: checking for opendir in -ldir" >&5
+echo "configure:1753: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1381,7 +1757,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1385 "configure"
+#line 1761 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1392,7 +1768,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1414,7 +1790,7 @@ fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1418: checking for opendir in -lx" >&5
+echo "configure:1794: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1422,7 +1798,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1426 "configure"
+#line 1802 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1433,7 +1809,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1456,12 +1832,12 @@ fi
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1460: checking for ANSI C header files" >&5
+echo "configure:1836: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1465 "configure"
+#line 1841 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1469,8 +1845,8 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1473: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
ac_cv_header_stdc=yes
@@ -1486,7 +1862,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1490 "configure"
+#line 1866 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1504,7 +1880,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1508 "configure"
+#line 1884 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1525,7 +1901,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1529 "configure"
+#line 1905 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1536,7 +1912,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1561,22 +1937,22 @@ fi
for ac_hdr in stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
- syscall.h a.out.h string.h utime.h memory.h
+ syscall.h a.out.h string.h utime.h memory.h direct.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1569: checking for $ac_hdr" >&5
+echo "configure:1945: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1574 "configure"
+#line 1950 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1579: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -1603,12 +1979,12 @@ done
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:1607: checking for uid_t in sys/types.h" >&5
+echo "configure:1983: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1612 "configure"
+#line 1988 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -1637,12 +2013,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1641: checking for size_t" >&5
+echo "configure:2017: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1646 "configure"
+#line 2022 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1651,7 +2027,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_size_t=yes
else
@@ -1670,12 +2046,12 @@ EOF
fi
echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:1674: checking for st_blksize in struct stat" >&5
+echo "configure:2050: checking for st_blksize in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1679 "configure"
+#line 2055 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1683,7 +2059,7 @@ int main() {
struct stat s; s.st_blksize;
; return 0; }
EOF
-if { (eval echo configure:1687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blksize=yes
else
@@ -1705,12 +2081,12 @@ fi
save_LIBOJBS="$LIBOBJS"
echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6
-echo "configure:1709: checking for st_blocks in struct stat" >&5
+echo "configure:2085: checking for st_blocks in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1714 "configure"
+#line 2090 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1718,7 +2094,7 @@ int main() {
struct stat s; s.st_blocks;
; return 0; }
EOF
-if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2098: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blocks=yes
else
@@ -1737,17 +2113,17 @@ if test $ac_cv_struct_st_blocks = yes; then
EOF
else
- LIBOBJS="$LIBOBJS fileblocks.o"
+ LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
fi
LIBOBJS="$save_LIBOBJS"
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:1746: checking for st_rdev in struct stat" >&5
+echo "configure:2122: checking for st_rdev in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1751 "configure"
+#line 2127 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1755,7 +2131,7 @@ int main() {
struct stat s; s.st_rdev;
; return 0; }
EOF
-if { (eval echo configure:1759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2135: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
@@ -1776,165 +2152,8 @@ EOF
fi
-echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:1781: checking size of short" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
- cat > conftest.$ac_ext <<EOF
-#line 1789 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(short));
- exit(0);
-}
-EOF
-if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
- ac_cv_sizeof_short=`cat conftestval`
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_sizeof_short=0
-fi
-rm -fr conftest*
-fi
-
-fi
-echo "$ac_t""$ac_cv_sizeof_short" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_SHORT $ac_cv_sizeof_short
-EOF
-
-
-echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1820: checking size of int" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
- cat > conftest.$ac_ext <<EOF
-#line 1828 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(int));
- exit(0);
-}
-EOF
-if { (eval echo configure:1839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
- ac_cv_sizeof_int=`cat conftestval`
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_sizeof_int=0
-fi
-rm -fr conftest*
-fi
-
-fi
-echo "$ac_t""$ac_cv_sizeof_int" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_INT $ac_cv_sizeof_int
-EOF
-
-
-echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1859: checking size of long" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
- cat > conftest.$ac_ext <<EOF
-#line 1867 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(long));
- exit(0);
-}
-EOF
-if { (eval echo configure:1878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
- ac_cv_sizeof_long=`cat conftestval`
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_sizeof_long=0
-fi
-rm -fr conftest*
-fi
-
-fi
-echo "$ac_t""$ac_cv_sizeof_long" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
-EOF
-
-
-echo $ac_n "checking size of void*""... $ac_c" 1>&6
-echo "configure:1898: checking size of void*" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
- cat > conftest.$ac_ext <<EOF
-#line 1906 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(void*));
- exit(0);
-}
-EOF
-if { (eval echo configure:1917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
- ac_cv_sizeof_voidp=`cat conftestval`
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_sizeof_voidp=0
-fi
-rm -fr conftest*
-fi
-
-fi
-echo "$ac_t""$ac_cv_sizeof_voidp" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_VOIDP $ac_cv_sizeof_voidp
-EOF
-
-
-
echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:1938: checking type of array argument to getgroups" >&5
+echo "configure:2157: checking type of array argument to getgroups" >&5
if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1942,7 +2161,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 1946 "configure"
+#line 2165 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@@ -1967,7 +2186,7 @@ main()
}
EOF
-if { (eval echo configure:1971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_type_getgroups=gid_t
else
@@ -1981,7 +2200,7 @@ fi
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 1985 "configure"
+#line 2204 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -2005,12 +2224,12 @@ EOF
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2009: checking return type of signal handlers" >&5
+echo "configure:2228: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2014 "configure"
+#line 2233 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2027,7 +2246,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:2031: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -2048,19 +2267,19 @@ EOF
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:2052: checking for working alloca.h" >&5
+echo "configure:2271: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2057 "configure"
+#line 2276 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:2064: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -2081,25 +2300,30 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:2085: checking for alloca" >&5
+echo "configure:2304: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2090 "configure"
+#line 2309 "configure"
#include "confdefs.h"
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
# else
-# ifdef _AIX
- #pragma alloca
+# if HAVE_ALLOCA_H
+# include <alloca.h>
# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
+# endif
# endif
# endif
# endif
@@ -2109,7 +2333,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:2113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -2134,19 +2358,19 @@ if test $ac_cv_func_alloca_works = no; then
# that cause trouble. Some versions do not even contain alloca or
# contain a buggy version. If you still want to use their alloca,
# use ar to extract alloca.o from them instead of compiling alloca.c.
- ALLOCA=alloca.o
+ ALLOCA=alloca.${ac_objext}
cat >> confdefs.h <<\EOF
#define C_ALLOCA 1
EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:2145: checking whether alloca needs Cray hooks" >&5
+echo "configure:2369: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2150 "configure"
+#line 2374 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -2171,12 +2395,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2175: checking for $ac_func" >&5
+echo "configure:2399: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2180 "configure"
+#line 2404 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2199,7 +2423,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2226,7 +2450,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:2230: checking stack direction for C alloca" >&5
+echo "configure:2454: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2234,7 +2458,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 2238 "configure"
+#line 2462 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -2253,7 +2477,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:2257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -2275,12 +2499,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2279: checking for pid_t" >&5
+echo "configure:2503: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2284 "configure"
+#line 2508 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2289,7 +2513,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_pid_t=yes
else
@@ -2309,18 +2533,18 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2313: checking for vfork.h" >&5
+echo "configure:2537: checking for vfork.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2318 "configure"
+#line 2542 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -2344,18 +2568,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2348: checking for working vfork" >&5
+echo "configure:2572: checking for working vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:2354: checking for vfork" >&5
+echo "configure:2578: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2359 "configure"
+#line 2583 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2378,7 +2602,7 @@ vfork();
; return 0; }
EOF
-if { (eval echo configure:2382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@@ -2397,9 +2621,10 @@ else
echo "$ac_t""no" 1>&6
fi
+ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2403 "configure"
+#line 2628 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2494,7 +2719,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@@ -2516,16 +2741,52 @@ EOF
fi
-for ac_func in dup2 setenv memmove mkdir strcasecmp strerror strftime\
- strstr strtoul strdup crypt flock
+echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
+echo "configure:2746: checking for 8-bit clean memcmp" >&5
+if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_memcmp_clean=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2754 "configure"
+#include "confdefs.h"
+
+main()
+{
+ char c0 = 0x40, c1 = 0x80, c2 = 0x81;
+ exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
+}
+
+EOF
+if { (eval echo configure:2764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_memcmp_clean=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_memcmp_clean=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
+test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
+
+for ac_func in dup2 memmove mkdir strcasecmp strerror strftime\
+ strchr strstr strtoul strdup crypt flock vsnprintf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2524: checking for $ac_func" >&5
+echo "configure:2785: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2529 "configure"
+#line 2790 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2548,7 +2809,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2569,24 +2830,24 @@ EOF
else
echo "$ac_t""no" 1>&6
-LIBOBJS="$LIBOBJS ${ac_func}.o"
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
fi
done
-for ac_func in fmod killpg random wait4 waitpid syscall getcwd\
+for ac_func in fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
- setpgrp2 getpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp
+ setpgrp2 getpgid setpgid getgroups getpriority\
+ dlopen sigprocmask sigaction _setjmp setpgrp setsid
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2585: checking for $ac_func" >&5
+echo "configure:2846: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2590 "configure"
+#line 2851 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2609,7 +2870,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2635,12 +2896,12 @@ done
if test "$ac_cv_func_strftime" = no; then
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:2639: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:2900: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2644 "configure"
+#line 2905 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -2648,7 +2909,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:2652: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2913: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -2669,12 +2930,12 @@ EOF
fi
echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:2673: checking for tm_zone in struct tm" >&5
+echo "configure:2934: checking for tm_zone in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2678 "configure"
+#line 2939 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -2682,7 +2943,7 @@ int main() {
struct tm tm; tm.tm_zone;
; return 0; }
EOF
-if { (eval echo configure:2686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2947: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -2702,12 +2963,12 @@ EOF
else
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:2706: checking for tzname" >&5
+echo "configure:2967: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2711 "configure"
+#line 2972 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -2717,7 +2978,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
-if { (eval echo configure:2721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -2739,14 +3000,14 @@ EOF
fi
cat > conftest.$ac_ext <<EOF
-#line 2743 "configure"
+#line 3004 "configure"
#include "confdefs.h"
int main() {
extern int daylight; int i = daylight;
; return 0; }
EOF
-if { (eval echo configure:2750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define HAVE_DAYLIGHT 1
@@ -2766,7 +3027,7 @@ EOF
else
echo $ac_n "checking for BSD signal semantics""... $ac_c" 1>&6
-echo "configure:2770: checking for BSD signal semantics" >&5
+echo "configure:3031: checking for BSD signal semantics" >&5
if eval "test \"`echo '$''{'rb_cv_bsd_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2774,7 +3035,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2778 "configure"
+#line 3039 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -2796,7 +3057,7 @@ main()
}
EOF
-if { (eval echo configure:2800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_bsd_signal=yes
else
@@ -2830,19 +3091,19 @@ EOF
else
echo $ac_n "checking whether getpgrp() has arg""... $ac_c" 1>&6
-echo "configure:2834: checking whether getpgrp() has arg" >&5
+echo "configure:3095: checking whether getpgrp() has arg" >&5
if eval "test \"`echo '$''{'rb_cv_bsdgetpgrp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2839 "configure"
+#line 3100 "configure"
#include "confdefs.h"
#include <unistd.h>
int main() {
getpgrp(0);
; return 0; }
EOF
-if { (eval echo configure:2846: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_bsdgetpgrp=yes
else
@@ -2863,19 +3124,19 @@ EOF
fi
echo $ac_n "checking whether setpgrp() has args""... $ac_c" 1>&6
-echo "configure:2867: checking whether setpgrp() has args" >&5
+echo "configure:3128: checking whether setpgrp() has args" >&5
if eval "test \"`echo '$''{'rb_cv_bsdsetpgrp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2872 "configure"
+#line 3133 "configure"
#include "confdefs.h"
#include <unistd.h>
int main() {
setpgrp(1, 1);
; return 0; }
EOF
-if { (eval echo configure:2879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_bsdsetpgrp=yes
else
@@ -2897,14 +3158,14 @@ EOF
fi
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:2901: checking whether byte ordering is bigendian" >&5
+echo "configure:3162: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 2908 "configure"
+#line 3169 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -2915,11 +3176,11 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:2919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 2923 "configure"
+#line 3184 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -2930,7 +3191,7 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:2934: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3195: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -2950,7 +3211,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2954 "configure"
+#line 3215 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -2963,7 +3224,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:2967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@@ -2987,14 +3248,14 @@ EOF
fi
echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-echo "configure:2991: checking whether char is unsigned" >&5
+echo "configure:3252: checking whether char is unsigned" >&5
if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$GCC" = yes; then
# GCC predefines this symbol on systems where it applies.
cat > conftest.$ac_ext <<EOF
-#line 2998 "configure"
+#line 3259 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
@@ -3016,7 +3277,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3020 "configure"
+#line 3281 "configure"
#include "confdefs.h"
/* volatile prevents gcc2 from optimizing the test away on sparcs. */
#if !defined(__STDC__) || __STDC__ != 1
@@ -3026,7 +3287,7 @@ main() {
volatile char c = 255; exit(c < 0);
}
EOF
-if { (eval echo configure:3030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_char_unsigned=yes
else
@@ -3050,20 +3311,68 @@ EOF
fi
+echo $ac_n "checking whether right shift preserve sign bit""... $ac_c" 1>&6
+echo "configure:3316: checking whether right shift preserve sign bit" >&5
+if eval "test \"`echo '$''{'rb_cv_rshift_sign'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3324 "configure"
+#include "confdefs.h"
+
+int
+main()
+{
+ if (-1==(-1>>1))
+ return 0;
+ return 1;
+}
+
+EOF
+if { (eval echo configure:3336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ rb_cv_rshift_sign=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ rb_cv_rshift_sign=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+ echo "$ac_t""$rb_cv_rshift_sign" 1>&6
+if test "$rb_cv_rshift_sign" = yes; then
+ cat >> confdefs.h <<\EOF
+#define RSHIFT(x,y) ((x)>>y)
+EOF
+
+else
+ cat >> confdefs.h <<\EOF
+#define RSHIFT(x,y) (((x)<0) ? ~((~(x))>>y) : (x)>>y)
+EOF
+
+fi
+
echo $ac_n "checking count field in FILE structures""... $ac_c" 1>&6
-echo "configure:3055: checking count field in FILE structures" >&5
+echo "configure:3364: checking count field in FILE structures" >&5
if eval "test \"`echo '$''{'rb_cv_fcnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3060 "configure"
+#line 3369 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3067: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3376: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_cnt"
else
@@ -3073,14 +3382,14 @@ fi
rm -f conftest*
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3077 "configure"
+#line 3386 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->__cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3084: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3393: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="__cnt"
else
@@ -3091,14 +3400,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3095 "configure"
+#line 3404 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_r = 0;
; return 0; }
EOF
-if { (eval echo configure:3102: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_r"
else
@@ -3109,14 +3418,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3113 "configure"
+#line 3422 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->readCount = 0;
; return 0; }
EOF
-if { (eval echo configure:3120: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3429: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="readCount"
else
@@ -3139,102 +3448,6 @@ EOF
fi
-if test "$ac_cv_func_getpwent" = yes; then
- echo $ac_n "checking struct passwd""... $ac_c" 1>&6
-echo "configure:3145: checking struct passwd" >&5
- cat > conftest.$ac_ext <<EOF
-#line 3147 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_change" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_CHANGE 1
-EOF
-
-fi
-rm -f conftest*
-
- cat > conftest.$ac_ext <<EOF
-#line 3162 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_quota" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_QUOTA 1
-EOF
-
-fi
-rm -f conftest*
-
- cat > conftest.$ac_ext <<EOF
-#line 3177 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_age" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_AGE 1
-EOF
-
-fi
-rm -f conftest*
-
- cat > conftest.$ac_ext <<EOF
-#line 3192 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_class" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_CLASS 1
-EOF
-
-fi
-rm -f conftest*
-
- cat > conftest.$ac_ext <<EOF
-#line 3207 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_comment" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_COMMENT 1
-EOF
-
-fi
-rm -f conftest*
-
- cat > conftest.$ac_ext <<EOF
-#line 3222 "configure"
-#include "confdefs.h"
-#include <pwd.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pw_expire" >/dev/null 2>&1; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define PW_EXPIRE 1
-EOF
-
-fi
-rm -f conftest*
-
- echo "$ac_t""done" 1>&6
-fi
-
# Check whether --with-dln-a-out or --without-dln-a-out was given.
if test "${with_dln_a_out+set}" = set; then
withval="$with_dln_a_out"
@@ -3251,7 +3464,7 @@ fi
case "$host_os" in
linux*)
echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6
-echo "configure:3255: checking whether ELF binaries are produced" >&5
+echo "configure:3468: checking whether ELF binaries are produced" >&5
if eval "test \"`echo '$''{'rb_cv_linux_elf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3259,7 +3472,7 @@ else
:
else
cat > conftest.$ac_ext <<EOF
-#line 3263 "configure"
+#line 3476 "configure"
#include "confdefs.h"
/* Test for whether ELF binaries are produced */
@@ -3279,7 +3492,7 @@ main() {
}
EOF
-if { (eval echo configure:3283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_linux_elf=yes
else
@@ -3309,11 +3522,14 @@ STATIC=
if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=unknown
echo $ac_n "checking whether OS depend dynamic link works""... $ac_c" 1>&6
-echo "configure:3313: checking whether OS depend dynamic link works" >&5
+echo "configure:3526: checking whether OS depend dynamic link works" >&5
if test "$GCC" = yes; then
case "$host_os" in
nextstep*) ;;
+ openstep*) ;;
+ rhapsody*) ;;
human*) ;;
+ cygwin*) CCDLFLAGS=-DDLLIMPORT;;
*) CCDLFLAGS=-fpic;;
esac
else
@@ -3343,21 +3559,44 @@ echo "configure:3313: checking whether OS depend dynamic link works" >&5
rb_cv_dlopen=yes ;;
linux*) LDSHARED="gcc -shared"
rb_cv_dlopen=yes ;;
+ freebsd3*) LDSHARED="ld -Bshareable"
+ LDFLAGS="-rdynamic"
+ rb_cv_dlopen=yes ;;
freebsd*) LDSHARED="ld -Bshareable"
rb_cv_dlopen=yes ;;
netbsd*) LDSHARED="ld -Bshareable"
rb_cv_dlopen=yes ;;
- openbsd*) LDSHARED="ld -Bshareable"
+ openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
+ CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r'
LDFLAGS="-u libsys_s"
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
+ openstep*) LDSHARED='cc -dynamic -bundle -undefined suppress'
+ LDFLAGS=""
+ DLDFLAGS="$ARCH_FLAG"
+ rb_cv_dlopen=yes ;;
+ rhapsody*) LDSHARED='cc -dynamic -bundle -undefined suppress'
+ LDFLAGS=""
+ DLDFLAGS="$ARCH_FLAG"
+ rb_cv_dlopen=yes ;;
aix*) LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)'
rb_cv_dlopen=yes ;;
human*) DLDFLAGS=''
LDSHARED=''
LDFLAGS='' ;;
+ beos*) LDSHARED="ld -xms"
+ case "$host_cpu" in
+ powerpc*)
+ DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
+ ;;
+ *)
+ DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
+ ;;
+ esac
+ rb_cv_dlopen=yes ;;
+ cygwin*) LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
*) LDSHARED='ld' ;;
esac
echo "$ac_t""$rb_cv_dlopen" 1>&6
@@ -3367,13 +3606,13 @@ dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6
-echo "configure:3371: checking whether matz's dln works" >&5
+echo "configure:3610: checking whether matz's dln works" >&5
cat confdefs.h > config.h
if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3377 "configure"
+#line 3616 "configure"
#include "confdefs.h"
#define USE_DLN_A_OUT
@@ -3383,7 +3622,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:3387: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3626: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_dln_a_out=yes
else
@@ -3430,6 +3669,21 @@ EOF
#define DLEXT ".o"
EOF
;;
+ openstep*) DLEXT=bundle
+ cat >> confdefs.h <<\EOF
+#define DLEXT ".bundle"
+EOF
+;;
+ rhapsody*) DLEXT=bundle
+ cat >> confdefs.h <<\EOF
+#define DLEXT ".bundle"
+EOF
+;;
+ cygwin*) DLEXT=dll
+ cat >> confdefs.h <<\EOF
+#define DLEXT ".dll"
+EOF
+;;
*) DLEXT=so
cat >> confdefs.h <<\EOF
#define DLEXT ".so"
@@ -3449,6 +3703,10 @@ case "$host_os" in
STRIP='strip -S -x';;
nextstep*)
STRIP='strip -A -n';;
+ openstep*)
+ STRIP='strip -A -n';;
+ rhapsody*)
+ STRIP='strip -A -n';;
esac
EXTSTATIC=
@@ -3466,7 +3724,7 @@ fi
case "$host_os" in
human*)
echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6
-echo "configure:3470: checking for _harderr in -lsignal" >&5
+echo "configure:3728: checking for _harderr in -lsignal" >&5
ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3474,7 +3732,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsignal $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3478 "configure"
+#line 3736 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3485,7 +3743,7 @@ int main() {
_harderr()
; return 0; }
EOF
-if { (eval echo configure:3489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3513,7 +3771,7 @@ else
fi
echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6
-echo "configure:3517: checking for hmemset in -lhmem" >&5
+echo "configure:3775: checking for hmemset in -lhmem" >&5
ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3521,7 +3779,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lhmem $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3525 "configure"
+#line 3783 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3532,7 +3790,7 @@ int main() {
hmemset()
; return 0; }
EOF
-if { (eval echo configure:3536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3562,12 +3820,12 @@ fi
for ac_func in select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3566: checking for $ac_func" >&5
+echo "configure:3824: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3571 "configure"
+#line 3829 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3590,7 +3848,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3615,7 +3873,7 @@ fi
done
echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6
-echo "configure:3619: checking whether PD libc _dtos18 fail to convert big number" >&5
+echo "configure:3877: checking whether PD libc _dtos18 fail to convert big number" >&5
if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3623,7 +3881,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3627 "configure"
+#line 3885 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3635,7 +3893,7 @@ main ()
}
EOF
-if { (eval echo configure:3639: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_missing__dtos18=yes
else
@@ -3657,7 +3915,7 @@ EOF
fi
echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6
-echo "configure:3661: checking whether PD libc fconvert fail to round" >&5
+echo "configure:3919: checking whether PD libc fconvert fail to round" >&5
if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3665,7 +3923,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3669 "configure"
+#line 3927 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3678,7 +3936,7 @@ main ()
}
EOF
-if { (eval echo configure:3682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_missing_fconvert=yes
else
@@ -3704,6 +3962,10 @@ EOF
binsuffix=.x
setup=Setup.x68
;;
+ cygwin*)
+ binsuffix=.exe
+ setup=Setup
+ ;;
*)
binsuffix=
setup=Setup
@@ -3712,16 +3974,76 @@ esac
+
+
+
if test "$prefix" = NONE; then
prefix=$ac_default_prefix
fi
if test "$fat_binary" = yes ; then
- CFLAGS="$CFLAGS -pipe $ARCH_FLAG"
+ CFLAGS="$CFLAGS $ARCH_FLAG"
+fi
+
+LIBRUBY='libruby.a'
+LIBRUBYARG='libruby.a'
+SOLIBS=
+if test "$host_os" = "beos"; then
+ CFLAGS="$CFLAGS -relax_pointers"
+ LIBRUBY='libruby.so'
+ LIBRUBYARG='-lruby'
+ SOLIBS='-lnet'
+ echo creating ruby.def
+ case "$host_cpu" in
+ powerpc*)
+ cp beos/ruby.def.in ruby.exp
+ ;;
+ *)
+ echo EXPORTS > ruby.def
+ cat beos/ruby.def.in >> ruby.def
+ ;;
+ esac
fi
+if test "$enable_shared" = 'yes'; then
+ LIBRUBY='libruby.so'
+ LIBRUBYARG='-L./ -lruby'
+fi
+
+case "$host_os" in
+ nextstep*)
+ CFLAGS="$CFLAGS -pipe"
+ ;;
+ openstep*)
+ CFLAGS="$CFLAGS -pipe"
+ ;;
+ rhasody*)
+ CFLAGS="$CFLAGS -pipe -no-precomp"
+ ;;
+ *)
+ ;;
+esac
+
+
+
+
+
+
+ri_prefix=
+test "$program_prefix" != NONE &&
+ ri_prefix=$program_prefix
+
+ri_suffix=
+test "$program_suffix" != NONE &&
+ ri_suffix=$program_suffix
+
+RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
cat >> confdefs.h <<EOF
-#define RUBY_LIB "${prefix}/lib/ruby"
+#define RUBY_LIB "${prefix}/lib/${RUBY_INSTALL_NAME}"
+EOF
+
+cat >> confdefs.h <<EOF
+#define RUBY_SITE_LIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby"
EOF
@@ -3729,12 +4051,21 @@ if test "$fat_binary" = yes ; then
arch="fat-${host_os}"
cat >> confdefs.h <<EOF
-#define RUBY_THIN_ARCHLIB "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}"
+#define RUBY_THIN_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}"
+EOF
+
+
+ cat >> confdefs.h <<EOF
+#define RUBY_SITE_THIN_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}"
EOF
cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/ruby/${arch}"
+#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+EOF
+
+ cat >> confdefs.h <<EOF
+#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
EOF
cat >> confdefs.h <<EOF
@@ -3744,7 +4075,11 @@ EOF
else
arch="${host_cpu}-${host_os}"
cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/ruby/${arch}"
+#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+EOF
+
+ cat >> confdefs.h <<EOF
+#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
EOF
cat >> confdefs.h <<EOF
@@ -3779,7 +4114,7 @@ EOF
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
- case `(ac_space=' '; set) 2>&1` in
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
@@ -3858,7 +4193,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ echo "$CONFIG_STATUS generated by autoconf version 2.12.2"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -3878,9 +4213,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
+s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
@@ -3910,6 +4247,7 @@ s%@YACC@%$YACC%g
s%@RANLIB@%$RANLIB%g
s%@AR@%$AR%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@SET_MAKE@%$SET_MAKE%g
s%@LIBOBJS@%$LIBOBJS%g
@@ -3923,6 +4261,9 @@ s%@STRIP@%$STRIP%g
s%@EXTSTATIC@%$EXTSTATIC%g
s%@binsuffix@%$binsuffix%g
s%@setup@%$setup%g
+s%@LIBRUBY@%$LIBRUBY%g
+s%@LIBRUBYARG@%$LIBRUBYARG%g
+s%@SOLIBS@%$SOLIBS%g
s%@arch@%$arch%g
CEOF
diff --git a/configure.bat b/configure.bat
index 35f9d48..093d435 100644
--- a/configure.bat
+++ b/configure.bat
@@ -2,4 +2,5 @@
sed -f top.sed Makefile.in >Makefile
sed -f top.sed ext/extmk.rb.in > ext\extmk.rb
copy ext\Setup.dj ext\Setup
-copy config.dj config.h
+copy config_h.dj config.h
+copy config_s.dj config.status
diff --git a/configure.in b/configure.in
index 567e58c..0477ade 100644
--- a/configure.in
+++ b/configure.in
@@ -24,28 +24,47 @@ AC_ARG_ENABLE(thread, [--disable-thread never use user-level thread], [
rb_thread=$enableval
])
if test $rb_thread = yes; then
- AC_DEFINE(THREAD)
+ AC_DEFINE(USE_THREAD)
fi
AC_CANONICAL_HOST
-
dnl checks for fat-binary
fat_binary=no
AC_ARG_ENABLE( fat-binary,
- [--enable-fat-binary build a NeXT Multi Architecture Binary. ],
+ [--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ],
[ fat_binary=$enableval ] )
-if test "$fat_binary" = yes ; then
+ if test "$fat_binary" = yes ; then
AC_MSG_CHECKING( target architecture )
- if test "$TARGET_ARCHS" = "" ; then
- if test `/usr/bin/arch` = "m68k" ; then
- TARGET_ARCHS="m68k i486"
+ case "$host_os" in
+ rhapsody*)
+ echo -n "MacOS X Server: "
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i386"
+ fi
+ ;;
+ nextstep*|openstep*)
+ echo -n "NeXTSTEP/OPENSTEP: "
+
+ if test "$host_os" = "rhapsody" ; then
+ echo -n "Rhapsody: "
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i486"
+ fi
else
- TARGET_ARCHS="m68k `/usr/bin/arch`"
+ echo -n "NeXTSTEP/OPENSTEP: "
+ if test "$TARGET_ARCHS" = "" ; then
+ if test `/usr/bin/arch` = "m68k" ; then
+ TARGET_ARCHS="m68k i486"
+ else # Black and Native one
+ TARGET_ARCHS="m68k `/usr/bin/arch`"
+ fi
+ fi
fi
- fi
+ ;;
+ esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
for archs in $TARGET_ARCHS
do
@@ -56,7 +75,6 @@ if test "$fat_binary" = yes ; then
echo "."
fi
-
AC_ARG_PROGRAM
dnl Checks for programs.
@@ -72,22 +90,70 @@ AC_PROG_MAKE_SET
# checks for UNIX variants that set C preprocessor variables
AC_MINIX
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(void*)
+
+AC_MSG_CHECKING(for prototypes)
+AC_CACHE_VAL(rb_cv_have_prototypes,
+ [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
+ rb_cv_have_prototypes=yes,
+ rb_cv_have_prototypes=no)])
+AC_MSG_RESULT($rb_cv_have_prototypes)
+if test "$rb_cv_have_prototypes" = yes; then
+ AC_DEFINE(HAVE_PROTOTYPES)
+fi
+
+AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
+AC_CACHE_VAL(rb_cv_stdarg,
+ [AC_TRY_COMPILE([
+#include <stdarg.h>
+int foo(int x, ...) {
+ va_list va;
+ va_start(va, x);
+ va_arg(va, int);
+ va_arg(va, char *);
+ va_arg(va, double);
+ return 0;
+}
+], [return foo(10, "", 3.14);],
+ rb_cv_stdarg=yes,
+ rb_cv_stdarg=no)])
+AC_MSG_RESULT($rb_cv_stdarg)
+if test "$rb_cv_stdarg" = yes; then
+ AC_DEFINE(HAVE_STDARG_PROTOTYPES)
+fi
+
+AC_MSG_CHECKING(for gcc attribute noreturn)
+AC_CACHE_VAL(rb_cv_have_attr_noreturn,
+ [AC_TRY_COMPILE([void exit(int x) __attribute__ ((noreturn));], [],
+ rb_cv_have_attr_noreturn=yes,
+ rb_cv_have_attr_noreturn=no)])
+AC_MSG_RESULT($rb_cv_have_attr_noreturn)
+if test "$rb_cv_have_attr_noreturn" = yes; then
+ AC_DEFINE(HAVE_ATTR_NORETURN)
+fi
+
dnl Checks for libraries.
case "$host_os" in
nextstep*) ;;
+openstep*) ;;
+rhapsody*) ;;
human*) ;;
+beos*) ;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
+AC_CHECK_LIB(xpg4, setlocale) # FreeBSD needs this
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
- syscall.h a.out.h string.h utime.h memory.h)
+ syscall.h a.out.h string.h utime.h memory.h direct.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
@@ -98,23 +164,19 @@ AC_STRUCT_ST_BLOCKS
LIBOBJS="$save_LIBOBJS"
AC_STRUCT_ST_RDEV
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(void*)
-
dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_FUNC_VFORK
-AC_REPLACE_FUNCS(dup2 setenv memmove mkdir strcasecmp strerror strftime\
- strstr strtoul strdup crypt flock)
-AC_CHECK_FUNCS(fmod killpg random wait4 waitpid syscall getcwd\
+AC_FUNC_MEMCMP
+AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strerror strftime\
+ strchr strstr strtoul strdup crypt flock vsnprintf)
+AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
- setpgrp2 getpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp)
+ setpgrp2 getpgid setpgid getgroups getpriority\
+ dlopen sigprocmask sigaction _setjmp setpgrp setsid)
if test "$ac_cv_func_strftime" = no; then
AC_STRUCT_TIMEZONE
AC_TRY_LINK([],
@@ -181,6 +243,26 @@ fi
AC_C_BIGENDIAN
AC_CHAR_UNSIGNED
+AC_MSG_CHECKING(whether right shift preserve sign bit)
+AC_CACHE_VAL(rb_cv_rshift_sign,
+ [AC_TRY_RUN([
+int
+main()
+{
+ if (-1==(-1>>1))
+ return 0;
+ return 1;
+}
+],
+ rb_cv_rshift_sign=yes,
+ rb_cv_rshift_sign=no)])
+ AC_MSG_RESULT($rb_cv_rshift_sign)
+if test "$rb_cv_rshift_sign" = yes; then
+ AC_DEFINE(RSHIFT(x,y), ((x)>>y))
+else
+ AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
+fi
+
AC_MSG_CHECKING([count field in FILE structures])
AC_CACHE_VAL(rb_cv_fcnt,
[AC_TRY_COMPILE([#include <stdio.h>],
@@ -205,17 +287,6 @@ else
AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
fi
-if test "$ac_cv_func_getpwent" = yes; then
- AC_MSG_CHECKING(struct passwd)
- AC_EGREP_HEADER(pw_change, pwd.h, AC_DEFINE(PW_CHANGE))
- AC_EGREP_HEADER(pw_quota, pwd.h, AC_DEFINE(PW_QUOTA))
- AC_EGREP_HEADER(pw_age, pwd.h, AC_DEFINE(PW_AGE))
- AC_EGREP_HEADER(pw_class, pwd.h, AC_DEFINE(PW_CLASS))
- AC_EGREP_HEADER(pw_comment, pwd.h, AC_DEFINE(PW_COMMENT))
- AC_EGREP_HEADER(pw_expire, pwd.h, AC_DEFINE(PW_EXPIRE))
- AC_MSG_RESULT(done)
-fi
-
dnl wheather use dln_a_out ot not
AC_ARG_WITH(dln-a-out, [--with-dln-a-out use dln_a_out if possible], [
case $withval in
@@ -271,7 +342,10 @@ if test "$with_dln_a_out" != yes; then
if test "$GCC" = yes; then
case "$host_os" in
nextstep*) ;;
+ openstep*) ;;
+ rhapsody*) ;;
human*) ;;
+ cygwin*) CCDLFLAGS=-DDLLIMPORT;;
*) CCDLFLAGS=-fpic;;
esac
else
@@ -301,21 +375,44 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes ;;
linux*) LDSHARED="gcc -shared"
rb_cv_dlopen=yes ;;
+ freebsd3*) LDSHARED="ld -Bshareable"
+ LDFLAGS="-rdynamic"
+ rb_cv_dlopen=yes ;;
freebsd*) LDSHARED="ld -Bshareable"
rb_cv_dlopen=yes ;;
netbsd*) LDSHARED="ld -Bshareable"
rb_cv_dlopen=yes ;;
- openbsd*) LDSHARED="ld -Bshareable"
+ openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
+ CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r'
LDFLAGS="-u libsys_s"
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
+ openstep*) LDSHARED='cc -dynamic -bundle -undefined suppress'
+ LDFLAGS=""
+ DLDFLAGS="$ARCH_FLAG"
+ rb_cv_dlopen=yes ;;
+ rhapsody*) LDSHARED='cc -dynamic -bundle -undefined suppress'
+ LDFLAGS=""
+ DLDFLAGS="$ARCH_FLAG"
+ rb_cv_dlopen=yes ;;
aix*) LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)'
rb_cv_dlopen=yes ;;
human*) DLDFLAGS=''
LDSHARED=''
LDFLAGS='' ;;
+ beos*) LDSHARED="ld -xms"
+ case "$host_cpu" in
+ powerpc*)
+ DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
+ ;;
+ *)
+ DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
+ ;;
+ esac
+ rb_cv_dlopen=yes ;;
+ cygwin*) LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
*) LDSHARED='ld' ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
@@ -357,6 +454,12 @@ else
AC_DEFINE(DLEXT, ".sl");;
nextstep*) DLEXT=o
AC_DEFINE(DLEXT, ".o");;
+ openstep*) DLEXT=bundle
+ AC_DEFINE(DLEXT, ".bundle");;
+ rhapsody*) DLEXT=bundle
+ AC_DEFINE(DLEXT, ".bundle");;
+ cygwin*) DLEXT=dll
+ AC_DEFINE(DLEXT, ".dll");;
*) DLEXT=so
AC_DEFINE(DLEXT, ".so");;
esac
@@ -374,6 +477,10 @@ case "$host_os" in
STRIP='strip -S -x';;
nextstep*)
STRIP='strip -A -n';;
+ openstep*)
+ STRIP='strip -A -n';;
+ rhapsody*)
+ STRIP='strip -A -n';;
esac
EXTSTATIC=
@@ -435,11 +542,18 @@ rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no)])
binsuffix=.x
setup=Setup.x68
;;
+ cygwin*)
+ binsuffix=.exe
+ setup=Setup
+ ;;
*)
binsuffix=
setup=Setup
;;
esac
+
+
+
AC_SUBST(binsuffix)
AC_SUBST(setup)
@@ -448,23 +562,82 @@ if test "$prefix" = NONE; then
fi
if test "$fat_binary" = yes ; then
- CFLAGS="$CFLAGS -pipe $ARCH_FLAG"
+ CFLAGS="$CFLAGS $ARCH_FLAG"
+fi
+
+LIBRUBY='libruby.a'
+LIBRUBYARG='libruby.a'
+SOLIBS=
+if test "$host_os" = "beos"; then
+ CFLAGS="$CFLAGS -relax_pointers"
+ LIBRUBY='libruby.so'
+ LIBRUBYARG='-lruby'
+ SOLIBS='-lnet'
+ echo creating ruby.def
+ case "$host_cpu" in
+ powerpc*)
+ cp beos/ruby.def.in ruby.exp
+ ;;
+ *)
+ echo EXPORTS > ruby.def
+ cat beos/ruby.def.in >> ruby.def
+ ;;
+ esac
fi
-AC_DEFINE_UNQUOTED(RUBY_LIB, "${prefix}/lib/ruby")
+if test "$enable_shared" = 'yes'; then
+ LIBRUBY='libruby.so'
+ LIBRUBYARG='-L./ -lruby'
+fi
+
+case "$host_os" in
+ nextstep*)
+ CFLAGS="$CFLAGS -pipe"
+ ;;
+ openstep*)
+ CFLAGS="$CFLAGS -pipe"
+ ;;
+ rhasody*)
+ CFLAGS="$CFLAGS -pipe -no-precomp"
+ ;;
+ *)
+ ;;
+esac
+
+
+AC_SUBST(LIBRUBY)
+AC_SUBST(LIBRUBYARG)
+AC_SUBST(SOLIBS)
+
+ri_prefix=
+test "$program_prefix" != NONE &&
+ ri_prefix=$program_prefix
+
+ri_suffix=
+test "$program_suffix" != NONE &&
+ ri_suffix=$program_suffix
+
+RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
+AC_DEFINE_UNQUOTED(RUBY_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby")
AC_SUBST(arch)dnl
if test "$fat_binary" = yes ; then
arch="fat-${host_os}"
AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
- "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}" )
+ "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}" )
+
+ AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
+ "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}" )
- AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${arch}")
+ AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}")
+ AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${host_os}" )
else
arch="${host_cpu}-${host_os}"
- AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${arch}")
+ AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}")
+ AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
fi
diff --git a/defines.h b/defines.h
index a24f9eb..fb10d62 100644
--- a/defines.h
+++ b/defines.h
@@ -12,18 +12,20 @@
#define RUBY
-/* define EUC/SJIS for default kanji-code */
-#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__)
-#undef EUC
-#define SJIS
+/* define RUBY_USE_EUC/SJIS for default kanji-code */
+#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__)
+#undef RUBY_USE_EUC
+#define RUBY_USE_SJIS
#else
-#define EUC
-#undef SJIS
+#define RUBY_USE_EUC
+#undef RUBY_USE_SJIS
#endif
#ifdef NeXT
#define DYNAMIC_ENDIAN /* determine endian at runtime */
+#ifndef __APPLE__
#define S_IXUSR _S_IXUSR /* execute/search permission, owner */
+#endif
#define S_IXGRP 0000010 /* execute/search permission, group */
#define S_IXOTH 0000001 /* execute/search permission, other */
#endif /* NeXT */
@@ -32,12 +34,22 @@
#include "missing/nt.h"
#endif
+#ifndef EXTERN
+#define EXTERN extern
+#endif
+
#ifdef sparc
#define FLUSH_REGISTER_WINDOWS asm("ta 3")
#else
#define FLUSH_REGISTER_WINDOWS /* empty */
#endif
+#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
+#define RUBY_PATH_SEP ";"
+#else
+#define RUBY_PATH_SEP ":"
+#endif
+
#if defined(__human68k__) || defined(__CYGWIN32__)
#undef HAVE_RANDOM
#undef HAVE_SETITIMER
diff --git a/dir.c b/dir.c
index 29ce261..51d7f9e 100644
--- a/dir.c
+++ b/dir.c
@@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
@@ -27,6 +27,9 @@
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
+#elif HAVE_DIRECT_H
+# include <direct.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
@@ -39,7 +42,7 @@
# if HAVE_NDIR_H
# include <ndir.h>
# endif
-# ifdef NT
+# if defined(NT) && defined(_MSC_VER)
# include "missing/dir.h"
# endif
#endif
@@ -50,7 +53,11 @@
char *getenv();
#endif
-static VALUE cDir;
+#ifdef USE_CWGUSI
+# include <sys/errno.h>
+#endif
+
+VALUE rb_cDir;
static void
free_dir(dir)
@@ -59,6 +66,8 @@ free_dir(dir)
if (dir) closedir(dir);
}
+static VALUE dir_close _((VALUE));
+
static VALUE
dir_s_open(dir_class, dirname)
VALUE dir_class, dirname;
@@ -71,7 +80,7 @@ dir_s_open(dir_class, dirname)
dirp = opendir(RSTRING(dirname)->ptr);
if (dirp == NULL) {
if (errno == EMFILE || errno == ENFILE) {
- gc_gc();
+ rb_gc();
dirp = opendir(RSTRING(dirname)->ptr);
}
if (dirp == NULL) {
@@ -81,13 +90,17 @@ dir_s_open(dir_class, dirname)
obj = Data_Wrap_Struct(dir_class, 0, free_dir, dirp);
+ if (rb_iterator_p()) {
+ return rb_ensure(rb_yield, obj, dir_close, obj);
+ }
+
return obj;
}
static void
dir_closed()
{
- Fail("closed directory");
+ rb_raise(rb_eIOError, "closed directory");
}
#define GetDIR(obj, dirp) {\
@@ -96,6 +109,27 @@ dir_closed()
}
static VALUE
+dir_read(dir)
+ VALUE dir;
+{
+ DIR *dirp;
+ struct dirent *dp;
+
+ GetDIR(dir, dirp);
+ errno = 0;
+ dp = readdir(dirp);
+ if (dp)
+ return rb_tainted_str_new(dp->d_name, NAMLEN(dp));
+ else if (errno == 0) { /* end of stream */
+ return Qnil;
+ }
+ else {
+ rb_sys_fail(0);
+ }
+ return Qnil; /* not reached */
+}
+
+static VALUE
dir_each(dir)
VALUE dir;
{
@@ -105,7 +139,7 @@ dir_each(dir)
GetDIR(dir, dirp);
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- file = str_taint(str_new(dp->d_name, NAMLEN(dp)));
+ file = rb_tainted_str_new(dp->d_name, NAMLEN(dp));
rb_yield(file);
}
return dir;
@@ -118,10 +152,10 @@ dir_tell(dir)
DIR *dirp;
int pos;
-#if !defined(__CYGWIN32__)
+#if !defined(__CYGWIN32__) && !defined(__BEOS__)
GetDIR(dir, dirp);
pos = telldir(dirp);
- return int2inum(pos);
+ return rb_int2inum(pos);
#else
rb_notimplement();
#endif
@@ -133,7 +167,7 @@ dir_seek(dir, pos)
{
DIR *dirp;
-#if !defined(__CYGWIN32__)
+#if !defined(__CYGWIN32__) && !defined(__BEOS__)
GetDIR(dir, dirp);
seekdir(dirp, NUM2INT(pos));
return dir;
@@ -177,8 +211,7 @@ dir_s_chdir(argc, argv, obj)
char *dist = "";
rb_secure(2);
- rb_scan_args(argc, argv, "01", &path);
- if (!NIL_P(path)) {
+ if (rb_scan_args(argc, argv, "01", &path) == 1) {
Check_SafeStr(path);
dist = RSTRING(path)->ptr;
}
@@ -190,7 +223,7 @@ dir_s_chdir(argc, argv, obj)
}
if (chdir(dist) < 0)
- rb_sys_fail(0);
+ rb_sys_fail(dist);
return INT2FIX(0);
}
@@ -199,32 +232,33 @@ static VALUE
dir_s_getwd(dir)
VALUE dir;
{
- extern char *getwd();
char path[MAXPATHLEN];
#ifdef HAVE_GETCWD
if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path);
#else
+ extern char *getwd();
if (getwd(path) == 0) rb_sys_fail(path);
#endif
- return str_taint(str_new2(path));
+ return rb_tainted_str_new2(path);
}
static VALUE
dir_s_chroot(dir, path)
VALUE dir, path;
{
-#if !defined(DJGPP) && !defined(__CYGWIN32__) && !defined(NT) && !defined(__human68k__)
+#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__)
rb_secure(2);
Check_SafeStr(path);
if (chroot(RSTRING(path)->ptr) == -1)
- rb_sys_fail(0);
+ rb_sys_fail(RSTRING(path)->ptr);
return INT2FIX(0);
#else
rb_notimplement();
+ return Qnil; /* not reached */
#endif
}
@@ -246,7 +280,7 @@ dir_s_mkdir(argc, argv, obj)
}
Check_SafeStr(path);
-#ifndef NT
+#if !defined(NT) && !defined(USE_CWGUSI)
if (mkdir(RSTRING(path)->ptr, mode) == -1)
rb_sys_fail(RSTRING(path)->ptr);
#else
@@ -266,7 +300,7 @@ dir_s_rmdir(obj, dir)
if (rmdir(RSTRING(dir)->ptr) < 0)
rb_sys_fail(RSTRING(dir)->ptr);
- return TRUE;
+ return Qtrue;
}
#define isdelim(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\0')
@@ -285,7 +319,7 @@ push_globs(ary, s)
if (fnames == (char**)-1) rb_sys_fail(s);
ff = fnames;
while (*ff) {
- ary_push(ary, str_taint(str_new2(*ff)));
+ rb_ary_push(ary, rb_tainted_str_new2(*ff));
free(*ff);
ff++;
}
@@ -341,22 +375,24 @@ push_braces(ary, s)
}
static VALUE
-dir_s_glob(dir, vstr)
- VALUE dir, vstr;
+dir_s_glob(dir, str)
+ VALUE dir, str;
{
char *p, *pend;
char buf[MAXPATHLEN];
char *t, *t0;
int nest;
VALUE ary;
- struct RString *str;
- Check_SafeStr(vstr);
- str = RSTRING(vstr);
- ary = ary_new();
+ Check_SafeStr(str);
+ if (RSTRING(str)->len > MAXPATHLEN) {
+ rb_raise(rb_eArgError, "pathname too long (%d bytes)",
+ RSTRING(str)->len);
+ }
+ ary = rb_ary_new();
- p = str->ptr;
- pend = p + str->len;
+ p = RSTRING(str)->ptr;
+ pend = p + RSTRING(str)->len;
while (p < pend) {
t = buf;
@@ -389,37 +425,48 @@ dir_foreach(io, dirname)
{
VALUE dir;
- dir = dir_s_open(cDir, dirname);
+ dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
return rb_ensure(dir_each, dir, dir_close, dir);
}
-void
-Init_Dir()
+static VALUE
+dir_entries(io, dirname)
+ VALUE io, dirname;
{
- extern VALUE mEnumerable;
-
- cDir = rb_define_class("Dir", cObject);
-
- rb_include_module(cDir, mEnumerable);
-
- rb_define_singleton_method(cDir, "open", dir_s_open, 1);
- rb_define_singleton_method(cDir, "foreach", dir_foreach, 1);
-
- rb_define_method(cDir,"each", dir_each, 0);
- rb_define_method(cDir,"rewind", dir_rewind, 0);
- rb_define_method(cDir,"tell", dir_tell, 0);
- rb_define_method(cDir,"seek", dir_seek, 1);
- rb_define_method(cDir,"close", dir_close, 0);
+ VALUE dir;
- rb_define_singleton_method(cDir,"chdir", dir_s_chdir, -1);
- rb_define_singleton_method(cDir,"getwd", dir_s_getwd, 0);
- rb_define_singleton_method(cDir,"pwd", dir_s_getwd, 0);
- rb_define_singleton_method(cDir,"chroot", dir_s_chroot, 1);
- rb_define_singleton_method(cDir,"mkdir", dir_s_mkdir, -1);
- rb_define_singleton_method(cDir,"rmdir", dir_s_rmdir, 1);
- rb_define_singleton_method(cDir,"delete", dir_s_rmdir, 1);
- rb_define_singleton_method(cDir,"unlink", dir_s_rmdir, 1);
+ dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
+ return rb_ensure(rb_Array, dir, dir_close, dir);
+}
- rb_define_singleton_method(cDir,"glob", dir_s_glob, 1);
- rb_define_singleton_method(cDir,"[]", dir_s_glob, 1);
+void
+Init_Dir()
+{
+ rb_cDir = rb_define_class("Dir", rb_cObject);
+
+ rb_include_module(rb_cDir, rb_mEnumerable);
+
+ rb_define_singleton_method(rb_cDir, "new", dir_s_open, 1);
+ rb_define_singleton_method(rb_cDir, "open", dir_s_open, 1);
+ rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, 1);
+ rb_define_singleton_method(rb_cDir, "entries", dir_entries, 1);
+
+ rb_define_method(rb_cDir,"read", dir_read, 0);
+ rb_define_method(rb_cDir,"each", dir_each, 0);
+ rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
+ rb_define_method(rb_cDir,"tell", dir_tell, 0);
+ rb_define_method(rb_cDir,"seek", dir_seek, 1);
+ rb_define_method(rb_cDir,"close", dir_close, 0);
+
+ rb_define_singleton_method(rb_cDir,"chdir", dir_s_chdir, -1);
+ rb_define_singleton_method(rb_cDir,"getwd", dir_s_getwd, 0);
+ rb_define_singleton_method(rb_cDir,"pwd", dir_s_getwd, 0);
+ rb_define_singleton_method(rb_cDir,"chroot", dir_s_chroot, 1);
+ rb_define_singleton_method(rb_cDir,"mkdir", dir_s_mkdir, -1);
+ rb_define_singleton_method(rb_cDir,"rmdir", dir_s_rmdir, 1);
+ rb_define_singleton_method(rb_cDir,"delete", dir_s_rmdir, 1);
+ rb_define_singleton_method(rb_cDir,"unlink", dir_s_rmdir, 1);
+
+ rb_define_singleton_method(rb_cDir,"glob", dir_s_glob, 1);
+ rb_define_singleton_method(rb_cDir,"[]", dir_s_glob, 1);
}
diff --git a/dln.c b/dln.c
index f4ab012..858291d 100644
--- a/dln.c
+++ b/dln.c
@@ -6,20 +6,20 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
-#ifdef _AIX
-#pragma alloca
-#endif
-
#include "config.h"
#include "defines.h"
#include "dln.h"
char *dln_argv0;
+#ifdef _AIX
+#pragma alloca
+#endif
+
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
#include <alloca.h>
#endif
@@ -36,7 +36,9 @@ void *xrealloc();
#include <stdio.h>
#ifndef NT
-#include <sys/file.h>
+# ifndef USE_CWGUSI
+# include <sys/file.h>
+# endif
#else
#include "missing/file.h"
#endif
@@ -58,15 +60,25 @@ char *strdup();
char *getenv();
#endif
+#ifdef __MACOS__
+# include <TextUtils.h>
+# include <CodeFragments.h>
+# include <Aliases.h>
+#endif
+
+#ifdef __BEOS__
+# include <image.h>
+#endif
+
int eaccess();
-#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT)
+#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(__CYGWIN32__) && !defined(_AIX)
/* dynamic load with dlopen() */
# define USE_DLN_DLOPEN
#endif
#ifndef FUNCNAME_PATTERN
-# if defined(__hp9000s300) || defined(__NetBSD__) || defined(__BORLANDC__) || defined(__FreeBSD__) || defined(NeXT)
+# if defined(__hp9000s300) || defined(__NetBSD__) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(NeXT) || defined(__WATCOMC__)
# define FUNCNAME_PATTERN "_Init_%.200s"
# else
# define FUNCNAME_PATTERN "Init_%.200s"
@@ -81,7 +93,11 @@ init_funcname(buf, file)
/* Load the file as an object one */
for (p = file, slash = p-1; *p; p++) /* Find position of last '/' */
+#ifdef __MACOS__
+ if (*p == ':') slash = p;
+#else
if (*p == '/') slash = p;
+#endif
sprintf(buf, FUNCNAME_PATTERN, slash + 1);
for (p = buf; *p; p++) { /* Delete suffix it it exists */
@@ -407,7 +423,7 @@ load_text_data(fd, hdrp, bss, disp)
}
static int
-undef_print(key, value)
+underb_f_print(key, value)
char *key, *value;
{
fprintf(stderr, " %s\n", key);
@@ -418,7 +434,7 @@ static void
dln_print_undef()
{
fprintf(stderr, " Undefined symbols:\n");
- st_foreach(undef_tbl, undef_print, NULL);
+ st_foreach(undef_tbl, underb_f_print, NULL);
}
static void
@@ -814,7 +830,7 @@ load_1(fd, disp, need_init)
for (sym = syms; sym<end; sym++) {
char *name = sym->n_un.n_name;
if (name[0] == '_' && sym->n_value >= block) {
- if (strcmp(name+1, "libs_to_be_linked") == 0) {
+ if (strcmp(name+1, "dln_libs_to_be_linked") == 0) {
libs_to_be_linked = (char**)sym->n_value;
}
else if (strcmp(name+1, buf) == 0) {
@@ -869,11 +885,11 @@ search_undef(key, value, lib_tbl)
}
struct symdef {
- int str_index;
+ int rb_str_index;
int lib_offset;
};
-char *dln_library_path = DLN_DEFAULT_LIB_PATH;
+char *dln_librrb_ary_path = DLN_DEFAULT_LIB_PATH;
static int
load_lib(lib)
@@ -904,10 +920,10 @@ load_lib(lib)
/* library search path: */
/* look for environment variable DLN_LIBRARY_PATH first. */
- /* then variable dln_library_path. */
+ /* then variable dln_librrb_ary_path. */
/* if path is still NULL, use "." for path. */
path = getenv("DLN_LIBRARY_PATH");
- if (path == NULL) path = dln_library_path;
+ if (path == NULL) path = dln_librrb_ary_path;
file = dln_find_file(lib, path);
fd = open(file, O_RDONLY);
@@ -936,7 +952,7 @@ load_lib(lib)
base = (struct symdef*)(data + 1);
name_base = (char*)(base + nsym) + sizeof(int);
while (nsym > 0) {
- char *name = name_base + base->str_index;
+ char *name = name_base + base->rb_str_index;
st_insert(lib_tbl, name, base->lib_offset + sizeof(ahdr));
nsym--;
@@ -1065,14 +1081,18 @@ dln_sym(name)
#include "dl.h"
#endif
-#ifdef _AIX
+#if defined(_AIX)
#include <ctype.h> /* for isdigit() */
#include <errno.h> /* for global errno */
#include <sys/ldr.h>
#endif
#ifdef NeXT
-/*#include <mach-o/rld.h>*/
+#if NS_TARGET_MAJOR < 4
+#include <mach-o/rld.h>
+#else
+#include <mach-o/dyld.h>
+#endif
#endif
#ifdef _WIN32
@@ -1109,21 +1129,28 @@ dln_strerror()
#ifdef _WIN32
static char message[1024];
+ int error = GetLastError();
+ char *p = message;
+ p += sprintf(message, "%d: ", error);
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
- GetLastError(),
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
- message,
- sizeof message,
+ error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ p,
+ sizeof message - strlen(message),
NULL);
+ for (p = message; *p; p++) {
+ if (*p == '\n' || *p == '\r')
+ *p = ' ';
+ }
return message;
#endif
}
-#ifdef _AIX
+#if defined(_AIX)
static void
aix_loaderror(char *pathname)
{
@@ -1166,7 +1193,7 @@ aix_loaderror(char *pathname)
ERRBUF_APPEND("\n");
}
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
- LoadError(errbuf);
+ rb_loaderror(errbuf);
return;
}
#endif
@@ -1193,7 +1220,7 @@ dln_load(file)
/* Load file */
if ((handle =
LoadLibraryExA(winfile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) == NULL) {
- printf("LoadLibraryExA\n");
+ printf("LoadLibraryExA: %s\n", winfile);
goto failed;
}
@@ -1229,15 +1256,15 @@ dln_load(file)
void *handle;
void (*init_fct)();
-# ifndef RTLD_LAZY
-# define RTLD_LAZY 1
-# endif
-# ifndef RTLD_GLOBAL
-# define RTLD_GLOBAL 0
-# endif
+#ifndef RTLD_LAZY
+# define RTLD_LAZY 1
+#endif
+#ifndef RTLD_GLOBAL
+# define RTLD_GLOBAL 0
+#endif
/* Load file */
- if ((handle = dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
+ if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
goto failed;
}
@@ -1260,15 +1287,15 @@ dln_load(file)
flags = BIND_DEFERRED;
lib = shl_load(file, flags, 0);
if (lib == NULL) {
- rb_sys_fail(file);
+ extern int errno;
+ rb_loaderror("%s - %s", strerror(errno), file);
}
shl_findsym(&lib, buf, TYPE_PROCEDURE, (void*)&init_fct);
if (init_fct == NULL) {
shl_findsym(&lib, buf, TYPE_UNDEFINED, (void*)&init_fct);
if (init_fct == NULL) {
- extern int errno;
errno = ENOSYM;
- rb_sys_fail(file);
+ rb_loaderror("%s - %s", strerror(ENOSYM), file);
}
}
(*init_fct)();
@@ -1276,7 +1303,7 @@ dln_load(file)
}
#endif /* hpux */
-#ifdef _AIX
+#if defined(_AIX)
#define DLN_DEFINED
{
void (*init_fct)();
@@ -1300,6 +1327,7 @@ dln_load(file)
Mi hisho@tasihara.nest.or.jp,
and... Miss ARAI Akino(^^;)
----------------------------------------------------*/
+#if NS_TARGET_MAJOR < 4 /* NeXTSTEP rld functions */
{
unsigned long init_address;
char *object_files[2] = {NULL, NULL};
@@ -1310,12 +1338,12 @@ dln_load(file)
/* Load object file, if return value ==0 , load failed*/
if(rld_load(NULL, NULL, object_files, NULL) == 0) {
- LoadError("Failed to load %.200s", file);
+ rb_loaderror("Failed to load %.200s", file);
}
/* lookup the initial function */
if(rld_lookup(NULL, buf, &init_address) == 0) {
- LoadError("Failed to lookup Init function %.200s",file);
+ rb_loaderror("Failed to lookup Init function %.200s", file);
}
/* Cannot call *init_address directory, so copy this value to
@@ -1325,8 +1353,133 @@ dln_load(file)
(*init_fct)();
return ;
}
+#else/* OPENSTEP dyld functions */
+ {
+ int dyld_result ;
+ NSObjectFileImage obj_file ; /* handle, but not use it */
+ /* "file" is module file name .
+ "buf" is initial function name with "_" . */
+
+ void (*init_fct)();
+
+
+ dyld_result = NSCreateObjectFileImageFromFile( file, &obj_file );
+
+ if (dyld_result != NSObjectFileImageSuccess) {
+ rb_loaderror("Failed to load %.200s", file);
+ }
+
+ NSLinkModule(obj_file, file, TRUE);
+
+ /* lookup the initial function */
+ /*NSIsSymbolNameDefined require function name without "_" */
+ if( NSIsSymbolNameDefined( buf + 1 ) ) {
+ rb_loaderror("Failed to lookup Init function %.200s",file);
+ }
+
+ /* NSLookupAndBindSymbol require function name with "_" !! */
+ init_fct = NSAddressOfSymbol( NSLookupAndBindSymbol( buf ) );
+ (*init_fct)();
+
+ return ;
+ }
+#endif /* rld or dyld */
#endif
+#ifdef __BEOS__
+# define DLN_DEFINED
+ {
+ status_t err_stat; /* BeOS error status code */
+ image_id img_id; /* extention module unique id */
+ void (*init_fct)(); /* initialize function for extention module */
+
+ /* load extention module */
+ img_id = load_add_on(file);
+ if (img_id <= 0) {
+ rb_loaderror("Failed to load %.200s", file);
+ }
+
+ /* find symbol for module initialize function. */
+ /* The Be Book KernelKit Images section described to use
+ B_SYMBOL_TYPE_TEXT for symbol of function, not
+ B_SYMBOL_TYPE_CODE. Why ? */
+ /* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */
+ /* "__Fv" dont need! The Be Book Bug ? */
+ err_stat = get_image_symbol(img_id, buf,
+ B_SYMBOL_TYPE_TEXT, &init_fct);
+
+ if (err_stat != B_NO_ERROR) {
+ char real_name[1024];
+ strcpy(real_name, buf);
+ strcat(real_name, "__Fv");
+ err_stat = get_image_symbol(img_id, real_name,
+ B_SYMBOL_TYPE_TEXT, &init_fct);
+ }
+
+ if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) {
+ unload_add_on(img_id);
+ rb_loaderror("Failed to lookup Init function %.200s", file);
+ }
+ else if (B_NO_ERROR != err_stat) {
+ char errmsg[] = "Internal of BeOS version. %.200s (symbol_name = %s)";
+ unload_add_on(img_id);
+ rb_loaderror(errmsg, strerror(err_stat), buf);
+ }
+
+ /* call module initialize function. */
+ (*init_fct)();
+ return;
+ }
+#endif /* __BEOS__*/
+
+#ifdef __MACOS__
+# define DLN_DEFINED
+ {
+ OSErr err;
+ FSSpec libspec;
+ CFragConnectionID connID;
+ Ptr mainAddr;
+ char errMessage[1024];
+ Boolean isfolder, didsomething;
+ Str63 fragname;
+ Ptr symAddr;
+ CFragSymbolClass class;
+ void (*init_fct)();
+ char fullpath[MAXPATHLEN];
+
+ strcpy(fullpath, file);
+
+ /* resolve any aliases to find the real file */
+ c2pstr(fullpath);
+ (void)FSMakeFSSpec(0, 0, fullpath, &libspec);
+ err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
+ if ( err ) {
+ rb_loaderror("Unresolved Alias - %s", file);
+ }
+
+ /* Load the fragment (or return the connID if it is already loaded */
+ fragname[0] = 0;
+ err = GetDiskFragment(&libspec, 0, 0, fragname,
+ kLoadCFrag, &connID, &mainAddr,
+ errMessage);
+ if ( err ) {
+ p2cstr(errMessage);
+ rb_loaderror("%s - %s",errMessage , file);
+ }
+
+ /* Locate the address of the correct init function */
+ c2pstr(buf);
+ err = FindSymbol(connID, buf, &symAddr, &class);
+ if ( err ) {
+ rb_loaderror("Unresolved symbols - %s" , file);
+ }
+
+ init_fct = (void (*)())symAddr;
+ (*init_fct)();
+ return;
+ }
+#endif /* __MACOS__ */
+
#ifndef DLN_DEFINED
rb_notimplement("dynamic link not supported");
#endif
@@ -1335,7 +1488,7 @@ dln_load(file)
#endif
#if !defined(_AIX) && !defined(NeXT)
failed:
- LoadError("%s - %s", dln_strerror(), file);
+ rb_loaderror("%s - %s", dln_strerror(), file);
#endif
}
@@ -1346,15 +1499,21 @@ dln_find_exe(fname, path)
char *fname;
char *path;
{
+ if (!path) {
#if defined(__human68k__)
- if (!path)
path = getenv("path");
- if (!path)
- path = "/usr/local/bin;/usr/usb;/usr/bin;/bin;.";
#else
- if (!path) path = getenv("PATH");
- if (!path) path = "/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
+ path = getenv("PATH");
#endif
+ }
+
+ if (!path) {
+#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
+ path = "/usr/local/bin;/usr/ucb;/usr/bin;/bin;.";
+#else
+ path = "/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
+#endif
+ }
return dln_find_1(fname, path, 1);
}
@@ -1367,6 +1526,30 @@ dln_find_file(fname, path)
return dln_find_1(fname, path, 0);
}
+#if defined(__CYGWIN32__)
+char *
+conv_to_posix_path(win32, posix)
+ char *win32;
+ char *posix;
+{
+ char *first = win32;
+ char *p = win32;
+ char *dst = posix;
+
+ for (p = win32; *p; p++)
+ if (*p == ';') {
+ *p = 0;
+ cygwin32_conv_to_posix_path(first, posix);
+ posix += strlen(posix);
+ *posix++ = ':';
+ first = p + 1;
+ *p = ';';
+ }
+ cygwin32_conv_to_posix_path(first, posix);
+ return dst;
+}
+#endif
+
static char fbuf[MAXPATHLEN];
static char *
@@ -1380,15 +1563,24 @@ dln_find_1(fname, path, exe_flag)
register char *bp;
struct stat st;
+#if defined(__CYGWIN32__)
+ char rubypath[MAXPATHLEN];
+ conv_to_posix_path(path, rubypath);
+ path = rubypath;
+#endif
+#ifndef __MACOS__
if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname;
+ if (exe_flag && strchr(fname, '/')) return fname;
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
if (fname[0] == '\\') return fname;
- if (fname[1] == ':') return fname;
+ if (strlen(fname) > 2 && fname[1] == ':') return fname;
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname;
+ if (exe_flag && strchr(fname, '\\')) return fname;
#endif
+#endif /* __MACOS__ */
for (dp = path;; dp = ++ep) {
register int l;
@@ -1396,11 +1588,7 @@ dln_find_1(fname, path, exe_flag)
int fspace;
/* extract a component */
-#if !defined(MSDOS) && !defined(NT) && !defined(__human68k__)
- ep = strchr(dp, ':');
-#else
- ep = strchr(dp, ';');
-#endif
+ ep = strchr(dp, RUBY_PATH_SEP[0]);
if (ep == NULL)
ep = dp+strlen(dp);
@@ -1417,7 +1605,11 @@ dln_find_1(fname, path, exe_flag)
** take the path literally.
*/
- if (*dp == '~' && (l == 1 || dp[1] == '/')) {
+ if (*dp == '~' && (l == 1 ||
+#if defined(MSDOS) || defined(NT) || defined(__human68k__)
+ dp[1] == '\\' ||
+#endif
+ dp[1] == '/')) {
char *home;
home = getenv("HOME");
@@ -1440,7 +1632,11 @@ dln_find_1(fname, path, exe_flag)
/* add a "/" between directory and filename */
if (ep[-1] != '/')
+#ifdef __MACOS__
+ *bp++ = ':';
+#else
*bp++ = '/';
+#endif
}
/* now append the file name */
diff --git a/dln.h b/dln.h
index 0e16170..7af1f63 100644
--- a/dln.h
+++ b/dln.h
@@ -11,12 +11,20 @@
#ifndef DLN_H
#define DLN_H
-char *dln_find_exe();
-char *dln_find_file();
+#ifndef _
+#ifndef __STDC__
+# define _(args) ()
+#else
+# define _(args) args
+#endif
+#endif
+
+char *dln_find_exe _((char*,char*));
+char *dln_find_file _((char*,char*));
#ifdef USE_DLN_A_OUT
extern char *dln_argv0;
#endif
-void dln_load();
+void dln_load _((char*));
#endif
diff --git a/enum.c b/enum.c
index d8e2fcd..2b4b904 100644
--- a/enum.c
+++ b/enum.c
@@ -6,13 +6,13 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
-VALUE mEnumerable;
+VALUE rb_mEnumerable;
static ID id_each, id_eqq, id_cmp;
VALUE
@@ -27,7 +27,7 @@ grep_i(i, arg)
VALUE i, *arg;
{
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
- ary_push(arg[1], i);
+ rb_ary_push(arg[1], i);
}
return Qnil;
}
@@ -46,14 +46,14 @@ static VALUE
enum_grep(obj, pat)
VALUE obj, pat;
{
- if (iterator_p()) {
+ if (rb_iterator_p()) {
rb_iterate(rb_each, obj, grep_iter_i, pat);
return obj;
}
else {
VALUE tmp, arg[2];
- arg[0] = pat; arg[1] = tmp = ary_new();
+ arg[0] = pat; arg[1] = tmp = rb_ary_new();
rb_iterate(rb_each, obj, grep_i, (VALUE)arg);
return tmp;
@@ -71,7 +71,7 @@ find_i(i, arg)
struct find_arg *arg;
{
if (RTEST(rb_yield(i))) {
- arg->found = TRUE;
+ arg->found = Qtrue;
arg->val = i;
rb_iter_break();
}
@@ -88,7 +88,7 @@ enum_find(argc, argv, obj)
VALUE if_none;
rb_scan_args(argc, argv, "01", &if_none);
- arg.found = FALSE;
+ arg.found = Qfalse;
rb_iterate(rb_each, obj, find_i, (VALUE)&arg);
if (arg.found) {
return arg.val;
@@ -104,7 +104,7 @@ find_all_i(i, tmp)
VALUE i, tmp;
{
if (RTEST(rb_yield(i))) {
- ary_push(tmp, i);
+ rb_ary_push(tmp, i);
}
return Qnil;
}
@@ -115,7 +115,7 @@ enum_find_all(obj)
{
VALUE tmp;
- tmp = ary_new();
+ tmp = rb_ary_new();
rb_iterate(rb_each, obj, find_all_i, tmp);
return tmp;
@@ -125,12 +125,7 @@ static VALUE
collect_i(i, tmp)
VALUE i, tmp;
{
- VALUE retval;
-
- retval = rb_yield(i);
- if (RTEST(retval)) {
- ary_push(tmp, retval);
- }
+ rb_ary_push(tmp, rb_yield(i));
return Qnil;
}
@@ -140,37 +135,17 @@ enum_collect(obj)
{
VALUE tmp;
- tmp = ary_new();
+ tmp = rb_ary_new();
rb_iterate(rb_each, obj, collect_i, tmp);
return tmp;
}
static VALUE
-reverse_i(i, tmp)
- VALUE i, tmp;
-{
- ary_unshift(tmp, i);
- return Qnil;
-}
-
-static VALUE
-enum_reverse(obj)
- VALUE obj;
-{
- VALUE tmp;
-
- tmp = ary_new();
- rb_iterate(rb_each, obj, reverse_i, tmp);
-
- return tmp;
-}
-
-static VALUE
enum_all(i, ary)
VALUE i, ary;
{
- ary_push(ary, i);
+ rb_ary_push(ary, i);
return Qnil;
}
@@ -180,7 +155,7 @@ enum_to_a(obj)
{
VALUE ary;
- ary = ary_new();
+ ary = rb_ary_new();
rb_iterate(rb_each, obj, enum_all, ary);
return ary;
@@ -190,7 +165,7 @@ static VALUE
enum_sort(obj)
VALUE obj;
{
- return ary_sort(enum_to_a(obj));
+ return rb_ary_sort(enum_to_a(obj));
}
static VALUE
@@ -203,7 +178,7 @@ min_i(i, min)
*min = i;
else {
cmp = rb_funcall(i, id_cmp, 1, *min);
- if (FIX2INT(cmp) < 0)
+ if (FIX2LONG(cmp) < 0)
*min = i;
}
return Qnil;
@@ -218,8 +193,8 @@ min_ii(i, min)
if (NIL_P(*min))
*min = i;
else {
- cmp = rb_yield(assoc_new(i, *min));
- if (FIX2INT(cmp) < 0)
+ cmp = rb_yield(rb_assoc_new(i, *min));
+ if (FIX2LONG(cmp) < 0)
*min = i;
}
return Qnil;
@@ -231,7 +206,7 @@ enum_min(obj)
{
VALUE min = Qnil;
- rb_iterate(rb_each, obj, iterator_p()?min_ii:min_i, (VALUE)&min);
+ rb_iterate(rb_each, obj, rb_iterator_p()?min_ii:min_i, (VALUE)&min);
return min;
}
@@ -245,7 +220,7 @@ max_i(i, max)
*max = i;
else {
cmp = rb_funcall(i, id_cmp, 1, *max);
- if (FIX2INT(cmp) > 0)
+ if (FIX2LONG(cmp) > 0)
*max = i;
}
return Qnil;
@@ -260,8 +235,8 @@ max_ii(i, max)
if (NIL_P(*max))
*max = i;
else {
- cmp = rb_yield(assoc_new(i, *max));
- if (FIX2INT(cmp) > 0)
+ cmp = rb_yield(rb_assoc_new(i, *max));
+ if (FIX2LONG(cmp) > 0)
*max = i;
}
return Qnil;
@@ -273,7 +248,7 @@ enum_max(obj)
{
VALUE max = Qnil;
- rb_iterate(rb_each, obj, iterator_p()?max_ii:max_i, (VALUE)&max);
+ rb_iterate(rb_each, obj, rb_iterator_p()?max_ii:max_i, (VALUE)&max);
return max;
}
@@ -333,8 +308,8 @@ enum_member(obj, val)
iv.i = 0;
iv.v = val;
rb_iterate(rb_each, obj, member_i, (VALUE)&iv);
- if (iv.i) return TRUE;
- return FALSE;
+ if (iv.i) return Qtrue;
+ return Qfalse;
}
static VALUE
@@ -346,7 +321,7 @@ length_i(i, length)
return Qnil;
}
-VALUE
+static VALUE
enum_length(obj)
VALUE obj;
{
@@ -356,26 +331,58 @@ enum_length(obj)
return INT2FIX(length);
}
+VALUE
+rb_enum_length(obj)
+ VALUE obj;
+{
+ return enum_length(obj);
+}
+
+static VALUE
+each_with_index_i(val, indexp)
+ VALUE val;
+ int *indexp;
+{
+#if 1
+ rb_yield(rb_assoc_new(val, INT2FIX(*indexp)));
+#else
+ rb_yield(rb_ary_concat(rb_Array(val), INT2FIX(*indexp)));
+#endif
+ (*indexp)++;
+ return Qnil;
+}
+
+static VALUE
+enum_each_with_index(obj)
+ VALUE obj;
+{
+ int index = 0;
+
+ rb_iterate(rb_each, obj, each_with_index_i, (VALUE)&index);
+ return Qnil;
+}
+
void
Init_Enumerable()
{
- mEnumerable = rb_define_module("Enumerable");
-
- rb_define_method(mEnumerable,"to_a", enum_to_a, 0);
-
- rb_define_method(mEnumerable,"sort", enum_sort, 0);
- rb_define_method(mEnumerable,"grep", enum_grep, 1);
- rb_define_method(mEnumerable,"find", enum_find, -1);
- rb_define_method(mEnumerable,"find_all", enum_find_all, 0);
- rb_define_method(mEnumerable,"collect", enum_collect, 0);
- rb_define_method(mEnumerable,"reverse", enum_reverse, 0);
- rb_define_method(mEnumerable,"min", enum_min, 0);
- rb_define_method(mEnumerable,"max", enum_max, 0);
- rb_define_method(mEnumerable,"index", enum_index, 1);
- rb_define_method(mEnumerable,"member?", enum_member, 1);
- rb_define_method(mEnumerable,"include?", enum_member, 1);
- rb_define_method(mEnumerable,"length", enum_length, 0);
- rb_define_method(mEnumerable,"size", enum_length, 0);
+ rb_mEnumerable = rb_define_module("Enumerable");
+
+ rb_define_method(rb_mEnumerable,"to_a", enum_to_a, 0);
+ rb_define_method(rb_mEnumerable,"entries", enum_to_a, 0);
+
+ rb_define_method(rb_mEnumerable,"sort", enum_sort, 0);
+ rb_define_method(rb_mEnumerable,"grep", enum_grep, 1);
+ rb_define_method(rb_mEnumerable,"find", enum_find, -1);
+ rb_define_method(rb_mEnumerable,"find_all", enum_find_all, 0);
+ rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
+ rb_define_method(rb_mEnumerable,"min", enum_min, 0);
+ rb_define_method(rb_mEnumerable,"max", enum_max, 0);
+ rb_define_method(rb_mEnumerable,"index", enum_index, 1);
+ rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
+ rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
+ rb_define_method(rb_mEnumerable,"length", enum_length, 0);
+ rb_define_method(rb_mEnumerable,"size", enum_length, 0);
+ rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
id_eqq = rb_intern("===");
id_each = rb_intern("each");
diff --git a/env.h b/env.h
index ebcfcc5..79fdfc2 100644
--- a/env.h
+++ b/env.h
@@ -12,6 +12,7 @@
#define ENV_H
extern struct FRAME {
+ VALUE self;
int argc;
VALUE *argv;
ID last_func;
@@ -21,16 +22,16 @@ extern struct FRAME {
char *file;
int line;
int iter;
-} *the_frame;
+} *ruby_frame;
-void gc_mark_frame _((struct FRAME *));
+void rb_gc_mark_frame _((struct FRAME *));
extern struct SCOPE {
struct RBasic super;
ID *local_tbl;
VALUE *local_vars;
int flag;
-} *the_scope;
+} *ruby_scope;
#define SCOPE_ALLOCA 0
#define SCOPE_MALLOC 1
@@ -38,7 +39,7 @@ extern struct SCOPE {
extern int rb_in_eval;
-extern VALUE the_class;
+extern VALUE ruby_class;
struct RVarmap {
struct RBasic super;
@@ -46,6 +47,6 @@ struct RVarmap {
VALUE val;
struct RVarmap *next;
};
-extern struct RVarmap *the_dyna_vars;
+extern struct RVarmap *ruby_dyna_vars;
#endif /* ENV_H */
diff --git a/error.c b/error.c
index 7163f62..44ca067 100644
--- a/error.c
+++ b/error.c
@@ -6,56 +6,46 @@
$Date$
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "env.h"
#include <stdio.h>
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
-extern char *sourcefile;
-extern int sourceline;
+#ifdef USE_CWGUSI
+#include <sys/errno.h>
+int sys_nerr = 256;
+#endif
-int nerrs;
+int ruby_nerrs;
static void
-err_sprintf(buf, fmt, args)
+err_snprintf(buf, len, fmt, args)
char *buf, *fmt;
+ int len;
va_list args;
{
- if (!sourcefile) {
- vsprintf(buf, fmt, args);
+ if (!ruby_sourcefile) {
+ vsnprintf(buf, len, fmt, args);
}
else {
- sprintf(buf, "%s:%d: ", sourcefile, sourceline);
- vsprintf((char*)buf+strlen(buf), fmt, args);
- }
-}
-
-static void
-err_append(s)
- char *s;
-{
- extern VALUE errinfo;
-
- if (rb_in_eval) {
- if (NIL_P(errinfo)) {
- errinfo = str_new2(s);
+ int n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
+ if (len > n) {
+ vsnprintf((char*)buf+n, len-n, fmt, args);
}
- else {
- str_cat(errinfo, "\n", 1);
- str_cat(errinfo, s, strlen(s));
- }
- }
- else {
- fputs(s, stderr);
- fputs("\n", stderr);
- fflush(stderr);
}
}
+static void err_append _((char*));
static void
err_print(fmt, args)
char *fmt;
@@ -63,66 +53,102 @@ err_print(fmt, args)
{
char buf[BUFSIZ];
- err_sprintf(buf, fmt, args);
+ err_snprintf(buf, BUFSIZ, fmt, args);
err_append(buf);
}
void
-Error(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_compile_error(char *fmt, ...)
+#else
+rb_compile_error(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
va_list args;
- va_start(args);
+ va_init_list(args, fmt);
err_print(fmt, args);
va_end(args);
- nerrs++;
+ ruby_nerrs++;
}
void
-Error_Append(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_compile_error_append(char *fmt, ...)
+#else
+rb_compile_error_append(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args);
- vsprintf(buf, fmt, args);
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
err_append(buf);
}
void
-Warning(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_warn(char *fmt, ...)
+#else
+rb_warn(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ char buf[BUFSIZ];
+ va_list args;
+
+ snprintf(buf, BUFSIZ, "warning: %s", fmt);
+
+ va_init_list(args, fmt);
+ err_print(buf, args);
+ va_end(args);
+}
+
+/* rb_warning() reports only in verbose mode */
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_warning(char *fmt, ...)
+#else
+rb_warning(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
char buf[BUFSIZ];
va_list args;
- if (!RTEST(verbose)) return;
+ if (!RTEST(rb_verbose)) return;
- sprintf(buf, "warning: %s", fmt);
+ snprintf(buf, BUFSIZ, "warning: %s", fmt);
- va_start(args);
+ va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
}
void
-Bug(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_bug(char *fmt, ...)
+#else
+rb_bug(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
char buf[BUFSIZ];
va_list args;
- sprintf(buf, "[BUG] %s", fmt);
+ snprintf(buf, BUFSIZ, "[BUG] %s", fmt);
rb_in_eval = 0;
- va_start(args);
+ va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
abort();
@@ -156,94 +182,133 @@ static struct types {
-1, 0,
};
-extern void TypeError();
-
void
rb_check_type(x, t)
VALUE x;
int t;
{
struct types *type = builtin_types;
+ int tt = TYPE(x);
- if (TYPE(x)!=(t)) {
+ if (tt != t) {
while (type->type >= 0) {
if (type->type == t) {
- TypeError("wrong argument type %s (expected %s)",
- rb_class2name(CLASS_OF(x)), type->name);
+ char *etype;
+
+ if (NIL_P(x)) {
+ etype = "nil";
+ }
+ else if (FIXNUM_P(x)) {
+ etype = "Fixnum";
+ }
+ else if (rb_special_const_p(x)) {
+ etype = RSTRING(rb_obj_as_string(x))->ptr;
+ }
+ else {
+ etype = rb_class2name(CLASS_OF(x));
+ }
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
+ etype, type->name);
}
type++;
}
- Bug("unknown type 0x%x", t);
+ rb_bug("unknown type 0x%x", t);
}
}
/* exception classes */
-#include "errno.h"
-
-extern VALUE cString;
-VALUE eGlobalExit, eException;
-VALUE eSystemExit, eInterrupt, eFatal;
-VALUE eRuntimeError;
-VALUE eSyntaxError;
-VALUE eTypeError;
-VALUE eArgError;
-VALUE eNameError;
-VALUE eIndexError;
-VALUE eNotImpError;
-VALUE eLoadError;
-VALUE eSecurityError;
-
-VALUE eSystemCallError;
-VALUE mErrno;
+#include <errno.h>
+
+VALUE rb_eException;
+VALUE rb_eSystemExit, rb_eInterrupt, rb_eFatal;
+VALUE rb_eStandardError;
+VALUE rb_eRuntimeError;
+VALUE rb_eSyntaxError;
+VALUE rb_eTypeError;
+VALUE rb_eArgError;
+VALUE rb_eNameError;
+VALUE rb_eIndexError;
+VALUE rb_eLoadError;
+VALUE rb_eSecurityError;
+VALUE rb_eNotImpError;
+
+VALUE rb_eSystemCallError;
+VALUE rb_mErrno;
VALUE
-exc_new(etype, ptr, len)
+rb_exc_new(etype, ptr, len)
VALUE etype;
char *ptr;
- UINT len;
+ int len;
{
- NEWOBJ(exc, struct RString);
- OBJSETUP(exc, etype, T_STRING);
-
- exc->len = len;
- exc->orig = 0;
- exc->ptr = ALLOC_N(char,len+1);
- if (ptr) {
- memcpy(exc->ptr, ptr, len);
- }
- exc->ptr[len] = '\0';
- return (VALUE)exc;
+ VALUE exc = rb_obj_alloc(etype);
+
+ rb_iv_set(exc, "mesg", rb_str_new(ptr, len));
+ return exc;
}
VALUE
-exc_new2(etype, s)
+rb_exc_new2(etype, s)
VALUE etype;
char *s;
{
- return exc_new(etype, s, strlen(s));
+ return rb_exc_new(etype, s, strlen(s));
}
VALUE
-exc_new3(etype, str)
+rb_exc_new3(etype, str)
VALUE etype, str;
{
- Check_Type(str, T_STRING);
- return exc_new(etype, RSTRING(str)->ptr, RSTRING(str)->len);
+ char *s;
+ int len;
+
+ s = str2cstr(str, &len);
+ return rb_exc_new(etype, s, len);
}
static VALUE
-exc_s_new(argc, argv, etype)
+exc_initialize(argc, argv, exc)
int argc;
VALUE *argv;
- VALUE etype;
+ VALUE exc;
{
- VALUE arg;
+ VALUE mesg;
- if (rb_scan_args(argc, argv, "01", &arg) == 0) {
- return exc_new(etype, 0, 0);
+ if (rb_scan_args(argc, argv, "01", &mesg) == 1) {
+ STR2CSTR(mesg); /* ensure mesg can be converted to String */
}
- Check_Type(arg, T_STRING);
- return exc_new3(etype, arg);
+ rb_iv_set(exc, "mesg", mesg);
+
+ return exc;
+}
+
+static VALUE
+exc_new(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE etype, exc;
+
+ if (argc == 1 && self == argv[0]) return self;
+ etype = CLASS_OF(self);
+ while (FL_TEST(etype, FL_SINGLETON)) {
+ etype = RCLASS(etype)->super;
+ }
+ exc = rb_obj_alloc(etype);
+ rb_obj_call_init(exc);
+
+ return exc;
+}
+
+static VALUE
+exc_to_s(exc)
+ VALUE exc;
+{
+ VALUE mesg = rb_iv_get(exc, "mesg");
+
+ if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc));
+ return mesg;
}
static VALUE
@@ -253,185 +318,314 @@ exc_inspect(exc)
VALUE str, klass;
klass = CLASS_OF(exc);
+ exc = rb_obj_as_string(exc);
if (RSTRING(exc)->len == 0) {
- return rb_class_path(klass);
+ return rb_str_dup(rb_class_path(klass));
}
- str = str_new2("#<");
+ str = rb_str_new2("#<");
klass = rb_class_path(klass);
- str_cat(str, RSTRING(klass)->ptr, RSTRING(klass)->len);
- str_cat(str, ":", 1);
- str_cat(str, RSTRING(exc)->ptr, RSTRING(exc)->len);
- str_cat(str, ">", 1);
+ rb_str_concat(str, klass);
+ rb_str_cat(str, ":", 1);
+ rb_str_concat(str, exc);
+ rb_str_cat(str, ">", 1);
return str;
}
static VALUE
+exc_backtrace(exc)
+ VALUE exc;
+{
+ return rb_iv_get(exc, "bt");
+}
+
+static VALUE
+check_backtrace(bt)
+ VALUE bt;
+{
+ int i;
+ static char *err = "backtrace must be Array of String";
+
+ if (!NIL_P(bt)) {
+ int t = TYPE(bt);
+
+ if (t == T_STRING) return rb_ary_new3(1, bt);
+ if (t != T_ARRAY) {
+ rb_raise(rb_eTypeError, err);
+ }
+ for (i=0;i<RARRAY(bt)->len;i++) {
+ if (TYPE(RARRAY(bt)->ptr[i]) != T_STRING) {
+ rb_raise(rb_eTypeError, err);
+ }
+ }
+ }
+ return bt;
+}
+
+static VALUE
+exc_set_backtrace(exc, bt)
+ VALUE exc;
+{
+ return rb_iv_set(exc, "bt", check_backtrace(bt));
+}
+
+static VALUE
exception(argc, argv)
int argc;
VALUE *argv;
{
- void ArgError();
VALUE v = Qnil;
+ VALUE etype = rb_eStandardError;
int i;
ID id;
if (argc == 0) {
- ArgError("wrong # of arguments");
+ rb_raise(rb_eArgError, "wrong # of arguments");
+ }
+ rb_warn("Exception() is now obsolete");
+ if (TYPE(argv[argc-1]) == T_CLASS) {
+ etype = argv[argc-1];
+ argc--;
+ if (!rb_funcall(etype, '<', 1, rb_eException)) {
+ rb_raise(rb_eTypeError, "exception should be subclass of Exception");
+ }
}
for (i=0; i<argc; i++) { /* argument check */
id = rb_to_id(argv[i]);
if (!rb_id2name(id)) {
- ArgError("argument needs to be symbol or string");
+ rb_raise(rb_eArgError, "argument needs to be symbol or string");
}
if (!rb_is_const_id(id)) {
- ArgError("identifier %s needs to be constant", rb_id2name(id));
+ rb_raise(rb_eArgError, "identifier `%s' needs to be constant",
+ rb_id2name(id));
}
}
for (i=0; i<argc; i++) {
- v = rb_define_class_under(the_class, rb_id2name(rb_to_id(argv[i])), eException);
+ v = rb_define_class_under(ruby_class,
+ rb_id2name(rb_to_id(argv[i])),
+ rb_eStandardError);
}
return v;
}
+#ifdef __BEOS__
+typedef struct {
+ VALUE *list;
+ size_t n;
+} syserr_list_entry;
+
+typedef struct {
+ int ix;
+ size_t n;
+} syserr_index_entry;
+
+static VALUE syserr_list_b_general[16+1];
+static VALUE syserr_list_b_os0[2+1];
+static VALUE syserr_list_b_os1[5+1];
+static VALUE syserr_list_b_os2[2+1];
+static VALUE syserr_list_b_os3[3+1];
+static VALUE syserr_list_b_os4[1+1];
+static VALUE syserr_list_b_app[15+1];
+static VALUE syserr_list_b_interface[0+1];
+static VALUE syserr_list_b_media[8+1];
+static VALUE syserr_list_b_midi[0+1];
+static VALUE syserr_list_b_storage[15+1];
+static VALUE syserr_list_b_posix[38+1];
+static VALUE syserr_list_b_mail[8+1];
+static VALUE syserr_list_b_print[1+1];
+static VALUE syserr_list_b_device[14+1];
+
+# define SYSERR_LIST_B(n) {(n), sizeof(n)/sizeof(VALUE)}
+static const syserr_list_entry syserr_list[] = {
+ SYSERR_LIST_B(syserr_list_b_general),
+ SYSERR_LIST_B(syserr_list_b_os0),
+ SYSERR_LIST_B(syserr_list_b_os1),
+ SYSERR_LIST_B(syserr_list_b_os2),
+ SYSERR_LIST_B(syserr_list_b_os3),
+ SYSERR_LIST_B(syserr_list_b_os4),
+ SYSERR_LIST_B(syserr_list_b_app),
+ SYSERR_LIST_B(syserr_list_b_interface),
+ SYSERR_LIST_B(syserr_list_b_media),
+ SYSERR_LIST_B(syserr_list_b_midi),
+ SYSERR_LIST_B(syserr_list_b_storage),
+ SYSERR_LIST_B(syserr_list_b_posix),
+ SYSERR_LIST_B(syserr_list_b_mail),
+ SYSERR_LIST_B(syserr_list_b_print),
+ SYSERR_LIST_B(syserr_list_b_device),
+};
+# undef SYSERR_LIST_B
+
+static const syserr_index_entry syserr_index[]= {
+ {0, 1}, {1, 5}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}, {11, 1},
+ {12, 1}, {13, 1}, {14, 1}, {0, 0},
+};
+#else
static VALUE *syserr_list;
+#endif
#ifndef NT
extern int sys_nerr;
#endif
-static void
+static VALUE
set_syserr(i, name)
int i;
char *name;
{
+#ifdef __BEOS__
+ VALUE *list;
+ int ix, offset;
+#endif
+ VALUE error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
+ rb_define_const(error, "Errno", INT2FIX(i));
+#ifdef __BEOS__
+ i -= B_GENERAL_ERROR_BASE;
+ ix = (i >> 12) & 0xf;
+ offset = (i >> 8) & 0xf;
+ if (offset < syserr_index[ix].n) {
+ ix = syserr_index[ix].ix;
+ if ((i & 0xff) < syserr_list[ix + offset].n) {
+ list = syserr_list[ix + offset].list;
+ list[i & 0xff] = error;
+ rb_global_variable(&list[i & 0xff]);
+ }
+ }
+#else
if (i <= sys_nerr) {
- syserr_list[i] = rb_define_class_under(mErrno, name, eSystemCallError);
- rb_global_variable(&syserr_list[i]);
+ syserr_list[i] = error;
}
+#endif
+ return error;
}
-static void init_syserr();
+static VALUE
+syserr_errno(self)
+ VALUE self;
+{
+ return rb_iv_get(self, "errno");
+}
+
+#ifdef __BEOS__
+static VALUE
+get_syserr(int i)
+{
+ VALUE *list;
+ int ix, offset;
+
+ i -= B_GENERAL_ERROR_BASE;
+ ix = (i >> 12) & 0xf;
+ offset = (i >> 8) & 0xf;
+ if (offset < syserr_index[ix].n) {
+ ix = syserr_index[ix].ix;
+ if ((i & 0xff) < syserr_list[ix + offset].n) {
+ list = syserr_list[ix + offset].list;
+ return list[i & 0xff];
+ }
+ }
+ return 0;
+}
+#endif /* __BEOS__ */
+
+static void init_syserr _((void));
void
Init_Exception()
{
- eGlobalExit = rb_define_class("GlobalExit", cString);
- rb_define_singleton_method(eGlobalExit, "new", exc_s_new, -1);
- rb_define_method(eGlobalExit, "inspect", exc_inspect, 0);
-
- eSystemExit = rb_define_class("SystemExit", eGlobalExit);
- eFatal = rb_define_class("fatal", eGlobalExit);
- eInterrupt = rb_define_class("Interrupt", eGlobalExit);
-
- eException = rb_define_class("Exception", eGlobalExit);
- eSyntaxError = rb_define_class("SyntaxError", eException);
- eTypeError = rb_define_class("TypeError", eException);
- eArgError = rb_define_class("ArgumentError", eException);
- eNameError = rb_define_class("NameError", eException);
- eIndexError = rb_define_class("IndexError", eException);
- eNotImpError = rb_define_class("NotImplementError", eException);
- eLoadError = rb_define_class("LoadError", eException);
-
- eRuntimeError = rb_define_class("RuntimeError", eException);
- eSecurityError = rb_define_class("SecurityError", eException);
+ rb_eException = rb_define_class("Exception", rb_cObject);
+ rb_define_method(rb_eException, "new", exc_new, -1);
+ rb_define_method(rb_eException, "initialize", exc_initialize, -1);
+ rb_define_method(rb_eException, "to_s", exc_to_s, 0);
+ rb_define_method(rb_eException, "to_str", exc_to_s, 0);
+ rb_define_method(rb_eException, "message", exc_to_s, 0);
+ rb_define_method(rb_eException, "inspect", exc_inspect, 0);
+ rb_define_method(rb_eException, "backtrace", exc_backtrace, 0);
+ rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
+
+ rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
+ rb_eFatal = rb_define_class("fatal", rb_eException);
+ rb_eInterrupt = rb_define_class("Interrupt", rb_eException);
+
+ rb_eStandardError = rb_define_class("StandardError", rb_eException);
+ rb_eSyntaxError = rb_define_class("SyntaxError", rb_eStandardError);
+ rb_eTypeError = rb_define_class("TypeError", rb_eStandardError);
+ rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
+ rb_eNameError = rb_define_class("NameError", rb_eStandardError);
+ rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
+ rb_eLoadError = rb_define_class("LoadError", rb_eStandardError);
+
+ rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
+ rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
+ rb_eNotImpError = rb_define_class("NotImplementError", rb_eException);
init_syserr();
rb_define_global_function("Exception", exception, -1);
}
-#define RAISE_ERROR(class) {\
- va_list args;\
- char buf[BUFSIZ];\
-\
- va_start(args);\
- vsprintf(buf, fmt, args);\
- va_end(args);\
-\
- rb_raise(exc_new2(class, buf));\
-}
-
void
-Raise(exc, fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_raise(VALUE exc, char *fmt, ...)
+#else
+rb_raise(exc, fmt, va_alist)
VALUE exc;
char *fmt;
va_dcl
+#endif
{
- RAISE_ERROR(exc);
-}
-
-void
-TypeError(fmt, va_alist)
- char *fmt;
- va_dcl
-{
- RAISE_ERROR(eTypeError);
-}
-
-void
-ArgError(fmt, va_alist)
- char *fmt;
- va_dcl
-{
- RAISE_ERROR(eArgError);
-}
+ va_list args;
+ char buf[BUFSIZ];
-void
-NameError(fmt, va_alist)
- char *fmt;
- va_dcl
-{
- RAISE_ERROR(eNameError);
+ va_init_list(args,fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ rb_exc_raise(rb_exc_new2(exc, buf));
}
void
-IndexError(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_loaderror(char *fmt, ...)
+#else
+rb_loaderror(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
- RAISE_ERROR(eIndexError);
-}
+ va_list args;
+ char buf[BUFSIZ];
-void
-Fail(fmt, va_alist)
- char *fmt;
- va_dcl
-{
- RAISE_ERROR(eRuntimeError);
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ rb_exc_raise(rb_exc_new2(rb_eLoadError, buf));
}
void
rb_notimplement()
{
- Raise(eNotImpError,
- "The %s() function is unimplemented on this machine",
- rb_id2name(the_frame->last_func));
+ rb_raise(rb_eNotImpError,
+ "The %s() function is unimplemented on this machine",
+ rb_id2name(ruby_frame->last_func));
}
void
-LoadError(fmt, va_alist)
- char *fmt;
- va_dcl
-{
- RAISE_ERROR(eLoadError);
-}
-
-void
-Fatal(fmt, va_alist)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_fatal(char *fmt, ...)
+#else
+rb_fatal(fmt, va_alist)
char *fmt;
va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args);
- vsprintf(buf, fmt, args);
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_in_eval = 0;
- rb_fatal(exc_new2(eFatal, buf));
+ rb_exc_fatal(rb_exc_new2(rb_eFatal, buf));
}
void
@@ -441,32 +635,79 @@ rb_sys_fail(mesg)
#ifndef NT
char *strerror();
#endif
- char buf[BUFSIZ];
+ char *err;
+ char *buf;
extern int errno;
int n = errno;
+ VALUE ee;
- if (RTEST(mesg))
- sprintf(buf, "%s - %s", strerror(errno), mesg);
- else
- sprintf(buf, "%s", strerror(errno));
+ err = strerror(errno);
+ if (mesg) {
+ buf = ALLOCA_N(char, strlen(err)+strlen(mesg)+4);
+ sprintf(buf, "%s - %s", err, mesg);
+ }
+ else {
+ buf = ALLOCA_N(char, strlen(err)+1);
+ strcpy(buf, err);
+ }
errno = 0;
+#ifdef __BEOS__
+ ee = get_syserr(n);
+ if (!ee) {
+ char name[6];
+
+ sprintf(name, "E%03d", n);
+ ee = set_syserr(n, name);
+ }
+#else
+# ifdef USE_CWGUSI
+ if (n < 0) {
+ int macoserr_index = sys_nerr - 1;
+ if (!syserr_list[macoserr_index]) {
+ char name[6];
+ sprintf(name, "E%03d", macoserr_index);
+ ee = set_syserr(macoserr_index, name);
+ }
+ }
+ else
+#endif /* USE_CWGUSI */
if (n > sys_nerr || !syserr_list[n]) {
char name[6];
sprintf(name, "E%03d", n);
- set_syserr(n, name);
+ ee = set_syserr(n, name);
+ }
+ else {
+ ee = syserr_list[n];
}
- rb_raise(exc_new2(syserr_list[n], buf));
+ ee = rb_exc_new2(ee, buf);
+#endif
+ rb_iv_set(ee, "errno", INT2FIX(n));
+ rb_exc_raise(ee);
}
static void
init_syserr()
{
- eSystemCallError = rb_define_class("SystemCallError", eException);
- mErrno = rb_define_module("Errno");
+#ifdef __BEOS__
+ int i, ix, offset;
+#endif
+ rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
+ rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);
+
+ rb_mErrno = rb_define_module("Errno");
+#ifdef __BEOS__
+ for (i = 0; syserr_index[i].n != 0; i++) {
+ ix = syserr_index[i].ix;
+ for (offset = 0; offset < syserr_index[i].n; offset++) {
+ MEMZERO(syserr_list[ix + offset].list, VALUE, syserr_list[ix + offset].n);
+ }
+ }
+#else
syserr_list = ALLOC_N(VALUE, sys_nerr+1);
MEMZERO(syserr_list, VALUE, sys_nerr+1);
+#endif
#ifdef EPERM
set_syserr(EPERM, "EPERM");
@@ -835,3 +1076,28 @@ init_syserr()
set_syserr(EDQUOT, "EDQUOT");
#endif
}
+
+static void
+err_append(s)
+ char *s;
+{
+ extern VALUE rb_errinfo;
+
+ if (rb_in_eval) {
+ if (NIL_P(rb_errinfo)) {
+ rb_errinfo = rb_exc_new2(rb_eSyntaxError, s);
+ }
+ else {
+ VALUE str = rb_str_to_str(rb_errinfo);
+
+ rb_str_cat(str, "\n", 1);
+ rb_str_cat(str, s, strlen(s));
+ rb_errinfo = rb_exc_new3(rb_eSyntaxError, str);
+ }
+ }
+ else {
+ fputs(s, stderr);
+ fputs("\n", stderr);
+ fflush(stderr);
+ }
+}
diff --git a/eval.c b/eval.c
index 42617c2..a7da313 100644
--- a/eval.c
+++ b/eval.c
@@ -6,14 +6,14 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1993-1997 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "node.h"
#include "env.h"
-#include "sig.h"
+#include "rubysig.h"
#include <stdio.h>
#include <setjmp.h>
@@ -21,13 +21,23 @@
#include "dln.h"
#ifndef HAVE_STRING_H
-char *strrchr();
+char *strrchr _((char*,char));
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef __BEOS__
+#include <net/socket.h>
+#endif
+
+#ifdef USE_CWGUSI
+#include <sys/stat.h>
+#include <sys/errno.h>
+#include <compat.h>
+#endif
+
#ifndef setjmp
#ifdef HAVE__SETJMP
#define setjmp(env) _setjmp(env)
@@ -35,23 +45,33 @@ char *strrchr();
#endif
#endif
-extern VALUE cData;
-
-VALUE cProc;
+VALUE rb_cProc;
+static VALUE rb_cBinding;
static VALUE proc_call _((VALUE,VALUE));
-static VALUE f_binding _((VALUE));
-static void f_END _((void));
-
-#define SCOPE_PRIVATE FL_USER4
-
-#define CACHE_SIZE 0x200
-#define CACHE_MASK 0x1ff
-#define EXPR1(c,m) ((((int)(c)>>3)^(m))&CACHE_MASK)
+static VALUE rb_f_binding _((VALUE));
+static void rb_f_END _((void));
+static VALUE rb_f_iterator_p _((void));
+static VALUE block_pass _((VALUE,NODE*));
+static VALUE rb_cMethod;
+static VALUE method_proc _((VALUE));
+
+static int scope_vmode;
+#define SCOPE_PUBLIC 0
+#define SCOPE_PRIVATE 1
+#define SCOPE_PROTECTED 2
+#define SCOPE_MODFUNC 5
+#define SCOPE_MASK 7
+#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
+#define SCOPE_TEST(f) (scope_vmode&(f))
+
+#define CACHE_SIZE 0x800
+#define CACHE_MASK 0x7ff
+#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
struct cache_entry { /* method hash table. */
ID mid; /* method's id */
ID mid0; /* method's original id */
- VALUE class; /* receiver's class */
+ VALUE klass; /* receiver's class */
VALUE origin; /* where method defined */
NODE *method;
int noex;
@@ -87,80 +107,69 @@ rb_clear_cache_by_id(id)
}
void
-rb_add_method(class, mid, node, noex)
- VALUE class;
+rb_add_method(klass, mid, node, noex)
+ VALUE klass;
ID mid;
NODE *node;
int noex;
{
NODE *body;
- if (NIL_P(class)) class = cObject;
- body = NEW_METHOD(node, noex);
- st_insert(RCLASS(class)->m_tbl, mid, body);
-}
-
-void
-rb_remove_method(class, mid)
- VALUE class;
- ID mid;
-{
- NODE *body;
-
- if (!st_delete(RCLASS(class)->m_tbl, &mid, &body)) {
- NameError("method `%s' not defined in %s",
- rb_id2name(mid), rb_class2name(class));
+ if (NIL_P(klass)) klass = rb_cObject;
+ if (klass == rb_cObject) {
+ rb_secure(4);
}
- rb_clear_cache_by_id(mid);
+ body = NEW_METHOD(node, noex);
+ st_insert(RCLASS(klass)->m_tbl, mid, body);
}
static NODE*
-search_method(class, id, origin)
- VALUE class, *origin;
+search_method(klass, id, origin)
+ VALUE klass, *origin;
ID id;
{
NODE *body;
- while (!st_lookup(RCLASS(class)->m_tbl, id, &body)) {
- class = (VALUE)RCLASS(class)->super;
- if (!class) return 0;
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
+ klass = RCLASS(klass)->super;
+ if (!klass) return 0;
}
- if (origin) *origin = class;
+ if (origin) *origin = klass;
return body;
}
static NODE*
-rb_get_method_body(classp, idp, noexp)
- VALUE *classp;
+rb_get_method_body(klassp, idp, noexp)
+ VALUE *klassp;
ID *idp;
int *noexp;
{
ID id = *idp;
- VALUE class = *classp;
+ VALUE klass = *klassp;
VALUE origin;
- NODE *body;
+ NODE * volatile body;
struct cache_entry *ent;
- if ((body = search_method(class, id, &origin)) == 0) {
+ if ((body = search_method(klass, id, &origin)) == 0) {
return 0;
}
if (!body->nd_body) return 0;
/* store in cache */
- ent = cache + EXPR1(class, id);
- ent->class = class;
+ ent = cache + EXPR1(klass, id);
+ ent->klass = klass;
ent->noex = body->nd_noex;
body = body->nd_body;
if (nd_type(body) == NODE_FBODY) {
ent->mid = id;
- *classp = body->nd_orig;
+ *klassp = body->nd_orig;
ent->origin = body->nd_orig;
*idp = ent->mid0 = body->nd_mid;
body = ent->method = body->nd_head;
}
else {
- *classp = (VALUE)origin;
+ *klassp = origin;
ent->origin = origin;
ent->mid = ent->mid0 = id;
ent->method = body;
@@ -171,23 +180,26 @@ rb_get_method_body(classp, idp, noexp)
}
void
-rb_alias(class, name, def)
- VALUE class;
+rb_alias(klass, name, def)
+ VALUE klass;
ID name, def;
{
VALUE origin;
NODE *orig, *body;
if (name == def) return;
- orig = search_method(class, def, &origin);
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ orig = search_method(klass, def, &origin);
if (!orig || !orig->nd_body) {
- if (TYPE(class) == T_MODULE) {
- orig = search_method(cObject, def, &origin);
+ if (TYPE(klass) == T_MODULE) {
+ orig = search_method(rb_cObject, def, &origin);
}
}
if (!orig || !orig->nd_body) {
- NameError("undefined method `%s' for `%s'",
- rb_id2name(def), rb_class2name((VALUE)class));
+ rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
+ rb_id2name(def), rb_class2name(klass));
}
body = orig->nd_body;
if (nd_type(body) == NODE_FBODY) { /* was alias */
@@ -196,101 +208,194 @@ rb_alias(class, name, def)
origin = body->nd_orig;
}
- st_insert(RCLASS(class)->m_tbl, name,
+ st_insert(RCLASS(klass)->m_tbl, name,
NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
}
static void
-rb_export_method(class, name, noex)
- VALUE class;
+remove_method(klass, mid)
+ VALUE klass;
+ ID mid;
+{
+ NODE *body;
+
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) {
+ rb_raise(rb_eNameError, "method `%s' not defined in %s",
+ rb_id2name(mid), rb_class2name(klass));
+ }
+ rb_clear_cache_by_id(mid);
+}
+
+void
+rb_remove_method(klass, name)
+ VALUE klass;
+ char *name;
+{
+ remove_method(klass, rb_intern(name));
+}
+
+void
+rb_disable_super(klass, name)
+ VALUE klass;
+ char *name;
+{
+ VALUE origin;
+ NODE *body;
+ ID mid = rb_intern(name);
+
+ body = search_method(klass, mid, &origin);
+ if (!body || !body->nd_body) {
+ rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
+ rb_id2name(mid), rb_class2name(klass));
+ }
+ if (origin == klass) {
+ body->nd_noex |= NOEX_UNDEF;
+ }
+ else {
+ rb_clear_cache_by_id(mid);
+ rb_add_method(ruby_class, mid, 0, NOEX_UNDEF);
+ }
+}
+
+void
+rb_enable_super(klass, name)
+ VALUE klass;
+ char *name;
+{
+ VALUE origin;
+ NODE *body;
+ ID mid = rb_intern(name);
+
+ body = search_method(klass, mid, &origin);
+ if (!body || !body->nd_body || origin != klass) {
+ rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
+ rb_id2name(mid), rb_class2name(klass));
+ }
+ body->nd_noex &= ~NOEX_UNDEF;
+}
+
+static void
+rb_export_method(klass, name, noex)
+ VALUE klass;
ID name;
- int noex;
+ ID noex;
{
NODE *body;
- struct RClass *origin;
+ VALUE origin;
- body = search_method(class, name, &origin);
- if (!body && TYPE(class) == T_MODULE) {
- body = search_method(cObject, name, &origin);
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ body = search_method(klass, name, &origin);
+ if (!body && TYPE(klass) == T_MODULE) {
+ body = search_method(rb_cObject, name, &origin);
}
if (!body) {
- NameError("undefined method `%s' for `%s'",
- rb_id2name(name), rb_class2name(class));
+ rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
+ rb_id2name(name), rb_class2name(klass));
}
if (body->nd_noex != noex) {
- if (class == (VALUE)origin) {
+ if (klass == origin) {
body->nd_noex = noex;
}
else {
rb_clear_cache_by_id(name);
- rb_add_method(class, name, NEW_ZSUPER(), noex);
+ rb_add_method(klass, name, NEW_ZSUPER(), noex);
}
}
}
-static VALUE
-method_boundp(class, id, ex)
- VALUE class;
+int
+rb_method_boundp(klass, id, ex)
+ VALUE klass;
ID id;
int ex;
{
int noex;
- if (rb_get_method_body(&class, &id, &noex)) {
- if (ex && noex == NOEX_PRIVATE)
- return FALSE;
- return TRUE;
+ if (rb_get_method_body(&klass, &id, &noex)) {
+ if (ex && noex & NOEX_PRIVATE)
+ return Qfalse;
+ return Qtrue;
}
- return FALSE;
+ return Qfalse;
}
-int
-rb_method_boundp(class, id, ex)
- VALUE class;
+void
+rb_attr(klass, id, read, write, ex)
+ VALUE klass;
ID id;
- int ex;
+ int read, write, ex;
{
- if (method_boundp(class, id, ex))
- return TRUE;
- return FALSE;
+ char *name;
+ char *buf;
+ ID attriv;
+ int noex;
+
+ if (!ex) noex = NOEX_PUBLIC;
+ else {
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
+ noex = NOEX_PRIVATE;
+ rb_warning("private attribute?");
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
+ else {
+ noex = NOEX_PUBLIC;
+ }
+ }
+
+ name = rb_id2name(id);
+ if (!name) {
+ rb_raise(rb_eArgError, "argument needs to be symbol or string");
+ }
+ buf = ALLOCA_N(char,strlen(name)+2);
+ sprintf(buf, "@%s", name);
+ attriv = rb_intern(buf);
+ if (read) {
+ rb_add_method(klass, id, NEW_IVAR(attriv), noex);
+ }
+ sprintf(buf, "%s=", name);
+ id = rb_intern(buf);
+ if (write) {
+ rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
+ }
}
static ID init, eqq, each, aref, aset, match;
-VALUE errinfo = Qnil, errat = Qnil;
-extern NODE *eval_tree0;
-extern NODE *eval_tree;
-extern int nerrs;
-
-extern VALUE mKernel;
-extern VALUE cModule;
-extern VALUE cClass;
-extern VALUE eFatal;
-extern VALUE eGlobalExit;
-extern VALUE eInterrupt;
-extern VALUE eSystemExit;
-extern VALUE eException;
-extern VALUE eRuntimeError;
-extern VALUE eSyntaxError;
-static VALUE eLocalJumpError;
-extern VALUE eSecurityError;
-
-extern VALUE TopSelf;
-
-struct FRAME *the_frame;
-struct SCOPE *the_scope;
+VALUE rb_errinfo = Qnil;
+extern NODE *ruby_eval_tree_begin;
+extern NODE *ruby_eval_tree;
+extern int ruby_nerrs;
+
+static VALUE rb_eLocalJumpError;
+static VALUE rb_eSysStackError;
+
+extern VALUE ruby_top_self;
+
+struct FRAME *ruby_frame;
+struct SCOPE *ruby_scope;
static struct FRAME *top_frame;
static struct SCOPE *top_scope;
#define PUSH_FRAME() { \
- struct FRAME *_frame = ALLOCA_N(struct FRAME,1);\
- _frame->prev = the_frame; \
- _frame->file = sourcefile; \
- _frame->line = sourceline; \
- _frame->iter = the_iter->iter; \
- _frame->cbase = the_frame->cbase; \
- the_frame = _frame; \
-
-#define POP_FRAME() the_frame = _frame->prev; }
+ struct FRAME _frame; \
+ _frame.prev = ruby_frame; \
+ _frame.file = ruby_sourcefile; \
+ _frame.line = ruby_sourceline; \
+ _frame.iter = ruby_iter->iter; \
+ _frame.cbase = ruby_frame->cbase; \
+ _frame.argc = 0; \
+ ruby_frame = &_frame; \
+
+#define POP_FRAME() \
+ ruby_sourcefile = _frame.file; \
+ ruby_sourceline = _frame.line; \
+ ruby_frame = _frame.prev; }
struct BLOCK {
NODE *var;
@@ -298,70 +403,95 @@ struct BLOCK {
VALUE self;
struct FRAME frame;
struct SCOPE *scope;
- VALUE class;
+ VALUE klass;
struct tag *tag;
int iter;
+ int vmode;
struct RVarmap *d_vars;
-#ifdef THREAD
+#ifdef USE_THREAD
VALUE orig_thread;
#endif
struct BLOCK *prev;
-} *the_block;
+};
+static struct BLOCK *ruby_block;
+static struct BLOCK *ruby_calling_block;
#define PUSH_BLOCK(v,b) { \
- struct BLOCK *_block = ALLOCA_N(struct BLOCK,1);\
- _block->tag = prot_tag; \
- _block->var = v; \
- _block->body = b; \
- _block->self = self; \
- _block->frame = *the_frame; \
- _block->class = the_class; \
- _block->frame.file = sourcefile; \
- _block->frame.line = sourceline; \
- _block->scope = the_scope; \
- _block->d_vars = the_dyna_vars; \
- _block->prev = the_block; \
- _block->iter = the_iter->iter; \
- the_block = _block;
+ struct BLOCK _block; \
+ _block.tag = prot_tag; \
+ _block.var = v; \
+ _block.body = b; \
+ _block.self = self; \
+ _block.frame = *ruby_frame; \
+ _block.klass = ruby_class; \
+ _block.frame.file = ruby_sourcefile;\
+ _block.frame.line = ruby_sourceline;\
+ _block.scope = ruby_scope; \
+ _block.d_vars = ruby_dyna_vars; \
+ _block.prev = ruby_block; \
+ _block.iter = ruby_iter->iter; \
+ _block.vmode = scope_vmode; \
+ ruby_block = &_block;
+
+#define POP_BLOCK() \
+ ruby_block = _block.prev; \
+}
#define PUSH_BLOCK2(b) { \
- struct BLOCK *_block = ALLOCA_N(struct BLOCK,1);\
- *_block = *b; \
- _block->prev = the_block; \
- the_block = _block;
+ struct BLOCK * volatile _old; \
+ struct BLOCK * volatile _old_call; \
+ _old = ruby_block; \
+ _old_call = ruby_calling_block; \
+ ruby_calling_block = b; \
+ ruby_block = b;
-#define POP_BLOCK() \
- the_block = the_block->prev; \
+#define POP_BLOCK2() \
+ ruby_calling_block = _old_call; \
+ ruby_block = _old; \
}
-struct RVarmap *the_dyna_vars;
+struct RVarmap *ruby_dyna_vars;
#define PUSH_VARS() { \
- struct RVarmap *_old; \
- _old = the_dyna_vars; \
- the_dyna_vars = 0;
+ struct RVarmap * volatile _oldvmap; \
+ _oldvmap = ruby_dyna_vars; \
+ ruby_dyna_vars = 0;
#define POP_VARS() \
- the_dyna_vars = _old; \
+ ruby_dyna_vars = _oldvmap; \
+}
+
+static struct RVarmap*
+new_dvar(id, value)
+ ID id;
+ VALUE value;
+{
+ NEWOBJ(vars, struct RVarmap);
+ OBJSETUP(vars, 0, T_VARMAP);
+ vars->id = id;
+ vars->val = value;
+ vars->next = ruby_dyna_vars;
+
+ return vars;
}
VALUE
-dyna_var_defined(id)
+rb_dvar_defined(id)
ID id;
{
- struct RVarmap *vars = the_dyna_vars;
+ struct RVarmap *vars = ruby_dyna_vars;
while (vars) {
- if (vars->id == id) return TRUE;
+ if (vars->id == id) return Qtrue;
vars = vars->next;
}
- return FALSE;
+ return Qfalse;
}
VALUE
-dyna_var_ref(id)
+rb_dvar_ref(id)
ID id;
{
- struct RVarmap *vars = the_dyna_vars;
+ struct RVarmap *vars = ruby_dyna_vars;
while (vars) {
if (vars->id == id) {
@@ -372,35 +502,48 @@ dyna_var_ref(id)
return Qnil;
}
-VALUE
-dyna_var_asgn(id, value)
+void
+rb_dvar_push(id, value)
ID id;
VALUE value;
{
- struct RVarmap *vars = the_dyna_vars;
+ ruby_dyna_vars = new_dvar(id, value);
+}
+
+void
+rb_dvar_asgn(id, value)
+ ID id;
+ VALUE value;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
while (vars) {
if (vars->id == id) {
vars->val = value;
- return value;
+ return;
}
vars = vars->next;
}
- {
- NEWOBJ(_vars, struct RVarmap);
- OBJSETUP(_vars, 0, T_VARMAP);
- _vars->id = id;
- _vars->val = value;
- _vars->next = the_dyna_vars;
- the_dyna_vars = _vars;
+ rb_dvar_push(id, value);
+ return;
+}
+
+static void
+dvar_asgn_push(id, value)
+ ID id;
+ VALUE value;
+{
+ rb_dvar_asgn(id, value);
+ if (ruby_calling_block) {
+ ruby_calling_block->d_vars = ruby_dyna_vars;
}
- return value;
}
-static struct iter {
+struct iter {
int iter;
struct iter *prev;
-} *the_iter;
+};
+static struct iter *ruby_iter;
#define ITER_NOT 0
#define ITER_PRE 1
@@ -408,46 +551,35 @@ static struct iter {
#define PUSH_ITER(i) { \
struct iter _iter; \
- _iter.prev = the_iter; \
+ _iter.prev = ruby_iter; \
_iter.iter = (i); \
- the_iter = &_iter; \
+ ruby_iter = &_iter; \
#define POP_ITER() \
- the_iter = _iter.prev; \
+ ruby_iter = _iter.prev; \
}
-#ifdef C_ALLOCA
-/* need to protect retval in struct tag from GC. */
-#define tag_retval_dcl VALUE *dd_retval
-#define tag_retval_init VALUE _tag_retval = Qnil;\
- _tag->dd_retval = &_tag_retval;
-#define tag_retval dd_retval[0]
-#else
-#define tag_retval_dcl VALUE retval
-#define tag_retval_init _tag->retval = Qnil
-#define tag_retval retval
-#endif
-
-static struct tag {
+struct tag {
jmp_buf buf;
struct FRAME *frame;
struct iter *iter;
ID tag;
- tag_retval_dcl;
- ID dst;
+ VALUE retval;
+ int dst;
struct tag *prev;
-} *prot_tag;
+};
+static struct tag *prot_tag;
#define PUSH_TAG(ptag) { \
- struct tag *_tag = ALLOCA_N(struct tag,1);\
- tag_retval_init; \
- _tag->frame = the_frame; \
- _tag->iter = the_iter; \
- _tag->prev = prot_tag; \
- _tag->tag_retval = Qnil; \
- _tag->tag = ptag; \
- _tag->dst = 0; \
- prot_tag = _tag;
+ struct tag _tag; \
+ _tag.retval = Qnil; \
+ _tag.frame = ruby_frame; \
+ _tag.iter = ruby_iter; \
+ _tag.prev = prot_tag; \
+ _tag.retval = Qnil; \
+ _tag.tag = ptag; \
+ _tag.dst = 0; \
+ prot_tag = &_tag;
#define PROT_NONE 0
#define PROT_FUNC -1
@@ -456,13 +588,15 @@ static struct tag {
#define EXEC_TAG() setjmp(prot_tag->buf)
#define JUMP_TAG(st) { \
- the_frame = prot_tag->frame; \
- the_iter = prot_tag->iter; \
+ ruby_frame = prot_tag->frame; \
+ ruby_iter = prot_tag->iter; \
longjmp(prot_tag->buf,(st)); \
}
#define POP_TAG() \
- prot_tag = _tag->prev; \
+ if (_tag.prev) \
+ _tag.prev->retval = _tag.retval;\
+ prot_tag = _tag.prev; \
}
#define TAG_RETURN 0x1
@@ -475,57 +609,68 @@ static struct tag {
#define TAG_FATAL 0x8
#define TAG_MASK 0xf
-VALUE the_class;
+VALUE ruby_class;
+static VALUE ruby_wrapper; /* security wrapper */
#define PUSH_CLASS() { \
- VALUE _class = the_class; \
+ VALUE _class = ruby_class; \
-#define POP_CLASS() the_class = _class; }
+#define POP_CLASS() ruby_class = _class; }
#define PUSH_SCOPE() { \
- struct SCOPE *_old; \
+ volatile int _vmode = scope_vmode; \
+ struct SCOPE * volatile _old; \
NEWOBJ(_scope, struct SCOPE); \
OBJSETUP(_scope, 0, T_SCOPE); \
_scope->local_tbl = 0; \
_scope->local_vars = 0; \
_scope->flag = 0; \
- _old = the_scope; \
- the_scope = _scope; \
+ _old = ruby_scope; \
+ ruby_scope = _scope; \
+ scope_vmode = SCOPE_PUBLIC;
+
+#define SCOPE_DONT_RECYCLE FL_USER2
+
+static void scope_dup(struct SCOPE *);
#define POP_SCOPE() \
- if (the_scope->flag == SCOPE_ALLOCA) {\
- the_scope->local_vars = 0;\
- the_scope->local_tbl = 0;\
- if (the_scope != top_scope)\
- gc_force_recycle(the_scope);\
+ if (ruby_scope->flag == SCOPE_ALLOCA) {\
+ if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
+ scope_dup(ruby_scope);\
+ FL_SET(_old, SCOPE_DONT_RECYCLE);\
+ }\
+ else {\
+ ruby_scope->local_vars = 0;\
+ ruby_scope->local_tbl = 0;\
+ if (ruby_scope != top_scope)\
+ rb_gc_force_recycle((VALUE)ruby_scope);\
+ }\
}\
else {\
- the_scope->flag |= SCOPE_NOSTACK;\
+ ruby_scope->flag |= SCOPE_NOSTACK;\
}\
- the_scope = _old;\
+ ruby_scope = _old;\
+ scope_vmode = _vmode;\
}
-static VALUE rb_eval();
-static VALUE eval();
-static NODE *compile();
+static VALUE rb_eval _((VALUE,NODE*));
+static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
+static NODE *compile _((VALUE,char*));
+static VALUE rb_yield_0 _((VALUE, VALUE, VALUE));
-static VALUE rb_call();
-VALUE rb_apply();
-VALUE rb_funcall2();
+static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
+static VALUE module_setup _((VALUE,NODE*));
-static VALUE module_setup();
-
-static VALUE massign();
-static void assign();
+static VALUE massign _((VALUE,NODE*,VALUE));
+static void assign _((VALUE,NODE*,VALUE));
static int safe_level = 0;
/* safe-level:
0 - strings from streams/environment/ARGV are tainted (default)
1 - no dangerous operation by tainted string
- 2 - some process operations prohibited
+ 2 - process/file operations prohibited
3 - all genetated strings are tainted
- 4 - no global variable value modification/no direct output
- 5 - no instance variable value modification
+ 4 - no global (non-tainted) variable modification/no direct output
*/
int
@@ -556,8 +701,8 @@ safe_setter(val)
int level = NUM2INT(val);
if (level < safe_level) {
- Raise(eSecurityError, "tried to downgrade safe level from %d to %d",
- safe_level, level);
+ rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d",
+ safe_level, level);
}
safe_level = level;
}
@@ -567,12 +712,14 @@ rb_check_safe_str(x)
VALUE x;
{
if (TYPE(x)!= T_STRING) {
- TypeError("wrong argument type %s (expected String)",
- rb_class2name(CLASS_OF(x)));
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
+ rb_class2name(CLASS_OF(x)));
}
- if (rb_safe_level() > 0 && str_tainted(x)) {
- Raise(eSecurityError, "Insecure operation - %s",
- rb_id2name(the_frame->last_func));
+ if (OBJ_TAINTED(x)) {
+ if (safe_level > 0){
+ rb_raise(rb_eSecurityError, "Insecure operation - %s",
+ rb_id2name(ruby_frame->last_func));
+ }
}
}
@@ -581,87 +728,95 @@ rb_secure(level)
int level;
{
if (level <= safe_level) {
- Raise(eSecurityError, "Insecure operation `%s' for level %d",
- rb_id2name(the_frame->last_func), level);
+ rb_raise(rb_eSecurityError, "Insecure operation `%s' for level %d",
+ rb_id2name(ruby_frame->last_func), safe_level);
}
}
-extern int sourceline;
-extern char *sourcefile;
-
static VALUE trace_func = 0;
-static void call_trace_func();
+static void call_trace_func _((char*,char*,int,VALUE,ID,VALUE));
static void
error_pos()
{
- if (sourcefile) {
- if (the_frame->last_func) {
- fprintf(stderr, "%s:%d:in `%s'", sourcefile, sourceline,
- rb_id2name(the_frame->last_func));
+ if (ruby_sourcefile) {
+ if (ruby_frame->last_func) {
+ fprintf(stderr, "%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
+ rb_id2name(ruby_frame->last_func));
}
else {
- fprintf(stderr, "%s:%d", sourcefile, sourceline);
+ fprintf(stderr, "%s:%d", ruby_sourcefile, ruby_sourceline);
}
}
}
+static VALUE
+get_backtrace(info)
+ VALUE info;
+{
+ if (NIL_P(info)) return Qnil;
+ return rb_funcall(info, rb_intern("backtrace"), 0);
+}
+
+static void
+set_backtrace(info, bt)
+ VALUE info, bt;
+{
+ rb_funcall(info, rb_intern("set_backtrace"), 1, bt);
+}
+
static void
error_print()
{
+ VALUE errat;
VALUE eclass;
+ VALUE einfo;
+ volatile int safe = safe_level;
- if (NIL_P(errinfo)) return;
+ if (NIL_P(rb_errinfo)) return;
+ errat = get_backtrace(rb_errinfo);
if (!NIL_P(errat)) {
- VALUE mesg = Qnil;
+ VALUE mesg = RARRAY(errat)->ptr[0];
- switch (TYPE(errat)) {
- case T_STRING:
- mesg = errat;
- errat = Qnil;
- break;
- case T_ARRAY:
- mesg = RARRAY(errat)->ptr[0];
- break;
- }
if (NIL_P(mesg)) error_pos();
else {
fwrite(RSTRING(mesg)->ptr, 1, RSTRING(mesg)->len, stderr);
}
}
- eclass = CLASS_OF(errinfo);
- if (eclass == eRuntimeError && RSTRING(errinfo)->len == 0) {
+ eclass = CLASS_OF(rb_errinfo);
+ einfo = rb_obj_as_string(rb_errinfo);
+ if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
fprintf(stderr, ": unhandled exception\n");
}
else {
VALUE epath;
epath = rb_class_path(eclass);
- if (RSTRING(errinfo)->len == 0) {
+ if (RSTRING(einfo)->len == 0) {
fprintf(stderr, ": ");
fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
putc('\n', stderr);
}
else {
- unsigned char *tail = 0;
- int len = RSTRING(errinfo)->len;
+ char *tail = 0;
+ int len = RSTRING(einfo)->len;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if (tail = strchr(RSTRING(errinfo)->ptr, '\n')) {
- len = tail - RSTRING(errinfo)->ptr;
+ if (tail = strchr(RSTRING(einfo)->ptr, '\n')) {
+ len = tail - RSTRING(einfo)->ptr;
tail++; /* skip newline */
}
fprintf(stderr, ": ");
- fwrite(RSTRING(errinfo)->ptr, 1, len, stderr);
+ fwrite(RSTRING(einfo)->ptr, 1, len, stderr);
if (epath) {
fprintf(stderr, " (");
fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
fprintf(stderr, ")\n");
}
if (tail) {
- fwrite(tail, 1, RSTRING(errinfo)->len-len-1, stderr);
+ fwrite(tail, 1, RSTRING(einfo)->len-len-1, stderr);
putc('\n', stderr);
}
}
@@ -677,7 +832,9 @@ error_print()
ep = RARRAY(errat);
for (i=1; i<ep->len; i++) {
- fprintf(stderr, "\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
+ if (TYPE(ep->ptr[i]) == T_STRING) {
+ fprintf(stderr, "\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
+ }
if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
fprintf(stderr, "\t ... %d levels...\n",
ep->len - TRACE_HEAD - TRACE_TAIL);
@@ -685,18 +842,18 @@ error_print()
}
}
}
+ safe_level = safe;
}
-#ifndef NT
+#if !defined(NT) && !defined(__MACOS__)
extern char **environ;
#endif
-char **origenviron;
+char **rb_origenviron;
void rb_call_inits _((void));
-void init_stack _((void));
-void init_heap _((void));
+void Init_stack _((void));
+void Init_heap _((void));
void Init_ext _((void));
-void gc_call_finalizer_at_exit _((void));
void
ruby_init()
@@ -705,31 +862,36 @@ ruby_init()
static struct iter iter;
int state;
- the_frame = top_frame = &frame;
- the_iter = &iter;
+ ruby_frame = top_frame = &frame;
+ ruby_iter = &iter;
- origenviron = environ;
+#ifdef __MACOS__
+ rb_origenviron = 0;
+#else
+ rb_origenviron = environ;
+#endif
- init_heap();
+ Init_heap();
PUSH_SCOPE();
- the_scope->local_vars = 0;
- the_scope->local_tbl = 0;
- top_scope = the_scope;
+ ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
+ top_scope = ruby_scope;
/* default visibility is private at toplevel */
- FL_SET(top_scope, SCOPE_PRIVATE);
+ SCOPE_SET(SCOPE_PRIVATE);
PUSH_TAG(PROT_NONE)
if ((state = EXEC_TAG()) == 0) {
rb_call_inits();
- the_class = cObject;
- the_frame->cbase = (VALUE)node_newnode(NODE_CREF,cObject,0,0);
- rb_define_global_const("TOPLEVEL_BINDING", f_binding(TopSelf));
+ ruby_class = rb_cObject;
+ ruby_frame->self = ruby_top_self;
+ ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,rb_cObject,0,0);
+ rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
ruby_prog_init();
}
POP_TAG();
if (state) error_print();
POP_SCOPE();
- the_scope = top_scope;
+ ruby_scope = top_scope;
}
static int ext_init = 0;
@@ -746,15 +908,14 @@ ruby_options(argc, argv)
NODE *save;
ruby_process_options(argc, argv);
- save = eval_tree;
- eval_tree = 0;
- Init_ext();
- ext_init = 1;
- rb_require_modules();
- eval_tree = save;
+ ext_init = 1; /* Init_ext() called in ruby_process_options */
+ save = ruby_eval_tree;
+ ruby_require_modules();
+ ruby_eval_tree = save;
}
POP_TAG();
if (state) {
+ trace_func = 0;
error_print();
exit(1);
}
@@ -767,16 +928,16 @@ eval_node(self)
VALUE result = Qnil;
NODE *tree;
- if (eval_tree0) {
- tree = eval_tree0;
- eval_tree0 = 0;
+ if (ruby_eval_tree_begin) {
+ tree = ruby_eval_tree_begin;
+ ruby_eval_tree_begin = 0;
rb_eval(self, tree);
}
- if (!eval_tree) return Qnil;
+ if (!ruby_eval_tree) return Qnil;
- tree = eval_tree;
- eval_tree = 0;
+ tree = ruby_eval_tree;
+ ruby_eval_tree = 0;
result = rb_eval(self, tree);
return result;
@@ -784,15 +945,14 @@ eval_node(self)
int rb_in_eval;
-#ifdef THREAD
-static void thread_cleanup();
-static void thread_wait_other_threads();
-static VALUE thread_current();
+#ifdef USE_THREAD
+static void rb_thread_cleanup _((void));
+static void rb_thread_wait_other_threads _((void));
#endif
static int exit_status;
-static void exec_end_proc();
+static void exec_end_proc _((void));
void
ruby_run()
@@ -800,16 +960,15 @@ ruby_run()
int state;
static int ex;
- if (nerrs > 0) exit(nerrs);
+ if (ruby_nerrs > 0) exit(ruby_nerrs);
- init_stack();
- errat = Qnil; /* clear for execution */
+ Init_stack();
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
if (!ext_init) Init_ext();
- eval_node(TopSelf);
+ eval_node(ruby_top_self);
}
POP_ITER();
POP_TAG();
@@ -819,12 +978,10 @@ ruby_run()
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
rb_trap_exit();
-#ifdef THREAD
- thread_cleanup();
- thread_wait_other_threads();
+#ifdef USE_THREAD
+ rb_thread_cleanup();
+ rb_thread_wait_other_threads();
#endif
- exec_end_proc();
- gc_call_finalizer_at_exit();
}
else {
ex = state;
@@ -834,63 +991,69 @@ ruby_run()
switch (ex & 0xf) {
case 0:
- exit(0);
+ ex = 0;
+ break;
case TAG_RETURN:
error_pos();
- fprintf(stderr, "unexpected return\n");
- exit(1);
+ fprintf(stderr, ": unexpected return\n");
+ ex = 1;
break;
case TAG_NEXT:
error_pos();
- fprintf(stderr, "unexpected next\n");
- exit(1);
+ fprintf(stderr, ": unexpected next\n");
+ ex = 1;
break;
case TAG_BREAK:
error_pos();
- fprintf(stderr, "unexpected break\n");
- exit(1);
+ fprintf(stderr, ": unexpected break\n");
+ ex = 1;
break;
case TAG_REDO:
error_pos();
- fprintf(stderr, "unexpected redo\n");
- exit(1);
+ fprintf(stderr, ": unexpected redo\n");
+ ex = 1;
break;
case TAG_RETRY:
error_pos();
- fprintf(stderr, "retry outside of rescue clause\n");
- exit(1);
+ fprintf(stderr, ": retry outside of rescue clause\n");
+ ex = 1;
break;
case TAG_RAISE:
case TAG_FATAL:
- if (obj_is_kind_of(errinfo, eSystemExit)) {
+ if (rb_obj_is_kind_of(rb_errinfo, rb_eSystemExit)) {
exit(exit_status);
}
error_print();
- exit(1);
+ ex = 1;
break;
default:
- Bug("Unknown longjmp status %d", ex);
+ rb_bug("Unknown longjmp status %d", ex);
break;
}
+ exec_end_proc();
+ rb_gc_call_finalizer_at_exit();
+ exit(ex);
}
static void
compile_error(at)
char *at;
{
- VALUE mesg;
+ VALUE str;
+ char *mesg;
+ int len;
- mesg = errinfo;
- nerrs = 0;
- errinfo = exc_new2(eSyntaxError, "compile error");
+ mesg = str2cstr(rb_errinfo, &len);
+ ruby_nerrs = 0;
+ str = rb_str_new2("compile error");
if (at) {
- str_cat(errinfo, " in ", 4);
- str_cat(errinfo, at, strlen(at));
+ rb_str_cat(str, " in ", 4);
+ rb_str_cat(str, at, strlen(at));
}
- str_cat(errinfo, "\n", 1);
- str_cat(errinfo, RSTRING(mesg)->ptr, RSTRING(mesg)->len);
- rb_raise(errinfo);
+ rb_str_cat(str, "\n", 1);
+ rb_str_cat(str, mesg, len);
+ rb_exc_raise(rb_exc_new3(rb_eSyntaxError, str));
}
VALUE
@@ -898,45 +1061,67 @@ rb_eval_string(str)
char *str;
{
VALUE v;
- char *oldsrc = sourcefile;
+ char *oldsrc = ruby_sourcefile;
- sourcefile = "(eval)";
- v = eval(TopSelf, str_new2(str), Qnil);
- sourcefile = oldsrc;
+ ruby_sourcefile = "(eval)";
+ v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
+ ruby_sourcefile = oldsrc;
return v;
}
-void
+VALUE
+rb_eval_string_protect(str, state)
+ char *str;
+ int *state;
+{
+ VALUE result; /* OK */
+ int status;
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = rb_eval_string(str);
+ }
+ POP_TAG();
+ if (state) {
+ *state = status;
+ }
+ if (status != 0) {
+ return Qnil;
+ }
+
+ return result;
+}
+
+VALUE
rb_eval_cmd(cmd, arg)
VALUE cmd, arg;
{
int state;
+ VALUE val; /* OK */
struct SCOPE *saved_scope;
- volatile int safe = rb_safe_level();
+ volatile int safe = safe_level;
if (TYPE(cmd) != T_STRING) {
- Check_Type(arg, T_ARRAY);
- rb_funcall2(cmd, rb_intern("call"),
- RARRAY(arg)->len, RARRAY(arg)->ptr);
- return;
+ return rb_funcall2(cmd, rb_intern("call"),
+ RARRAY(arg)->len, RARRAY(arg)->ptr);
}
PUSH_CLASS();
PUSH_TAG(PROT_NONE);
- saved_scope = the_scope;
- the_scope = top_scope;
+ saved_scope = ruby_scope;
+ ruby_scope = top_scope;
- the_class = cObject;
- if (str_tainted(cmd)) {
- safe_level = 5;
+ ruby_class = rb_cObject;
+ if (OBJ_TAINTED(cmd)) {
+ safe_level = 4;
}
if ((state = EXEC_TAG()) == 0) {
- eval(TopSelf, cmd, Qnil);
+ val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
- the_scope = saved_scope;
+ ruby_scope = saved_scope;
safe_level = safe;
POP_TAG();
POP_CLASS();
@@ -945,42 +1130,45 @@ rb_eval_cmd(cmd, arg)
case 0:
break;
case TAG_RETURN:
- Raise(eLocalJumpError, "unexpected return");
+ rb_raise(rb_eLocalJumpError, "unexpected return");
break;
case TAG_NEXT:
- Raise(eLocalJumpError, "unexpected next");
+ rb_raise(rb_eLocalJumpError, "unexpected next");
break;
case TAG_BREAK:
- Raise(eLocalJumpError, "unexpected break");
+ rb_raise(rb_eLocalJumpError, "unexpected break");
break;
case TAG_REDO:
- Raise(eLocalJumpError, "unexpected redo");
+ rb_raise(rb_eLocalJumpError, "unexpected redo");
break;
case TAG_RETRY:
- Raise(eLocalJumpError, "retry outside of rescue clause");
+ rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
break;
default:
JUMP_TAG(state);
break;
}
+ return val;
}
-void
+VALUE
rb_trap_eval(cmd, sig)
VALUE cmd;
int sig;
{
int state;
+ VALUE val; /* OK */
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- rb_eval_cmd(cmd, ary_new3(1, INT2FIX(sig)));
+ val = rb_eval_cmd(cmd, rb_ary_new3(1, INT2FIX(sig)));
}
POP_TAG();
if (state) {
- trap_immediate = 0;
+ rb_trap_immediate = 0;
JUMP_TAG(state);
}
+ return val;
}
static VALUE
@@ -988,7 +1176,7 @@ superclass(self, node)
VALUE self;
NODE *node;
{
- VALUE val = 0; /* OK */
+ VALUE val; /* OK */
int state;
PUSH_TAG(PROT_NONE);
@@ -996,21 +1184,23 @@ superclass(self, node)
val = rb_eval(self, node);
}
POP_TAG();
- if (state == TAG_RAISE) {
+ if (state) {
superclass_error:
switch (nd_type(node)) {
case NODE_COLON2:
- TypeError("undefined superclass `%s'", rb_id2name(node->nd_mid));
+ rb_raise(rb_eTypeError, "undefined superclass `%s'",
+ rb_id2name(node->nd_mid));
case NODE_CVAR:
- TypeError("undefined superclass `%s'", rb_id2name(node->nd_vid));
+ rb_raise(rb_eTypeError, "undefined superclass `%s'",
+ rb_id2name(node->nd_vid));
default:
- TypeError("superclass undefined");
+ rb_raise(rb_eTypeError, "superclass undefined");
}
JUMP_TAG(state);
}
if (TYPE(val) != T_CLASS) goto superclass_error;
if (FL_TEST(val, FL_SINGLETON)) {
- TypeError("can't make subclass of virtual class");
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
}
return val;
@@ -1023,12 +1213,12 @@ ev_const_defined(cref, id)
{
NODE *cbase = cref;
- while (cbase && cbase->nd_clss != cObject) {
- struct RClass *class = RCLASS(cbase->nd_clss);
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ struct RClass *klass = RCLASS(cbase->nd_clss);
- if (class->iv_tbl &&
- st_lookup(class->iv_tbl, id, 0)) {
- return TRUE;
+ if (klass->iv_tbl &&
+ st_lookup(klass->iv_tbl, id, 0)) {
+ return Qtrue;
}
cbase = cbase->nd_next;
}
@@ -1043,11 +1233,11 @@ ev_const_get(cref, id)
NODE *cbase = cref;
VALUE result;
- while (cbase && cbase->nd_clss != cObject) {
- struct RClass *class = RCLASS(cbase->nd_clss);
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ struct RClass *klass = RCLASS(cbase->nd_clss);
- if (class->iv_tbl &&
- st_lookup(class->iv_tbl, id, &result)) {
+ if (klass->iv_tbl &&
+ st_lookup(klass->iv_tbl, id, &result)) {
return result;
}
cbase = cbase->nd_next;
@@ -1056,43 +1246,43 @@ ev_const_get(cref, id)
}
static VALUE
-mod_nesting()
+rb_mod_nesting()
{
- NODE *cbase = (NODE*)the_frame->cbase;
- VALUE ary = ary_new();
+ NODE *cbase = (NODE*)ruby_frame->cbase;
+ VALUE ary = rb_ary_new();
- while (cbase && cbase->nd_clss != cObject) {
- ary_push(ary, cbase->nd_clss);
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ rb_ary_push(ary, cbase->nd_clss);
cbase = cbase->nd_next;
}
return ary;
}
static VALUE
-mod_s_constants()
+rb_mod_s_constants()
{
- NODE *cbase = (NODE*)the_frame->cbase;
- VALUE ary = ary_new();
+ NODE *cbase = (NODE*)ruby_frame->cbase;
+ VALUE ary = rb_ary_new();
- while (cbase && cbase->nd_clss != cObject) {
- mod_const_at(cbase->nd_clss, ary);
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ rb_mod_const_at(cbase->nd_clss, ary);
cbase = cbase->nd_next;
}
- mod_const_of(((NODE*)the_frame->cbase)->nd_clss, ary);
+ rb_mod_const_of(((NODE*)ruby_frame->cbase)->nd_clss, ary);
return ary;
}
static VALUE
-mod_remove_method(mod, name)
+rb_mod_remove_method(mod, name)
VALUE mod, name;
{
- rb_remove_method(mod, rb_to_id(name));
+ remove_method(mod, rb_to_id(name));
return mod;
}
static VALUE
-mod_undef_method(mod, name)
+rb_mod_undef_method(mod, name)
VALUE mod, name;
{
ID id = rb_to_id(name);
@@ -1103,16 +1293,27 @@ mod_undef_method(mod, name)
}
static VALUE
-mod_alias_method(mod, new, old)
- VALUE mod, new, old;
+rb_mod_alias_method(mod, newname, oldname)
+ VALUE mod, newname, oldname;
{
- ID id = rb_to_id(new);
+ ID id = rb_to_id(newname);
- rb_alias(mod, id, rb_to_id(old));
+ rb_alias(mod, id, rb_to_id(oldname));
rb_clear_cache_by_id(id);
return mod;
}
+#ifdef C_ALLOCA
+# define TMP_PROTECT NODE * volatile __protect_tmp=0
+# define TMP_ALLOC(n) \
+ (__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
+ ALLOC_N(VALUE,n),__protect_tmp,n), \
+ (void*)__protect_tmp->nd_head)
+#else
+# define TMP_PROTECT typedef int foobazzz
+# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
+#endif
+
#define SETUP_ARGS(anode) {\
NODE *n = anode;\
if (!n) {\
@@ -1122,17 +1323,17 @@ mod_alias_method(mod, new, old)
else if (nd_type(n) == NODE_ARRAY) {\
argc=n->nd_alen;\
if (argc > 0) {\
- char *file = sourcefile;\
- int line = sourceline;\
+ char *file = ruby_sourcefile;\
+ int line = ruby_sourceline;\
int i;\
n = anode;\
- argv = ALLOCA_N(VALUE,argc);\
+ argv = TMP_ALLOC(argc);\
for (i=0;i<argc;i++) {\
argv[i] = rb_eval(self,n->nd_head);\
n=n->nd_next;\
}\
- sourcefile = file;\
- sourceline = line;\
+ ruby_sourcefile = file;\
+ ruby_sourceline = line;\
}\
else {\
argc = 0;\
@@ -1141,19 +1342,31 @@ mod_alias_method(mod, new, old)
}\
else {\
VALUE args = rb_eval(self,n);\
- char *file = sourcefile;\
- int line = sourceline;\
+ char *file = ruby_sourcefile;\
+ int line = ruby_sourceline;\
if (TYPE(args) != T_ARRAY)\
args = rb_Array(args);\
argc = RARRAY(args)->len;\
argv = ALLOCA_N(VALUE, argc);\
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
- sourcefile = file;\
- sourceline = line;\
+ ruby_sourcefile = file;\
+ ruby_sourceline = line;\
}\
}
-#define MATCH_DATA the_scope->local_vars[node->nd_cnt]
+#define BEGIN_CALLARGS {\
+ struct BLOCK *tmp_block = ruby_block;\
+ if (ruby_iter->iter == ITER_PRE) {\
+ ruby_block = ruby_block->prev;\
+ }\
+ PUSH_ITER(ITER_NOT);
+
+#define END_CALLARGS \
+ ruby_block = tmp_block;\
+ POP_ITER();\
+}
+
+#define MATCH_DATA ruby_scope->local_vars[node->nd_cnt]
static char* is_defined _((VALUE, NODE*, char*));
@@ -1196,9 +1409,9 @@ is_defined(self, node, buf)
switch (nd_type(node)) {
case NODE_SUPER:
case NODE_ZSUPER:
- if (the_frame->last_func == 0) return 0;
- else if (method_boundp(RCLASS(the_frame->last_class)->super,
- the_frame->last_func, 1)) {
+ if (ruby_frame->last_func == 0) return 0;
+ else if (rb_method_boundp(RCLASS(ruby_frame->last_class)->super,
+ ruby_frame->last_func, 1)) {
if (nd_type(node) == NODE_SUPER) {
return arg_defined(self, node->nd_args, buf, "super");
}
@@ -1206,8 +1419,8 @@ is_defined(self, node, buf)
}
break;
- case NODE_FCALL:
case NODE_VCALL:
+ case NODE_FCALL:
val = CLASS_OF(self);
goto check_bound;
@@ -1219,11 +1432,9 @@ is_defined(self, node, buf)
val = CLASS_OF(val);
}
POP_TAG();
- if (state) {
- return 0;
- }
+ if (state) return 0;
check_bound:
- if (method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) {
+ if (rb_method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) {
return arg_defined(self, node->nd_args, buf, "method");
}
break;
@@ -1233,7 +1444,7 @@ is_defined(self, node, buf)
return "method";
case NODE_YIELD:
- if (iterator_p()) {
+ if (rb_iterator_p()) {
return "yield";
}
break;
@@ -1256,14 +1467,16 @@ is_defined(self, node, buf)
case NODE_MASGN:
case NODE_LASGN:
case NODE_DASGN:
+ case NODE_DASGN_PUSH:
case NODE_GASGN:
case NODE_IASGN:
case NODE_CASGN:
return "assignment";
case NODE_LVAR:
- case NODE_DVAR:
return "local-variable";
+ case NODE_DVAR:
+ return "local-variable(in-block)";
case NODE_GVAR:
if (rb_gvar_defined(node->nd_entry)) {
@@ -1278,7 +1491,7 @@ is_defined(self, node, buf)
break;
case NODE_CVAR:
- if (ev_const_defined(the_frame->cbase, node->nd_vid)) {
+ if (ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
return "constant";
}
break;
@@ -1289,28 +1502,30 @@ is_defined(self, node, buf)
val = rb_eval(self, node->nd_head);
}
POP_TAG();
- if (state) {
- return 0;
- }
+ if (state) return 0;
else {
switch (TYPE(val)) {
case T_CLASS:
case T_MODULE:
if (rb_const_defined_at(val, node->nd_mid))
return "constant";
+ default:
+ if (rb_method_boundp(val, node->nd_mid, 1)) {
+ return "method";
+ }
}
}
break;
case NODE_NTH_REF:
- if (reg_nth_defined(node->nd_nth, MATCH_DATA)) {
+ if (rb_reg_nth_defined(node->nd_nth, MATCH_DATA)) {
sprintf(buf, "$%d", node->nd_nth);
return buf;
}
break;
case NODE_BACK_REF:
- if (reg_nth_defined(0, MATCH_DATA)) {
+ if (rb_reg_nth_defined(0, MATCH_DATA)) {
sprintf(buf, "$%c", node->nd_nth);
return buf;
}
@@ -1330,12 +1545,31 @@ is_defined(self, node, buf)
return 0;
}
-static int handle_rescue();
-VALUE rb_yield_0();
+static int handle_rescue _((VALUE,NODE*));
static void blk_free();
static VALUE
+rb_obj_is_block(block)
+ VALUE block;
+{
+ if (TYPE(block) == T_DATA && RDATA(block)->dfree == blk_free) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+static VALUE
+rb_obj_is_proc(proc)
+ VALUE proc;
+{
+ if (rb_obj_is_block(proc) && rb_obj_is_kind_of(proc, rb_cProc)) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+static VALUE
set_trace_func(obj, trace)
VALUE obj, trace;
{
@@ -1343,58 +1577,73 @@ set_trace_func(obj, trace)
trace_func = 0;
return Qnil;
}
- if (TYPE(trace) != T_DATA || RDATA(trace)->dfree != blk_free) {
- TypeError("trace_func needs to be Proc");
+ if (!rb_obj_is_proc(trace)) {
+ rb_raise(rb_eTypeError, "trace_func needs to be Proc");
}
return trace_func = trace;
}
static void
-call_trace_func(event, file, line, self, id)
+call_trace_func(event, file, line, self, id, klass)
char *event;
char *file;
int line;
VALUE self;
ID id;
+ VALUE klass; /* OK */
{
int state;
volatile VALUE trace;
struct FRAME *prev;
+ char *file_save = ruby_sourcefile;
+ int line_save = ruby_sourceline;
if (!trace_func) return;
trace = trace_func;
trace_func = 0;
-#ifdef THREAD
- thread_critical++;
+#ifdef USE_THREAD
+ rb_thread_critical++;
#endif
- prev = the_frame;
+ prev = ruby_frame;
PUSH_FRAME();
- *the_frame = *_frame->prev;
- the_frame->prev = prev;
+ *ruby_frame = *_frame.prev;
+ ruby_frame->prev = prev;
- the_frame->line = sourceline = line;
- the_frame->file = sourcefile = file;
+ if (file) {
+ ruby_frame->line = ruby_sourceline = line;
+ ruby_frame->file = ruby_sourcefile = file;
+ }
+ if (klass) {
+ if (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = self;
+ }
+ }
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- proc_call(trace, ary_new3(5, str_new2(event),
- str_new2(sourcefile),
- INT2FIX(sourceline),
- INT2FIX(id),
- self?f_binding(self):Qnil));
+ proc_call(trace, rb_ary_new3(6, rb_str_new2(event),
+ rb_str_new2(ruby_sourcefile),
+ INT2FIX(ruby_sourceline),
+ INT2FIX(id),
+ self?rb_f_binding(self):Qnil,
+ klass));
}
POP_TAG();
POP_FRAME();
-#ifdef THREAD
- thread_critical--;
+#ifdef USE_THREAD
+ rb_thread_critical--;
#endif
if (!trace_func) trace_func = trace;
+ ruby_sourceline = line_save;
+ ruby_sourcefile = file_save;
if (state) JUMP_TAG(state);
}
-static void return_value _((VALUE val));
+static void return_check _((void));
+#define return_value(v) prot_tag->retval = (v)
+
static VALUE
rb_eval(self, node)
VALUE self;
@@ -1402,6 +1651,10 @@ rb_eval(self, node)
{
int state;
volatile VALUE result = Qnil;
+#ifdef NOBLOCK_RECUR
+ NODE * volatile next = 0;
+ NODE * volatile nstack = 0;
+#endif
#define RETURN(v) { result = (v); goto finish; }
@@ -1410,14 +1663,26 @@ rb_eval(self, node)
switch (nd_type(node)) {
case NODE_BLOCK:
+#ifndef NOBLOCK_RECUR
+ if (!node->nd_next) {
+ node = node->nd_head;
+ goto again;
+ }
while (node) {
result = rb_eval(self, node->nd_head);
node = node->nd_next;
}
break;
-
+#else
+ if (next) {
+ nstack = rb_node_newnode(NODE_CREF,next,0,nstack);
+ }
+ next = node->nd_next;
+ node = node->nd_head;
+ goto again;
+#endif
case NODE_POSTEXE:
- f_END();
+ rb_f_END();
nd_set_type(node, NODE_NIL); /* exec just once */
result = Qnil;
break;
@@ -1429,12 +1694,12 @@ rb_eval(self, node)
/* nodes for speed-up(default match) */
case NODE_MATCH:
- result = reg_match2(node->nd_head->nd_lit);
+ result = rb_reg_match2(node->nd_head->nd_lit);
break;
/* nodes for speed-up(literal match) */
case NODE_MATCH2:
- result = reg_match(rb_eval(self,node->nd_recv),
+ result = rb_reg_match(rb_eval(self,node->nd_recv),
rb_eval(self,node->nd_value));
break;
@@ -1444,7 +1709,7 @@ rb_eval(self, node)
VALUE r = rb_eval(self,node->nd_recv);
VALUE l = rb_eval(self,node->nd_value);
if (TYPE(r) == T_STRING) {
- result = reg_match(l, r);
+ result = rb_reg_match(l, r);
}
else {
result = rb_funcall(r, match, 1, l);
@@ -1454,7 +1719,7 @@ rb_eval(self, node)
/* nodes for speed-up(top-level loop for -n/-p) */
case NODE_OPT_N:
- while (!NIL_P(f_gets())) {
+ while (!NIL_P(rb_gets())) {
rb_eval(self, node->nd_body);
}
RETURN(Qnil);
@@ -1466,14 +1731,18 @@ rb_eval(self, node)
RETURN(Qnil);
case NODE_TRUE:
- RETURN(TRUE);
+ RETURN(Qtrue);
case NODE_FALSE:
- RETURN(FALSE);
+ RETURN(Qfalse);
case NODE_IF:
- sourceline = nd_line(node);
+ ruby_sourceline = nd_line(node);
+#ifdef NOBLOCK_RECUR
+ if (RTEST(result)){
+#else
if (RTEST(rb_eval(self, node->nd_cond))) {
+#endif
node = node->nd_body;
}
else {
@@ -1485,7 +1754,11 @@ rb_eval(self, node)
{
VALUE val;
+#ifdef NOBLOCK_RECUR
+ val = result;
+#else
val = rb_eval(self, node->nd_head);
+#endif
node = node->nd_body;
while (node) {
NODE *tag;
@@ -1497,10 +1770,25 @@ rb_eval(self, node)
while (tag) {
if (trace_func) {
call_trace_func("line", tag->nd_file, nd_line(tag),
- self, the_frame->last_func);
+ self, ruby_frame->last_func, 0);
}
- sourceline = nd_line(tag);
- if (RTEST(rb_funcall2(rb_eval(self, tag->nd_head),eqq,1,&val))){
+ ruby_sourcefile = tag->nd_file;
+ ruby_sourceline = nd_line(tag);
+ if (nd_type(tag->nd_head) == NODE_WHEN) {
+ VALUE v = rb_eval(self, tag->nd_head->nd_head);
+ int i;
+
+ if (TYPE(v) != T_ARRAY) v = rb_Array(v);
+ for (i=0; i<RARRAY(v)->len; i++) {
+ if (RTEST(rb_funcall2(RARRAY(v)->ptr[i], eqq, 1, &val))){
+ node = node->nd_body;
+ goto again;
+ }
+ }
+ tag = tag->nd_next;
+ continue;
+ }
+ if (RTEST(rb_funcall2(rb_eval(self, tag->nd_head), eqq, 1, &val))) {
node = node->nd_body;
goto again;
}
@@ -1515,7 +1803,7 @@ rb_eval(self, node)
PUSH_TAG(PROT_NONE);
switch (state = EXEC_TAG()) {
case 0:
- sourceline = nd_line(node);
+ ruby_sourceline = nd_line(node);
if (node->nd_state && !RTEST(rb_eval(self, node->nd_cond)))
goto while_out;
do {
@@ -1539,9 +1827,7 @@ rb_eval(self, node)
}
while_out:
POP_TAG();
- if (state) {
- JUMP_TAG(state);
- }
+ if (state) JUMP_TAG(state);
RETURN(Qnil);
case NODE_UNTIL:
@@ -1571,11 +1857,13 @@ rb_eval(self, node)
}
until_out:
POP_TAG();
- if (state) {
- JUMP_TAG(state);
- }
+ if (state) JUMP_TAG(state);
RETURN(Qnil);
+ case NODE_BLOCK_PASS:
+ result = block_pass(self, node);
+ break;
+
case NODE_ITER:
case NODE_FOR:
{
@@ -1592,21 +1880,21 @@ rb_eval(self, node)
}
else {
VALUE recv;
- char *file = sourcefile;
- int line = sourceline;
+ char *file = ruby_sourcefile;
+ int line = ruby_sourceline;
recv = rb_eval(self, node->nd_iter);
PUSH_ITER(ITER_PRE);
- sourcefile = file;
- sourceline = line;
+ ruby_sourcefile = file;
+ ruby_sourceline = line;
result = rb_call(CLASS_OF(recv),recv,each,0,0,0);
POP_ITER();
}
}
- else if (the_block->tag->dst == state) {
+ else if (_block.tag->dst == state) {
state &= TAG_MASK;
if (state == TAG_RETURN) {
- result = prot_tag->tag_retval;
+ result = prot_tag->retval;
}
}
POP_TAG();
@@ -1646,14 +1934,32 @@ rb_eval(self, node)
JUMP_TAG(TAG_RETRY);
break;
+ case NODE_RESTARGS:
+ result = rb_eval(self, node->nd_head);
+ if (TYPE(result) != T_ARRAY) {
+ result = rb_Array(result);
+ }
+ break;
+
case NODE_YIELD:
- result = rb_yield_0(rb_eval(self, node->nd_stts), 0);
+ if (node->nd_stts) {
+ result = rb_eval(self, node->nd_stts);
+ if (nd_type(node->nd_stts) == NODE_RESTARGS &&
+ RARRAY(result)->len == 1)
+ {
+ result = RARRAY(result)->ptr[0];
+ }
+ }
+ else {
+ result = Qnil;
+ }
+ result = rb_yield_0(result, 0, 0);
break;
case NODE_RESCUE:
retry_entry:
{
- volatile VALUE e_info = errinfo, e_at = errat;
+ volatile VALUE e_info = rb_errinfo;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
@@ -1662,6 +1968,7 @@ rb_eval(self, node)
POP_TAG();
if (state == TAG_RAISE) {
NODE * volatile resq = node->nd_resq;
+
while (resq) {
if (handle_rescue(self, resq)) {
state = 0;
@@ -1671,8 +1978,7 @@ rb_eval(self, node)
}
POP_TAG();
if (state == 0) {
- errinfo = e_info;
- errat = e_at;
+ rb_errinfo = e_info;
}
else if (state == TAG_RETRY) {
state = 0;
@@ -1683,8 +1989,9 @@ rb_eval(self, node)
resq = resq->nd_head; /* next rescue */
}
}
- if (state) {
- JUMP_TAG(state);
+ if (state) JUMP_TAG(state);
+ if (node->nd_else) { /* no exception raised, else clause given */
+ result = rb_eval(self, node->nd_else);
}
}
break;
@@ -1695,10 +2002,13 @@ rb_eval(self, node)
result = rb_eval(self, node->nd_head);
}
POP_TAG();
- rb_eval(self, node->nd_ensr);
- if (state) {
- JUMP_TAG(state);
+ if (node->nd_ensr) {
+ VALUE retval = prot_tag->retval; /* save retval */
+
+ rb_eval(self, node->nd_ensr);
+ return_value(retval);
}
+ if (state) JUMP_TAG(state);
break;
case NODE_AND:
@@ -1714,45 +2024,65 @@ rb_eval(self, node)
goto again;
case NODE_NOT:
- if (RTEST(rb_eval(self, node->nd_body))) result = FALSE;
- else result = TRUE;
+ if (RTEST(rb_eval(self, node->nd_body))) result = Qfalse;
+ else result = Qtrue;
break;
case NODE_DOT2:
case NODE_DOT3:
- RETURN(range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end)));
+ result = rb_range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end));
+#if 0
+ break;
+#else
+ result = rb_range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end));
+ if (node->nd_state) break;
+ if (nd_type(node->nd_beg) == NODE_LIT && FIXNUM_P(node->nd_beg->nd_lit) &&
+ nd_type(node->nd_end) == NODE_LIT && FIXNUM_P(node->nd_end->nd_lit))
+ {
+ nd_set_type(node, NODE_LIT);
+ node->nd_lit = result;
+ }
+ else {
+ node->nd_state = 1;
+ }
+#endif
+ break;
case NODE_FLIP2: /* like AWK */
- if (node->nd_state == 0) {
+ if (ruby_scope->local_vars == 0) {
+ rb_bug("unexpected local variable");
+ }
+ if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) {
if (RTEST(rb_eval(self, node->nd_beg))) {
- node->nd_state = rb_eval(self, node->nd_end)?0:1;
- result = TRUE;
+ ruby_scope->local_vars[node->nd_cnt] =
+ RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue;
+ result = Qtrue;
}
else {
- result = FALSE;
+ result = Qfalse;
}
}
else {
if (RTEST(rb_eval(self, node->nd_end))) {
- node->nd_state = 0;
+ ruby_scope->local_vars[node->nd_cnt] = Qfalse;
}
- result = TRUE;
+ result = Qtrue;
}
break;
case NODE_FLIP3: /* like SED */
- if (node->nd_state == 0) {
- if (RTEST(rb_eval(self, node->nd_beg))) {
- node->nd_state = 1;
- result = TRUE;
- }
- result = FALSE;
+ if (ruby_scope->local_vars == 0) {
+ rb_bug("unexpected local variable");
+ }
+ if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) {
+ result = RTEST(rb_eval(self, node->nd_beg));
+ ruby_scope->local_vars[node->nd_cnt] = result;
}
else {
if (RTEST(rb_eval(self, node->nd_end))) {
- node->nd_state = 0;
+ ruby_scope->local_vars[node->nd_cnt] = Qfalse;
}
- result = TRUE;
+ result = Qtrue;
}
break;
@@ -1760,18 +2090,32 @@ rb_eval(self, node)
if (node->nd_stts) {
return_value(rb_eval(self, node->nd_stts));
}
+ return_check();
JUMP_TAG(TAG_RETURN);
break;
+ case NODE_ARGSCAT:
+ result = rb_ary_concat(rb_eval(self, node->nd_head),
+ rb_eval(self, node->nd_body));
+ break;
+
case NODE_CALL:
{
VALUE recv;
int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
- PUSH_ITER(ITER_NOT);
+ BEGIN_CALLARGS;
+#ifdef NOBLOCK_RECUR_incomplete
+ printf("mid %s recv: ", rb_id2name(node->nd_mid));
+ rb_p(result);
+ recv = result;
+#else
recv = rb_eval(self, node->nd_recv);
+#endif
SETUP_ARGS(node->nd_args);
- POP_ITER();
+ END_CALLARGS;
+
result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
}
break;
@@ -1779,10 +2123,12 @@ rb_eval(self, node)
case NODE_FCALL:
{
int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
- PUSH_ITER(ITER_NOT);
+ BEGIN_CALLARGS;
SETUP_ARGS(node->nd_args);
- POP_ITER();
+ END_CALLARGS;
+
result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1);
}
break;
@@ -1795,48 +2141,54 @@ rb_eval(self, node)
case NODE_ZSUPER:
{
int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
+ if (ruby_frame->last_class == 0) {
+ rb_raise(rb_eNameError, "superclass method `%s' disabled",
+ rb_id2name(ruby_frame->last_func));
+ }
if (nd_type(node) == NODE_ZSUPER) {
- argc = the_frame->argc;
- argv = the_frame->argv;
+ argc = ruby_frame->argc;
+ argv = ruby_frame->argv;
}
else {
- PUSH_ITER(ITER_NOT);
+ BEGIN_CALLARGS;
SETUP_ARGS(node->nd_args);
- POP_ITER();
+ END_CALLARGS;
}
- PUSH_ITER(the_iter->iter?ITER_PRE:ITER_NOT);
- result = rb_call(RCLASS(the_frame->last_class)->super, self,
- the_frame->last_func, argc, argv, 1);
+ PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
+ result = rb_call(RCLASS(ruby_frame->last_class)->super,
+ ruby_frame->self, ruby_frame->last_func,
+ argc, argv, 3);
POP_ITER();
}
break;
case NODE_SCOPE:
{
- VALUE save = the_frame->cbase;
+ VALUE save = ruby_frame->cbase;
PUSH_SCOPE();
PUSH_TAG(PROT_NONE);
- if (node->nd_rval) the_frame->cbase = (VALUE)node->nd_rval;
+ if (node->nd_rval) ruby_frame->cbase = node->nd_rval;
if (node->nd_tbl) {
VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1);
*vars++ = (VALUE)node;
- the_scope->local_vars = vars;
- memclear(the_scope->local_vars, node->nd_tbl[0]);
- the_scope->local_tbl = node->nd_tbl;
+ ruby_scope->local_vars = vars;
+ rb_mem_clear(ruby_scope->local_vars, node->nd_tbl[0]);
+ ruby_scope->local_tbl = node->nd_tbl;
}
else {
- the_scope->local_vars = 0;
- the_scope->local_tbl = 0;
+ ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
}
if ((state = EXEC_TAG()) == 0) {
- result = rb_eval(self, node->nd_body);
+ result = rb_eval(self, node->nd_next);
}
POP_TAG();
POP_SCOPE();
- the_frame->cbase = save;
+ ruby_frame->cbase = save;
if (state) JUMP_TAG(state);
}
break;
@@ -1846,12 +2198,23 @@ rb_eval(self, node)
int argc; VALUE *argv; /* used in SETUP_ARGS */
VALUE recv, val;
NODE *rval;
+ TMP_PROTECT;
recv = rb_eval(self, node->nd_recv);
rval = node->nd_args->nd_head;
SETUP_ARGS(node->nd_args->nd_next);
val = rb_funcall2(recv, aref, argc-1, argv);
- val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
+ if (node->nd_mid == 0) { /* OR */
+ if (RTEST(val)) break;
+ val = rb_eval(self, rval);
+ }
+ else if (node->nd_mid == 1) { /* AND */
+ if (!RTEST(val)) break;
+ val = rb_eval(self, rval);
+ }
+ else {
+ val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
+ }
argv[argc-1] = val;
val = rb_funcall2(recv, aset, argc, argv);
result = val;
@@ -1865,75 +2228,94 @@ rb_eval(self, node)
recv = rb_eval(self, node->nd_recv);
val = rb_funcall(recv, id, 0);
+ if (node->nd_next->nd_mid == 0) { /* OR */
+ if (RTEST(val)) break;
+ val = rb_eval(self, node->nd_value);
+ }
+ else if (node->nd_next->nd_mid == 1) { /* AND */
+ if (!RTEST(val)) break;
+ val = rb_eval(self, node->nd_value);
+ }
+ else {
+ val = rb_funcall(val, node->nd_next->nd_mid, 1,
+ rb_eval(self, node->nd_value));
+ }
- val = rb_funcall(val, node->nd_next->nd_mid, 1,
- rb_eval(self, node->nd_value));
-
- rb_funcall2(recv, id_attrset(id), 1, &val);
+ rb_funcall2(recv, node->nd_next->nd_aid, 1, &val);
result = val;
}
break;
+ case NODE_OP_ASGN_AND:
+ result = rb_eval(self, node->nd_head);
+ if (RTEST(result)) {
+ result = rb_eval(self, node->nd_value);
+ }
+ break;
+
+ case NODE_OP_ASGN_OR:
+ result = rb_eval(self, node->nd_head);
+ if (!RTEST(result)) {
+ result = rb_eval(self, node->nd_value);
+ }
+ break;
+
case NODE_MASGN:
result = massign(self, node, rb_eval(self, node->nd_value));
break;
case NODE_LASGN:
- if (the_scope->local_vars == 0)
- Bug("unexpected local variable assignment");
- the_scope->local_vars[node->nd_cnt] = rb_eval(self, node->nd_value);
- result = the_scope->local_vars[node->nd_cnt];
+ if (ruby_scope->local_vars == 0)
+ rb_bug("unexpected local variable assignment");
+ result = rb_eval(self, node->nd_value);
+ ruby_scope->local_vars[node->nd_cnt] = result;
break;
case NODE_DASGN:
- result = dyna_var_asgn(node->nd_vid, rb_eval(self, node->nd_value));
+ result = rb_eval(self, node->nd_value);
+ rb_dvar_asgn(node->nd_vid, result);
break;
- case NODE_GASGN:
- {
- VALUE val;
+ case NODE_DASGN_PUSH:
+ result = rb_eval(self, node->nd_value);
+ dvar_asgn_push(node->nd_vid, result);
+ break;
- val = rb_eval(self, node->nd_value);
- rb_gvar_set(node->nd_entry, val);
- result = val;
- }
+ case NODE_GASGN:
+ result = rb_eval(self, node->nd_value);
+ rb_gvar_set(node->nd_entry, result);
break;
case NODE_IASGN:
- {
- VALUE val;
-
- val = rb_eval(self, node->nd_value);
- rb_ivar_set(self, node->nd_vid, val);
- result = val;
- }
+ result = rb_eval(self, node->nd_value);
+ rb_ivar_set(self, node->nd_vid, result);
break;
case NODE_CASGN:
- {
- VALUE val;
-
- val = rb_eval(self, node->nd_value);
- /* check for static scope constants */
- if (RTEST(verbose) &&
- ev_const_defined(the_frame->cbase, node->nd_vid)) {
- Warning("already initialized constant %s",
- rb_id2name(node->nd_vid));
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class/module to define constant");
+ }
+ result = rb_eval(self, node->nd_value);
+ /* check for static scope constants */
+ if (RTEST(rb_verbose) &&
+ ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
+ if (RTEST(rb_verbose)) {
+ rb_warning("already initialized constant %s",
+ rb_id2name(node->nd_vid));
}
- rb_const_set(the_class, node->nd_vid, val);
- result = val;
}
+ rb_const_set(ruby_class, node->nd_vid, result);
break;
case NODE_LVAR:
- if (the_scope->local_vars == 0) {
- Bug("unexpected local variable");
+ if (ruby_scope->local_vars == 0) {
+ rb_bug("unexpected local variable");
}
- result = the_scope->local_vars[node->nd_cnt];
+ result = ruby_scope->local_vars[node->nd_cnt];
break;
case NODE_DVAR:
- result = dyna_var_ref(node->nd_vid);
+ result = rb_dvar_ref(node->nd_vid);
break;
case NODE_GVAR:
@@ -1945,53 +2327,68 @@ rb_eval(self, node)
break;
case NODE_CVAR:
- result = ev_const_get(the_frame->cbase, node->nd_vid);
+ result = ev_const_get((NODE*)ruby_frame->cbase, node->nd_vid);
+ break;
+
+ case NODE_BLOCK_ARG:
+ if (ruby_scope->local_vars == 0)
+ rb_bug("unexpected block argument");
+ if (rb_iterator_p()) {
+ result = rb_f_lambda();
+ ruby_scope->local_vars[node->nd_cnt] = result;
+ }
+ else {
+ result = Qnil;
+ }
break;
case NODE_COLON2:
{
- VALUE cls;
+ VALUE klass;
- cls = rb_eval(self, node->nd_head);
- switch (TYPE(cls)) {
+ klass = rb_eval(self, node->nd_head);
+ switch (TYPE(klass)) {
case T_CLASS:
case T_MODULE:
break;
default:
- Check_Type(cls, T_CLASS);
- break;
+ return rb_funcall(klass, node->nd_mid, 0, 0);
}
- result = rb_const_get_at(cls, node->nd_mid);
+ result = rb_const_get_at(klass, node->nd_mid);
}
break;
+ case NODE_COLON3:
+ result = rb_const_get_at(rb_cObject, node->nd_mid);
+ break;
+
case NODE_NTH_REF:
- result = reg_nth_match(node->nd_nth, MATCH_DATA);
+ result = rb_reg_nth_match(node->nd_nth, MATCH_DATA);
break;
case NODE_BACK_REF:
switch (node->nd_nth) {
case '&':
- result = reg_last_match(MATCH_DATA);
+ result = rb_reg_last_match(MATCH_DATA);
break;
case '`':
- result = reg_match_pre(MATCH_DATA);
+ result = rb_reg_match_pre(MATCH_DATA);
break;
case '\'':
- result = reg_match_post(MATCH_DATA);
+ result = rb_reg_match_post(MATCH_DATA);
break;
case '+':
- result = reg_match_last(MATCH_DATA);
+ result = rb_reg_match_last(MATCH_DATA);
break;
default:
- Bug("unexpected back-ref");
+ rb_bug("unexpected back-ref");
}
break;
case NODE_HASH:
{
NODE *list;
- VALUE hash = hash_new();
+ VALUE hash = rb_hash_new();
VALUE key, val;
list = node->nd_head;
@@ -1999,17 +2396,17 @@ rb_eval(self, node)
key = rb_eval(self, list->nd_head);
list = list->nd_next;
if (list == 0)
- Bug("odd number list for Hash");
+ rb_bug("odd number list for Hash");
val = rb_eval(self, list->nd_head);
list = list->nd_next;
- hash_aset(hash, key, val);
+ rb_hash_aset(hash, key, val);
}
result = hash;
}
break;
case NODE_ZARRAY: /* zero length list */
- result = ary_new();
+ result = rb_ary_new();
break;
case NODE_ARRAY:
@@ -2018,7 +2415,7 @@ rb_eval(self, node)
int i;
i = node->nd_alen;
- ary = ary_new2(i);
+ ary = rb_ary_new2(i);
for (i=0;node;node=node->nd_next) {
RARRAY(ary)->ptr[i++] = rb_eval(self, node->nd_head);
RARRAY(ary)->len = i;
@@ -2029,7 +2426,7 @@ rb_eval(self, node)
break;
case NODE_STR:
- result = str_new3(node->nd_lit);
+ result = rb_str_new3(node->nd_lit);
break;
case NODE_DSTR:
@@ -2040,36 +2437,39 @@ rb_eval(self, node)
VALUE str, str2;
NODE *list = node->nd_next;
- str = str_new3(node->nd_lit);
+ str = rb_str_new3(node->nd_lit);
while (list) {
- if (nd_type(list->nd_head) == NODE_STR) {
- str2 = list->nd_head->nd_lit;
- }
- else {
- if (nd_type(list->nd_head) == NODE_EVSTR) {
+ if (list->nd_head) {
+ switch (nd_type(list->nd_head)) {
+ case NODE_STR:
+ str2 = list->nd_head->nd_lit;
+ break;
+ case NODE_EVSTR:
rb_in_eval++;
- eval_tree = 0;
- list->nd_head = compile(list->nd_head->nd_lit);
+ list->nd_head = compile(list->nd_head->nd_lit,0);
+ ruby_eval_tree = 0;
rb_in_eval--;
- if (nerrs > 0) {
- compile_error("string expand");
+ if (ruby_nerrs > 0) {
+ compile_error("string expansion");
}
+ /* fall through */
+ default:
+ str2 = rb_eval(self, list->nd_head);
+ str2 = rb_obj_as_string(str2);
+ break;
}
- str2 = rb_eval(self, list->nd_head);
- str2 = obj_as_string(str2);
- }
- if (str2) {
- str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
+ rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
+ if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
}
list = list->nd_next;
}
switch (nd_type(node)) {
case NODE_DREGX:
- result = reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
+ result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
node->nd_cflag);
break;
case NODE_DREGX_ONCE: /* regexp expand once */
- result = reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
+ result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
node->nd_cflag);
nd_set_type(node, NODE_LIT);
node->nd_lit = result;
@@ -2093,9 +2493,10 @@ rb_eval(self, node)
break;
case NODE_ATTRSET:
- if (the_frame->argc != 1)
- ArgError("Wrong # of arguments(%d for 1)", the_frame->argc);
- result = rb_ivar_set(self, node->nd_vid, the_frame->argv[0]);
+ if (ruby_frame->argc != 1)
+ rb_raise(rb_eArgError, "Wrong # of arguments(%d for 1)",
+ ruby_frame->argc);
+ result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]);
break;
case NODE_DEFN:
@@ -2104,28 +2505,51 @@ rb_eval(self, node)
VALUE origin;
int noex;
- body = search_method(the_class, node->nd_mid, &origin);
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class to add method");
+ }
+ if (ruby_class == rb_cObject && node->nd_mid == init) {
+ rb_warn("re-defining Object#initialize may cause infinite loop");
+ }
+ body = search_method(ruby_class, node->nd_mid, &origin);
if (body) {
- if (origin == (VALUE)the_class) {
- Warning("discarding old %s", rb_id2name(node->nd_mid));
+ if (origin == ruby_class) {
+ if (safe_level >= 3) {
+ rb_raise(rb_eSecurityError, "re-defining method prohibited");
+ }
+ if (RTEST(rb_verbose)) {
+ rb_warning("discarding old %s", rb_id2name(node->nd_mid));
+ }
}
rb_clear_cache_by_id(node->nd_mid);
}
- if (FL_TEST(the_scope,SCOPE_PRIVATE)) {
+ if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
noex = NOEX_PRIVATE;
}
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
else {
noex = NOEX_PUBLIC;
}
- rb_add_method(the_class, node->nd_mid, node->nd_defn, noex);
- if (FL_TEST(the_class, FL_SINGLETON)) {
- VALUE recv = rb_iv_get(the_class, "__attached__");
- rb_funcall(recv, rb_intern("singleton_method_added"),
+ if (body && origin == ruby_class && body->nd_noex & NOEX_UNDEF) {
+ noex |= NOEX_UNDEF;
+ }
+ rb_add_method(ruby_class, node->nd_mid, node->nd_defn, noex);
+ if (scope_vmode == SCOPE_MODFUNC) {
+ rb_add_method(rb_singleton_class(ruby_class),
+ node->nd_mid, node->nd_defn, NOEX_PUBLIC);
+ rb_funcall(ruby_class, rb_intern("singleton_method_added"),
+ 1, INT2FIX(node->nd_mid));
+ }
+ if (FL_TEST(ruby_class, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(ruby_class, "__attached__"),
+ rb_intern("singleton_method_added"),
1, INT2FIX(node->nd_mid));
}
else {
- rb_funcall(the_class, rb_intern("method_added"),
+ rb_funcall(ruby_class, rb_intern("method_added"),
1, INT2FIX(node->nd_mid));
}
result = Qnil;
@@ -2135,28 +2559,38 @@ rb_eval(self, node)
case NODE_DEFS:
if (node->nd_defn) {
VALUE recv = rb_eval(self, node->nd_recv);
- VALUE class;
- NODE *body;
+ VALUE klass;
+ NODE *body = 0;
if (FIXNUM_P(recv)) {
- TypeError("Can't define method \"%s\" for Fixnum",
- rb_id2name(node->nd_mid));
+ rb_raise(rb_eTypeError, "Can't define method \"%s\" for Fixnum",
+ rb_id2name(node->nd_mid));
}
if (NIL_P(recv)) {
- TypeError("Can't define method \"%s\" for nil",
- rb_id2name(node->nd_mid));
+ rb_raise(rb_eTypeError, "Can't define method \"%s\" for nil",
+ rb_id2name(node->nd_mid));
}
if (rb_special_const_p(recv)) {
- TypeError("Can't define method \"%s\" for special constants",
- rb_id2name(node->nd_mid));
+ rb_raise(rb_eTypeError,
+ "Can't define method \"%s\" for special constants",
+ rb_id2name(node->nd_mid));
}
- class = rb_singleton_class(recv);
- if (st_lookup(RCLASS(class)->m_tbl, node->nd_mid, &body)) {
- Warning("redefine %s", rb_id2name(node->nd_mid));
+ if (rb_safe_level() >= 4 && !FL_TEST(recv, FL_TAINT)) {
+ rb_raise(rb_eSecurityError, "can't define singleton method");
+ }
+ klass = rb_singleton_class(recv);
+ if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
+ if (safe_level >= 3) {
+ rb_raise(rb_eSecurityError, "re-defining method prohibited");
+ }
+ if (RTEST(rb_verbose)) {
+ rb_warning("redefine %s", rb_id2name(node->nd_mid));
+ }
}
rb_clear_cache_by_id(node->nd_mid);
- rb_add_method(class, node->nd_mid, node->nd_defn, NOEX_PUBLIC);
+ rb_add_method(klass, node->nd_mid, node->nd_defn,
+ NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
rb_funcall(recv, rb_intern("singleton_method_added"),
1, INT2FIX(node->nd_mid));
result = Qnil;
@@ -2168,20 +2602,41 @@ rb_eval(self, node)
VALUE origin;
NODE *body;
- body = search_method(the_class, node->nd_mid, &origin);
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class to undef method");
+ }
+ if (ruby_class == rb_cObject) {
+ rb_secure(4);
+ }
+ body = search_method(ruby_class, node->nd_mid, &origin);
if (!body || !body->nd_body) {
- NameError("undefined method `%s' for class `%s'",
- rb_id2name(node->nd_mid), rb_class2name((VALUE)the_class));
+ char *s0 = " class";
+ VALUE klass = ruby_class;
+
+ if (FL_TEST(ruby_class, FL_SINGLETON)) {
+ VALUE obj = rb_iv_get(ruby_class, "__attached__");
+ switch (TYPE(obj)) {
+ case T_MODULE:
+ case T_CLASS:
+ klass = obj;
+ s0 = "";
+ }
+ }
+ rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
+ rb_id2name(node->nd_mid),s0,rb_class2name(klass));
}
rb_clear_cache_by_id(node->nd_mid);
- rb_add_method(the_class, node->nd_mid, 0, NOEX_PUBLIC);
+ rb_add_method(ruby_class, node->nd_mid, 0, NOEX_PUBLIC);
result = Qnil;
}
break;
case NODE_ALIAS:
- rb_alias(the_class, node->nd_new, node->nd_old);
- rb_funcall(the_class, rb_intern("method_added"),
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class to make alias");
+ }
+ rb_alias(ruby_class, node->nd_new, node->nd_old);
+ rb_funcall(ruby_class, rb_intern("method_added"),
1, INT2FIX(node->nd_mid));