ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.xs
(Generate patch)

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.44 by root, Tue Feb 18 22:12:12 2014 UTC vs.
Revision 1.48 by root, Sun Sep 20 23:25:53 2015 UTC

324 324
325 ++enc->depth; 325 ++enc->depth;
326 326
327 encode_uint (enc, MAJOR_ARRAY, len + 1); 327 encode_uint (enc, MAJOR_ARRAY, len + 1);
328 328
329 if (SvMAGICAL (av))
329 for (i = 0; i <= len; ++i) 330 for (i = 0; i <= len; ++i)
330 { 331 {
331 SV **svp = av_fetch (av, i, 0); 332 SV **svp = av_fetch (av, i, 0);
332 encode_sv (enc, svp ? *svp : &PL_sv_undef); 333 encode_sv (enc, svp ? *svp : &PL_sv_undef);
333 } 334 }
335 else
336 for (i = 0; i <= len; ++i)
337 {
338 SV *sv = AvARRAY (av)[i];
339 encode_sv (enc, sv ? sv : &PL_sv_undef);
340 }
334 341
335 --enc->depth; 342 --enc->depth;
336} 343}
337 344
338static void 345static void
577} 584}
578 585
579static SV * 586static SV *
580encode_cbor (SV *scalar, CBOR *cbor) 587encode_cbor (SV *scalar, CBOR *cbor)
581{ 588{
582 enc_t enc = { }; 589 enc_t enc = { 0 };
583 590
584 enc.cbor = *cbor; 591 enc.cbor = *cbor;
585 enc.sv = sv_2mortal (NEWSV (0, INIT_SIZE)); 592 enc.sv = sv_2mortal (NEWSV (0, INIT_SIZE));
586 enc.cur = SvPVX (enc.sv); 593 enc.cur = SvPVX (enc.sv);
587 enc.end = SvEND (enc.sv); 594 enc.end = SvEND (enc.sv);
1156} 1163}
1157 1164
1158static SV * 1165static SV *
1159decode_cbor (SV *string, CBOR *cbor, char **offset_return) 1166decode_cbor (SV *string, CBOR *cbor, char **offset_return)
1160{ 1167{
1161 dec_t dec = { }; 1168 dec_t dec = { 0 };
1162 SV *sv; 1169 SV *sv;
1163 STRLEN len; 1170 STRLEN len;
1164 char *data = SvPVbyte (string, len); 1171 char *data = SvPVbyte (string, len);
1165 1172
1166 if (len > cbor->max_size && cbor->max_size) 1173 if (len > cbor->max_size && cbor->max_size)
1257 1264
1258 int major = *p >> MAJOR_SHIFT; 1265 int major = *p >> MAJOR_SHIFT;
1259 1266
1260 switch (major) 1267 switch (major)
1261 { 1268 {
1269 case MAJOR_TAG >> MAJOR_SHIFT:
1270 ++count; // tags merely prefix another value
1271 break;
1272
1262 case MAJOR_BYTES >> MAJOR_SHIFT: 1273 case MAJOR_BYTES >> MAJOR_SHIFT:
1263 case MAJOR_TEXT >> MAJOR_SHIFT: 1274 case MAJOR_TEXT >> MAJOR_SHIFT:
1264 case MAJOR_ARRAY >> MAJOR_SHIFT: 1275 case MAJOR_ARRAY >> MAJOR_SHIFT:
1265 case MAJOR_MAP >> MAJOR_SHIFT: 1276 case MAJOR_MAP >> MAJOR_SHIFT:
1266 { 1277 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines