summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-15 05:43:28 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-15 05:43:28 +0000
commit2631e080db1e1dde9603d6bfa6f2f6f21fd7c628 (patch)
tree4c4e8c773950d0e980c260123753b0a24d9cfc62
parentc25084921670dfe33a0871ee7b94c102fea0ea3a (diff)
ruby 1.1b9_20
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog15
-rw-r--r--config.guess3
-rw-r--r--configure2
-rw-r--r--configure.in2
-rw-r--r--error.c30
-rw-r--r--intern.h2
-rw-r--r--io.c2
-rw-r--r--random.c71
-rw-r--r--regex.c53
-rw-r--r--regex.h3
-rw-r--r--sample/test.rb1
-rw-r--r--util.c2
-rw-r--r--version.h4
13 files changed, 138 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b897d7a6f..da56f8ed34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
diff --git a/config.guess b/config.guess
index 2b0a7393fa..bc489a68bc 100644
--- a/config.guess
+++ b/config.guess
@@ -737,6 +737,9 @@ EOF
BeMac:BeOS:*:*)
echo powerpc-apple-beos
exit 0 ;;
+ BePC:BeOS:*:*)
+ echo i586-pc-beos
+ exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
diff --git a/configure b/configure
index 567c9cc1e6..de201811c6 100644
--- a/configure
+++ b/configure
@@ -2681,7 +2681,7 @@ 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\
diff --git a/configure.in b/configure.in
index 2665d083df..edc76766e2 100644
--- a/configure.in
+++ b/configure.in
@@ -151,7 +151,7 @@ AC_FUNC_VFORK
AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 setenv memmove mkdir strcasecmp strerror strftime\
strchr strstr strtoul strdup crypt flock)
-AC_CHECK_FUNCS(fmod killpg random wait4 waitpid syscall getcwd\
+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\
diff --git a/error.c b/error.c
index 937e497673..41578c9112 100644
--- a/error.c
+++ b/error.c
@@ -474,11 +474,29 @@ set_syserr(i, name)
int i;
char *name;
{
+#ifdef __BEOS__
+ VALUE *list;
+ int ix, offset;
+#endif
VALUE error = rb_define_class_under(mErrno, name, 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] = error;
}
+#endif
return error;
}
@@ -707,12 +725,24 @@ rb_sys_fail(mesg)
static void
init_syserr()
{
+#ifdef __BEOS__
+ int i, ix, offset;
+#endif
eSystemCallError = rb_define_class("SystemCallError", eStandardError);
rb_define_method(eSystemCallError, "errno", syserr_errno, 0);
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");
diff --git a/intern.h b/intern.h
index ced4e017fb..78d249b521 100644
--- a/intern.h
+++ b/intern.h
@@ -10,7 +10,7 @@ VALUE ary_new2 _((int));
VALUE ary_new3 __((int,...));
VALUE ary_new4 _((int, VALUE *));
VALUE ary_freeze _((VALUE));
-VALUE ary_aref(int, VALUE*, VALUE);
+VALUE ary_aref _((int, VALUE*, VALUE));
void ary_store _((VALUE, int, VALUE));
VALUE ary_push _((VALUE, VALUE));
VALUE ary_pop _((VALUE));
diff --git a/io.c b/io.c
index 4f01b4d6e0..14655c7538 100644
--- a/io.c
+++ b/io.c
@@ -99,7 +99,7 @@ struct timeval time_timeval();
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# else
# if defined(__BEOS__)
-# define ReadDataPending(fp) (fp->state._eof == 0)
+# define ReadDataPending(fp) (fp->_state._eof == 0)
# elif defined(USE_CWGUSI)
# define ReadDataPending(fp) (fp->state.eof == 0)
# else
diff --git a/random.c b/random.c
index 21e93f3b51..c819e101b1 100644
--- a/random.c
+++ b/random.c
@@ -28,6 +28,51 @@ struct timeval {
# include <stdlib.h>
#endif
+/*
+ * Prefer to use drand48, otherwise use random, or rand as a last resort.
+ */
+#ifdef HAVE_DRAND48
+
+#ifndef HAVE_DRAND48_DECL
+double drand48 _((void));
+void srand48 _((long));
+#endif
+
+#define SRANDOM(s) srand48((long)(s))
+#define RANDOM_NUMBER drand48()
+
+#else /* not HAVE_DRAND48 */
+
+/*
+ * The largest number returned by the random number generator is
+ * RANDOM_MAX. If we're using `rand' it's RAND_MAX, but if we're
+ * using `random' it's 2^31-1.
+ */
+#ifndef RANDOM_MAX
+# ifndef HAVE_RANDOM
+# define RANDOM_MAX RAND_MAX
+# else
+# define RANDOM_MAX 2147483647.0
+# endif
+#endif
+
+#ifdef HAVE_RANDOM
+
+#define RANDOM random
+#define SRANDOM srandom
+
+#else /* HAVE_RANDOM */
+
+#define RANDOM rand
+#define SRANDOM srand
+
+#endif /* HAVE_RANDOM */
+
+/* 0 <= RANDOM_NUMBER <= 1 */
+#define RANDOM_NUMBER (((double)RANDOM())/(double)RANDOM_MAX)
+
+#endif /* not HAVE_DRAND48 */
+
#ifdef HAVE_RANDOM
static int first = 1;
static char state[256];
@@ -61,19 +106,13 @@ f_srand(argc, argv, obj)
else {
setstate(state);
}
+#endif
- srandom(seed);
- old = saved_seed;
- saved_seed = seed;
-
- return int2inum(old);
-#else
- srand(seed);
+ SRANDOM(seed);
old = saved_seed;
saved_seed = seed;
return int2inum(old);
-#endif
}
static VALUE
@@ -93,18 +132,10 @@ f_rand(obj, vmax)
}
max = NUM2INT(vmax);
- if (max == 0) ArgError("rand(0)");
-
-#ifdef HAVE_RANDOM
- val = random();
-#else
- val = rand();
-#endif
-#ifdef RAND_MAX
- val = val * (double)max / (double)RAND_MAX;
-#else
- val = (val>>8) % max;
-#endif
+ if (max == 0) {
+ return float_new(RANDOM_NUMBER);
+ }
+ val = max*RANDOM_NUMBER;
if (val < 0) val = -val;
return int2inum(val);
diff --git a/regex.c b/regex.c
index b6fabb585d..9a28afa56b 100644
--- a/regex.c
+++ b/regex.c
@@ -32,13 +32,6 @@
#include <ctype.h>
#include <sys/types.h>
-#ifdef __MWERKS__
-#include "ruby.h"
-#endif
-
-#include "config.h"
-#include "defines.h"
-
#ifdef __STDC__
#define P(s) s
#define MALLOC_ARG_T size_t
@@ -49,6 +42,20 @@
#define const
#endif
+#ifdef __MWERKS__
+#include "ruby.h"
+#else
+
+#include "config.h"
+#include "defines.h"
+
+void *xmalloc P((unsigned long));
+void *xcalloc P((unsigned long,unsigned long));
+void *xrealloc P((void*,unsigned long));
+void free P((void*));
+
+#endif
+
/* #define NO_ALLOCA /* try it out for now */
#ifndef NO_ALLOCA
/* Make alloca work the best possible way. */
@@ -80,7 +87,7 @@ char *alloca();
#ifdef C_ALLOCA
#define FREE_VARIABLES() alloca(0)
#else
-#define FREE_VARIABLES() 0
+#define FREE_VARIABLES()
#endif
#define FREE_AND_RETURN_VOID(stackb) return
@@ -91,7 +98,7 @@ char *alloca();
(type*) memcpy(stackx, stackb, len * sizeof (type)))
#else /* NO_ALLOCA defined */
-#define RE_ALLOCATE malloc
+#define RE_ALLOCATE xmalloc
#define FREE_VAR(var) if (var) free(var); var = NULL
#define FREE_VARIABLES() \
@@ -824,14 +831,14 @@ print_compiled_pattern(bufp)
static char*
calculate_must_string(start, end)
- unsigned char *start;
- unsigned char *end;
+ char *start;
+ char *end;
{
int mcnt, mcnt2;
int max = 0;
- unsigned char *p = start;
- unsigned char *pend = end;
- unsigned char *must = 0;
+ char *p = start;
+ char *pend = end;
+ char *must = 0;
if (start == NULL) return 0;
@@ -1020,21 +1027,19 @@ re_compile_pattern(pattern, size, bufp)
/* Initialize the syntax table. */
init_syntax_once();
- if (bufp->allocated == 0)
- {
- bufp->allocated = INIT_BUF_SIZE;
- if (bufp->buffer)
- /* EXTEND_BUFFER loses when bufp->allocated is 0. */
- bufp->buffer = (char *) xrealloc (bufp->buffer, INIT_BUF_SIZE);
- else
- /* Caller did not allocate a buffer. Do it for them. */
+ if (bufp->allocated == 0) {
+ bufp->allocated = INIT_BUF_SIZE;
+ if (bufp->buffer)
+ /* EXTEND_BUFFER loses when bufp->allocated is 0. */
+ bufp->buffer = (char *) xrealloc (bufp->buffer, INIT_BUF_SIZE);
+ else
+ /* Caller did not allocate a buffer. Do it for them. */
bufp->buffer = (char *) xmalloc(INIT_BUF_SIZE);
if (!bufp->buffer) goto memory_exhausted;
begalt = b = bufp->buffer;
}
- while (p != pend)
- {
+ while (p != pend) {
PATFETCH(c);
switch (c)
diff --git a/regex.h b/regex.h
index 1d25ea62e1..406351afd7 100644
--- a/regex.h
+++ b/regex.h
@@ -169,12 +169,13 @@ extern long re_syntax_options;
#define MBCTYPE_EUC 1
#define MBCTYPE_SJIS 2
-extern const unsigned char *mbctab;
extern int current_mbctype;
#ifdef __STDC__
+extern const unsigned char *mbctab;
void mbcinit (int);
#else
+extern unsigned char *mbctab;
void mbcinit ();
#endif
diff --git a/sample/test.rb b/sample/test.rb
index 6b6150ab29..912f84e2d4 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -850,7 +850,6 @@ $x = ary.pack($format)
ary2 = $x.unpack($format)
ok(ary.length == ary2.length)
-p [ary.join(':'), ary2.join(':')]
ok(ary.join(':') == ary2.join(':'))
ok($x =~ /def/)
diff --git a/util.c b/util.c
index 8dea777ffa..f299c1cf04 100644
--- a/util.c
+++ b/util.c
@@ -10,6 +10,8 @@
************************************************/
+#include <stdio.h>
+
#define RUBY_NO_INLINE
#include "ruby.h"
diff --git a/version.h b/version.h
index 6d2eb3944a..bdc3d707c2 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "1.1b9_19"
-#define VERSION_DATE "98/05/13"
+#define RUBY_VERSION "1.1b9_20"
+#define VERSION_DATE "98/05/15"