Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3e0fed

Browse files
author
matz
committed
1.1c2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 2562004 commit e3e0fed

File tree

14 files changed

+1291
-50
lines changed

14 files changed

+1291
-50
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Mon Aug 10 14:05:30 1998 Yukihiro Matsumoto <[email protected]>
2+
3+
* process.c (f_system): removed fflush(stdin).
4+
5+
Fri Aug 7 17:44:44 1998 Yukihiro Matsumoto <[email protected]>
6+
7+
* error.c (err_snprintf): replace sprintf for fixed sized buffer,
8+
with snprintf to avoid buffer over-run. For systems which does
9+
dot provide snprintf, missing/snprintf.c added.
10+
111
Tue Jul 28 13:03:25 1998 Yukihiro Matsumoto <[email protected]>
212

313
* array.c (ary_s_new): argument to specify initial value is added.

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ missing/mkdir.c
151151
missing/nt.c
152152
missing/nt.h
153153
missing/setenv.c
154+
missing/snprintf.c
154155
missing/strcasecmp.c
155156
missing/strchr.c
156157
missing/strdup.c

Makefile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ mkdir.o: @srcdir@/missing/mkdir.c
147147
setenv.o: @srcdir@/missing/setenv.c
148148
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/setenv.c
149149

150+
snprintf.o: @srcdir@/missing/snprintf.c
151+
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/snprintf.c
152+
150153
strcasecmp.o: @srcdir@/missing/strcasecmp.c
151154
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strcasecmp.c
152155

configure

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,7 +2633,7 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
26332633
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o"
26342634

26352635
for ac_func in dup2 setenv memmove mkdir strcasecmp strerror strftime\
2636-
strchr strstr strtoul strdup crypt flock
2636+
strchr strstr strtoul strdup crypt flock snprintf
26372637
do
26382638
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
26392639
echo "configure:2640: checking for $ac_func" >&5
@@ -3925,12 +3925,15 @@ esac
39253925

39263926

39273927

3928+
3929+
3930+
39283931
if test "$prefix" = NONE; then
39293932
prefix=$ac_default_prefix
39303933
fi
39313934

39323935
if test "$fat_binary" = yes ; then
3933-
CFLAGS="$CFLAGS -pipe $ARCH_FLAG"
3936+
CFLAGS="$CFLAGS $ARCH_FLAG"
39343937
fi
39353938

39363939
LIBRUBY='libruby.a'
@@ -3958,9 +3961,19 @@ if test "$enable_shared" = 'yes'; then
39583961
LIBRUBYARG='-L./ -lruby'
39593962
fi
39603963

3961-
if test "$host_os" = "rhapsody" ; then
3962-
CFLAGS="$CFLAGS -no-precomp"
3963-
fi
3964+
case "$host_os" in
3965+
nextstep*)
3966+
CFLAGS="$CFLAGS -pipe"
3967+
;;
3968+
openstep*)
3969+
CFLAGS="$CFLAGS -pipe"
3970+
;;
3971+
rhasody*)
3972+
CFLAGS="$CFLAGS -pipe -no-precomp"
3973+
;;
3974+
*)
3975+
;;
3976+
esac
39643977

39653978

39663979

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ AC_FUNC_ALLOCA
159159
AC_FUNC_VFORK
160160
AC_FUNC_MEMCMP
161161
AC_REPLACE_FUNCS(dup2 setenv memmove mkdir strcasecmp strerror strftime\
162-
strchr strstr strtoul strdup crypt flock)
162+
strchr strstr strtoul strdup crypt flock snprintf)
163163
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
164164
truncate chsize times utimes fcntl lockf setitimer\
165165
setruid seteuid setreuid setrgid setegid setregid\

error.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ extern int sourceline;
3232
int nerrs;
3333

3434
static void
35-
err_sprintf(buf, fmt, args)
35+
err_snprintf(buf, len, fmt, args)
3636
char *buf, *fmt;
37+
int len;
3738
va_list args;
3839
{
3940
if (!sourcefile) {
40-
vsprintf(buf, fmt, args);
41+
vsnprintf(buf, len, fmt, args);
4142
}
4243
else {
43-
sprintf(buf, "%s:%d: ", sourcefile, sourceline);
44-
vsprintf((char*)buf+strlen(buf), fmt, args);
44+
int n = snprintf(buf, len, "%s:%d: ", sourcefile, sourceline);
45+
if (len > n) {
46+
vsnprintf((char*)buf+n, len-n, fmt, args);
47+
}
4548
}
4649
}
4750

@@ -53,7 +56,7 @@ err_print(fmt, args)
5356
{
5457
char buf[BUFSIZ];
5558

56-
err_sprintf(buf, fmt, args);
59+
err_snprintf(buf, BUFSIZ, fmt, args);
5760
err_append(buf);
5861
}
5962

@@ -87,7 +90,7 @@ Error_Append(fmt, va_alist)
8790
char buf[BUFSIZ];
8891

