1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/{stubs,tcltklib}.c, ext/tk/tkutil/tkutil.c: fix warnings

about constness and signedness.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-07-23 09:27:49 +00:00
parent 7b9b1f45d3
commit ed9a65c4f6
5 changed files with 54 additions and 44 deletions

View file

@ -1,3 +1,8 @@
Wed Jul 23 18:27:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/tk/{stubs,tcltklib}.c, ext/tk/tkutil/tkutil.c: fix warnings
about constness and signedness.
Wed Jul 23 17:04:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Jul 23 17:04:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl/openssl_missing.h (d2i_of_void): define for older * ext/openssl/openssl_missing.h (d2i_of_void): define for older

View file

@ -1,2 +1,2 @@
tcltklib.o: tcltklib.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h tcltklib.o: tcltklib.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.h
stubs.o: stubs.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.o: stubs.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.h

View file

@ -318,7 +318,7 @@ ruby_tk_stubs_init(tcl_ip)
if ((*p_Tk_Init)(tcl_ip) == TCL_ERROR) if ((*p_Tk_Init)(tcl_ip) == TCL_ERROR)
return FAIL_Tk_Init; return FAIL_Tk_Init;
if (!Tk_InitStubs(tcl_ip, "8.1", 0)) if (!Tk_InitStubs(tcl_ip, (char *)"8.1", 0))
return FAIL_Tk_InitStubs; return FAIL_Tk_InitStubs;
#ifdef __MACOS__ #ifdef __MACOS__
@ -357,7 +357,7 @@ ruby_tk_stubs_safeinit(tcl_ip)
if ((*p_Tk_SafeInit)(tcl_ip) == TCL_ERROR) if ((*p_Tk_SafeInit)(tcl_ip) == TCL_ERROR)
return FAIL_Tk_Init; return FAIL_Tk_Init;
if (!Tk_InitStubs(tcl_ip, "8.1", 0)) if (!Tk_InitStubs(tcl_ip, (char *)"8.1", 0))
return FAIL_Tk_InitStubs; return FAIL_Tk_InitStubs;
#ifdef __MACOS__ #ifdef __MACOS__

View file

