Skip to content

Commit

Permalink
use long instead of int
Browse files Browse the repository at this point in the history
  • Loading branch information
flori committed Sep 17, 2010
1 parent 5ffce18 commit db3dc79
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
40 changes: 20 additions & 20 deletions ext/json/ext/generator/generator.c
Expand Up @@ -74,7 +74,7 @@ static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080
* If presented with a length > 4, this returns 0. The Unicode
* definition of UTF-8 goes up to 4-byte sequences.
*/
static unsigned char isLegalUTF8(const UTF8 *source, int length)
static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length)
{
UTF8 a;
const UTF8 *srcptr = source+length;
Expand Down Expand Up @@ -223,7 +223,7 @@ static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
{
const char *ptr = RSTRING_PTR(string), *p;
int len = RSTRING_LEN(string), start = 0, end = 0;
unsigned long len = RSTRING_LEN(string), start = 0, end = 0;
const char *escape = NULL;
int escape_len;
unsigned char c;
Expand Down Expand Up @@ -284,7 +284,7 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
fbuffer_append(buffer, ptr + start, end - start);
}

static char *fstrndup(const char *ptr, int len) {
static char *fstrndup(const char *ptr, unsigned long len) {
char *result;
if (len <= 0) return NULL;
result = ALLOC_N(char, len);
Expand All @@ -302,7 +302,7 @@ static FBuffer *fbuffer_alloc()
return fb;
}

static FBuffer *fbuffer_alloc_with_length(unsigned int initial_length)
static FBuffer *fbuffer_alloc_with_length(unsigned long initial_length)
{
FBuffer *fb;
assert(initial_length > 0);
Expand All @@ -328,9 +328,9 @@ static void fbuffer_clear(FBuffer *fb)
fb->len = 0;
}

static void fbuffer_inc_capa(FBuffer *fb, unsigned int requested)
static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
{
unsigned int required;
unsigned long required;

if (!fb->ptr) {
fb->ptr = ALLOC_N(char, fb->initial_length);
Expand All @@ -345,7 +345,7 @@ static void fbuffer_inc_capa(FBuffer *fb, unsigned int requested)
}
}

static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned int len)
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
{
if (len > 0) {
fbuffer_inc_capa(fb, len);
Expand All @@ -370,7 +370,7 @@ static void freverse(char *start, char *end)
}
}

static int fltoa(long number, char *buf)
static long fltoa(long number, char *buf)
{
static char digits[] = "0123456789";
long sign = number;
Expand All @@ -386,13 +386,13 @@ static int fltoa(long number, char *buf)
static void fbuffer_append_long(FBuffer *fb, long number)
{
char buf[20];
int len = fltoa(number, buf);
unsigned long len = fltoa(number, buf);
fbuffer_append(fb, buf, len);
}

static FBuffer *fbuffer_dup(FBuffer *fb)
{
int len = fb->len;
unsigned long len = fb->len;
FBuffer *result;

if (len > 0) {
Expand Down Expand Up @@ -628,39 +628,39 @@ static VALUE cState_configure(VALUE self, VALUE opts)
opts = tmp;
tmp = rb_hash_aref(opts, ID2SYM(i_indent));
if (RTEST(tmp)) {
int len;
unsigned long len;
Check_Type(tmp, T_STRING);
len = RSTRING_LEN(tmp);
state->indent = fstrndup(RSTRING_PTR(tmp), len);
state->indent_len = len;
}
tmp = rb_hash_aref(opts, ID2SYM(i_space));
if (RTEST(tmp)) {
int len;
unsigned long len;
Check_Type(tmp, T_STRING);
len = RSTRING_LEN(tmp);
state->space = fstrndup(RSTRING_PTR(tmp), len);
state->space_len = len;
}
tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
if (RTEST(tmp)) {
int len;
unsigned long len;
Check_Type(tmp, T_STRING);
len = RSTRING_LEN(tmp);
state->space_before = fstrndup(RSTRING_PTR(tmp), len);
state->space_before_len = len;
}
tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
if (RTEST(tmp)) {
int len;
unsigned long len;
Check_Type(tmp, T_STRING);
len = RSTRING_LEN(tmp);
state->array_nl = fstrndup(RSTRING_PTR(tmp), len);
state->array_nl_len = len;
}
tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
if (RTEST(tmp)) {
int len;
unsigned long len;
Check_Type(tmp, T_STRING);
len = RSTRING_LEN(tmp);
state->object_nl = fstrndup(RSTRING_PTR(tmp), len);
Expand Down Expand Up @@ -1065,7 +1065,7 @@ static VALUE cState_indent(VALUE self)
*/
static VALUE cState_indent_set(VALUE self, VALUE indent)
{
int len;
unsigned long len;
GET_STATE(self);
Check_Type(indent, T_STRING);
len = RSTRING_LEN(indent);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ static VALUE cState_space(VALUE self)
*/
static VALUE cState_space_set(VALUE self, VALUE space)
{
int len;
unsigned long len;
GET_STATE(self);
Check_Type(space, T_STRING);
len = RSTRING_LEN(space);
Expand Down Expand Up @@ -1139,7 +1139,7 @@ static VALUE cState_space_before(VALUE self)
*/
static VALUE cState_space_before_set(VALUE self, VALUE space_before)
{
int len;
unsigned long len;
GET_STATE(self);
Check_Type(space_before, T_STRING);
len = RSTRING_LEN(space_before);
Expand Down Expand Up @@ -1177,7 +1177,7 @@ static VALUE cState_object_nl(VALUE self)
*/
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
{
int len;
unsigned long len;
GET_STATE(self);
Check_Type(object_nl, T_STRING);
len = RSTRING_LEN(object_nl);
Expand Down Expand Up @@ -1212,7 +1212,7 @@ static VALUE cState_array_nl(VALUE self)
*/
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
{
int len;
unsigned long len;
GET_STATE(self);
Check_Type(array_nl, T_STRING);
len = RSTRING_LEN(array_nl);
Expand Down
14 changes: 7 additions & 7 deletions ext/json/ext/generator/generator.h
Expand Up @@ -50,10 +50,10 @@
/* fbuffer implementation */

typedef struct FBufferStruct {
unsigned int initial_length;
unsigned long initial_length;
char *ptr;
unsigned int len;
unsigned int capa;
unsigned long len;
unsigned long capa;
} FBuffer;

#define FBUFFER_INITIAL_LENGTH 4096
Expand All @@ -63,13 +63,13 @@ typedef struct FBufferStruct {
#define FBUFFER_CAPA(fb) (fb->capa)
#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb)

static char *fstrndup(const char *ptr, int len);
static char *fstrndup(const char *ptr, unsigned long len);
static FBuffer *fbuffer_alloc();
static FBuffer *fbuffer_alloc_with_length(unsigned initial_length);
static FBuffer *fbuffer_alloc_with_length(unsigned long initial_length);
static void fbuffer_free(FBuffer *fb);
static void fbuffer_free_only_buffer(FBuffer *fb);
static void fbuffer_clear(FBuffer *fb);
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned int len);
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len);
static void fbuffer_append_long(FBuffer *fb, long number);
static void fbuffer_append_char(FBuffer *fb, char newchr);
static FBuffer *fbuffer_dup(FBuffer *fb);
Expand Down Expand Up @@ -99,7 +99,7 @@ static const int halfShift = 10; /* used for shifting by 10 bits */
static const UTF32 halfBase = 0x0010000UL;
static const UTF32 halfMask = 0x3FFUL;

static unsigned char isLegalUTF8(const UTF8 *source, int length);
static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
static void unicode_escape(char *buf, UTF16 character);
static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string);
Expand Down

0 comments on commit db3dc79

Please sign in to comment.