8992
va_init_list(args, fmt);
90-
vsprintf(buf, fmt, args);
93+
vsnprintf(buf, BUFSIZ, fmt, args);
9194
va_end(args);
9295
err_append(buf);
9396
}
@@ -104,7 +107,7 @@ Warn(fmt, va_alist)
104107
char buf[BUFSIZ];
105108
va_list args;
106109

107-
sprintf(buf, "warning: %s", fmt);
110+
snprintf(buf, BUFSIZ, "warning: %s", fmt);
108111

109112
va_init_list(args, fmt);
110113
err_print(buf, args);
@@ -126,7 +129,7 @@ Warning(fmt, va_alist)
126129

127130
if (!RTEST(verbose)) return;
128131

129-
sprintf(buf, "warning: %s", fmt);
132+
snprintf(buf, BUFSIZ, "warning: %s", fmt);
130133

131134
va_init_list(args, fmt);
132135
err_print(buf, args);
@@ -145,7 +148,7 @@ Bug(fmt, va_alist)
145148
char buf[BUFSIZ];
146149
va_list args;
147150

148-
sprintf(buf, "[BUG] %s", fmt);
151+
snprintf(buf, BUFSIZ, "[BUG] %s", fmt);
149152
rb_in_eval = 0;
150153

151154
va_init_list(args, fmt);
@@ -566,7 +569,7 @@ Init_Exception()
566569
va_list args;\
567570
char buf[BUFSIZ];\
568571
va_init_list(args,fmt);\
569-
vsprintf(buf, fmt, args);\
572+
vsnprintf(buf, BUFSIZ, fmt, args);\
570573
va_end(args);\
571574
rb_raise(exc_new2(klass, buf));\
572575
}
@@ -677,7 +680,7 @@ Fatal(fmt, va_alist)
677680
char buf[BUFSIZ];
678681

679682
va_init_list(args, fmt);
680-
vsprintf(buf, fmt, args);
683+
vsnprintf(buf, BUFSIZ, fmt, args);
681684
va_end(args);
682685

683686
rb_in_eval = 0;
@@ -704,7 +707,7 @@ rb_sys_fail(mesg)
704707
}
705708
else {
706709
buf = ALLOCA_N(char, strlen(err)+1);
707-
sprintf(buf, "%s", err);
710+
strcpy(buf, err);
708711
}
709712

710713
errno = 0;

