1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-02-05 10:27:34 +00:00
parent 06d4e3b42d
commit 9b64dfe3b8
22 changed files with 893 additions and 448 deletions

View file

@ -1,3 +1,38 @@
Fri Feb 5 03:26:56 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
* ruby.c (proc_options): -e without program prints error.
Fri Feb 5 00:01:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (terms): needed to clear heredoc_end.
* numeric.c (flo_div): allow float division by zero.
Thu Feb 4 11:56:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* missing/strtod.c: for compatibility.
* configure.in (strtod): add strtod compatible check.
* numeric.c (rb_num2long): missing/vsnprintf.c does not supprt
floating points.
* numeric.c (flo_to_s): ditto.
Wed Feb 3 23:02:12 1999 Yoshida Masato <yoshidam@yoshidam.net>
* regex.c (re_compile_pattern): use ismbchar() to get next char.
* regex.c (re_search): wrong mbchar shift.
* re.c (rb_reg_search): needed to reset $KCODE after match.
* regex.c (re_compile_fastmap): mbchars should match with \w.
Wed Feb 3 22:35:12 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* parse.y (yylex): too big float raise warning, not error.
Tue Feb 2 23:41:42 1999 Yoshida Masato <yoshidam@yoshidam.net> Tue Feb 2 23:41:42 1999 Yoshida Masato <yoshidam@yoshidam.net>
* regex.c (re_match): wrong boundary. * regex.c (re_match): wrong boundary.

View file

@ -153,6 +153,7 @@ missing/strdup.c
missing/strerror.c missing/strerror.c
missing/strftime.c missing/strftime.c
missing/strstr.c missing/strstr.c
missing/strtod.c
missing/strtol.c missing/strtol.c
missing/strtoul.c missing/strtoul.c
missing/vsnprintf.c missing/vsnprintf.c

View file

@ -18,7 +18,7 @@ AUTOCONF = autoconf
@SET_MAKE@ @SET_MAKE@
prefix = @prefix@ prefix = @prefix@
CFLAGS = @CFLAGS@ -I@srcdir@ -I@includedir@ CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLIBS = EXTLIBS =
LIBS = @LIBS@ $(EXTLIBS) LIBS = @LIBS@ $(EXTLIBS)
@ -186,6 +186,9 @@ strftime.o: @srcdir@/missing/strftime.c
strstr.o: @srcdir@/missing/strstr.c strstr.o: @srcdir@/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c
strtod.o: @srcdir@/missing/strtod.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtod.c
strtol.o: @srcdir@/missing/strtol.c strtol.o: @srcdir@/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c

