Skip to content

Commit 7d2ad6d

Browse files
committed
Remove quirks mode
1 parent a985a0c commit 7d2ad6d

19 files changed

+143
-619
lines changed

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ source 'https://rubygems.org'
55
gemspec :name => 'json'
66
gemspec :name => 'json_pure'
77
gemspec :name => 'json-java'
8-
9-
gem 'simplecov'

TODO

Lines changed: 0 additions & 1 deletion
This file was deleted.

ext/json/ext/generator/generator.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
1414

1515
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
1616
i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
17-
i_quirks_mode, i_pack, i_unpack, i_create_id, i_extend, i_key_p,
17+
i_pack, i_unpack, i_create_id, i_extend, i_key_p,
1818
i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth,
1919
i_buffer_initial_length, i_dup;
2020

@@ -622,8 +622,6 @@ static VALUE cState_configure(VALUE self, VALUE opts)
622622
state->allow_nan = RTEST(tmp);
623623
tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
624624
state->ascii_only = RTEST(tmp);
625-
tmp = rb_hash_aref(opts, ID2SYM(i_quirks_mode));
626-
state->quirks_mode = RTEST(tmp);
627625
return self;
628626
}
629627

@@ -657,7 +655,6 @@ static VALUE cState_to_h(VALUE self)
657655
rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len));
658656
rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
659657
rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
660-
rb_hash_aset(result, ID2SYM(i_quirks_mode), state->quirks_mode ? Qtrue : Qfalse);
661658
rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
662659
rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
663660
rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
@@ -943,8 +940,6 @@ static VALUE cState_generate(VALUE self, VALUE obj)
943940
* * *allow_nan*: true if NaN, Infinity, and -Infinity should be
944941
* generated, otherwise an exception is thrown, if these values are
945942
* encountered. This options defaults to false.
946-
* * *quirks_mode*: Enables quirks_mode for parser, that is for example
947-
* generating single JSON values instead of documents is possible.
948943
* * *buffer_initial_length*: sets the initial length of the generator's
949944
* internal buffer.
950945
*/
@@ -1251,29 +1246,6 @@ static VALUE cState_ascii_only_p(VALUE self)
12511246
return state->ascii_only ? Qtrue : Qfalse;
12521247
}
12531248

1254-
/*
1255-
* call-seq: quirks_mode?
1256-
*
1257-
* Returns true, if quirks mode is enabled. Otherwise returns false.
1258-
*/
1259-
static VALUE cState_quirks_mode_p(VALUE self)
1260-
{
1261-
GET_STATE(self);
1262-
return state->quirks_mode ? Qtrue : Qfalse;
1263-
}
1264-
1265-
/*
1266-
* call-seq: quirks_mode=(enable)
1267-
*
1268-
* If set to true, enables the quirks_mode mode.
1269-
*/
1270-
static VALUE cState_quirks_mode_set(VALUE self, VALUE enable)
1271-
{
1272-
GET_STATE(self);
1273-
state->quirks_mode = RTEST(enable);
1274-
return Qnil;
1275-
}
1276-
12771249
/*
12781250
* call-seq: depth
12791251
*
@@ -1362,9 +1334,6 @@ void Init_generator(void)
13621334
rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
13631335
rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
13641336
rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
1365-
rb_define_method(cState, "quirks_mode?", cState_quirks_mode_p, 0);
1366-
rb_define_method(cState, "quirks_mode", cState_quirks_mode_p, 0);
1367-
rb_define_method(cState, "quirks_mode=", cState_quirks_mode_set, 1);
13681337
rb_define_method(cState, "depth", cState_depth, 0);
13691338
rb_define_method(cState, "depth=", cState_depth_set, 1);
13701339
rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
@@ -1416,7 +1385,6 @@ void Init_generator(void)
14161385
i_max_nesting = rb_intern("max_nesting");
14171386
i_allow_nan = rb_intern("allow_nan");
14181387
i_ascii_only = rb_intern("ascii_only");
1419-
i_quirks_mode = rb_intern("quirks_mode");
14201388
i_depth = rb_intern("depth");
14211389
i_buffer_initial_length = rb_intern("buffer_initial_length");
14221390
i_pack = rb_intern("pack");

ext/json/ext/generator/generator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ typedef struct JSON_Generator_StateStruct {
7373
long max_nesting;
7474
char allow_nan;
7575
char ascii_only;
76-
char quirks_mode;
7776
long depth;
7877
long buffer_initial_length;
7978
} JSON_Generator_State;

java/src/json/ext/Generator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ RubyString generateNew(Session session, T object) {
172172
result = RubyString.newString(session.getRuntime(), buffer);
173173
ThreadContext context = session.getContext();
174174
RuntimeInfo info = session.getInfo();
175-
if (info.encodingsSupported()) {
176-
result.force_encoding(context, info.utf8.get());
177-
}
175+
result.force_encoding(context, info.utf8.get());
178176
return result;
179177
}
180178

@@ -381,8 +379,7 @@ void generate(Session session, RubyString object, ByteList buffer) {
381379
RuntimeInfo info = session.getInfo();
382380
RubyString src;
383381

384-
if (info.encodingsSupported() &&
385-
object.encoding(session.getContext()) != info.utf8.get()) {
382+
if (object.encoding(session.getContext()) != info.utf8.get()) {
386383
src = (RubyString)object.encode(session.getContext(),
387384
info.utf8.get());
388385
} else {

java/src/json/ext/GeneratorState.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ public IRubyObject initialize_copy(ThreadContext context, IRubyObject vOrig) {
208208
public IRubyObject generate(ThreadContext context, IRubyObject obj) {
209209
RubyString result = Generator.generateJson(context, obj, this);
210210
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
211-
if (info.encodingsSupported()) {
212-
result.force_encoding(context, info.utf8.get());
213-
}
211+
result.force_encoding(context, info.utf8.get());
214212
return result;
215213
}
216214

@@ -412,7 +410,7 @@ public IRubyObject depth_set(IRubyObject vDepth) {
412410
private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
413411
RubyString str = value.convertToString();
414412
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
415-
if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
413+
if (str.encoding(context) != info.utf8.get()) {
416414
str = (RubyString)str.encode(context, info.utf8.get());
417415
}
418416
return str.getByteList().dup();

java/src/json/ext/OptionsReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ RubyString getString(String key, RubyString defaultValue) {
8484

8585
RubyString str = value.convertToString();
8686
RuntimeInfo info = getRuntimeInfo();
87-
if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
87+
if (str.encoding(context) != info.utf8.get()) {
8888
str = (RubyString)str.encode(context, info.utf8.get());
8989
}
9090
return str;

0 commit comments

Comments
 (0)