berns 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/berns/berns.c +23 -26
- data/lib/berns/berns.so +0 -0
- data/lib/berns/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bce7bd3384f01f587a75bd722cca156b4357e0953bd90a5a2c8f97a630deb8db
|
4
|
+
data.tar.gz: 2c830eb788274a6d96e3e0a7db0e75826dea451eabecb3444878901d6e1adb08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20138c2bc54ab035eb9d79f1e0ae18065ba422157fa453258acd5d974f08062afee105b50d2d3564b3e4882b4331ec6f93e4da3a3091a1440ad8a74c10f1686
|
7
|
+
data.tar.gz: 598843f7a87302d0a59ba53d8e52caf0f864a2e146b473c2d95b50f1da5b11536603f4d9f51f990de385bbaa08fb6e273381672eb823ddda2b0bb614532aef33
|
data/ext/berns/berns.c
CHANGED
@@ -51,7 +51,7 @@ static const size_t sllen = 1;
|
|
51
51
|
rb_check_arity(argc, 0, 1); \
|
52
52
|
\
|
53
53
|
char *tag = #element_name; \
|
54
|
-
char *string = void_element(tag, strlen(tag),
|
54
|
+
char *string = void_element(tag, strlen(tag), argv[0]); \
|
55
55
|
VALUE rstring = rb_utf8_str_new_cstr(string); \
|
56
56
|
free(string); \
|
57
57
|
\
|
@@ -67,7 +67,7 @@ static const size_t sllen = 1;
|
|
67
67
|
\
|
68
68
|
CONTENT_FROM_BLOCK; \
|
69
69
|
char *tag = #element_name; \
|
70
|
-
char *string = element(tag, strlen(tag), RSTRING_PTR(content), RSTRING_LEN(content),
|
70
|
+
char *string = element(tag, strlen(tag), RSTRING_PTR(content), RSTRING_LEN(content), argv[0]); \
|
71
71
|
VALUE rstring = rb_utf8_str_new_cstr(string); \
|
72
72
|
free(string); \
|
73
73
|
\
|
@@ -168,21 +168,21 @@ static char * string_value_to_attribute(const char *attr, const size_t attrlen,
|
|
168
168
|
}
|
169
169
|
}
|
170
170
|
|
171
|
-
static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE
|
172
|
-
if (TYPE(
|
171
|
+
static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE value) {
|
172
|
+
if (TYPE(value) == T_IMEMO) {
|
173
173
|
return strdup("");
|
174
174
|
}
|
175
175
|
|
176
|
-
Check_Type(
|
176
|
+
Check_Type(value, T_HASH);
|
177
177
|
|
178
|
-
if (rb_hash_size(
|
178
|
+
if (rb_hash_size(value) == 1) {
|
179
179
|
return strdup("");
|
180
180
|
}
|
181
181
|
|
182
182
|
VALUE subkey;
|
183
183
|
VALUE subvalue;
|
184
184
|
|
185
|
-
const VALUE keys = rb_funcall(
|
185
|
+
const VALUE keys = rb_funcall(value, rb_intern("keys"), 0);
|
186
186
|
const VALUE length = RARRAY_LEN(keys);
|
187
187
|
|
188
188
|
size_t allocated = 256;
|
@@ -194,7 +194,7 @@ static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE *v
|
|
194
194
|
|
195
195
|
for (unsigned int i = 0; i < length; i++) {
|
196
196
|
subkey = rb_ary_entry(keys, i);
|
197
|
-
subvalue = rb_hash_aref(
|
197
|
+
subvalue = rb_hash_aref(value, subkey);
|
198
198
|
|
199
199
|
switch(TYPE(subkey)) {
|
200
200
|
case T_STRING:
|
@@ -243,6 +243,8 @@ static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE *v
|
|
243
243
|
combined = strdup("");
|
244
244
|
break;
|
245
245
|
|
246
|
+
case T_NIL:
|
247
|
+
/* Fall through. */
|
246
248
|
case T_TRUE:
|
247
249
|
combined = string_value_to_attribute(subattr, subattr_len, "", 0);
|
248
250
|
break;
|
@@ -256,13 +258,8 @@ static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE *v
|
|
256
258
|
combined = string_value_to_attribute(subattr, subattr_len, RSTRING_PTR(subvalue), RSTRING_LEN(subvalue));
|
257
259
|
break;
|
258
260
|
|
259
|
-
case T_NIL:
|
260
|
-
subvalue = rb_utf8_str_new_cstr("");
|
261
|
-
combined = string_value_to_attribute(subattr, subattr_len, RSTRING_PTR(subvalue), RSTRING_LEN(subvalue));
|
262
|
-
break;
|
263
|
-
|
264
261
|
case T_HASH:
|
265
|
-
combined = hash_value_to_attribute(subattr, subattr_len,
|
262
|
+
combined = hash_value_to_attribute(subattr, subattr_len, subvalue);
|
266
263
|
break;
|
267
264
|
|
268
265
|
default:
|
@@ -313,7 +310,7 @@ static char * hash_value_to_attribute(char *attr, const size_t attrlen, VALUE *v
|
|
313
310
|
/*
|
314
311
|
* Convert an attribute name and value into a string.
|
315
312
|
*/
|
316
|
-
static char * to_attribute(VALUE attr, VALUE
|
313
|
+
static char * to_attribute(VALUE attr, VALUE value) {
|
317
314
|
switch(TYPE(attr)) {
|
318
315
|
case T_SYMBOL:
|
319
316
|
attr = rb_sym2str(attr);
|
@@ -327,7 +324,7 @@ static char * to_attribute(VALUE attr, VALUE *value) {
|
|
327
324
|
char *val = NULL;
|
328
325
|
VALUE str;
|
329
326
|
|
330
|
-
switch(TYPE(
|
327
|
+
switch(TYPE(value)) {
|
331
328
|
case T_NIL:
|
332
329
|
case T_TRUE:
|
333
330
|
val = empty_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr));
|
@@ -339,14 +336,14 @@ static char * to_attribute(VALUE attr, VALUE *value) {
|
|
339
336
|
val = hash_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr), value);
|
340
337
|
break;
|
341
338
|
case T_STRING:
|
342
|
-
val = string_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr), RSTRING_PTR(
|
339
|
+
val = string_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr), RSTRING_PTR(value), RSTRING_LEN(value));
|
343
340
|
break;
|
344
341
|
case T_SYMBOL:
|
345
|
-
str = rb_sym2str(
|
342
|
+
str = rb_sym2str(value);
|
346
343
|
val = string_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr), RSTRING_PTR(str), RSTRING_LEN(str));
|
347
344
|
break;
|
348
345
|
default:
|
349
|
-
str = rb_funcall(
|
346
|
+
str = rb_funcall(value, rb_intern("to_s"), 0);
|
350
347
|
val = string_value_to_attribute(RSTRING_PTR(attr), RSTRING_LEN(attr), RSTRING_PTR(str), RSTRING_LEN(str));
|
351
348
|
break;
|
352
349
|
}
|
@@ -372,7 +369,7 @@ static VALUE external_to_attribute(RB_UNUSED_VAR(VALUE self), VALUE attr, VALUE
|
|
372
369
|
|
373
370
|
StringValue(attr);
|
374
371
|
|
375
|
-
char *val = to_attribute(attr,
|
372
|
+
char *val = to_attribute(attr, value);
|
376
373
|
VALUE rstring = rb_utf8_str_new_cstr(val);
|
377
374
|
free(val);
|
378
375
|
|
@@ -393,7 +390,7 @@ static VALUE external_to_attributes(RB_UNUSED_VAR(VALUE self), VALUE attributes)
|
|
393
390
|
}
|
394
391
|
|
395
392
|
char *empty = "";
|
396
|
-
char *attrs = hash_value_to_attribute(empty, 0,
|
393
|
+
char *attrs = hash_value_to_attribute(empty, 0, attributes);
|
397
394
|
|
398
395
|
VALUE rstring = rb_utf8_str_new_cstr(attrs);
|
399
396
|
free(attrs);
|
@@ -401,9 +398,9 @@ static VALUE external_to_attributes(RB_UNUSED_VAR(VALUE self), VALUE attributes)
|
|
401
398
|
return rstring;
|
402
399
|
}
|
403
400
|
|
404
|
-
static char * void_element(char *tag, size_t tlen, VALUE
|
401
|
+
static char * void_element(char *tag, size_t tlen, VALUE attributes) {
|
405
402
|
/* T_IMEMO is what we get if an optional argument was not passed. */
|
406
|
-
if (TYPE(
|
403
|
+
if (TYPE(attributes) == T_IMEMO) {
|
407
404
|
size_t total = tag_olen + tlen + tag_clen + 1;
|
408
405
|
char *string = malloc(total);
|
409
406
|
char *ptr;
|
@@ -454,7 +451,7 @@ static VALUE external_void_element(int argc, VALUE *arguments, RB_UNUSED_VAR(VAL
|
|
454
451
|
|
455
452
|
StringValue(tag);
|
456
453
|
|
457
|
-
char *string = void_element(RSTRING_PTR(tag), RSTRING_LEN(tag),
|
454
|
+
char *string = void_element(RSTRING_PTR(tag), RSTRING_LEN(tag), attributes);
|
458
455
|
VALUE rstring = rb_utf8_str_new_cstr(string);
|
459
456
|
|
460
457
|
free(string);
|
@@ -462,7 +459,7 @@ static VALUE external_void_element(int argc, VALUE *arguments, RB_UNUSED_VAR(VAL
|
|
462
459
|
return rstring;
|
463
460
|
}
|
464
461
|
|
465
|
-
static char * element(char *tag, size_t tlen, char *content, size_t conlen, VALUE
|
462
|
+
static char * element(char *tag, size_t tlen, char *content, size_t conlen, VALUE attributes) {
|
466
463
|
char *empty = "";
|
467
464
|
char *attrs = hash_value_to_attribute(empty, 0, attributes);
|
468
465
|
size_t alen = strlen(attrs);
|
@@ -529,7 +526,7 @@ static VALUE external_element(int argc, VALUE *arguments, RB_UNUSED_VAR(VALUE se
|
|
529
526
|
|
530
527
|
CONTENT_FROM_BLOCK;
|
531
528
|
|
532
|
-
char *string = element(RSTRING_PTR(tag), RSTRING_LEN(tag), RSTRING_PTR(content), RSTRING_LEN(content),
|
529
|
+
char *string = element(RSTRING_PTR(tag), RSTRING_LEN(tag), RSTRING_PTR(content), RSTRING_LEN(content), attributes);
|
533
530
|
VALUE rstring = rb_utf8_str_new_cstr(string);
|
534
531
|
free(string);
|
535
532
|
|
data/lib/berns/berns.so
CHANGED
Binary file
|
data/lib/berns/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Beck
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-05-
|
12
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: benchmark-ips
|