From e18d2d6fbb9fe6e1b1bfe1521378f23aeb1b6d02 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Wed, 7 Apr 2010 16:32:25 -0400 Subject: [PATCH] removed deprecated RegexpOfHolding --- HISTORY | 1 + ext/cbson/cbson.c | 15 +--------- lib/bson.rb | 1 - lib/bson/bson_ruby.rb | 8 +---- lib/bson/types/regexp_of_holding.rb | 45 ----------------------------- test/mongo_bson/bson_test.rb | 7 ----- 6 files changed, 3 insertions(+), 74 deletions(-) delete mode 100644 lib/bson/types/regexp_of_holding.rb diff --git a/HISTORY b/HISTORY index ebee923..93e3f4b 100644 --- a/HISTORY +++ b/HISTORY @@ -12,6 +12,7 @@ you may want to remove * Removed the following deprecated items: * GridStore class + * RegexpOfHolding class * BSON-related code extracted into two separate gems: bson and bson_ext (thx to Chuck Remes). * mongo_ext no longer exists. diff --git a/ext/cbson/cbson.c b/ext/cbson/cbson.c index 3a050de..bc1c45c 100644 --- a/ext/cbson/cbson.c +++ b/ext/cbson/cbson.c @@ -63,7 +63,6 @@ static VALUE Code; static VALUE MinKey; static VALUE MaxKey; static VALUE Regexp; -static VALUE RegexpOfHolding; static VALUE OrderedHash; static VALUE InvalidKeyName; static VALUE InvalidStringEncoding; @@ -687,12 +686,10 @@ static VALUE get_value(const char* buffer, int* position, int type) { int pattern_length = strlen(buffer + *position); VALUE pattern = STR_NEW(buffer + *position, pattern_length); int flags_length, flags = 0, i = 0; - char extra[10]; VALUE argv[3]; *position += pattern_length + 1; flags_length = strlen(buffer + *position); - extra[0] = 0; for (i = 0; i < flags_length; i++) { char flag = buffer[*position + i]; if (flag == 'i') { @@ -704,19 +701,10 @@ static VALUE get_value(const char* buffer, int* position, int type) { else if (flag == 'x') { flags |= EXTENDED; } - else if (strlen(extra) < 9) { - strncat(extra, &flag, 1); - } } argv[0] = pattern; argv[1] = INT2FIX(flags); - if(extra[0] == 0) { - value = rb_class_new_instance(2, argv, Regexp); - } - else { // Deserializing a RegexpOfHolding - argv[2] = rb_str_new2(extra); - value = rb_class_new_instance(3, argv, RegexpOfHolding); - } + value = rb_class_new_instance(2, argv, Regexp); *position += flags_length + 1; break; } @@ -900,7 +888,6 @@ void Init_cbson() { MaxKey = rb_const_get(bson, rb_intern("MaxKey")); rb_require("bson/types/regexp_of_holding"); Regexp = rb_const_get(rb_cObject, rb_intern("Regexp")); - RegexpOfHolding = rb_const_get(bson, rb_intern("RegexpOfHolding")); rb_require("bson/exceptions"); InvalidKeyName = rb_const_get(bson, rb_intern("InvalidKeyName")); InvalidStringEncoding = rb_const_get(bson, rb_intern("InvalidStringEncoding")); diff --git a/lib/bson.rb b/lib/bson.rb index dbe4ff5..6057668 100644 --- a/lib/bson.rb +++ b/lib/bson.rb @@ -36,7 +36,6 @@ require 'bson/types/binary' require 'bson/types/code' require 'bson/types/dbref' require 'bson/types/objectid' -require 'bson/types/regexp_of_holding' require 'bson/types/min_max_keys' require 'base64' diff --git a/lib/bson/bson_ruby.rb b/lib/bson/bson_ruby.rb index 23ddbee..1a3d4ef 100644 --- a/lib/bson/bson_ruby.rb +++ b/lib/bson/bson_ruby.rb @@ -322,13 +322,7 @@ module BSON options |= Regexp::IGNORECASE if options_str.include?('i') options |= Regexp::MULTILINE if options_str.include?('m') options |= Regexp::EXTENDED if options_str.include?('x') - options_str.gsub!(/[imx]/, '') # Now remove the three we understand - if options_str == '' - Regexp.new(str, options) - else - warn("Using deprecated Regexp options #{options_str}; future versions of this MongoDB driver will support only i, m, and x. See deprecated class RegexpOfHolding for more info.") - RegexpOfHolding.new(str, options, options_str) - end + Regexp.new(str, options) end def deserialize_string_data(buf) diff --git a/lib/bson/types/regexp_of_holding.rb b/lib/bson/types/regexp_of_holding.rb deleted file mode 100644 index 74182df..0000000 --- a/lib/bson/types/regexp_of_holding.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -- -# Copyright (C) 2008-2010 10gen Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ++ - -module BSON - - # A Regexp that can hold on to extra options and ignore them. Mongo - # regexes may contain option characters beyond 'i', 'm', and 'x'. (Note - # that Mongo only uses those three, but that regexes coming from other - # languages may store different option characters.) - # - # Note that you do not have to use this class at all if you wish to - # store regular expressions in Mongo. The Mongo and Ruby regex option - # flags are the same. Storing regexes is discouraged, in any case. - # - # @deprecated - class RegexpOfHolding < Regexp - - attr_accessor :extra_options_str - - # @deprecated we're no longer supporting this. - # +str+ and +options+ are the same as Regexp. +extra_options_str+ - # contains all the other flags that were in Mongo but we do not use or - # understand. - def initialize(str, options, extra_options_str) - warn "RegexpOfHolding is deprecated; the modifiers i, m, and x will be stored automatically as BSON." + - "If you're only storing the options i, m, and x, you can safely ignore this message." - super(str, options) - @extra_options_str = extra_options_str - end - end - -end diff --git a/test/mongo_bson/bson_test.rb b/test/mongo_bson/bson_test.rb index d5cbbf4..2adb3db 100644 --- a/test/mongo_bson/bson_test.rb +++ b/test/mongo_bson/bson_test.rb @@ -153,18 +153,11 @@ class BSONTest < Test::Unit::TestCase r = doc2['doc'] assert_kind_of Regexp, r - r = RegexpOfHolding.new('st', 0, 'zywcab') - assert_equal 'zywcab', r.extra_options_str - doc = {'doc' => r} bson_doc = BSON::BSON_CODER.serialize(doc) doc2 = nil doc2 = BSON::BSON_CODER.deserialize(bson_doc) assert_equal doc, doc2 - - r = doc2['doc'] - assert_kind_of RegexpOfHolding, r - assert_equal 'abcwyz', r.extra_options_str # must be sorted end def test_boolean