[前][次][番号順一覧][スレッド一覧]

ruby-changes:11715

From: nobu <ko1@a...>
Date: Thu, 7 May 2009 14:16:41 +0900 (JST)
Subject: [ruby-changes:11715] Ruby:r23358 (trunk): * string.c, include/ruby/encoding.h: fixed types.

nobu	2009-05-07 14:16:26 +0900 (Thu, 07 May 2009)

  New Revision: 23358

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23358

  Log:
    * string.c, include/ruby/encoding.h: fixed types.
    * include/ruby/encoding.h (rb_enc_nth): long is used for index.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/encoding.h
    trunk/string.c

Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 23357)
+++ include/ruby/encoding.h	(revision 23358)
@@ -47,7 +47,7 @@
 #define ENC_CODERANGE_7BIT	((int)FL_USER8)
 #define ENC_CODERANGE_VALID	((int)FL_USER9)
 #define ENC_CODERANGE_BROKEN	((int)(FL_USER8|FL_USER9))
-#define ENC_CODERANGE(obj) (RBASIC(obj)->flags & ENC_CODERANGE_MASK)
+#define ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & ENC_CODERANGE_MASK)
 #define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_7BIT)
 #define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \
 				   (RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr))
@@ -88,7 +88,7 @@
 PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
 VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
 long rb_enc_strlen(const char*, const char*, rb_encoding*);
-char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
+char* rb_enc_nth(const char*, const char*, long, rb_encoding*);
 VALUE rb_obj_encoding(VALUE);
 VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23357)
+++ ChangeLog	(revision 23358)
@@ -1,3 +1,9 @@
+Thu May  7 14:16:24 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c, include/ruby/encoding.h: fixed types.
+
+	* include/ruby/encoding.h (rb_enc_nth): long is used for index.
+
 Thu May  7 14:01:55 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* range.c (r_le): fixed types.
Index: string.c
===================================================================
--- string.c	(revision 23357)
+++ string.c	(revision 23358)
@@ -143,7 +143,7 @@
 # define NONASCII_MASK 0x80808080UL
 #endif
 #ifdef NONASCII_MASK