@ -119,7 +119,7 @@ fprintf(stderr, ARG1, ARG2, ARG3); fprintf(stderr, "\n"); fflush(stderr); }
static const char tcltklib_release_date[] = TCLTKLIB_RELEASE_DATE; static const char tcltklib_release_date[] = TCLTKLIB_RELEASE_DATE;
/* finalize_proc_name */ /* finalize_proc_name */
static char *finalize_hook_name = "INTERP_FINALIZE_HOOK"; static const char finalize_hook_name[] = "INTERP_FINALIZE_HOOK";
static void ip_finalize _((Tcl_Interp*)); static void ip_finalize _((Tcl_Interp*));
@ -188,13 +188,14 @@ static VALUE ip_invoke_real _((int, VALUE*, VALUE));
static VALUE ip_invoke _((int, VALUE*, VALUE)); static VALUE ip_invoke _((int, VALUE*, VALUE));
static VALUE ip_invoke_with_position _((int, VALUE*, VALUE, Tcl_QueuePosition)); static VALUE ip_invoke_with_position _((int, VALUE*, VALUE, Tcl_QueuePosition));
static VALUE tk_funcall _((VALUE(), int, VALUE*, VALUE)); static VALUE tk_funcall _((VALUE(), int, VALUE*, VALUE));
static VALUE callq_safelevel_handler _((VALUE, VALUE));
/* Tcl's object type */ /* Tcl's object type */
#if TCL_MAJOR_VERSION >= 8 #if TCL_MAJOR_VERSION >= 8
static char *Tcl_ObjTypeName_ByteArray = "bytearray"; static const char Tcl_ObjTypeName_ByteArray[] = "bytearray";
static Tcl_ObjType *Tcl_ObjType_ByteArray; static Tcl_ObjType *Tcl_ObjType_ByteArray;
static char *Tcl_ObjTypeName_String = "string"; static const char Tcl_ObjTypeName_String[] = "string";
static Tcl_ObjType *Tcl_ObjType_String; static Tcl_ObjType *Tcl_ObjType_String;
#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
@ -1044,12 +1045,12 @@ call_original_exit(ptr, state)
} else { } else {
/* string interface */ /* string interface */
char **argv; CONST84 char **argv;
#define USE_RUBY_ALLOC 0 #define USE_RUBY_ALLOC 0
#if USE_RUBY_ALLOC #if USE_RUBY_ALLOC
argv = (char **)ALLOC_N(char *, 3); /* XXXXXXXXXX */ argv = ALLOC_N(char *, 3); /* XXXXXXXXXX */
#else /* not USE_RUBY_ALLOC */ #else /* not USE_RUBY_ALLOC */
argv = (char **)ckalloc(sizeof(char *) * 3); argv = (CONST84 char **)ckalloc(sizeof(char *) * 3);
#if 0 /* use Tcl_Preserve/Release */ #if 0 /* use Tcl_Preserve/Release */
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
#endif #endif
@ -1059,8 +1060,7 @@ call_original_exit(ptr, state)
argv[1] = Tcl_GetStringFromObj(state_obj, (int*)NULL); argv[1] = Tcl_GetStringFromObj(state_obj, (int*)NULL);
argv[2] = (char *)NULL; argv[2] = (char *)NULL;
ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, 2, argv);
2, (CONST84 char **)argv);
#if USE_RUBY_ALLOC #if USE_RUBY_ALLOC
free(argv); free(argv);
@ -1502,7 +1502,7 @@ static VALUE
lib_num_of_mainwindows(self) lib_num_of_mainwindows(self)
VALUE self; VALUE self;
{ {
#ifdef RUBY_VM /* Ruby 1.9+ !!! */ #ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */
return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self); return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self);
#else #else
return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL); return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL);
@ -2944,7 +2944,9 @@ ip_ruby_cmd_receiver_const_get(name)
char *name; char *name;
{ {
volatile VALUE klass = rb_cObject; volatile VALUE klass = rb_cObject;
#if 0
char *head, *tail; char *head, *tail;
#endif
int state; int state;
#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER #if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
@ -2994,8 +2996,9 @@ ip_ruby_cmd_receiver_get(str)
char *str; char *str;
{ {
volatile VALUE receiver; volatile VALUE receiver;
volatile VALUE klass = rb_cObject; #if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
int state; int state;
#endif
if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) { if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
/* class | module | constant */ /* class | module | constant */
@ -6093,10 +6096,6 @@ get_str_from_obj(obj)
int len, binary = 0; int len, binary = 0;
const char *s; const char *s;
volatile VALUE str; volatile VALUE str;
#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 4)
int len2;
const char *s2;
#endif
#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
s = Tcl_GetStringFromObj(obj, &len); s = Tcl_GetStringFromObj(obj, &len);
@ -6105,7 +6104,7 @@ get_str_from_obj(obj)
/* TCL_VERSION 8.1 -- 8.3 */ /* TCL_VERSION 8.1 -- 8.3 */
if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) { if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
/* possibly binary string */ /* possibly binary string */
s = Tcl_GetByteArrayFromObj(obj, &len); s = (char *)Tcl_GetByteArrayFromObj(obj, &len);
binary = 1; binary = 1;
} else { } else {
/* possibly text string */ /* possibly text string */
@ -6113,7 +6112,7 @@ get_str_from_obj(obj)
} }
#else /* TCL_VERSION >= 8.4 */ #else /* TCL_VERSION >= 8.4 */
if (IS_TCL_BYTEARRAY(obj)) { if (IS_TCL_BYTEARRAY(obj)) {
s = Tcl_GetByteArrayFromObj(obj, &len); s = (char *)Tcl_GetByteArrayFromObj(obj, &len);
binary = 1; binary = 1;
} else { } else {
s = Tcl_GetStringFromObj(obj, &len); s = Tcl_GetStringFromObj(obj, &len);
@ -6153,7 +6152,7 @@ get_obj_from_str(str)
StringValue(enc); StringValue(enc);
if (strcmp(RSTRING_PTR(enc), "binary") == 0) { if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
/* binary string */ /* binary string */
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str)); return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
} else { } else {
/* text string */ /* text string */
return Tcl_NewStringObj(s, RSTRING_LEN(str)); return Tcl_NewStringObj(s, RSTRING_LEN(str));
@ -6161,11 +6160,11 @@ get_obj_from_str(str)
#ifdef HAVE_RUBY_ENCODING_H #ifdef HAVE_RUBY_ENCODING_H
} else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) { } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
/* binary string */ /* binary string */
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str)); return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
#endif #endif
} else if (strlen(s) != RSTRING_LEN(str)) { } else if (strlen(s) != RSTRING_LEN(str)) {
/* probably binary string */ /* probably binary string */
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str)); return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
} else { } else {
/* probably text string */ /* probably text string */
return Tcl_NewStringObj(s, RSTRING_LEN(str)); return Tcl_NewStringObj(s, RSTRING_LEN(str));
@ -7343,7 +7342,7 @@ lib_fromUTF8_core(ip_obj, src, encodename)
StringValue(str); StringValue(str);
tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LEN(str)); tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LEN(str));
Tcl_IncrRefCount(tclstr); Tcl_IncrRefCount(tclstr);
s = Tcl_GetByteArrayFromObj(tclstr, &len); s = (char*)Tcl_GetByteArrayFromObj(tclstr, &len);
str = rb_tainted_str_new(s, len); str = rb_tainted_str_new(s, len);
s = (char*)NULL; s = (char*)NULL;
Tcl_DecrRefCount(tclstr); Tcl_DecrRefCount(tclstr);
@ -9195,7 +9194,7 @@ create_dummy_encoding_for_tk_core(interp, name, error_mode)
VALUE name; VALUE name;
VALUE error_mode; VALUE error_mode;
{ {
struct tcltkip *ptr = get_ip(interp); get_ip(interp);
rb_secure(4); rb_secure(4);
@ -10148,6 +10147,8 @@ Init_tcltklib()
Tcl_ObjType_String = Tcl_GetObjType(Tcl_ObjTypeName_String); Tcl_ObjType_String = Tcl_GetObjType(Tcl_ObjTypeName_String);
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
(void)call_original_exit;
} }
/* eof */ /* eof */

