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>
* regex.c (re_match): wrong boundary.

View file

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

View file

@ -18,7 +18,7 @@ AUTOCONF = autoconf
@SET_MAKE@
prefix = @prefix@
CFLAGS = @CFLAGS@ -I@srcdir@ -I@includedir@
CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLIBS =
LIBS = @LIBS@ $(EXTLIBS)
@ -186,6 +186,9 @@ strftime.o: @srcdir@/missing/strftime.c
strstr.o: @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
$(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
fat_binary=no
AC_ARG_ENABLE( fat-binary,
AC_ARG_ENABLE(fat-binary,
[--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ],
[ fat_binary=$enableval ] )
[fat_binary=$enableval])
if test "$fat_binary" = yes ; then
AC_MSG_CHECKING( target architecture )
AC_MSG_CHECKING(target architecture)
case "$host_os" in
rhapsody*)
@ -105,24 +105,26 @@ AC_CHECK_SIZEOF(void*)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_MSG_CHECKING(for prototypes)
AC_CACHE_VAL(rb_cv_have_prototypes,
AC_CACHE_CHECK(for prototypes, 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(token paste string)
AC_TRY_COMPILE([#define paste(a,b) a##b],
[ int xy = 1; return paste(x,y);],
AC_DEFINE(TOKEN_PASTE(x,y),[x##y]) AC_MSG_RESULT(ANSI),
AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y]) AC_MSG_RESULT(KnR1))
AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
[AC_TRY_COMPILE([#define paste(a,b) a##b],
[int xy = 1; return paste(x,y);],
rb_cv_tokenpaste=ansi,
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_VAL(rb_cv_stdarg,
AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
[AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
@ -136,17 +138,14 @@ int foo(int x, ...) {
], [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_CACHE_CHECK(for gcc attribute noreturn, 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
@ -203,8 +202,7 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
AC_MSG_CHECKING(for BSD signal semantics)
AC_CACHE_VAL(rb_cv_bsd_signal,
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
@ -225,8 +223,8 @@ main()
}
],
rb_cv_bsd_signal=yes,
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
AC_DEFINE(BSD_SIGNAL)
fi
@ -236,32 +234,57 @@ if test "$ac_cv_func_setpgrp2" = yes; then
AC_DEFINE(BSD_GETPGRP, getpgrp2)
AC_DEFINE(BSD_SETPGRP, setpgrp2)
else
AC_MSG_CHECKING(whether getpgrp() has arg)
AC_CACHE_VAL(rb_cv_bsdgetpgrp,
AC_CACHE_CHECK(whether getpgrp() has arg, rb_cv_bsdgetpgrp,
[AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);],
rb_cv_bsdgetpgrp=yes,
rb_cv_bsdgetpgrp=no)])
AC_MSG_RESULT($rb_cv_bsdgetpgrp)
if test "$rb_cv_bsdgetpgrp" = yes; then
AC_DEFINE(BSD_GETPGRP, getpgrp)
fi
AC_MSG_CHECKING(whether setpgrp() has args)
AC_CACHE_VAL(rb_cv_bsdsetpgrp,
AC_CACHE_CHECK(whether setpgrp() has args, rb_cv_bsdsetpgrp,
[AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(1, 1);],
rb_cv_bsdsetpgrp=yes,
rb_cv_bsdsetpgrp=no)])
AC_MSG_RESULT($rb_cv_bsdsetpgrp)
if test "$rb_cv_bsdsetpgrp" = yes; then
AC_DEFINE(BSD_SETPGRP, setpgrp)
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_CHAR_UNSIGNED
AC_MSG_CHECKING(whether right shift preserve sign bit)
AC_CACHE_VAL(rb_cv_rshift_sign,
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([
int
main()
@ -272,15 +295,15 @@ main()
}
],
rb_cv_rshift_sign=yes,
rb_cv_rshift_sign=no)])
AC_MSG_RESULT($rb_cv_rshift_sign)
rb_cv_rshift_sign=no,
rb_cv_rshift_sign=yes)])
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_MSG_CHECKING(count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[AC_TRY_COMPILE([#include <stdio.h>],
[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
linux*)
AC_MSG_CHECKING(whether ELF binaries are produced)
AC_CACHE_VAL(rb_cv_binary_elf,
AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
[AC_TRY_RUN([
/* Test for whether ELF binaries are produced */
#include <fcntl.h>
@ -334,8 +356,7 @@ main() {
],
rb_cv_binary_elf=yes,
rb_cv_binary_elf=no,
[:])])
AC_MSG_RESULT($rb_cv_binary_elf)
rb_cv_binary_elf=yes)])
if test "$rb_cv_binary_elf" = no; then
with_dln_a_out=yes
host_os=${host_os}-a_out
@ -435,9 +456,8 @@ fi
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
AC_MSG_CHECKING(whether matz's dln works)
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([
#define USE_DLN_A_OUT
#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=no)])
AC_MSG_RESULT($rb_cv_dln_a_out)
if test "$rb_cv_dln_a_out" = yes; then
dln_a_out_works=yes
AC_DEFINE(USE_DLN_A_OUT)
@ -512,8 +531,8 @@ case "$host_os" in
AC_CHECK_LIB(signal, _harderr)
AC_CHECK_LIB(hmem, hmemset)
AC_CHECK_FUNCS(select)
AC_MSG_CHECKING(whether PD libc _dtos18 fail to convert big number)
AC_CACHE_VAL(rb_cv_missing__dtos18,
AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
rb_cv_missing__dtos18,
[AC_TRY_RUN(
changequote(<<, >>)dnl
<<
@ -526,13 +545,12 @@ main ()
}
>>,
changequote([, ])dnl
rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no)])
AC_MSG_RESULT($rb_cv_missing__dtos18)
rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
if test "$rb_cv_missing__dtos18" = yes; then
AC_DEFINE(MISSING__DTOS18)
fi
AC_MSG_CHECKING(whether PD libc fconvert fail to round)
AC_CACHE_VAL(rb_cv_missing_fconvert,
AC_CACHE_CHECK(whether PD libc fconvert fail to round,
rb_cv_missing_fconvert,
[AC_TRY_RUN(
changequote(<<, >>)dnl
<<
@ -546,8 +564,7 @@ main ()
}
>>,
changequote([, ])dnl
rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no)])
AC_MSG_RESULT($rb_cv_missing_fconvert)
rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
if test "$rb_cv_missing_fconvert" = yes; then
AC_DEFINE(MISSING_FCONVERT)
fi

View file

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

View file

@ -1,11 +1,11 @@
English.rb access global variables by english names
Env.rb access environment variables as globals
README this file
base64.rb encode/decode base64 (bit obsolete)
base64.rb encode/decode base64 (obsolete)
cgi-lib.rb decode CGI data
complex.rb complex number suppor
date.rb date object (compatible)
date2.rb date object based on Julian date
date2.rb yet another (better) date object
debug.rb ruby debugger
delegate.rb delegate messages to other object
e2mmap.rb exception utilities
@ -15,6 +15,7 @@ finalize.rb add finalizer to the object
find.rb traverse directory tree
ftools.rb file tools
ftplib.rb ftp access library
getoptlong.rb GNU getoptlong compatible
getopts.rb parse command line options
importenv.rb access environment variables as globals
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
parsearg.rb argument parser using getopts
parsedate.rb parse date string
ping.rb
ping.rb check whether host is up, using TCP echo.
profile.rb ruby profiler
pstore.rb persistent object strage using marshal
rational.rb rational number support
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
singleton.rb singleton design pattern library
sync.rb 2 phase lock
@ -43,19 +44,5 @@ tempfile.rb temporary file that automatically removed
thread.rb thread support
thwait.rb thread syncronization class
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
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 # == 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 ENV['SERVER_SOFTWARE'] =~ /^Microsoft-/ then
@ -67,7 +81,13 @@ class CGI < SimpleDelegator
str.gsub!(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
str
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)
@ -97,12 +117,12 @@ class CGI < SimpleDelegator
if ENV.has_key?('HTTP_COOKIE')
@cookie = {}
ENV['HTTP_COOKIE'].split("; ").each do |x|
key, val = x.split(/=/,2).collect{|x|unescape(x)}
if @cookie.include?(key)
@cookie[key] += "\0" + (val or "")
else
@cookie[key] = (val or "")
end
key, val = x.split(/=/,2).collect{|x|unescape(x)}
if @cookie.include?(key)
@cookie[key] += "\0" + (val or "")
else
@cookie[key] = (val or "")
end
end
end
end
@ -123,6 +143,13 @@ class CGI < SimpleDelegator
(options['secure'] ? '; secure' : '')
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"])
print CGI.header(*header)
print "<html><head><title>"

View file

@ -9,7 +9,7 @@ module ParseDate
'thu' => 4, 'fri' => 5, 'sat' => 6 }
DAYPAT = DAYS.keys.join('|')
def parsedate(date)
def parsedate(date, guess=false)
# part of ISO 8601
# yyyy-mm-dd | yyyy-mm | yyyy
# date hh:mm:ss | date Thh:mm:ss
@ -63,6 +63,19 @@ module ParseDate
mon = MONTHS[$2.downcase]
year = $3.to_i
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
end

View file

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

View file

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

9
pack.c
View file

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

View file

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

View file

@ -1679,6 +1679,7 @@ yycompile(f)
ruby__end__seen = 0;
ruby_eval_tree = 0;
newline_seen = 0;
heredoc_end = 0;
ruby_sourcefile = f;
ruby_in_compile = 1;
n = yyparse();
@ -2420,8 +2421,8 @@ arg_ambiguous()
rb_warning("ambiguous first argument; make sure");
}
#ifndef atof
double atof();
#ifndef strtod
double strtod ();
#endif
static int
@ -2866,7 +2867,8 @@ retry:
if (is_float) {
double d = strtod(tok(), 0);
if (errno == ERANGE) {
yyerror("Float out of range");
rb_warn("Float %s out of range", tok());
errno = 0;
}
yylval.val = rb_float_new(d);
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,
start, range, regs);
if (FL_TEST(reg, KCODE_FIXED))
kcode_reset_option();
if (result == -2) {
rb_reg_raise(RREGEXP(reg)->str, RREGEXP(reg)->len,
"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 *p = pattern;
char *nextp;
char *pend = pattern + size;
register unsigned c, c1;
char *p0;
@ -2018,15 +2019,16 @@ re_compile_pattern(pattern, size, bufp)
normal_char: /* Expects the character in `c'. */
had_mbchar = 0;
if (ismbchar(c)) {
had_mbchar = 0;
had_mbchar = 1;
c1 = p - pattern;
}
numeric_char:
nextp = p + ismbchar(c);
if (!pending_exact || pending_exact + *pending_exact + 1 != b
|| *pending_exact >= (c1 ? 0176 : 0177)
|| *p == '+' || *p == '?'
|| *p == '*' || *p == '^'
|| *p == '{') {
|| *nextp == '+' || *nextp == '?'
|| *nextp == '*' || *nextp == '^'
|| *nextp == '{') {
laststart = b;
BUFPUSH(exactn);
pending_exact = b;
@ -2637,7 +2639,7 @@ re_compile_fastmap(bufp)
{
if (TRANSLATE_P())
j = translate[j];
fastmap[j] = (j>0x7f?2:1);
fastmap[j] = (j>0x7f?(ismbchar(j)?0:2):1);
}
{
unsigned short size;
@ -2846,15 +2848,17 @@ re_search(bufp, string, size, startpos, range, regs)
int len = ismbchar(c);
if (fastmap[c])
break;
c = *p++;
range -= len;
p += len;
range -= len + 1;
c = *p;
if (fastmap[c] == 2)
break;
}
else
else {
if (fastmap[MAY_TRANSLATE() ? translate[c] : c])
break;
range--;
range--;
}
}
startpos += irange - range;
}

18
ruby.c
View file

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

View file

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

View file

@ -1140,7 +1140,7 @@ rb_str_gsub_bang(argc, argv, str)
}
if (RSTRING(str)->len > offset) {
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);
bp = buf + len;
}

View file

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