-    if (sizeof(VALUE) * 2 < e - p) {
+    if ((int)sizeof(VALUE) * 2 < e - p) {
         const VALUE *s, *t;
         const VALUE lowbits = sizeof(VALUE) - 1;
         s = (const VALUE*)(~lowbits & ((VALUE)p + lowbits));
@@ -957,7 +957,8 @@
 str_strlen(VALUE str, rb_encoding *enc)
 {
     const char *p, *e;
-    int n, cr;
+    long n;
+    int cr;
 
     if (single_byte_optimizable(str)) return RSTRING_LEN(str);
     if (!enc) enc = STR_ENC_GET(str);
@@ -967,7 +968,7 @@
     if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
         enc == rb_utf8_encoding()) {
         VALUE len = 0;
-	if (sizeof(VALUE) * 2 < e - p) {
+	if ((int)sizeof(VALUE) * 2 < e - p) {
 	    const VALUE *s, *t;
 	    const VALUE lowbits = sizeof(VALUE) - 1;
 	    s = (const VALUE*)(~lowbits & ((VALUE)p + lowbits));
@@ -1007,10 +1008,10 @@
 VALUE
 rb_str_length(VALUE str)
 {
-    int len;
+    long len;
 
     len = str_strlen(str, STR_ENC_GET(str));
-    return INT2NUM(len);
+    return LONG2NUM(len);
 }
 
 /*
@@ -1310,7 +1311,7 @@
 }
 
 char*
-rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
+rb_enc_nth(const char *p, const char *e, long nth, rb_encoding *enc)
 {
     if (rb_enc_mbmaxlen(enc) == 1) {
         p += nth;
@@ -1351,7 +1352,7 @@
 }
 
 static char*
-str_nth(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte)
+str_nth(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
 {
     if (singlebyte)
 	p += nth;
@@ -1364,8 +1365,8 @@
 }
 
 /* char offset to byte offset */
-static int
-str_offset(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte)
+static long
+str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
 {
     const char *pp = str_nth(p, e, nth, enc, singlebyte);
     if (!pp) return e - p;
@@ -1374,9 +1375,9 @@
 
 #ifdef NONASCII_MASK
 static char *
-str_utf8_nth(const char *p, const char *e, int nth)
+str_utf8_nth(const char *p, const char *e, long nth)
 {
-    if (sizeof(VALUE) * 2 < nth) {
+    if ((int)SIZEOF_VALUE * 2 < nth) {
 	const VALUE *s, *t;
 	const VALUE lowbits = sizeof(VALUE) - 1;
 	s = (const VALUE*)(~lowbits & ((VALUE)p + lowbits));
@@ -1388,7 +1389,7 @@
 	do {
 	    nth -= count_utf8_lead_bytes_with_word(s);
 	    s++;
-	} while (s < t && sizeof(VALUE) <= nth);
+	} while (s < t && (int)sizeof(VALUE) <= nth);
 	p = (char *)s;
     }
     while (p < e) {
@@ -1401,8 +1402,8 @@
     return (char *)p;
 }
 
-static int
-str_utf8_offset(const char *p, const char *e, int nth)
+static long
+str_utf8_offset(const char *p, const char *e, long nth)
 {
     const char *pp = str_utf8_nth(p, e, nth);
     if (!pp) return e - p;
@@ -1886,7 +1887,7 @@
     if (FIXNUM_P(str2) || TYPE(str2) == T_BIGNUM) {
 	rb_encoding *enc = STR_ENC_GET(str1);
 	unsigned int c = NUM2UINT(str2);
-	int pos = RSTRING_LEN(str1);
+	long pos = RSTRING_LEN(str1);
 	int len = rb_enc_codelen(c, enc);
 	int cr = ENC_CODERANGE(str1);
 
@@ -1990,7 +1991,7 @@
 	    data += sizeof(uint32_t)-align;
 	    len -= sizeof(uint32_t)-align;
 
-	    sl = CHAR_BIT * (sizeof(uint32_t)-align);
+	    sl = CHAR_BIT * ((int)sizeof(uint32_t)-align);
 	    sr = CHAR_BIT * align;
 
 	    while (len >= sizeof(uint32_t)) {
@@ -2083,7 +2084,7 @@
 VALUE
 rb_hash_uint(VALUE h, VALUE i)
 {
-    unsigned int v = 0;
+    unsigned long v = 0;
     h += i;
 #ifdef WORDS_BIGENDIAN
 #if SIZEOF_VALUE*CHAR_BIT > 12*8
@@ -2148,7 +2149,7 @@
 int
 rb_memhash(const void *ptr, long len)
 {
-    return hash(ptr, len, rb_hash_start(0));
+    return (int)hash(ptr, len, rb_hash_start(0));
 }
 
 int
@@ -2158,7 +2159,7 @@
     if (e) {
 	if (rb_enc_str_asciionly_p(str)) e = 0;
     }
-    return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)) ^ e;
+    return (int)rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)) ^ e;
 }
 
 int
@@ -4838,7 +4839,7 @@
 	    else {
 		c = errc;
 	    }
-	    if (c != -1) {
+	    if (c != (unsigned int)-1) {
 		if (save == c) {
 		    CHECK_IF_ASCII(c);
 		    continue;
@@ -6609,7 +6610,7 @@
     ptr = p = RSTRING_PTR(str);
     len = RSTRING_LEN(str);
     pend = p + len;
-    if (bits >= sizeof(long)*CHAR_BIT) {
+    if (bits >= (int)sizeof(long)*CHAR_BIT) {
 	VALUE sum = INT2FIX(0);
 
 	while (p < pend) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]