eval.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,11 +3748,11 @@ backtrace(lev)
37483748
ary = ary_new();
37493749
if (lev < 0) {
37503750
if (frame->last_func) {
3751-
sprintf(buf, "%s:%d:in `%s'", sourcefile, sourceline,
3751+
snprintf(buf, BUFSIZ, "%s:%d:in `%s'", sourcefile, sourceline,
37523752
rb_id2name(frame->last_func));
37533753
}
37543754
else {
3755-
sprintf(buf, "%s:%d", sourcefile, sourceline);
3755+
snprintf(buf, BUFSIZ, "%s:%d", sourcefile, sourceline);
37563756
}
37573757
ary_push(ary, str_new2(buf));
37583758
}
@@ -3764,12 +3764,12 @@ backtrace(lev)
37643764
}
37653765
while (frame && frame->file) {
37663766
if (frame->prev && frame->prev->last_func) {
3767-
sprintf(buf, "%s:%d:in `%s'",
3767+
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
37683768
frame->file, frame->line,
37693769
rb_id2name(frame->prev->last_func));
37703770
}
37713771
else {
3772-
sprintf(buf, "%s:%d", frame->file, frame->line);
3772+
snprintf(buf, BUFSIZ, "%s:%d", frame->file, frame->line);
37733773
}
37743774
ary_push(ary, str_new2(buf));
37753775
frame = frame->prev;

ext/socket/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
have_library("net", "socket")
1212
else
1313
test_func = "socket"
14-
have_library("socket", "socket")
1514
have_library("inet", "gethostbyname")
1615
have_library("nsl", "gethostbyname")
16+
have_library("socket", "socket")
1717
end
1818
have_header("sys/un.h")
1919
if have_func(test_func)

lib/matrix.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
22
# matrix.rb -
33
# $Release Version: 1.0$
4-
# $Revision: 1.5 $
5-
# $Date: 1998/07/14 14:35:18 $
4+
# $Revision: 1.6 $
5+
# $Date: 1998/07/31 03:39:49 $
66
# Original Version from Smalltalk-80 version
77
# on July 23, 1985 at 8:37:17 am
88
# by Keiju ISHITSUKA
@@ -179,7 +179,7 @@ module ExceptionForMatrix
179179
end
180180

181181
class Matrix
182-
@RCS_ID='-$Id: matrix.rb,v 1.5 1998/07/14 14:35:18 keiju Exp keiju $-'
182+
@RCS_ID='-$Id: matrix.rb,v 1.6 1998/07/31 03:39:49 keiju Exp keiju $-'
183183

184184
include ExceptionForMatrix
185185

@@ -361,7 +361,7 @@ def ==(other)
361361

362362
other.compare_by_row_vectors(@rows)
363363
end
364-
alias eqn? ==
364+
alias eql? ==
365365

366366
def compare_by_row_vectors(rows)
367367
return FALSE unless @rows.size == rows.size
@@ -515,7 +515,7 @@ def inverse_from(src)
515515
end
516516

517517
for i in 0 .. size
518-
continue if i == k
518+
next if i == k
519519
q = a[i][k] / akk
520520
a[i][k] = 0
521521

@@ -620,7 +620,7 @@ def rank
620620
break
621621
end
622622
end while a[i][k] == 0
623-
continue if nothing
623+
next if nothing
624624
a[i], a[k] = a[k], a[i]
625625
akk = a[k][k]
626626
end

lib/telnet.rb

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
#
22
# telnet.rb
3-
# ver0.12 1998/06/01
3+
# ver0.122 1998/08/05
44
# Wakou Aoyama <[email protected]>
55
#
6+
# ver0.122 1998/08/05
7+
# support for HP-UX 10.20 thanks to WATANABE Tetsuya <[email protected]>
8+
# socket.<< --> socket.write
9+
#
10+
# ver0.121 1998/07/15
11+
# string.+= --> string.concat
12+
#
13+
# ver0.12 1998/06/01
14+
# add timeout, waittime.
15+
#
16+
# ver0.11 1998/04/21
17+
# add realtime output.
18+
#
19+
# ver0.10 1998/04/13
20+
# first release.
21+
#
622
# == make new Telnet object
723
# host = Telnet.new({"Binmode" => TRUE, default: TRUE
824
# "Host" => "localhost", default: "localhost"
@@ -139,14 +155,14 @@ def initialize(options)
139155
end
140156

141157
message = "Trying " + @options["Host"] + "...\n"
142-
STDOUT << message
143-
@log << message if @options.include?("Output_log")
158+
STDOUT.write(message)
159+
@log.write(message) if @options.include?("Output_log")
144160

145161
is_timeout = timeout(@options["Timeout"]){
146162
begin
147163
@sock = TCPsocket.open(@options["Host"], @options["Port"])
148164
rescue
149-
@log << $! << "\n" if @options.include?("Output_log")
165+
@log.write($! + "\n") if @options.include?("Output_log")
150166
raise
151167
end
152168
}
@@ -155,8 +171,8 @@ def initialize(options)
155171
@sock.binmode if @options["Binmode"]
156172

157173
message = "Connected to " + @options["Host"] + ".\n"
158-
STDOUT << message
159-
@log << message if @options.include?("Output_log")
174+
STDOUT.write(message)
175+
@log.write(message) if @options.include?("Output_log")
160176

161177
super(@sock)
162178
end
@@ -166,7 +182,7 @@ def preprocess(str)
166182

167183
# respond to "IAC DO x" or "IAC DON'T x" with "IAC WON'T x"
168184
str.gsub!(/([^#{IAC}])?#{IAC}[#{DO}#{DONT}](.|\n)/no){
169-
@sock << IAC << WONT << $2
185+
@sock.write(IAC + WONT + $2)
170186
$1
171187
}
172188

@@ -175,7 +191,7 @@ def preprocess(str)
175191

176192
# respond to "IAC AYT" (are you there)
177193
str.gsub!(/([^#{IAC}])?#{IAC}#{AYT}/no){
178-
@sock << "nobody here but us pigeons" << CR
194+
@sock.write("nobody here but us pigeons" + CR)
179195
$1
180196
}
181197

@@ -212,7 +228,7 @@ def waitfor(options)
212228
ensure
213229
@log.print(buf) if @options.include?("Output_log")
214230
yield buf if iterator?
215-
line += buf
231+
line.concat(buf)
216232
end
217233
end
218234
line
@@ -231,7 +247,7 @@ def cmd(options)
231247
end
232248

233249
select(nil, [@sock])
234-
@sock << string.gsub(/\n/, CR) << CR
250+
@sock.write(string.gsub(/\n/, CR) + CR)
235251
if iterator?
236252
waitfor({"Prompt" => match, "Timeout" => timeout}){|c| yield c }
237253
else
@@ -249,14 +265,14 @@ def login(options, password = '')
249265

250266
if iterator?
251267
line = waitfor(/login[: ]*$/){|c| yield c }
252-
line += cmd({"String" => username,
253-
"Match" => /Password[: ]*$/}){|c| yield c }
254-
line += cmd(password){|c| yield c }
268+
line.concat( cmd({"String" => username,
269+
"Match" => /Password[: ]*$/}){|c| yield c } )
270+
line.concat( cmd(password){|c| yield c } )
255271
else
256272
line = waitfor(/login[: ]*$/)
257-
line += cmd({"String" => username,
258-
"Match" => /Password[: ]*$/})
259-
line += cmd(password)
273+
line.concat( cmd({"String" => username,
274+
"Match" => /Password[: ]*$/}) )
275+
line.concat( cmd(password) )
260276
end
261277
line
262278
end

0 commit comments

Comments
 (0)