summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--Makefile.in3
-rw-r--r--array.c2
-rw-r--r--ext/curses/extconf.rb1
-rw-r--r--ext/dbm/extconf.rb1
-rw-r--r--ext/etc/extconf.rb1
-rw-r--r--ext/extmk.rb.in17
-rw-r--r--ext/socket/extconf.rb1
-rw-r--r--gc.c9
-rw-r--r--intern.h1
-rw-r--r--lib/mkmf.rb41
-rw-r--r--object.c8
-rw-r--r--pack.c58
-rw-r--r--string.c17
-rw-r--r--time.c21
-rw-r--r--version.h4
16 files changed, 152 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index c868453f81..a2de4ca7f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Wed Apr 22 16:52:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_14.
+
+ * string.c (str_modify): check for embedded pointer reference.
+
+ * gc.c (obj_free): ditto.
+
+ * pack.c (pack_pack): p/P template to embed pointers.
+
+Wed Apr 22 00:07:10 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_rindex): embarrassing typo.
+
Tue Apr 21 12:31:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_13.
diff --git a/Makefile.in b/Makefile.in
index ebdaeb7fac..64ac30fef4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -10,7 +10,8 @@ YACC = @YACC@
PURIFY =
@SET_MAKE@
-CFLAGS = @CFLAGS@ -I@srcdir@
+prefix = @prefix@
+CFLAGS = @CFLAGS@ -I@includedir@ -I@srcdir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
LIBS = @LIBS@ $(EXTLIBS)
MISSING = @LIBOBJS@ @ALLOCA@
diff --git a/array.c b/array.c
index 3b9d0b923d..ca6ab3cad6 100644
--- a/array.c
+++ b/array.c
@@ -416,7 +416,7 @@ ary_rindex(ary, val)
VALUE ary;
VALUE val;
{
- int i = i<RARRAY(ary)->len;
+ int i = RARRAY(ary)->len;
while (i--) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 9b28437843..720bccb8d2 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -1,3 +1,4 @@
+require 'mkmf'
$CFLAGS="-I/usr/include/ncurses -I/usr/local/include/ncurses"
$LDFLAGS="-L/usr/local/lib"
make=FALSE
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 595640737d..38a0efbf19 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,3 +1,4 @@
+require 'mkmf'
$LDFLAGS = "-L/usr/local/lib"
have_library("gdbm", "dbm_open") or have_library("dbm", "dbm_open")
if have_func("dbm_open")
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 884de93ec8..a02ff8c091 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -1,3 +1,4 @@
+require 'mkmf'
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
a = have_func("getlogin")
b = have_func("getpwent")
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 2ea88ee2dd..5aba725301 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -59,13 +59,11 @@ end
if PLATFORM == "m68k-human"
CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
-LINK = "@CC@ -o conftest -I#{$topdir} " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s"
-CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} " + CFLAGS + " %s conftest.c"
else
CFLAGS = "@CFLAGS@"
-LINK = "@CC@ -o conftest -I#{$topdir} " + CFLAGS + " %s @LDFLAGS@ %s conftest.c %s"
-CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} " + CFLAGS + " %s conftest.c"
end
+LINK = "@CC@ -o conftest -I#{$topdir} " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s"
+CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} " + CFLAGS + " %s conftest.c"
if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM
$null = open("nul", "w")
@@ -76,6 +74,9 @@ end
$orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
+ if $DEBUG
+ return system(command)
+ end
$stderr.reopen($null)
$stdout.reopen($null)
r = system(command)
@@ -238,7 +239,8 @@ hdrdir = #{$topdir}
CC = @CC@
-CFLAGS = %s -I#{$topdir} %s #$CFLAGS %s
+prefix = @prefix@
+CFLAGS = %s -I@includedir@ -I#{$topdir} %s #$CFLAGS %s
DLDFLAGS = @DLDFLAGS@ #$LDFLAGS
LDSHARED = @LDSHARED@
", if $static then "" else "@CCDLFLAGS@" end, CFLAGS, $defs.join(" ")
@@ -274,6 +276,7 @@ libdir = @libdir@/$(RUBY_INSTALL_NAME)/@arch@
TARGET = %s.%s
INSTALL = %s@INSTALL@
+INSTALL_DATA = %s@INSTALL_DATA@
binsuffix = @binsuffix@
@@ -285,7 +288,7 @@ clean:; @rm -f *.o *.so *.sl
realclean: clean
", target,
- if $static then "o" else "@DLEXT@" end, $dots
+ if $static then "o" else "@DLEXT@" end, $dots, $dots
mfile.printf "\
@@ -298,7 +301,7 @@ install:
"
end
for rb in Dir["lib/*.rb"]
- mfile.printf "\t$(INSTALL) %s @libdir@/$(RUBY_INSTALL_NAME)\n", rb
+ mfile.printf "\t$(INSTALL_DATA) %s @libdir@/$(RUBY_INSTALL_NAME)\n", rb
end
mfile.printf "\n"
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index bbda95cf83..80bd74338c 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -1,3 +1,4 @@
+require 'mkmf'
$LDFLAGS = "-L/usr/local/lib"
case PLATFORM
when /mswin32/
diff --git a/gc.c b/gc.c
index 51dc8109ea..1642b4bf8b 100644
--- a/gc.c
+++ b/gc.c
@@ -418,6 +418,11 @@ gc_mark(ptr)
/* fall through */
case NODE_METHOD: /* 2 */
case NODE_NOT:
+ case NODE_GASGN:
+ case NODE_LASGN:
+ case NODE_DASGN:
+ case NODE_IASGN:
+ case NODE_CASGN:
obj = RANY(obj->as.node.u2.node);
goto Top;
@@ -652,7 +657,9 @@ obj_free(obj)
}
break;
case T_STRING:
- if (!RANY(obj)->as.string.orig) free(RANY(obj)->as.string.ptr);
+#define STR_NO_ORIG FL_USER3 /* copied from string.c */
+ if (!RANY(obj)->as.string.orig && FL_TEST(obj, STR_NO_ORIG))
+ free(RANY(obj)->as.string.ptr);
break;
case T_ARRAY:
if (RANY(obj)->as.array.ptr) free(RANY(obj)->as.array.ptr);
diff --git a/intern.h b/intern.h
index 6654640044..2b87408ac7 100644
--- a/intern.h
+++ b/intern.h
@@ -187,7 +187,6 @@ VALUE rb_inspect _((VALUE));
VALUE obj_is_instance_of _((VALUE, VALUE));
VALUE obj_is_kind_of _((VALUE, VALUE));
VALUE obj_alloc _((VALUE));
-int rb_obj2int _((VALUE));
VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE));
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index eb56585871..e4b589f52e 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -36,6 +36,7 @@ $install = CONFIG["INSTALL_PROGRAM"]
$install_data = CONFIG["INSTALL_DATA"]
if $install !~ /^\// then
$install = CONFIG["srcdir"]+"/"+$install
+ $install_data = CONFIG["srcdir"]+"/"+$install_data
end
if File.exist? $archdir + "/ruby.h"
@@ -47,25 +48,38 @@ else
exit 1
end
-nul = "> /dev/null"
-
CFLAGS = CONFIG["CFLAGS"]
if PLATFORM == "m68k-human"
- nul = "> nul"
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
end
-if $DEBUG
- nul = ""
+if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM
+ $null = open("nul", "w")
+else
+ $null = open("/dev/null", "w")
+end
+LINK = "#{CONFIG['CC']} -o conftest } -I#{CONFIG['includedir']} -I#{$srcdir} #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c #{CONFIG['LIBS']} %s"
+CPP = "#{CONFIG['CPP']} -E -I#{CONFIG['includedir']} -I#{$srcdir} #{CFLAGS} %s conftest.c"
+
+$orgerr = $stderr.dup
+$orgout = $stdout.dup
+def xsystem command
+ if $DEBUG
+ return system(command)
+ end
+ $stderr.reopen($null)
+ $stdout.reopen($null)
+ r = system(command)
+ $stderr.reopen($orgerr)
+ $stdout.reopen($orgout)
+ return r
end
-LINK = CONFIG["CC"]+" -o conftest -I#{$srcdir} " + CFLAGS + " %s " + CONFIG["LDFLAGS"] + " %s conftest.c " + CONFIG["LIBS"] + "%s " + nul + " 2>&1"
-CPP = CONFIG["CPP"] + " -E -I#{$srcdir} " + CFLAGS + " %s conftest.c " + nul + " 2>&1"
def try_link(libs)
- system(format(LINK, $CFLAGS, $LDFLAGS, libs))
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, libs))
end
def try_cpp
- system(format(CPP, $CFLAGS))
+ xsystem(format(CPP, $CFLAGS))
end
def have_library(lib, func)
@@ -241,7 +255,8 @@ hdrdir = #{$hdrdir}
CC = gcc
-CFLAGS = #{CONFIG["CCDLFLAGS"]} -I#{$hdrdir} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")}
+prefix = #{CONFIG["prefix"]}
+CFLAGS = #{CONFIG["CCDLFLAGS"]} -I#{CONFIG["includedir"]} -I#{$hdrdir} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")}
DLDFLAGS = #{CONFIG["DLDFLAGS"]} #{$LDFLAGS}
LDSHARED = #{CONFIG["LDSHARED"]}
@@ -258,6 +273,7 @@ OBJS = #{$objs}
TARGET = #{target}.#{CONFIG["DLEXT"]}
INSTALL = #{$install}
+INSTALL_DATA = #{$install_data}
binsuffix = #{CONFIG["binsuffix"]}
@@ -276,7 +292,7 @@ $(libdir)/$(TARGET): $(TARGET)
$(INSTALL) $(TARGET) $(libdir)/$(TARGET)
EOMF
for rb in Dir["lib/*.rb"]
- mfile.printf "\t$(INSTALL) %s %s\n", rb, $libdir
+ mfile.printf "\t$(INSTALL_DATA) %s %s\n", rb, $libdir
end
mfile.printf "\n"
@@ -335,9 +351,8 @@ EOMF
end
$local_libs = nil
-$libs = nil
+$libs = PLATFORM =~ /cygwin32/ ? nil : "-lc"
$objs = nil
$CFLAGS = nil
$LDFLAGS = nil
$defs = []
-
diff --git a/object.c b/object.c
index 88667e66f9..41acb4d021 100644
--- a/object.c
+++ b/object.c
@@ -743,14 +743,6 @@ rb_Integer(val)
return f_integer(Qnil, val);
}
-int
-rb_obj2int(obj)
- VALUE obj;
-{
- VALUE i = f_integer(Qnil, obj);
- return NUM2INT(i);
-}
-
static VALUE
to_flo(val)
VALUE val;
diff --git a/pack.c b/pack.c
index 52a0dd5027..6cd644c331 100644
--- a/pack.c
+++ b/pack.c
@@ -83,6 +83,18 @@ static char *toofew = "too few arguments";
static void encodes();
+static void
+pack_add_ptr(str, add)
+ VALUE str, add;
+{
+#define STR_NO_ORIG FL_USER3 /* copied from string.c */
+ if (!RSTRING(str)->orig) {
+ RSTRING(str)->orig = ary_new();
+ FL_SET(str, STR_NO_ORIG);
+ }
+ ary_push(RSTRING(str)->orig, add);
+}
+
static VALUE
pack_pack(ary, fmt)
VALUE ary, fmt;
@@ -463,6 +475,22 @@ pack_pack(ary, fmt)
}
break;
+ case 'P':
+ len = 1;
+ /* FALL THROUGH */
+ case 'p':
+ while (len-- > 0) {
+ char *t;
+ from = NEXTFROM;
+ if (NIL_P(from)) t = "";
+ else {
+ t = STR2CSTR(from);
+ pack_add_ptr(res, from);
+ }
+ str_cat(res, (char*)&t, sizeof(char*));
+ }
+ break;
+
default:
break;
}
@@ -926,6 +954,36 @@ pack_unpack(str, fmt)
s += len;
break;
+ case 'P':
+ if (sizeof(char *) <= send - s) {
+ char *t;
+ VALUE str = str_new(0, 0);
+ memcpy(&t, s, sizeof(char *));
+ s += sizeof(char *);
+ if (t)
+ str_cat(str, t, len);
+ ary_push(ary, str);
+ }
+ break;
+
+ case 'p':
+ if (len > (send - s) / sizeof(char *))
+ len = (send - s) / sizeof(char *);
+ while (len-- > 0) {
+ if (send - s < sizeof(char *))
+ break;
+ else {
+ char *t;
+ VALUE str = str_new(0, 0);
+ memcpy(&t, s, sizeof(char *));
+ s += sizeof(char *);
+ if (t)
+ str_cat(str, t, strlen(t));
+ ary_push(ary, str);
+ }
+ }
+ break;
+
default:
break;
}
diff --git a/string.c b/string.c
index 19321c09e5..45c01c6899 100644
--- a/string.c
+++ b/string.c
@@ -28,6 +28,7 @@ VALUE cString;
#define STR_FREEZE FL_USER1
#define STR_TAINT FL_USER2
+#define STR_NO_ORIG FL_USER3
void reg_prepare_re _((VALUE));
void kcode_reset_option _((void));
@@ -84,12 +85,12 @@ VALUE
str_new4(orig)
VALUE orig;
{
- if (RSTRING(orig)->orig) {
- return str_freeze(RSTRING(orig)->orig);
- }
- else if (FL_TEST(orig, STR_FREEZE)) {
+ if (FL_TEST(orig, STR_FREEZE)) {
return orig;
}
+ else if (RSTRING(orig)->orig && !FL_TEST(orig, STR_NO_ORIG)) {
+ return str_freeze(RSTRING(orig)->orig);
+ }
else {
NEWOBJ(str, struct RString);
OBJSETUP(str, cString, T_STRING);
@@ -110,7 +111,7 @@ str_assign(str, str2)
VALUE str, str2;
{
if (NIL_P(str2) || str == str2) return;
- if (!RSTRING(str)->orig && RSTRING(str)->ptr)
+ if ((!RSTRING(str)->orig||FL_TEST(str, STR_NO_ORIG)) && RSTRING(str)->ptr)
free(RSTRING(str)->ptr);
RSTRING(str)->ptr = RSTRING(str2)->ptr;
RSTRING(str)->len = RSTRING(str2)->len;
@@ -143,7 +144,7 @@ str_clone(orig)
{
VALUE str;
- if (RSTRING(orig)->orig)
+ if (RSTRING(orig)->orig && !FL_TEST(orig, STR_NO_ORIG))
str = str_new3(RSTRING(orig)->orig);
else
str = str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
@@ -336,7 +337,7 @@ str_modify(str)
}
if (FL_TEST(str, STR_FREEZE))
TypeError("can't modify frozen string");
- if (!RSTRING(str)->orig) return;
+ if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return;
ptr = RSTRING(str)->ptr;
RSTRING(str)->ptr = ALLOC_N(char, RSTRING(str)->len+1);
if (RSTRING(str)->ptr) {
@@ -367,7 +368,7 @@ VALUE
str_dup_frozen(str)
VALUE str;
{
- if (RSTRING(str)->orig) {
+ if (RSTRING(str)->orig && !FL_TEST(str, STR_NO_ORIG)) {
return str_freeze(RSTRING(str)->orig);
}
if (FL_TEST(str, STR_FREEZE))
diff --git a/time.c b/time.c
index 93011ff241..dbeafb4e55 100644
--- a/time.c
+++ b/time.c
@@ -150,6 +150,17 @@ static char *months [12] = {
"jul", "aug", "sep", "oct", "nov", "dec",
};
+static int
+obj2int(obj)
+ VALUE obj;
+{
+ if (TYPE(obj) == T_STRING) {
+ obj = str2inum(RSTRING(obj)->ptr, 10);
+ }
+
+ return NUM2INT(obj);
+}
+
static void
time_arg(argc, argv, args)
int argc;
@@ -171,7 +182,7 @@ time_arg(argc, argv, args)
rb_scan_args(argc, argv, "15", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5]);
}
- args[0] = rb_obj2int(v[0]);
+ args[0] = obj2int(v[0]);
if (args[0] < 70) args[0] += 100;
if (args[0] > 1900) args[0] -= 1900;
if (NIL_P(v[1])) {
@@ -189,25 +200,25 @@ time_arg(argc, argv, args)
char c = RSTRING(v[1])->ptr[0];
if ('0' <= c && c <= '9') {
- args[1] = rb_obj2int(v[1])-1;
+ args[1] = obj2int(v[1])-1;
}
}
}
else {
- args[1] = rb_obj2int(v[1]) - 1;
+ args[1] = obj2int(v[1]) - 1;
}
if (NIL_P(v[2])) {
args[2] = 1;
}
else {
- args[2] = rb_obj2int(v[2]);
+ args[2] = obj2int(v[2]);
}
for (i=3;i<6;i++) {
if (NIL_P(v[i])) {
args[i] = 0;
}
else {
- args[i] = rb_obj2int(v[i]);
+ args[i] = obj2int(v[i]);
}
}
diff --git a/version.h b/version.h
index c3989c2096..d833a21273 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "1.1b9_13"
-#define VERSION_DATE "98/04/21"
+#define RUBY_VERSION "1.1b9_14"
+#define VERSION_DATE "98/04/22"