oj 3.11.1 → 3.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/ext/oj/buf.h +34 -38
  4. data/ext/oj/cache8.c +59 -62
  5. data/ext/oj/cache8.h +8 -7
  6. data/ext/oj/circarray.c +33 -35
  7. data/ext/oj/circarray.h +11 -9
  8. data/ext/oj/code.c +170 -174
  9. data/ext/oj/code.h +21 -20
  10. data/ext/oj/compat.c +159 -166
  11. data/ext/oj/custom.c +802 -851
  12. data/ext/oj/dump.c +766 -778
  13. data/ext/oj/dump.h +49 -51
  14. data/ext/oj/dump_compat.c +1 -0
  15. data/ext/oj/dump_leaf.c +116 -157
  16. data/ext/oj/dump_object.c +609 -628
  17. data/ext/oj/dump_strict.c +318 -327
  18. data/ext/oj/encode.h +3 -4
  19. data/ext/oj/err.c +39 -25
  20. data/ext/oj/err.h +24 -15
  21. data/ext/oj/extconf.rb +2 -1
  22. data/ext/oj/fast.c +1042 -1041
  23. data/ext/oj/hash.c +62 -66
  24. data/ext/oj/hash.h +7 -6
  25. data/ext/oj/hash_test.c +450 -443
  26. data/ext/oj/mimic_json.c +412 -402
  27. data/ext/oj/object.c +559 -528
  28. data/ext/oj/odd.c +123 -128
  29. data/ext/oj/odd.h +27 -25
  30. data/ext/oj/oj.c +1123 -924
  31. data/ext/oj/oj.h +286 -298
  32. data/ext/oj/parse.c +938 -930
  33. data/ext/oj/parse.h +70 -69
  34. data/ext/oj/rails.c +836 -839
  35. data/ext/oj/rails.h +7 -7
  36. data/ext/oj/reader.c +135 -140
  37. data/ext/oj/reader.h +66 -79
  38. data/ext/oj/resolve.c +43 -43
  39. data/ext/oj/resolve.h +3 -2
  40. data/ext/oj/rxclass.c +67 -68
  41. data/ext/oj/rxclass.h +12 -10
  42. data/ext/oj/saj.c +451 -479
  43. data/ext/oj/scp.c +93 -103
  44. data/ext/oj/sparse.c +770 -730
  45. data/ext/oj/stream_writer.c +120 -149
  46. data/ext/oj/strict.c +71 -86
  47. data/ext/oj/string_writer.c +198 -243
  48. data/ext/oj/trace.c +29 -33
  49. data/ext/oj/trace.h +14 -11
  50. data/ext/oj/util.c +103 -103
  51. data/ext/oj/util.h +3 -2
  52. data/ext/oj/val_stack.c +47 -47
  53. data/ext/oj/val_stack.h +79 -86
  54. data/ext/oj/wab.c +291 -309
  55. data/lib/oj/bag.rb +1 -0
  56. data/lib/oj/easy_hash.rb +5 -4
  57. data/lib/oj/mimic.rb +0 -12
  58. data/lib/oj/version.rb +1 -1
  59. data/test/activerecord/result_test.rb +7 -2
  60. data/test/foo.rb +35 -32
  61. data/test/test_fast.rb +32 -2
  62. data/test/test_generate.rb +21 -0
  63. data/test/test_hash.rb +10 -0
  64. data/test/test_scp.rb +1 -1
  65. metadata +4 -2
data/ext/oj/trace.c CHANGED
@@ -1,27 +1,27 @@
1
1
  // Copyright (c) 2018 Peter Ohler. All rights reserved.
2
+ // Licensed under the MIT License. See LICENSE file in the project root for license details.
2
3
 
3
- #include "parse.h"
4
4
  #include "trace.h"
5
5
 
6
- #define MAX_INDENT 256
6
+ #include "parse.h"
7
+
8
+ #define MAX_INDENT 256
7
9
 
