Get rid of the declaration of rb_str_cat2().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ttate 2002-05-20 09:38:23 +00:00
Родитель 077d92a044
Коммит a2db8e72c1
4 изменённых файлов: 37 добавлений и 48 удалений

Просмотреть файл

@ -17,7 +17,7 @@ if( ARGV.include?("--help") )
<max_cbent>: maximum number of callback entries
--enable-asm use the embedded assembler for passing arguments.
(this option is available for i386 machine now.)
--enable-dlstack use a stack emulation for constructing function call. [experimental]
--enable-dlstack use a stack emulation for constructing function call.
EOF
exit(0)
end
@ -33,7 +33,7 @@ if (Config::CONFIG['CC'] =~ /gcc/) && (Config::CONFIG['arch'] =~ /i.86/)
else
$with_asm = false
end
$with_dlstack = false
$with_dlstack = ! $with_asm
$with_type_int = try_run(<<EOF)
int main(){ return sizeof(int) == sizeof(long); }
@ -165,11 +165,6 @@ else
exit(0)
end
method(:have_func).arity == 1 or have_func("rb_str_cat2", "ruby.h")
if method(:have_func).arity == 1 or !have_func("rb_block_given_p", "ruby.h")
$dlconfig_h << "#define rb_block_given_p rb_iterator_p\n"
end
def File.update(file, str)
begin
open(file){|f|f.read} == str

Просмотреть файл

@ -7,14 +7,6 @@
VALUE rb_cDLSymbol;
#ifndef HAVE_RB_STR_CAT2
static VALUE
rb_str_cat2(VALUE str, const char *s)
{
return rb_str_cat(str, s, strlen(s));
}
#endif
static const char *
char2type(int ch)
{

Просмотреть файл

@ -148,30 +148,32 @@ test_append(char *ary[], int len, char *astr)
};
};
void
int
test_init(int *argc, char **argv[])
{
int i;
printf("test_init(0x%x,0x%x)\n",argc,argv);
printf("\t*(0x%x) => %d\n",argc,*argc);
char s[256];
for( i=0; i < (*argc); i++ ){
printf("\t(*(0x%x)[%d]) => %s\n", argv, i, (*argv)[i]);
};
};
sprintf(s, "arg%d", i);
if( strcmp((*argv)[i], s) != 0 ){
return 1;
}
}
return 0;
}
FILE *
test_open(const char *filename, const char *mode)
{
FILE *file;
file = fopen(filename,mode);
printf("test_open(%s,%s):0x%x\n",filename,mode,file);
return file;
};
void
test_close(FILE *file)
{
printf("test_close(0x%x)\n",file);
fclose(file);
};
@ -182,26 +184,29 @@ test_gets(char *s, int size, FILE *f)
};
typedef int callback1_t(int, char *);
#define CALLBACK_MSG "callback message"
int
test_callback1(int err, const char *msg)
{
printf("internal callback function (err = %d, msg = '%s')\n",
err, msg ? msg : "(null)");
return 1;
};
if( strcmp(msg, CALLBACK_MSG) == 0 ){
return 1;
}
else{
return 0;
}
}
int
test_call_func1(callback1_t *func)
{
if( func ){
return (*func)(0, "this is test_call_func1.");
return (*func)(0, CALLBACK_MSG);
}
else{
printf("test_call_func1(func = 0)\n");
return -1;
return 0;
}
};
}
struct test_data *
test_data_init()
@ -227,16 +232,6 @@ test_data_add(struct test_data *list, const char *name)
list->next = data;
};
void
test_data_print(struct test_data *list)
{
struct test_data *data;
for( data = list->next; data; data = data->next ){
printf("name = %s\n", data->name);
};
};
struct test_data *
test_data_aref(struct test_data *list, int i)
{

Просмотреть файл

@ -3,11 +3,16 @@
require 'dl'
require 'dl/import'
$FAIL = 0
$TOTAL = 0
def assert(label, ty, *conds)
$TOTAL += 1
cond = !conds.include?(false)
if( cond )
printf("succeed in `#{label}'\n")
else
$FAIL += 1
case ty
when :may
printf("fail in `#{label}' ... expected\n")
@ -158,12 +163,12 @@ DL.dlopen($LIB){|h|
debug r,rs
assert("strcat", :must, rs[0].to_s == "abcx")
init = h["test_init","0iP"]
init = h["test_init","IiP"]
debug init
argc = 3
argv = ["arg0","arg1","arg2"].to_ptr
r,rs = init[argc, argv.ref]
debug r,rs
assert("init", :must, r == 0)
}
@ -203,9 +208,11 @@ assert("callback1", :must, r == 1)
callback2 = DL.set_callback("LLP", 0){|arg1,arg2|
ptr = arg2 # DL::PtrData.new(arg2)
msg = ptr.to_s
print("user defined callback function",
"(err = #{arg1}, msg = '#{msg}')\n")
2
if( msg == "callback message" )
2
else
0
end
}
debug callback2
r,rs = h["test_call_func1", "IP"][callback2]
@ -249,14 +256,12 @@ assert("set value", :must, ptr[:l] == lval) unless (Fixnum === :-)
data_init = h["test_data_init", "P"]
data_add = h["test_data_add", "0PS"]
data_print = h["test_data_print", "0P"]
data_aref = h["test_data_aref", "PPI"]
r,rs = data_init[]
ptr = r
data_add[ptr, "name1"]
data_add[ptr, "name2"]
data_add[ptr, "name3"]
data_print[ptr]
r,rs = data_aref[ptr, 1]
ptr = r
@ -288,3 +293,5 @@ assert("struct!", :must,
ptr["l"] == 4)
GC.start
printf("fail/total = #{$FAIL}/#{$TOTAL}\n")