453
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -38,12 +38,12 @@ AC_CANONICAL_HOST
dnl checks for fat-binary dnl checks for fat-binary
fat_binary=no fat_binary=no
AC_ARG_ENABLE( fat-binary, AC_ARG_ENABLE(fat-binary,
[--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ], [--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ],
[ fat_binary=$enableval ] ) [fat_binary=$enableval])
if test "$fat_binary" = yes ; then if test "$fat_binary" = yes ; then
AC_MSG_CHECKING( target architecture ) AC_MSG_CHECKING(target architecture)
case "$host_os" in case "$host_os" in
rhapsody*) rhapsody*)
@ -105,24 +105,26 @@ AC_CHECK_SIZEOF(void*)
AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double) AC_CHECK_SIZEOF(double)
AC_MSG_CHECKING(for prototypes) AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
AC_CACHE_VAL(rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);], [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
rb_cv_have_prototypes=yes, rb_cv_have_prototypes=yes,
rb_cv_have_prototypes=no)]) rb_cv_have_prototypes=no)])
AC_MSG_RESULT($rb_cv_have_prototypes)
if test "$rb_cv_have_prototypes" = yes; then if test "$rb_cv_have_prototypes" = yes; then
AC_DEFINE(HAVE_PROTOTYPES) AC_DEFINE(HAVE_PROTOTYPES)
fi fi
AC_MSG_CHECKING(token paste string) AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
AC_TRY_COMPILE([#define paste(a,b) a##b], [AC_TRY_COMPILE([#define paste(a,b) a##b],
[ int xy = 1; return paste(x,y);], [int xy = 1; return paste(x,y);],
AC_DEFINE(TOKEN_PASTE(x,y),[x##y]) AC_MSG_RESULT(ANSI), rb_cv_tokenpaste=ansi,
AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y]) AC_MSG_RESULT(KnR1)) rb_cv_tokenpaste=knr)])
if test "$rb_cv_tokenpaste" = ansi; then
AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
else
AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
fi
AC_MSG_CHECKING(for variable length prototypes and stdarg.h) AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
AC_CACHE_VAL(rb_cv_stdarg,
[AC_TRY_COMPILE([ [AC_TRY_COMPILE([
#include <stdarg.h> #include <stdarg.h>
int foo(int x, ...) { int foo(int x, ...) {
@ -136,17 +138,14 @@ int foo(int x, ...) {
], [return foo(10, "", 3.14);], ], [return foo(10, "", 3.14);],
rb_cv_stdarg=yes, rb_cv_stdarg=yes,
rb_cv_stdarg=no)]) rb_cv_stdarg=no)])
AC_MSG_RESULT($rb_cv_stdarg)
if test "$rb_cv_stdarg" = yes; then if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES) AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi fi
AC_MSG_CHECKING(for gcc attribute noreturn) AC_CACHE_CHECK(for gcc attribute noreturn, rb_cv_have_attr_noreturn,
AC_CACHE_VAL(rb_cv_have_attr_noreturn,
[AC_TRY_COMPILE([void exit(int x) __attribute__ ((noreturn));], [], [AC_TRY_COMPILE([void exit(int x) __attribute__ ((noreturn));], [],
rb_cv_have_attr_noreturn=yes, rb_cv_have_attr_noreturn=yes,
rb_cv_have_attr_noreturn=no)]) rb_cv_have_attr_noreturn=no)])
AC_MSG_RESULT($rb_cv_have_attr_noreturn)
if test "$rb_cv_have_attr_noreturn" = yes; then if test "$rb_cv_have_attr_noreturn" = yes; then
AC_DEFINE(HAVE_ATTR_NORETURN) AC_DEFINE(HAVE_ATTR_NORETURN)
fi fi
@ -203,8 +202,7 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL) AC_DEFINE(POSIX_SIGNAL)
else else
AC_MSG_CHECKING(for BSD signal semantics) AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
AC_CACHE_VAL(rb_cv_bsd_signal,
[AC_TRY_RUN([ [AC_TRY_RUN([
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
@ -225,8 +223,8 @@ main()
} }
], ],
rb_cv_bsd_signal=yes, rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
rb_cv_bsd_signal=no)]) rb_cv_bsd_signal=no)])
AC_MSG_RESULT($rb_cv_bsd_signal)
if test "$rb_cv_bsd_signal" = yes; then if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL) AC_DEFINE(BSD_SIGNAL)
fi fi
@ -236,32 +234,57 @@ if test "$ac_cv_func_setpgrp2" = yes; then
AC_DEFINE(BSD_GETPGRP, getpgrp2) AC_DEFINE(BSD_GETPGRP, getpgrp2)
AC_DEFINE(BSD_SETPGRP, setpgrp2) AC_DEFINE(BSD_SETPGRP, setpgrp2)
else else
AC_MSG_CHECKING(whether getpgrp() has arg) AC_CACHE_CHECK(whether getpgrp() has arg, rb_cv_bsdgetpgrp,
AC_CACHE_VAL(rb_cv_bsdgetpgrp,
[AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], [AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);],
rb_cv_bsdgetpgrp=yes, rb_cv_bsdgetpgrp=yes,
rb_cv_bsdgetpgrp=no)]) rb_cv_bsdgetpgrp=no)])
AC_MSG_RESULT($rb_cv_bsdgetpgrp)
if test "$rb_cv_bsdgetpgrp" = yes; then if test "$rb_cv_bsdgetpgrp" = yes; then
AC_DEFINE(BSD_GETPGRP, getpgrp) AC_DEFINE(BSD_GETPGRP, getpgrp)
fi fi
AC_MSG_CHECKING(whether setpgrp() has args) AC_CACHE_CHECK(whether setpgrp() has args, rb_cv_bsdsetpgrp,
AC_CACHE_VAL(rb_cv_bsdsetpgrp,
[AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(1, 1);], [AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(1, 1);],
rb_cv_bsdsetpgrp=yes, rb_cv_bsdsetpgrp=yes,
rb_cv_bsdsetpgrp=no)]) rb_cv_bsdsetpgrp=no)])
AC_MSG_RESULT($rb_cv_bsdsetpgrp)
if test "$rb_cv_bsdsetpgrp" = yes; then if test "$rb_cv_bsdsetpgrp" = yes; then
AC_DEFINE(BSD_SETPGRP, setpgrp) AC_DEFINE(BSD_SETPGRP, setpgrp)
fi fi
fi fi
AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
[AC_TRY_RUN([
double strtod ();
int
main()
{
{
/* Some versions of Linux strtod mis-parse strings with leading '+'. */
char *string = " +69";
char *term;
double value;
value = strtod(string, &term);
if (value != 69 || term != (string + 4))
exit(1);
}
{
/* Under Solaris 2.4, strtod returns the wrong value for the
terminating character under some conditions. */
char *string = "NaN";
char *term;
strtod(string, &term);
if (term != string && *(term - 1) == 0)
exit(1);
}
exit(0);
}
], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_CHAR_UNSIGNED AC_CHAR_UNSIGNED
AC_MSG_CHECKING(whether right shift preserve sign bit) AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
AC_CACHE_VAL(rb_cv_rshift_sign,
[AC_TRY_RUN([ [AC_TRY_RUN([
int int
main() main()
@ -272,15 +295,15 @@ main()
} }
], ],
rb_cv_rshift_sign=yes, rb_cv_rshift_sign=yes,
rb_cv_rshift_sign=no)]) rb_cv_rshift_sign=no,
AC_MSG_RESULT($rb_cv_rshift_sign) rb_cv_rshift_sign=yes)])
if test "$rb_cv_rshift_sign" = yes; then if test "$rb_cv_rshift_sign" = yes; then
AC_DEFINE(RSHIFT(x,y), ((x)>>y)) AC_DEFINE(RSHIFT(x,y), ((x)>>y))
else else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y)) AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi fi
AC_MSG_CHECKING([count field in FILE structures]) AC_MSG_CHECKING(count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt, AC_CACHE_VAL(rb_cv_fcnt,
[AC_TRY_COMPILE([#include <stdio.h>], [AC_TRY_COMPILE([#include <stdio.h>],
[FILE *f = stdin; f->_cnt = 0;], rb_cv_fcnt="_cnt", ) [FILE *f = stdin; f->_cnt = 0;], rb_cv_fcnt="_cnt", )
@ -313,8 +336,7 @@ AC_ARG_WITH(dln-a-out, [--with-dln-a-out use dln_a_out if possible], [
case "$host_os" in case "$host_os" in
linux*) linux*)
AC_MSG_CHECKING(whether ELF binaries are produced) AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
AC_CACHE_VAL(rb_cv_binary_elf,
[AC_TRY_RUN([ [AC_TRY_RUN([
/* Test for whether ELF binaries are produced */ /* Test for whether ELF binaries are produced */
#include <fcntl.h> #include <fcntl.h>
@ -334,8 +356,7 @@ main() {
], ],
rb_cv_binary_elf=yes, rb_cv_binary_elf=yes,
rb_cv_binary_elf=no, rb_cv_binary_elf=no,
[:])]) rb_cv_binary_elf=yes)])
AC_MSG_RESULT($rb_cv_binary_elf)
if test "$rb_cv_binary_elf" = no; then if test "$rb_cv_binary_elf" = no; then
with_dln_a_out=yes with_dln_a_out=yes
host_os=${host_os}-a_out host_os=${host_os}-a_out
@ -435,9 +456,8 @@ fi
dln_a_out_works=no dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then if test "$ac_cv_header_a_out_h" = yes; then
if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
AC_MSG_CHECKING(whether matz's dln works)
cat confdefs.h > config.h cat confdefs.h > config.h
AC_CACHE_VAL(rb_cv_dln_a_out, AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
[AC_TRY_COMPILE([ [AC_TRY_COMPILE([
#define USE_DLN_A_OUT #define USE_DLN_A_OUT
#include "dln.c" #include "dln.c"
@ -445,7 +465,6 @@ if test "$ac_cv_header_a_out_h" = yes; then
[], [],
rb_cv_dln_a_out=yes, rb_cv_dln_a_out=yes,
rb_cv_dln_a_out=no)]) rb_cv_dln_a_out=no)])
AC_MSG_RESULT($rb_cv_dln_a_out)
if test "$rb_cv_dln_a_out" = yes; then if test "$rb_cv_dln_a_out" = yes; then
dln_a_out_works=yes dln_a_out_works=yes
AC_DEFINE(USE_DLN_A_OUT) AC_DEFINE(USE_DLN_A_OUT)
@ -512,8 +531,8 @@ case "$host_os" in
AC_CHECK_LIB(signal, _harderr) AC_CHECK_LIB(signal, _harderr)
AC_CHECK_LIB(hmem, hmemset) AC_CHECK_LIB(hmem, hmemset)
AC_CHECK_FUNCS(select) AC_CHECK_FUNCS(select)
AC_MSG_CHECKING(whether PD libc _dtos18 fail to convert big number) AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
AC_CACHE_VAL(rb_cv_missing__dtos18, rb_cv_missing__dtos18,
[AC_TRY_RUN( [AC_TRY_RUN(
changequote(<<, >>)dnl changequote(<<, >>)dnl
<< <<
@ -526,13 +545,12 @@ main ()
} }
>>, >>,
changequote([, ])dnl changequote([, ])dnl
rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no)]) rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
AC_MSG_RESULT($rb_cv_missing__dtos18)
if test "$rb_cv_missing__dtos18" = yes; then if test "$rb_cv_missing__dtos18" = yes; then
AC_DEFINE(MISSING__DTOS18) AC_DEFINE(MISSING__DTOS18)
fi fi
AC_MSG_CHECKING(whether PD libc fconvert fail to round) AC_CACHE_CHECK(whether PD libc fconvert fail to round,
AC_CACHE_VAL(rb_cv_missing_fconvert, rb_cv_missing_fconvert,
[AC_TRY_RUN( [AC_TRY_RUN(
changequote(<<, >>)dnl changequote(<<, >>)dnl
<< <<
@ -546,8 +564,7 @@ main ()
} }
>>, >>,
changequote([, ])dnl changequote([, ])dnl
rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no)]) rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
AC_MSG_RESULT($rb_cv_missing_fconvert)
if test "$rb_cv_missing_fconvert" = yes; then if test "$rb_cv_missing_fconvert" = yes; then
AC_DEFINE(MISSING_FCONVERT) AC_DEFINE(MISSING_FCONVERT)
fi fi

View file

@ -519,7 +519,7 @@ if $extlist.size > 0
if File.exist?(f) if File.exist?(f)
$extinit += format("\ $extinit += format("\
\tInit_%s();\n\ \tInit_%s();\n\
\trb_provide(\"%s.o\");\n\ \trb_provide(\"%s.so\");\n\
", t, t) ", t, t)
$extobjs = "" unless $extobjs $extobjs = "" unless $extobjs
$extobjs += "ext/" $extobjs += "ext/"

View file

@ -1,11 +1,11 @@
English.rb access global variables by english names English.rb access global variables by english names
Env.rb access environment variables as globals Env.rb access environment variables as globals
README this file README this file
base64.rb encode/decode base64 (bit obsolete) base64.rb encode/decode base64 (obsolete)
cgi-lib.rb decode CGI data cgi-lib.rb decode CGI data
complex.rb complex number suppor complex.rb complex number suppor
date.rb date object (compatible) date.rb date object (compatible)
date2.rb date object based on Julian date date2.rb yet another (better) date object
debug.rb ruby debugger debug.rb ruby debugger
delegate.rb delegate messages to other object delegate.rb delegate messages to other object
e2mmap.rb exception utilities e2mmap.rb exception utilities
@ -15,6 +15,7 @@ finalize.rb add finalizer to the object
find.rb traverse directory tree find.rb traverse directory tree
ftools.rb file tools ftools.rb file tools
ftplib.rb ftp access library ftplib.rb ftp access library
getoptlong.rb GNU getoptlong compatible
getopts.rb parse command line options getopts.rb parse command line options
importenv.rb access environment variables as globals importenv.rb access environment variables as globals
jcode.rb japanese text handling (replace String methods) jcode.rb japanese text handling (replace String methods)
@ -29,12 +30,12 @@ open3.rb open subprocess connection stdin/stdout/stderr
ostruct.rb python style object ostruct.rb python style object
parsearg.rb argument parser using getopts parsearg.rb argument parser using getopts
parsedate.rb parse date string parsedate.rb parse date string
ping.rb ping.rb check whether host is up, using TCP echo.
profile.rb ruby profiler profile.rb ruby profiler
pstore.rb persistent object strage using marshal pstore.rb persistent object strage using marshal
rational.rb rational number support rational.rb rational number support
readbytes.rb define IO#readbytes readbytes.rb define IO#readbytes
shell.rb shell like operation under Ruby (imcomlete) shell.rb shell like operation under Ruby (imcomplete)
shellwords.rb split into words like shell shellwords.rb split into words like shell
singleton.rb singleton design pattern library singleton.rb singleton design pattern library
sync.rb 2 phase lock sync.rb 2 phase lock
@ -43,19 +44,5 @@ tempfile.rb temporary file that automatically removed
thread.rb thread support thread.rb thread support
thwait.rb thread syncronization class thwait.rb thread syncronization class
timeout.rb provids timeout timeout.rb provids timeout
tk.rb Tk interface
tkafter.rb
tkbgerror.rb Tk error module
tkcanvas.rb Tk canvas interface
tkclass.rb provides generic names for Tk classes
tkdialog.rb Tk dialog class
tkentry.rb Tk entry class
tkfont.rb Tk font support
tkmenubar.rb TK menubar utility
tkmngfocus.rb focus manager
tkpalette.rb pallete support
tkscrollbox.rb scroll box, also example of compound widget
tktext.rb text classes
tkvirtevent.rb virtual event support
tracer.rb execution tracer tracer.rb execution tracer
weakref.rb weak reference class weakref.rb weak reference class

View file

@ -25,6 +25,20 @@
# #
# print CGI.header("HTTP/1.0 200 OK", "Content-Type: text/html") # print CGI.header("HTTP/1.0 200 OK", "Content-Type: text/html")
# print CGI.header # == print CGI.header("Content-Type: text/html") # print CGI.header # == print CGI.header("Content-Type: text/html")
#
# make HTML tag string
# CGI.tag("element", {"attribute_name"=>"attribute_value"}){"content"}
#
# print CGI.tag("HTML"){
# CGI.tag("HEAD"){ CGI.tag("TITLE"){"TITLE"} } +
# CGI.tag("BODY"){
# CGI.tag("FORM", {"ACTION"=>"test.rb", "METHOD"=>"POST"}){
# CGI.tag("INPUT", {"TYPE"=>"submit", "VALUE"=>"submit"})
# } +
# CGI.tag("HR")
# }
# }
# if running on Windows(IIS or PWS) then change cwd. # if running on Windows(IIS or PWS) then change cwd.
if ENV['SERVER_SOFTWARE'] =~ /^Microsoft-/ then if ENV['SERVER_SOFTWARE'] =~ /^Microsoft-/ then
@ -67,7 +81,13 @@ class CGI < SimpleDelegator
str.gsub!(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") } str.gsub!(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
str str
end end
module_function :escape, :unescape
# escape HTML
def escapeHTML(str)
str.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
module_function :escape, :unescape, :escapeHTML
def initialize(input = $stdin) def initialize(input = $stdin)
@ -97,12 +117,12 @@ class CGI < SimpleDelegator
if ENV.has_key?('HTTP_COOKIE') if ENV.has_key?('HTTP_COOKIE')
@cookie = {} @cookie = {}
ENV['HTTP_COOKIE'].split("; ").each do |x| ENV['HTTP_COOKIE'].split("; ").each do |x|
key, val = x.split(/=/,2).collect{|x|unescape(x)} key, val = x.split(/=/,2).collect{|x|unescape(x)}
if @cookie.include?(key) if @cookie.include?(key)
@cookie[key] += "\0" + (val or "") @cookie[key] += "\0" + (val or "")
else else
@cookie[key] = (val or "") @cookie[key] = (val or "")
end end
end end
end end
end end
@ -123,6 +143,13 @@ class CGI < SimpleDelegator
(options['secure'] ? '; secure' : '') (options['secure'] ? '; secure' : '')
end end
def CGI.tag(element, attributes = {})
"<" + escapeHTML(element) + attributes.collect{|name, value|
" " + escapeHTML(name) + '="' + escapeHTML(value) + '"'
}.to_s + ">" +
(iterator? ? yield.to_s + "</" + escapeHTML(element) + ">" : "")
end
def CGI.message(msg, title = "", header = ["Content-Type: text/html"]) def CGI.message(msg, title = "", header = ["Content-Type: text/html"])
print CGI.header(*header) print CGI.header(*header)
print "<html><head><title>" print "<html><head><title>"

View file

@ -9,7 +9,7 @@ module ParseDate
'thu' => 4, 'fri' => 5, 'sat' => 6 } 'thu' => 4, 'fri' => 5, 'sat' => 6 }
DAYPAT = DAYS.keys.join('|') DAYPAT = DAYS.keys.join('|')
def parsedate(date) def parsedate(date, guess=false)
# part of ISO 8601 # part of ISO 8601
# yyyy-mm-dd | yyyy-mm | yyyy # yyyy-mm-dd | yyyy-mm | yyyy
# date hh:mm:ss | date Thh:mm:ss # date hh:mm:ss | date Thh:mm:ss
@ -63,6 +63,19 @@ module ParseDate
mon = MONTHS[$2.downcase] mon = MONTHS[$2.downcase]
year = $3.to_i year = $3.to_i
end end
if guess
if year < 100
if year >= 69
year += 1900
else
year += 2000
end
end
elsif date.sub!(/(\d+)-(#{MONTHPAT})-(\d+)/i, ' ')
mday = $1.to_i
mon = MONTHS[$2.downcase]
year = $3.to_i
end
return year, mon, mday, hour, min, sec, zone, wday return year, mon, mday, hour, min, sec, zone, wday
end end

View file

@ -1,134 +1,139 @@
# =begin
# telnet.rb
# ver0.16 1998/10/09 telnet.rb ver0.161 1999/02/03
# Wakou Aoyama <wakou@fsinet.or.jp> Wakou Aoyama <wakou@fsinet.or.jp>
#
# ver0.16 1998/10/09 ver0.161 1999/02/03
# preprocess method change for the better select --> IO::select
# add binmode method.
# change default Binmode ver0.16 1998/10/09
# TRUE --> FALSE preprocess method change for the better
# add binmode method.
# ver0.15 1998/10/04 change default Binmode
# add telnetmode method. TRUE --> FALSE
#
# ver0.141 1998/09/22 ver0.15 1998/10/04
# change default prompt add telnetmode method.
# /[$%#>] $/ --> /[$%#>] \Z/
# ver0.141 1998/09/22
# ver0.14 1998/09/01 change default prompt
# IAC WILL SGA send EOL --> CR+NULL /[$%#>] $/ --> /[$%#>] \Z/
# IAC WILL SGA IAC DO BIN send EOL --> CR
# NONE send EOL --> LF ver0.14 1998/09/01
# add Dump_log option. IAC WILL SGA send EOL --> CR+NULL
# IAC WILL SGA IAC DO BIN send EOL --> CR
# ver0.13 1998/08/25 NONE send EOL --> LF
# add print method. add Dump_log option.
#
# ver0.122 1998/08/05 ver0.13 1998/08/25
# support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com> add print method.
# socket.<< --> socket.write
# ver0.122 1998/08/05
# ver0.121 1998/07/15 support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
# string.+= --> string.concat socket.<< --> socket.write
#
# ver0.12 1998/06/01 ver0.121 1998/07/15
# add timeout, waittime. string.+= --> string.concat
#
# ver0.11 1998/04/21 ver0.12 1998/06/01
# add realtime output. add timeout, waittime.
#
# ver0.10 1998/04/13 ver0.11 1998/04/21
# first release. add realtime output.
#
# == make new Telnet object ver0.10 1998/04/13
# host = Telnet.new({"Binmode" => FALSE, default: FALSE first release.
# "Host" => "localhost", default: "localhost"
# "Output_log" => "output_log", default: not output == make new Telnet object
# "Dump_log" => "dump_log", default: not output host = Telnet.new({"Binmode" => FALSE, default: FALSE
# "Port" => 23, default: 23 "Host" => "localhost", default: "localhost"
# "Prompt" => /[$%#>] \Z/, default: /[$%#>] \Z/ "Output_log" => "output_log", default: not output
# "Telnetmode" => TRUE, default: TRUE "Dump_log" => "dump_log", default: not output
# "Timeout" => 10, default: 10 "Port" => 23, default: 23
# "Waittime" => 0}) default: 0 "Prompt" => /[$%#>] \Z/, default: /[$%#>] \Z/
# "Telnetmode" => TRUE, default: TRUE
# if set "Telnetmode" option FALSE. not TELNET command interpretation. "Timeout" => 10, default: 10
# "Waittime" is time to confirm "Prompt". There is a possibility that "Waittime" => 0}) default: 0
# the same character as "Prompt" is included in the data, and, when
# the network or the host is very heavy, the value is enlarged. if set "Telnetmode" option FALSE. not TELNET command interpretation.
# "Waittime" is time to confirm "Prompt". There is a possibility that
# == wait for match the same character as "Prompt" is included in the data, and, when
# line = host.waitfor(/match/) the network or the host is very heavy, the value is enlarged.
# line = host.waitfor({"Match" => /match/,
# "String" => "string", == wait for match
# "Timeout" => secs}) line = host.waitfor(/match/)
# if set "String" option. Match = Regexp.new(quote(string)) line = host.waitfor({"Match" => /match/,
# "String" => "string",
# realtime output. of cource, set sync=TRUE or flush is necessary. "Timeout" => secs})
# host.waitfor(/match/){|c| print c } if set "String" option. Match = Regexp.new(quote(string))
# host.waitfor({"Match" => /match/,
# "String" => "string", realtime output. of cource, set sync=TRUE or flush is necessary.
# "Timeout" => secs}){|c| print c} host.waitfor(/match/){|c| print c }
# host.waitfor({"Match" => /match/,
# == send string and wait prompt "String" => "string",
# line = host.cmd("string") "Timeout" => secs}){|c| print c}
# line = host.cmd({"String" => "string",
# "Prompt" => /[$%#>] \Z/, == send string and wait prompt
# "Timeout" => 10}) line = host.cmd("string")
# line = host.cmd({"String" => "string",
# realtime output. of cource, set sync=TRUE or flush is necessary. "Prompt" => /[$%#>] \Z/,
# host.cmd("string"){|c| print c } "Timeout" => 10})
# host.cmd({"String" => "string",
# "Prompt" => /[$%#>] \Z/, realtime output. of cource, set sync=TRUE or flush is necessary.
# "Timeout" => 10}){|c| print c } host.cmd("string"){|c| print c }
# host.cmd({"String" => "string",
# == send string "Prompt" => /[$%#>] \Z/,
# host.print("string") "Timeout" => 10}){|c| print c }
#
# == turn telnet command interpretation == send string
# host.telnetmode # turn on/off host.print("string")
# host.telnetmode(TRUE) # on
# host.telnetmode(FALSE) # off == turn telnet command interpretation
# host.telnetmode # turn on/off
# == toggle newline translation host.telnetmode(TRUE) # on
# host.binmode # turn TRUE/FALSE host.telnetmode(FALSE) # off
# host.binmode(TRUE) # no translate newline
# host.binmode(FALSE) # translate newline == toggle newline translation
# host.binmode # turn TRUE/FALSE
# == login host.binmode(TRUE) # no translate newline
# host.login("username", "password") host.binmode(FALSE) # translate newline
# host.login({"Name" => "username",
# "Password" => "password", == login
# "Prompt" => /[$%#>] \Z/, host.login("username", "password")
# "Timeout" => 10}) host.login({"Name" => "username",
# "Password" => "password",
# realtime output. of cource, set sync=TRUE or flush is necessary. "Prompt" => /[$%#>] \Z/,
# host.login("username", "password"){|c| print c } "Timeout" => 10})
# host.login({"Name" => "username",
# "Password" => "password", realtime output. of cource, set sync=TRUE or flush is necessary.
# "Prompt" => /[$%#>] \Z/, host.login("username", "password"){|c| print c }
# "Timeout" => 10}){|c| print c } host.login({"Name" => "username",
# "Password" => "password",
# and Telnet object has socket class methods "Prompt" => /[$%#>] \Z/,
# "Timeout" => 10}){|c| print c }
# == sample
# localhost = Telnet.new({"Host" => "localhost", and Telnet object has socket class methods
# "Timeout" => 10,
# "Prompt" => /[$%#>] \Z/}) == sample
# localhost.login("username", "password"){|c| print c } localhost = Telnet.new({"Host" => "localhost",
# localhost.cmd("command"){|c| print c } "Timeout" => 10,
# localhost.close "Prompt" => /[$%#>] \Z/})
# localhost.login("username", "password"){|c| print c }
# == sample 2 localhost.cmd("command"){|c| print c }
# checks a POP server to see if you have mail. localhost.close
#
# pop = Telnet.new({"Host" => "your_destination_host_here", == sample 2
# "Port" => 110, checks a POP server to see if you have mail.
# "Telnetmode" => FALSE,
# "Prompt" => /^\+OK/}) pop = Telnet.new({"Host" => "your_destination_host_here",
# pop.cmd("user " + "your_username_here"){|c| print c} "Port" => 110,
# pop.cmd("pass " + "your_password_here"){|c| print c} "Telnetmode" => FALSE,
# pop.cmd("list"){|c| print c} "Prompt" => /^\+OK/})
pop.cmd("user " + "your_username_here"){|c| print c}
pop.cmd("pass " + "your_password_here"){|c| print c}
pop.cmd("list"){|c| print c}
=end
require "socket" require "socket"
require "delegate" require "delegate"

266
missing/strtod.c Normal file
View file

@ -0,0 +1,266 @@
/*
* strtod.c --
*
* Source code for the "strtod" library procedure.
*
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id$
*/
#include "config.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <ctype.h>
#include <errno.h>
extern int errno;
#ifndef __STDC__
# ifdef __GNUC__
# define const __const__
# else
# define const
# endif
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
static int maxExponent = 511; /* Largest possible base 10 exponent. Any
* exponent larger than this will already
* produce underflow or overflow, so there's
* no need to worry about additional digits.
*/
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
10., /* is 10^2^i. Used to convert decimal */
100., /* exponents into floating-point numbers. */
1.0e4,
1.0e8,
1.0e16,
1.0e32,
1.0e64,
1.0e128,
1.0e256
};
/*
*----------------------------------------------------------------------
*
* strtod --
*
* This procedure converts a floating-point number from an ASCII
* decimal representation to internal double-precision format.
*
* Results:
* The return value is the double-precision floating-point
* representation of the characters in string. If endPtr isn't
* NULL, then *endPtr is filled in with the address of the
* next character after the last one that was part of the
* floating-point number.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
double
strtod(string, endPtr)
const char *string; /* A decimal ASCII floating-point number,
* optionally preceded by white space.
* Must have form "-I.FE-X", where I is the
* integer part of the mantissa, F is the
* fractional part of the mantissa, and X
* is the exponent. Either of the signs
* may be "+", "-", or omitted. Either I
* or F may be omitted, or both. The decimal
* point isn't necessary unless F is present.
* The "E" may actually be an "e". E and X
* may both be omitted (but not just one).
*/
char **endPtr; /* If non-NULL, store terminating character's
* address here. */
{
int sign, expSign = FALSE;
double fraction, dblExp, *d;
register const char *p;
register int c;
int exp = 0; /* Exponent read from "EX" field. */
int fracExp = 0; /* Exponent that derives from the fractional
* part. Under normal circumstatnces, it is
* the negative of the number of digits in F.
* However, if I is very long, the last digits
* of I get dropped (otherwise a long I with a
* large negative exponent could cause an
* unnecessary overflow on I alone). In this
* case, fracExp is incremented one for each
* dropped digit. */
int mantSize; /* Number of digits in mantissa. */
int decPt; /* Number of mantissa digits BEFORE decimal
* point. */
const char *pExp; /* Temporarily holds location of exponent
* in string. */
/*
* Strip off leading blanks and check for a sign.
*/
p = string;
while (isspace(*p)) {
p += 1;
}
if (*p == '-') {
sign = TRUE;
p += 1;
} else {
if (*p == '+') {
p += 1;
}
sign = FALSE;
}
/*
* Count the number of digits in the mantissa (including the decimal
* point), and also locate the decimal point.
*/
decPt = -1;
for (mantSize = 0; ; mantSize += 1)
{
c = *p;
if (!isdigit(c)) {
if ((c != '.') || (decPt >= 0)) {
break;
}
decPt = mantSize;
}
p += 1;
}
/*
* Now suck up the digits in the mantissa. Use two integers to
* collect 9 digits each (this is faster than using floating-point).
* If the mantissa has more than 18 digits, ignore the extras, since
* they can't affect the value anyway.
*/
pExp = p;
p -= mantSize;
if (decPt < 0) {
decPt = mantSize;
} else {
mantSize -= 1; /* One of the digits was the point. */
}
if (mantSize > 18) {
fracExp = decPt - 18;
mantSize = 18;
} else {
fracExp = decPt - mantSize;
}
if (mantSize == 0) {
fraction = 0.0;
p = string;
goto done;
} else {
int frac1, frac2;
frac1 = 0;
for ( ; mantSize > 9; mantSize -= 1)
{
c = *p;
p += 1;
if (c == '.') {
c = *p;
p += 1;
}
frac1 = 10*frac1 + (c - '0');
}
frac2 = 0;
for (; mantSize > 0; mantSize -= 1)
{
c = *p;
p += 1;
if (c == '.') {
c = *p;
p += 1;
}
frac2 = 10*frac2 + (c - '0');
}
fraction = (1.0e9 * frac1) + frac2;
}
/*
* Skim off the exponent.
*/
p = pExp;
if ((*p == 'E') || (*p == 'e')) {
p += 1;
if (*p == '-') {
expSign = TRUE;
p += 1;
} else {
if (*p == '+') {
p += 1;
}
expSign = FALSE;
}
while (isdigit(*p)) {
exp = exp * 10 + (*p - '0');
p += 1;
}
}
if (expSign) {
exp = fracExp - exp;
} else {
exp = fracExp + exp;
}
/*
* Generate a floating-point number that represents the exponent.
* Do this by processing the exponent one bit at a time to combine
* many powers of 2 of 10. Then combine the exponent with the
* fraction.
*/
if (exp < 0) {
expSign = TRUE;
exp = -exp;
} else {
expSign = FALSE;
}
if (exp > maxExponent) {
exp = maxExponent;
errno = ERANGE;
}
dblExp = 1.0;
for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
if (exp & 01) {
dblExp *= *d;
}
}
if (expSign) {
fraction /= dblExp;
} else {
fraction *= dblExp;
}
done:
if (endPtr != NULL) {
*endPtr = (char *) p;
}
if (sign) {
return -fraction;
}
return fraction;
}

View file

@ -416,7 +416,15 @@ BSD__ultoa(val, endp, base, octzero, xdigs)
#ifdef FLOATING_POINT #ifdef FLOATING_POINT
#include <math.h> #include <math.h>
#include "floatio.h" /* #include "floatio.h" */
#ifndef MAXEXP
# define MAXEXP 1024
#endif
#ifndef MAXFRACT
# define MAXFRACT 64
#endif
#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ #define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
#define DEFPREC 6 #define DEFPREC 6

View file

@ -184,11 +184,14 @@ flo_to_s(flt)
VALUE flt; VALUE flt;
{ {
char buf[24]; char buf[24];
char *s;
snprintf(buf, 24, "%.10g", RFLOAT(flt)->value); sprintf(buf, "%-.10g", RFLOAT(flt)->value);
if (strchr(buf, '.') == 0 && if (s = strchr(buf, ' ')) *s = '\0';
strcmp(buf, "Inf") != 0 && s = buf; if (s[0] == '-') s++;
strcmp(buf, "NaN") != 0) { if (strchr(s, '.') == 0 &&
strcmp(s, "Inf") != 0 &&
strcmp(s, "NaN") != 0) {
int len = strlen(buf); int len = strlen(buf);
char *ind = strchr(buf, 'e'); char *ind = strchr(buf, 'e');
@ -276,14 +279,11 @@ flo_div(x, y)
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
f_y = FIX2LONG(y); f_y = FIX2LONG(y);
if (f_y == 0) rb_num_zerodiv();
return rb_float_new(RFLOAT(x)->value / (double)f_y); return rb_float_new(RFLOAT(x)->value / (double)f_y);
case T_BIGNUM: case T_BIGNUM:
d = rb_big2dbl(y); d = rb_big2dbl(y);
if (d == 0.0) rb_num_zerodiv();
return rb_float_new(RFLOAT(x)->value / d); return rb_float_new(RFLOAT(x)->value / d);
case T_FLOAT: case T_FLOAT:
if (RFLOAT(y)->value == 0.0) rb_num_zerodiv();
return rb_float_new(RFLOAT(x)->value / RFLOAT(y)->value); return rb_float_new(RFLOAT(x)->value / RFLOAT(y)->value);
default: default:
return rb_num_coerce_bin(x, y); return rb_num_coerce_bin(x, y);
@ -668,8 +668,12 @@ rb_num2long(val)
return (long)(RFLOAT(val)->value); return (long)(RFLOAT(val)->value);
} }
else { else {
rb_raise(rb_eTypeError, "float %g out of rang of integer", char buf[24];
RFLOAT(val)->value); char *s;
sprintf(buf, "%-.10g", RFLOAT(val)->value);
if (s = strchr(buf, ' ')) *s = '\0';
rb_raise(rb_eTypeError, "float %s out of rang of integer", buf);
} }
case T_BIGNUM: case T_BIGNUM:

9
pack.c
View file

@ -16,7 +16,7 @@
#define define_swapx(x, xtype) \ #define define_swapx(x, xtype) \
static xtype \ static xtype \
TAKEN_PASTE(swap,x)(z) \ TOKEN_PASTE(swap,x)(z) \
xtype z; \ xtype z; \
{ \ { \
xtype r; \ xtype r; \
@ -64,9 +64,8 @@ define_swapx(s,short);
+(((x)&0x0000000000FF0000)<<24) \ +(((x)&0x0000000000FF0000)<<24) \
+(((x)&0x0000FF0000000000)>>24) \ +(((x)&0x0000FF0000000000)>>24) \
+(((x)&0x00000000FF000000)<<8) \ +(((x)&0x00000000FF000000)<<8) \
+(((x)&0x000000FF00000000)>>8) +(((x)&0x000000FF00000000)>>8) )
#else #else
define_swapx(l,long); define_swapx(l,long);
#endif #endif
#endif #endif
@ -223,7 +222,7 @@ endian()
#ifdef FLOAT_SWAPPER #ifdef FLOAT_SWAPPER
#define FLOAT_CONVWITH(y) FLOAT_SWAPPER y; #define FLOAT_CONVWITH(y) FLOAT_SWAPPER y;
#define HTONF(x,y) (memcpy(&y,&x,sizeof(float)), \ #define HTONF(x,y) (memcpy(&y,&x,sizeof(float)), \
x = htonf((FLOAT_SWAPPER)y), \ y = htonf((FLOAT_SWAPPER)y), \
memcpy(&x,&y,sizeof(float)), \ memcpy(&x,&y,sizeof(float)), \
x) x)
#define HTOVF(x,y) (memcpy(&y,&x,sizeof(float)), \ #define HTOVF(x,y) (memcpy(&y,&x,sizeof(float)), \
@ -249,7 +248,7 @@ endian()
#ifdef DOUBLE_SWAPPER #ifdef DOUBLE_SWAPPER
#define DOUBLE_CONVWITH(y) DOUBLE_SWAPPER y; #define DOUBLE_CONVWITH(y) DOUBLE_SWAPPER y;
#define HTOND(x,y) (memcpy(&y,&x,sizeof(double)), \ #define HTOND(x,y) (memcpy(&y,&x,sizeof(double)), \
x = htond((DOUBLE_SWAPPER)y), \ y = htond((DOUBLE_SWAPPER)y), \
memcpy(&x,&y,sizeof(double)), \ memcpy(&x,&y,sizeof(double)), \
x) x)
#define HTOVD(x,y) (memcpy(&y,&x,sizeof(double)), \ #define HTOVD(x,y) (memcpy(&y,&x,sizeof(double)), \

View file

@ -4590,6 +4590,7 @@ yycompile(f)
ruby__end__seen = 0; ruby__end__seen = 0;
ruby_eval_tree = 0; ruby_eval_tree = 0;
newline_seen = 0; newline_seen = 0;
heredoc_end = 0;
ruby_sourcefile = f; ruby_sourcefile = f;
ruby_in_compile = 1; ruby_in_compile = 1;
n = yyparse(); n = yyparse();
@ -5331,8 +5332,8 @@ arg_ambiguous()
rb_warning("ambiguous first argument; make sure"); rb_warning("ambiguous first argument; make sure");
} }
#ifndef atof #ifndef strtod
double atof(); double strtod ();
#endif #endif
static int static int
@ -5777,7 +5778,8 @@ retry:
if (is_float) { if (is_float) {
double d = strtod(tok(), 0); double d = strtod(tok(), 0);
if (errno == ERANGE) { if (errno == ERANGE) {
yyerror("Float out of range"); rb_warn("Float %s out of range", tok());
errno = 0;
} }
yylval.val = rb_float_new(d); yylval.val = rb_float_new(d);
return tFLOAT; return tFLOAT;

View file

@ -1679,6 +1679,7 @@ yycompile(f)
ruby__end__seen = 0; ruby__end__seen = 0;
ruby_eval_tree = 0; ruby_eval_tree = 0;
newline_seen = 0; newline_seen = 0;
heredoc_end = 0;
ruby_sourcefile = f; ruby_sourcefile = f;
ruby_in_compile = 1; ruby_in_compile = 1;
n = yyparse(); n = yyparse();
@ -2420,8 +2421,8 @@ arg_ambiguous()
rb_warning("ambiguous first argument; make sure"); rb_warning("ambiguous first argument; make sure");
} }
#ifndef atof #ifndef strtod
double atof(); double strtod ();
#endif #endif
static int static int
@ -2866,7 +2867,8 @@ retry:
if (is_float) { if (is_float) {
double d = strtod(tok(), 0); double d = strtod(tok(), 0);
if (errno == ERANGE) { if (errno == ERANGE) {
yyerror("Float out of range"); rb_warn("Float %s out of range", tok());
errno = 0;
} }
yylval.val = rb_float_new(d); yylval.val = rb_float_new(d);
return tFLOAT; return tFLOAT;

3
re.c
View file

@ -482,6 +482,9 @@ rb_reg_search(reg, str, start, reverse)
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len, result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
start, range, regs); start, range, regs);
if (FL_TEST(reg, KCODE_FIXED))
kcode_reset_option();
if (result == -2) { if (result == -2) {
rb_reg_raise(RREGEXP(reg)->str, RREGEXP(reg)->len, rb_reg_raise(RREGEXP(reg)->str, RREGEXP(reg)->len,
"Stack overfow in regexp matcher", reg); "Stack overfow in regexp matcher", reg);

22
regex.c
View file

@ -1025,6 +1025,7 @@ re_compile_pattern(pattern, size, bufp)
{ {
register char *b = bufp->buffer; register char *b = bufp->buffer;
register char *p = pattern; register char *p = pattern;
char *nextp;
char *pend = pattern + size; char *pend = pattern + size;
register unsigned c, c1; register unsigned c, c1;
char *p0; char *p0;
@ -2018,15 +2019,16 @@ re_compile_pattern(pattern, size, bufp)
normal_char: /* Expects the character in `c'. */ normal_char: /* Expects the character in `c'. */
had_mbchar = 0; had_mbchar = 0;
if (ismbchar(c)) { if (ismbchar(c)) {
had_mbchar = 0; had_mbchar = 1;
c1 = p - pattern; c1 = p - pattern;
} }
numeric_char: numeric_char:
nextp = p + ismbchar(c);
if (!pending_exact || pending_exact + *pending_exact + 1 != b if (!pending_exact || pending_exact + *pending_exact + 1 != b
|| *pending_exact >= (c1 ? 0176 : 0177) || *pending_exact >= (c1 ? 0176 : 0177)
|| *p == '+' || *p == '?' || *nextp == '+' || *nextp == '?'
|| *p == '*' || *p == '^' || *nextp == '*' || *nextp == '^'
|| *p == '{') { || *nextp == '{') {
laststart = b; laststart = b;
BUFPUSH(exactn); BUFPUSH(exactn);
pending_exact = b; pending_exact = b;
@ -2637,7 +2639,7 @@ re_compile_fastmap(bufp)
{ {
if (TRANSLATE_P()) if (TRANSLATE_P())
j = translate[j]; j = translate[j];
fastmap[j] = (j>0x7f?2:1); fastmap[j] = (j>0x7f?(ismbchar(j)?0:2):1);
} }
{ {
unsigned short size; unsigned short size;
@ -2846,15 +2848,17 @@ re_search(bufp, string, size, startpos, range, regs)
int len = ismbchar(c); int len = ismbchar(c);
if (fastmap[c]) if (fastmap[c])
break; break;
c = *p++; p += len;
range -= len; range -= len + 1;
c = *p;
if (fastmap[c] == 2) if (fastmap[c] == 2)
break; break;
} }
else else {
if (fastmap[MAY_TRANSLATE() ? translate[c] : c]) if (fastmap[MAY_TRANSLATE() ? translate[c] : c])
break; break;
range--; range--;
}
} }
startpos += irange - range; startpos += irange - range;
} }

18
ruby.c
View file

@ -279,6 +279,10 @@ proc_options(argcp, argvp)
case 'e': case 'e':
forbid_setid("-e"); forbid_setid("-e");
if (!argv[1]) {
fprintf(stderr, "%s: no code specified for -e\n", origargv[0]);
exit(2);
}
if (!e_fp) { if (!e_fp) {
e_tmpname = ruby_mktemp(); e_tmpname = ruby_mktemp();
if (!e_tmpname) rb_fatal("Can't mktemp"); if (!e_tmpname) rb_fatal("Can't mktemp");
@ -288,11 +292,9 @@ proc_options(argcp, argvp)
} }
if (script == 0) script = e_tmpname; if (script == 0) script = e_tmpname;
} }
if (argv[1]) { fputs(argv[1], e_fp);
fputs(argv[1], e_fp);
argc--, argv++;
}
putc('\n', e_fp); putc('\n', e_fp);
argc--, argv++;
break; break;
case 'r': case 'r':
@ -404,8 +406,8 @@ proc_options(argcp, argvp)
exit(0); exit(0);
} }
else { else {
printf("%s: invalid option --%s (-h will show valid options)\n", fprintf(stderr, "%s: invalid option --%s (-h will show valid options)\n",
origargv[0], s); origargv[0], s);
exit(2); exit(2);
} }
break; break;
@ -416,8 +418,8 @@ proc_options(argcp, argvp)
break; break;
default: default:
printf("%s: invalid option -%c (-h will show valid options)\n", fprintf(stderr, "%s: invalid option -%c (-h will show valid options)\n",
origargv[0], *s); origargv[0], *s);
exit(2); exit(2);
case 0: case 0:

View file

@ -183,7 +183,7 @@ ok(i>4)
check "exception"; check "exception";
begin begin
fail "this must be handled" raise "this must be handled"
ok(false) ok(false)
rescue rescue
ok(true) ok(true)
@ -191,7 +191,7 @@ end
$bad = true $bad = true
begin begin
fail "this must be handled no.2" raise "this must be handled no.2"
rescue rescue
if $bad if $bad
$bad = false $bad = false
@ -205,9 +205,9 @@ ok(true)
$string = "this must be handled no.3" $string = "this must be handled no.3"
begin begin
begin begin
fail "exception in rescue clause" raise "exception in rescue clause"
rescue rescue
fail $string raise $string
end end
ok(false) ok(false)
rescue rescue
@ -217,9 +217,9 @@ end
# exception in ensure clause # exception in ensure clause
begin begin
begin begin
fail "this must be handled no.4" raise "this must be handled no.4"
ensure ensure
fail "exception in ensure clause" raise "exception in ensure clause"
end end
ok(false) ok(false)
rescue rescue
@ -229,7 +229,7 @@ end
$bad = true $bad = true
begin begin
begin begin
fail "this must be handled no.5" raise "this must be handled no.5"
ensure ensure
$bad = false $bad = false
end end
@ -240,7 +240,7 @@ ok(!$bad)
$bad = true $bad = true
begin begin
begin begin
fail "this must be handled no.6" raise "this must be handled no.6"
ensure ensure
$bad = false $bad = false
end end
@ -355,7 +355,7 @@ ok($x[1] == 2)
ok(begin ok(begin
for k,v in $y for k,v in $y
fail if k*2 != v raise if k*2 != v
end end
true true
rescue rescue
@ -746,7 +746,7 @@ if defined? Process.kill
sleep 0.1 sleep 0.1
ok($x == 2) ok($x == 2)
trap "SIGINT", proc{fail "Interrupt"} trap "SIGINT", proc{raise "Interrupt"}
x = false x = false
begin begin

View file

@ -1140,7 +1140,7 @@ rb_str_gsub_bang(argc, argv, str)
} }
if (RSTRING(str)->len > offset) { if (RSTRING(str)->len > offset) {
len = bp - buf; len = bp - buf;
if (blen - len < RSTRING(str)->len - offset) { if (blen - len < RSTRING(str)->len - offset + 1) {
REALLOC_N(buf, char, len + RSTRING(str)->len - offset + 1); REALLOC_N(buf, char, len + RSTRING(str)->len - offset + 1);
bp = buf + len; bp = buf + len;
} }

View file

@ -1,2 +1,2 @@
#define RUBY_VERSION "1.3.1" #define RUBY_VERSION "1.3.1"
#define VERSION_DATE "99/02/03" #define VERSION_DATE "99/02/05"