View file

@ -205,6 +205,7 @@ fromDefaultEnc_toUTF8(str, self)
return tk_toUTF8(1, argv, self); return tk_toUTF8(1, argv, self);
} }
#if 0
static VALUE static VALUE
fromUTF8_toDefaultEnc(str, self) fromUTF8_toDefaultEnc(str, self)
VALUE str; VALUE str;
@ -215,6 +216,7 @@ fromUTF8_toDefaultEnc(str, self)
argv[0] = str; argv[0] = str;
return tk_fromUTF8(1, argv, self); return tk_fromUTF8(1, argv, self);
} }
#endif
static int static int
to_strkey(key, value, hash) to_strkey(key, value, hash)
@ -968,12 +970,14 @@ tcl2rb_bool(self, value)
} }
} }
#if 0
static VALUE static VALUE
tkstr_to_dec(value) tkstr_to_dec(value)
VALUE value; VALUE value;
{ {
return rb_cstr_to_inum(RSTRING_PTR(value), 10, 1); return rb_cstr_to_inum(RSTRING_PTR(value), 10, 1);
} }
#endif
static VALUE static VALUE
tkstr_to_int(value) tkstr_to_int(value)
@ -1077,8 +1081,8 @@ tcl2rb_num_or_str(self, value)
struct cbsubst_info { struct cbsubst_info {
int full_subst_length; int full_subst_length;
int keylen[CBSUBST_TBL_MAX]; int keylen[CBSUBST_TBL_MAX];
unsigned char *key[CBSUBST_TBL_MAX]; char *key[CBSUBST_TBL_MAX];
unsigned char type[CBSUBST_TBL_MAX]; char type[CBSUBST_TBL_MAX];
ID ivar[CBSUBST_TBL_MAX]; ID ivar[CBSUBST_TBL_MAX];
VALUE proc; VALUE proc;
VALUE aliases; VALUE aliases;
@ -1100,9 +1104,9 @@ subst_free(ptr)
if (ptr) { if (ptr) {
for(i = 0; i < CBSUBST_TBL_MAX; i++) { for(i = 0; i < CBSUBST_TBL_MAX; i++) {
if (ptr->key[i] != (unsigned char *)NULL) { if (ptr->key[i] != NULL) {
free(ptr->key[i]); free(ptr->key[i]);
ptr->key[i] = (unsigned char *)NULL; ptr->key[i] = NULL;
} }
} }
free(ptr); free(ptr);
@ -1122,7 +1126,7 @@ allocate_cbsubst_info()
for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) { for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
inf->keylen[idx] = 0; inf->keylen[idx] = 0;
inf->key[idx] = (unsigned char *) NULL; inf->key[idx] = NULL;
inf->type[idx] = '\0'; inf->type[idx] = '\0';
inf->ivar[idx] = (ID) 0; inf->ivar[idx] = (ID) 0;
} }
@ -1240,7 +1244,7 @@ cbsubst_sym_to_subst(self, sym)
{ {
struct cbsubst_info *inf; struct cbsubst_info *inf;
const char *str; const char *str;
unsigned char *buf, *ptr; char *buf, *ptr;
int idx, len; int idx, len;
ID id; ID id;
volatile VALUE ret; volatile VALUE ret;
@ -1273,7 +1277,7 @@ cbsubst_sym_to_subst(self, sym)
ptr += len; ptr += len;
} else { } else {
/* single char */ /* single char */
*(ptr++) = idx; *(ptr++) = (unsigned char)idx;
} }
*(ptr++) = ' '; *(ptr++) = ' ';
@ -1294,7 +1298,7 @@ cbsubst_get_subst_arg(argc, argv, self)
{ {
struct cbsubst_info *inf; struct cbsubst_info *inf;
const char *str; const char *str;
unsigned char *buf, *ptr; char *buf, *ptr;
int i, idx, len; int i, idx, len;
ID id; ID id;
volatile VALUE arg_sym, ret; volatile VALUE arg_sym, ret;
@ -1339,7 +1343,7 @@ cbsubst_get_subst_arg(argc, argv, self)
ptr += len; ptr += len;
} else { } else {
/* single char */ /* single char */
*(ptr++) = idx; *(ptr++) = (unsigned char)idx;
} }
*(ptr++) = ' '; *(ptr++) = ' ';
@ -1364,7 +1368,7 @@ cbsubst_get_subst_key(self, str)
volatile VALUE ret; volatile VALUE ret;
VALUE keyval; VALUE keyval;
int i, len, keylen, idx; int i, len, keylen, idx;
unsigned char *buf, *ptr, *key; char *buf, *ptr, *key;
list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str); list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str);
len = RARRAY_LEN(list); len = RARRAY_LEN(list);
@ -1372,11 +1376,11 @@ cbsubst_get_subst_key(self, str)
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
ptr = buf = ALLOC_N(unsigned char, inf->full_subst_length + len + 1); ptr = buf = ALLOC_N(char, inf->full_subst_length + len + 1);
for(i = 0; i < len; i++) { for(i = 0; i < len; i++) {
keyval = RARRAY_PTR(list)[i]; keyval = RARRAY_PTR(list)[i];
key = (unsigned char*)RSTRING_PTR(keyval); key = RSTRING_PTR(keyval);
if (*key == '%') { if (*key == '%') {
if (*(key + 2) == '\0') { if (*(key + 2) == '\0') {
/* single char */ /* single char */
@ -1386,7 +1390,7 @@ cbsubst_get_subst_key(self, str)
keylen = RSTRING_LEN(keyval) - 1; keylen = RSTRING_LEN(keyval) - 1;
for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) { for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
if (inf->keylen[idx] != keylen) continue; if (inf->keylen[idx] != keylen) continue;
if (inf->key[idx][0] != *(key + 1)) continue; if ((unsigned char)inf->key[idx][0] != (unsigned char)*(key + 1)) continue;
if (strncmp(inf->key[idx], key + 1, keylen)) continue; if (strncmp(inf->key[idx], key + 1, keylen)) continue;
break; break;
} }
@ -1402,7 +1406,7 @@ cbsubst_get_subst_key(self, str)
} }
*ptr = '\0'; *ptr = '\0';
ret = rb_str_new2((const char*)buf); ret = rb_str_new2(buf);
free(buf); free(buf);
return ret; return ret;
} }
@ -1412,16 +1416,16 @@ cbsubst_get_all_subst_keys(self)
VALUE self; VALUE self;
{ {
struct cbsubst_info *inf; struct cbsubst_info *inf;
unsigned char *buf, *ptr; char *buf, *ptr;
unsigned char *keys_buf, *keys_ptr; char *keys_buf, *keys_ptr;
int idx, len; int idx, len;
volatile VALUE ret; volatile VALUE ret;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
ptr = buf = ALLOC_N(unsigned char, inf->full_subst_length + 1); ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
keys_ptr = keys_buf = ALLOC_N(unsigned char, CBSUBST_TBL_MAX + 1); keys_ptr = keys_buf = ALLOC_N(char, CBSUBST_TBL_MAX + 1);
for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) { for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
if (inf->ivar[idx] == (ID) 0) continue; if (inf->ivar[idx] == (ID) 0) continue;
@ -1445,7 +1449,7 @@ cbsubst_get_all_subst_keys(self)
*ptr = '\0'; *ptr = '\0';
*keys_ptr = '\0'; *keys_ptr = '\0';
ret = rb_ary_new3(2, rb_str_new2(keys_buf), rb_str_new2((const char*)buf)); ret = rb_ary_new3(2, rb_str_new2(keys_buf), rb_str_new2(buf));
free(buf); free(buf);
free(keys_buf); free(keys_buf);