a couple of fixes

This commit is contained in:
Mike Dirolf 2009-03-11 10:49:30 -04:00
parent 29e538e935
commit 68807b8df5
2 changed files with 13 additions and 10 deletions

View File

@ -493,16 +493,19 @@ static VALUE get_value(const char* buffer, int* position, int type) {
int flags_length = strlen(buffer + *position); int flags_length = strlen(buffer + *position);
int i = 0; int i = 0;
char flags[4]; int flags;
flags[0] = 0;
char extra[10]; char extra[10];
extra[0] = 0; extra[0] = 0;
for (i = 0; i < flags_length; i++) { for (i = 0; i < flags_length; i++) {
char flag = buffer[*position + i]; char flag = buffer[*position + i];
if (flag == 'i' || flag == 'm' || flag == 'x') { if (flag == 'i') {
if (strlen(flags) < 3) { flags |= RE_OPTION_IGNORECASE;
strncat(flags, &flag, 1);
} }
else if (flag == 'm') {
flags |= RE_OPTION_MULTILINE;
}
else if (flag == 'x') {
flags |= RE_OPTION_EXTENDED;
} }
else if (strlen(extra) < 9) { else if (strlen(extra) < 9) {
strncat(extra, &flag, 1); strncat(extra, &flag, 1);
@ -510,7 +513,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
} }
VALUE argv[3] = { VALUE argv[3] = {
pattern, pattern,
rb_str_new2(flags), INT2FIX(flags),
rb_str_new2(extra) rb_str_new2(extra)
}; };
value = rb_class_new_instance(3, argv, RegexpOfHolding); value = rb_class_new_instance(3, argv, RegexpOfHolding);
@ -538,14 +541,14 @@ static VALUE get_value(const char* buffer, int* position, int type) {
int value_length; int value_length;
memcpy(&value_length, buffer + *position, 4); memcpy(&value_length, buffer + *position, 4);
value = ID2SYM(rb_intern(buffer + *position + 4)); value = ID2SYM(rb_intern(buffer + *position + 4));
*position += value_length + 5; *position += value_length + 4;
break; break;
} }
case 16: case 16:
{ {
int i; int i;
memcpy(&i, buffer + *position, 4); memcpy(&i, buffer + *position, 4);
value = INT2FIX(i); value = LL2NUM(i);
*position += 4; *position += 4;
break; break;
} }

View File

@ -93,7 +93,7 @@ EOS
# Turn those BSON bytes back into a Ruby object. # Turn those BSON bytes back into a Ruby object.
# #
# We're passing a nil db to the contructor here, but that's OK because # We're passing a nil db to the contructor here, but that's OK because
# the BSON DBFef bytes don't contain the db object in any case, and we # the BSON DBRef bytes don't contain the db object in any case, and we
# don't care what the database is. # don't care what the database is.
obj_from_bson = BSON.new.deserialize(ByteBuffer.new(bson_from_ruby)) obj_from_bson = BSON.new.deserialize(ByteBuffer.new(bson_from_ruby))
assert_kind_of OrderedHash, obj_from_bson assert_kind_of OrderedHash, obj_from_bson