8
- static void
9
- fill_indent(char *indent, int depth) {
10
+ static void fill_indent(char *indent, int depth) {
10
11
  if (MAX_INDENT <= depth) {
11
- depth = MAX_INDENT - 1;
12
+ depth = MAX_INDENT - 1;
12
13
  } else if (depth < 0) {
13
- depth = 0;
14
+ depth = 0;
14
15
  }
15
16
  if (0 < depth) {
16
- memset(indent, ' ', depth);
17
+ memset(indent, ' ', depth);
17
18
  }
18
19
  indent[depth] = '\0';
19
20
  }
20
21
 
21
- void
22
- oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where) {
23
- char fmt[64];
24
- char indent[MAX_INDENT];
22
+ void oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where) {
23
+ char fmt[64];
24
+ char indent[MAX_INDENT];
25
25
 
26
26
  depth *= 2;
27
27
  fill_indent(indent, depth);
@@ -29,46 +29,42 @@ oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, Tra
29
29
  printf(fmt, file, line, indent, func, rb_obj_classname(obj));
30
30
  }
31
31
 
32
- void
33
- oj_trace_parse_call(const char *func, ParseInfo pi, const char *file, int line, VALUE obj) {
34
- char fmt[64];
35
- char indent[MAX_INDENT];
36
- int depth = (int)(stack_size(&pi->stack) * 2);
32
+ void oj_trace_parse_call(const char *func, ParseInfo pi, const char *file, int line, VALUE obj) {
33
+ char fmt[64];
34
+ char indent[MAX_INDENT];
35
+ int depth = (int)(stack_size(&pi->stack) * 2);
37
36
 
38
37
  fill_indent(indent, depth);
39
38
  sprintf(fmt, "#0:%%13s:%%3d:Oj:-:%%%ds %%s %%s\n", depth);
40
39
  printf(fmt, file, line, indent, func, rb_obj_classname(obj));
41
40
  }
42
41
 
43
- void
44
- oj_trace_parse_in(const char *func, ParseInfo pi, const char *file, int line) {
45
- char fmt[64];
46
- char indent[MAX_INDENT];
47
- int depth = (int)(stack_size(&pi->stack) * 2);
42
+ void oj_trace_parse_in(const char *func, ParseInfo pi, const char *file, int line) {
43
+ char fmt[64];
44
+ char indent[MAX_INDENT];
45
+ int depth = (int)(stack_size(&pi->stack) * 2);
48
46
 
49
47
  fill_indent(indent, depth);
50
48
  sprintf(fmt, "#0:%%13s:%%3d:Oj:}:%%%ds %%s\n", depth);
51
49
  printf(fmt, file, line, indent, func);
52
50
  }
53
51
 
54
- void
55
- oj_trace_parse_hash_end(ParseInfo pi, const char *file, int line) {
56
- char fmt[64];
57
- char indent[MAX_INDENT];
58
- int depth = (int)(stack_size(&pi->stack) * 2 - 2);
59
- Val v = stack_peek(&pi->stack);
60
- VALUE obj = v->val;
52
+ void oj_trace_parse_hash_end(ParseInfo pi, const char *file, int line) {
53
+ char fmt[64];
54
+ char indent[MAX_INDENT];
55
+ int depth = (int)(stack_size(&pi->stack) * 2 - 2);
56
+ Val v = stack_peek(&pi->stack);
57
+ VALUE obj = v->val;
61
58
 
62
59
  fill_indent(indent, depth);
63
60
  sprintf(fmt, "#0:%%13s:%%3d:Oj:{:%%%ds hash_end %%s\n", depth);
64
61
  printf(fmt, file, line, indent, rb_obj_classname(obj));
65
62
  }
66
63
 
67
- void
68
- oj_trace_parse_array_end(ParseInfo pi, const char *file, int line) {
69
- char fmt[64];
70
- char indent[MAX_INDENT];
71
- int depth = (int)(stack_size(&pi->stack) * 2);
64
+ void oj_trace_parse_array_end(ParseInfo pi, const char *file, int line) {
65
+ char fmt[64];
66
+ char indent[MAX_INDENT];
67
+ int depth = (int)(stack_size(&pi->stack) * 2);
72
68
 
73
69
  fill_indent(indent, depth);
74
70
  sprintf(fmt, "#0:%%13s:%%3d:Oj:{:%%%ds array_ned\n", depth);
data/ext/oj/trace.h CHANGED
@@ -1,25 +1,28 @@
1
1
  // Copyright (c) 2018 Peter Ohler. All rights reserved.
2
+ // Licensed under the MIT License. See LICENSE file in the project root for license details.
2
3
 
3
4
  #ifndef OJ_TRACE_H
4
5
  #define OJ_TRACE_H
5
6
 
6
- #include <stdbool.h>
7
7
  #include <ruby.h>
8
+ #include <stdbool.h>
8
9
 
9
10
  typedef enum {
10
- TraceIn = '}',
11
- TraceOut = '{',
12
- TraceCall = '-',
13
- TraceRubyIn = '>',
14
- TraceRubyOut = '<',
11
+ TraceIn = '}',
12
+ TraceOut = '{',
13
+ TraceCall = '-',
14
+ TraceRubyIn = '>',
15
+ TraceRubyOut = '<',
15
16
  } TraceWhere;
16
17
 
17
18
  struct _parseInfo;
18
19
 
19
- extern void oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where);
20
- extern void oj_trace_parse_in(const char *func, struct _parseInfo *pi, const char *file, int line);
21
- extern void oj_trace_parse_call(const char *func, struct _parseInfo *pi, const char *file, int line, VALUE obj);
22
- extern void oj_trace_parse_hash_end(struct _parseInfo *pi, const char *file, int line);
23
- extern void oj_trace_parse_array_end(struct _parseInfo *pi, const char *file, int line);
20
+ extern void
21
+ oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where);
22
+ extern void oj_trace_parse_in(const char *func, struct _parseInfo *pi, const char *file, int line);
23
+ extern void
24
+ oj_trace_parse_call(const char *func, struct _parseInfo *pi, const char *file, int line, VALUE obj);
25
+ extern void oj_trace_parse_hash_end(struct _parseInfo *pi, const char *file, int line);
26
+ extern void oj_trace_parse_array_end(struct _parseInfo *pi, const char *file, int line);
24
27
 
25
28
  #endif /* OJ_TRACE_H */
data/ext/oj/util.c CHANGED
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) 2019 Peter Ohler. All rights reserved.
2
+ // Licensed under the MIT License. See LICENSE file in the project root for license details.
2
3
 
3
4
  #include "util.h"
4
5
 
@@ -8,129 +9,128 @@
8
9
  #include <string.h>
9
10
  #include <time.h>
10
11
 
11
- #define SECS_PER_DAY 86400LL
12
- #define SECS_PER_YEAR 31536000LL
13
- #define SECS_PER_LEAP 31622400LL
14
- #define SECS_PER_QUAD_YEAR (SECS_PER_YEAR * 3 + SECS_PER_LEAP)
15
- #define SECS_PER_CENT (SECS_PER_QUAD_YEAR * 24 + SECS_PER_YEAR * 4)
16
- #define SECS_PER_LEAP_CENT (SECS_PER_CENT + SECS_PER_DAY)
17
- #define SECS_PER_QUAD_CENT (SECS_PER_CENT * 4 + SECS_PER_DAY)
12
+ #define SECS_PER_DAY 86400LL
13
+ #define SECS_PER_YEAR 31536000LL
14
+ #define SECS_PER_LEAP 31622400LL
15
+ #define SECS_PER_QUAD_YEAR (SECS_PER_YEAR * 3 + SECS_PER_LEAP)
16
+ #define SECS_PER_CENT (SECS_PER_QUAD_YEAR * 24 + SECS_PER_YEAR * 4)
17
+ #define SECS_PER_LEAP_CENT (SECS_PER_CENT + SECS_PER_DAY)
18
+ #define SECS_PER_QUAD_CENT (SECS_PER_CENT * 4 + SECS_PER_DAY)
18
19
 
19
- static int64_t eom_secs[] = {
20
- 2678400, // January (31)
21
- 5097600, // February (28) 2419200 2505600
22
- 7776000, // March (31)
23
- 10368000, // April (30 2592000
24
- 13046400, // May (31)
25
- 15638400, // June (30)
26
- 18316800, // July (31)
27
- 20995200, // August (31)
28
- 23587200, // September (30)
29
- 26265600, // October (31)
30
- 28857600, // November (30)
31
- 31536000, // December (31)
20
+ static int64_t eom_secs[] = {
21
+ 2678400, // January (31)
22
+ 5097600, // February (28) 2419200 2505600
23
+ 7776000, // March (31)
24
+ 10368000, // April (30 2592000
25
+ 13046400, // May (31)
26
+ 15638400, // June (30)
27
+ 18316800, // July (31)
28
+ 20995200, // August (31)
29
+ 23587200, // September (30)
30
+ 26265600, // October (31)
31
+ 28857600, // November (30)
32
+ 31536000, // December (31)
32
33
  };
33
34
 
34
- static int64_t eom_leap_secs[] = {
35
- 2678400, // January (31)
36
- 5184000, // February (28) 2419200 2505600
37
- 7862400, // March (31)
38
- 10454400, // April (30 2592000
39
- 13132800, // May (31)
40
- 15724800, // June (30)
41
- 18403200, // July (31)
42
- 21081600, // August (31)
43
- 23673600, // September (30)
44
- 26352000, // October (31)
45
- 28944000, // November (30)
46
- 31622400, // December (31)
35
+ static int64_t eom_leap_secs[] = {
36
+ 2678400, // January (31)
37
+ 5184000, // February (28) 2419200 2505600
38
+ 7862400, // March (31)
39
+ 10454400, // April (30 2592000
40
+ 13132800, // May (31)
41
+ 15724800, // June (30)
42
+ 18403200, // July (31)
43
+ 21081600, // August (31)
44
+ 23673600, // September (30)
45
+ 26352000, // October (31)
46
+ 28944000, // November (30)
47
+ 31622400, // December (31)
47
48
  };
48
49
 
50
+ void sec_as_time(int64_t secs, TimeInfo ti) {
51
+ int64_t qc = 0;
52
+ int64_t c = 0;
53
+ int64_t qy = 0;
54
+ int64_t y = 0;
55
+ bool leap = false;
56
+ int64_t *ms;
57
+ int m;
58
+ int shift = 0;
49
59
 
50
- void
51
- sec_as_time(int64_t secs, TimeInfo ti) {
52
- int64_t qc = 0;
53
- int64_t c = 0;
54
- int64_t qy = 0;
55
- int64_t y = 0;
56
- bool leap = false;
57
- int64_t *ms;
58
- int m;
59
- int shift = 0;
60
-
61
- secs += 62167219200LL; // normalize to first day of the year 0
60
+ secs += 62167219200LL; // normalize to first day of the year 0
62
61
  if (secs < 0) {
63
- shift = -secs / SECS_PER_QUAD_CENT;
64
- shift++;
65
- secs += shift * SECS_PER_QUAD_CENT;
62
+ shift = -secs / SECS_PER_QUAD_CENT;
63
+ shift++;
64
+ secs += shift * SECS_PER_QUAD_CENT;
66
65
  }
67
- qc = secs / SECS_PER_QUAD_CENT;
66
+ qc = secs / SECS_PER_QUAD_CENT;
68
67
  secs = secs - qc * SECS_PER_QUAD_CENT;
69
68
  if (secs < SECS_PER_LEAP) {
70
- leap = true;
69
+ leap = true;
71
70
  } else if (secs < SECS_PER_QUAD_YEAR) {
72
- if (SECS_PER_LEAP <= secs) {
73
- secs -= SECS_PER_LEAP;
74
- y = secs / SECS_PER_YEAR;
75
- secs = secs - y * SECS_PER_YEAR;
76
- y++;
77
- leap = false;
78
- }
79
- } else if (secs < SECS_PER_LEAP_CENT) { // first century in 400 years is a leap century (one extra day)
80
- qy = secs / SECS_PER_QUAD_YEAR;
81
- secs = secs - qy * SECS_PER_QUAD_YEAR;
82
- if (secs < SECS_PER_LEAP) {
83
- leap = true;
84
- } else {
85
- secs -= SECS_PER_LEAP;
86
- y = secs / SECS_PER_YEAR;
87
- secs = secs - y * SECS_PER_YEAR;
88
- y++;
89
- }
71
+ if (SECS_PER_LEAP <= secs) {
72
+ secs -= SECS_PER_LEAP;
73
+ y = secs / SECS_PER_YEAR;
74
+ secs = secs - y * SECS_PER_YEAR;
75
+ y++;
76
+ leap = false;
77
+ }
78
+ } else if (secs < SECS_PER_LEAP_CENT) { // first century in 400 years is a leap century (one
79
+ // extra day)
80
+ qy = secs / SECS_PER_QUAD_YEAR;
81
+ secs = secs - qy * SECS_PER_QUAD_YEAR;
82
+ if (secs < SECS_PER_LEAP) {
83
+ leap = true;
84
+ } else {
85
+ secs -= SECS_PER_LEAP;
86
+ y = secs / SECS_PER_YEAR;
87
+ secs = secs - y * SECS_PER_YEAR;
88
+ y++;
89
+ }
90
90
  } else {
91
- secs -= SECS_PER_LEAP_CENT;
92
- c = secs / SECS_PER_CENT;
93
- secs = secs - c * SECS_PER_CENT;
94
- c++;
95
- if (secs < SECS_PER_YEAR * 4) {
96
- y = secs / SECS_PER_YEAR;
97
- secs = secs - y * SECS_PER_YEAR;
98
- } else {
99
- secs -= SECS_PER_YEAR * 4;
100
- qy = secs / SECS_PER_QUAD_YEAR;
101
- secs = secs - qy * SECS_PER_QUAD_YEAR;
102
- qy++;
103
- if (secs < SECS_PER_LEAP) {
104
- leap = true;
105
- } else {
106
- secs -= SECS_PER_LEAP;
107
- y = secs / SECS_PER_YEAR;
108
- secs = secs - y * SECS_PER_YEAR;
109
- y++;
110
- }
111
- }
91
+ secs -= SECS_PER_LEAP_CENT;
92
+ c = secs / SECS_PER_CENT;
93
+ secs = secs - c * SECS_PER_CENT;
94
+ c++;
95
+ if (secs < SECS_PER_YEAR * 4) {
96
+ y = secs / SECS_PER_YEAR;
97
+ secs = secs - y * SECS_PER_YEAR;
98
+ } else {
99
+ secs -= SECS_PER_YEAR * 4;
100
+ qy = secs / SECS_PER_QUAD_YEAR;
101
+ secs = secs - qy * SECS_PER_QUAD_YEAR;
102
+ qy++;
103
+ if (secs < SECS_PER_LEAP) {
104
+ leap = true;
105
+ } else {
106
+ secs -= SECS_PER_LEAP;
107
+ y = secs / SECS_PER_YEAR;
108
+ secs = secs - y * SECS_PER_YEAR;
109
+ y++;
110
+ }
111
+ }
112
112
  }
113
113
  ti->year = (int)((qc - (int64_t)shift) * 400 + c * 100 + qy * 4 + y);
114
114
  if (leap) {
115
- ms = eom_leap_secs;
115
+ ms = eom_leap_secs;
116
116
  } else {
117
- ms = eom_secs;
117
+ ms = eom_secs;
118
118
  }
119
119
  for (m = 1; m <= 12; m++, ms++) {
120
- if (secs < *ms) {
121
- if (1 < m) {
122
- secs -= *(ms - 1);
123
- }
124
- ti->mon = m;
125
- break;
126
- }
120
+ if (secs < *ms) {
121
+ if (1 < m) {
122
+ secs -= *(ms - 1);
123
+ }
124
+ ti->mon = m;
125
+ break;
126
+ }
127
127
  }
128
128
  ti->day = (int)(secs / 86400LL);
129
- secs = secs - (int64_t)ti->day * 86400LL;
129
+ secs = secs - (int64_t)ti->day * 86400LL;
130
130
  ti->day++;
131
131
  ti->hour = (int)(secs / 3600LL);
132
- secs = secs - (int64_t)ti->hour * 3600LL;
133
- ti->min = (int)(secs / 60LL);
134
- secs = secs - (int64_t)ti->min * 60LL;
135
- ti->sec = (int)secs;
132
+ secs = secs - (int64_t)ti->hour * 3600LL;
133
+ ti->min = (int)(secs / 60LL);
134
+ secs = secs - (int64_t)ti->min * 60LL;
135
+ ti->sec = (int)secs;
136
136
  }
data/ext/oj/util.h CHANGED
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) 2019 Peter Ohler. All rights reserved.
2
+ // Licensed under the MIT License. See LICENSE file in the project root for license details.
2
3
 
3
4
  #ifndef OJ_UTIL_H
4
5
  #define OJ_UTIL_H
@@ -12,8 +13,8 @@ typedef struct _timeInfo {
12
13
  int day;
13
14
  int mon;
14
15
  int year;
15
- } *TimeInfo;
16
+ } * TimeInfo;
16
17
 
17
- extern void sec_as_time(int64_t secs, TimeInfo ti);
18
+ extern void sec_as_time(int64_t secs, TimeInfo ti);
18
19
 
19
20
  #endif /* OJ_UTIL_H */
data/ext/oj/val_stack.c CHANGED
@@ -1,18 +1,19 @@
1
1
  // Copyright (c) 2011 Peter Ohler. All rights reserved.
2
+ // Licensed under the MIT License. See LICENSE file in the project root for license details.
3
+
4
+ #include "val_stack.h"
2
5
 
3
6
  #include <string.h>
4
7
 
5
- #include "oj.h"
6
8
  #include "odd.h"
7
- #include "val_stack.h"
9
+ #include "oj.h"
8
10
 
9
- static void
10
- mark(void *ptr) {
11
- ValStack stack = (ValStack)ptr;
12
- Val v;
11
+ static void mark(void *ptr) {
12
+ ValStack stack = (ValStack)ptr;
13
+ Val v;
13
14
 
14
15
  if (0 == ptr) {
15
- return;
16
+ return;
16
17
  }
17
18
  #ifdef HAVE_PTHREAD_MUTEX_INIT
18
19
  pthread_mutex_lock(&stack->mutex);
@@ -21,22 +22,22 @@ mark(void *ptr) {
21
22
  rb_gc_mark(stack->mutex);
22
23
  #endif
23
24
  for (v = stack->head; v < stack->tail; v++) {
24
- if (Qnil != v->val && Qundef != v->val) {
25
- rb_gc_mark(v->val);
26
- }
27
- if (Qnil != v->key_val && Qundef != v->key_val) {
28
- rb_gc_mark(v->key_val);
29
- }
30
- if (NULL != v->odd_args) {
31
- VALUE *a;
32
- int i;
25
+ if (Qnil != v->val && Qundef != v->val) {
26
+ rb_gc_mark(v->val);
27
+ }
28
+ if (Qnil != v->key_val && Qundef != v->key_val) {
29
+ rb_gc_mark(v->key_val);
30
+ }
31
+ if (NULL != v->odd_args) {
32
+ VALUE *a;
33
+ int i;
33
34
 
34
- for (i = v->odd_args->odd->attr_cnt, a = v->odd_args->args; 0 < i; i--, a++) {
35
- if (Qnil != *a) {
36
- rb_gc_mark(*a);
37
- }
38
- }
39
- }
35
+ for (i = v->odd_args->odd->attr_cnt, a = v->odd_args->args; 0 < i; i--, a++) {
36
+ if (Qnil != *a) {
37
+ rb_gc_mark(*a);
38
+ }
39
+ }
40
+ }
40
41
  }
41
42
  #ifdef HAVE_PTHREAD_MUTEX_INIT
42
43
  pthread_mutex_unlock(&stack->mutex);
@@ -48,43 +49,42 @@ mark(void *ptr) {
48
49
  VALUE
49
50
  oj_stack_init(ValStack stack) {
50
51
  #ifdef HAVE_PTHREAD_MUTEX_INIT
51
- int err;
52
+ int err;
52
53
 
53
54
  if (0 != (err = pthread_mutex_init(&stack->mutex, 0))) {
54
- rb_raise(rb_eException, "failed to initialize a mutex. %s", strerror(err));
55
+ rb_raise(rb_eException, "failed to initialize a mutex. %s", strerror(err));
55
56
  }
56
57
  #else
57
58
  stack->mutex = rb_mutex_new();
58
59
  #endif
59
- stack->head = stack->base;
60
- stack->end = stack->base + sizeof(stack->base) / sizeof(struct _val);
61
- stack->tail = stack->head;
62
- stack->head->val = Qundef;
63
- stack->head->key = NULL;
64
- stack->head->key_val = Qundef;
60
+ stack->head = stack->base;
61
+ stack->end = stack->base + sizeof(stack->base) / sizeof(struct _val);
62
+ stack->tail = stack->head;
63
+ stack->head->val = Qundef;
64
+ stack->head->key = NULL;
65
+ stack->head->key_val = Qundef;
65
66
  stack->head->classname = NULL;
66
- stack->head->odd_args = NULL;
67
- stack->head->clas = Qundef;
68
- stack->head->klen = 0;
69
- stack->head->clen = 0;
70
- stack->head->next = NEXT_NONE;
67
+ stack->head->odd_args = NULL;
68
+ stack->head->clas = Qundef;
69
+ stack->head->klen = 0;
70
+ stack->head->clen = 0;
71
+ stack->head->next = NEXT_NONE;
71
72
 
72
73
  return Data_Wrap_Struct(oj_cstack_class, mark, 0, stack);
73
74
  }
74
75
 
75
- const char*
76
- oj_stack_next_string(ValNext n) {
76
+ const char *oj_stack_next_string(ValNext n) {
77
77
  switch (n) {
78
- case NEXT_ARRAY_NEW: return "array element or close";
79
- case NEXT_ARRAY_ELEMENT: return "array element";
80
- case NEXT_ARRAY_COMMA: return "comma";
81
- case NEXT_HASH_NEW: return "hash pair or close";
82
- case NEXT_HASH_KEY: return "hash key";
83
- case NEXT_HASH_COLON: return "colon";
84
- case NEXT_HASH_VALUE: return "hash value";
85
- case NEXT_HASH_COMMA: return "comma";
86
- case NEXT_NONE: break;
87
- default: break;
78
+ case NEXT_ARRAY_NEW: return "array element or close";
79
+ case NEXT_ARRAY_ELEMENT: return "array element";
80
+ case NEXT_ARRAY_COMMA: return "comma";
81
+ case NEXT_HASH_NEW: return "hash pair or close";
82
+ case NEXT_HASH_KEY: return "hash key";
83
+ case NEXT_HASH_COLON: return "colon";
84
+ case NEXT_HASH_VALUE: return "hash value";
85
+ case NEXT_HASH_COMMA: return "comma";
86
+ case NEXT_NONE: break;
87
+ default: break;
88
88
  }
89
89
  return "nothing";
90
90
  }