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

Comparing Convert-BER-XS/XS.xs (file contents):
Revision 1.25 by root, Sun Apr 21 10:40:30 2019 UTC vs.
Revision 1.28 by root, Tue Apr 23 17:55:54 2019 UTC

141{ 141{
142 if (!SvOK (profile)) 142 if (!SvOK (profile))
143 return default_profile; 143 return default_profile;
144 144
145 if (!SvROK (profile)) 145 if (!SvROK (profile))
146 croak ("invalid profile"); 146 croak ("Convert::BER::XS::Profile expected");
147 147
148 profile = SvRV (profile); 148 profile = SvRV (profile);
149 149
150 if (SvSTASH (profile) != profile_stash) 150 if (SvSTASH (profile) != profile_stash)
151 croak ("invalid profile object"); 151 croak ("Convert::BER::XS::Profile expected");
152 152
153 return (void *)profile; 153 return (void *)profile;
154} 154}
155 155
156static int 156static int
402 static char oid[MAX_OID_STRLEN]; // static, because too large for stack 402 static char oid[MAX_OID_STRLEN]; // static, because too large for stack
403 char *app = oid; 403 char *app = oid;
404 404
405 if (relative) 405 if (relative)
406 app = write_uv (app, w); 406 app = write_uv (app, w);
407 else
408 {
409 UV w1, w2;
410
407 else if (w < 2 * 40) 411 if (w < 2 * 40)
408 { 412 (w1 = w / 40), (w2 = w % 40);
413 else
414 (w1 = 2), (w2 = w - 2 * 40);
415
409 app = write_uv (app, (U8)w / 40); 416 app = write_uv (app, w1);
410 *app++ = '.'; 417 *app++ = '.';
411 app = write_uv (app, (U8)w % 40);
412 }
413 else
414 {
415 app = write_uv (app, 2); 418 app = write_uv (app, w2);
416 *app++ = '.';
417 app = write_uv (app, w - 2 * 40);
418 } 419 }
419 420
420 while (cur < end) 421 while (cur < end)
421 { 422 {
422 // we assume an oid component is never > 64 digits 423 // we assume an oid component is never > 64 digits
675 else 676 else
676 { 677 {
677 U8 *lenb = cur++; 678 U8 *lenb = cur++;
678 679
679#if UVSIZE > 4 680#if UVSIZE > 4
680 *cur = val >> 56; cur += *cur > 0; 681 *cur = val >> 56; cur += val >= ((UV)1 << (8 * 7));
681 *cur = val >> 48; cur += *cur > 0; 682 *cur = val >> 48; cur += val >= ((UV)1 << (8 * 6));
682 *cur = val >> 40; cur += *cur > 0; 683 *cur = val >> 40; cur += val >= ((UV)1 << (8 * 5));
683 *cur = val >> 32; cur += *cur > 0; 684 *cur = val >> 32; cur += val >= ((UV)1 << (8 * 4));
684#endif 685#endif
685 *cur = val >> 24; cur += *cur > 0; 686 *cur = val >> 24; cur += val >= ((UV)1 << (8 * 3));
686 *cur = val >> 16; cur += *cur > 0; 687 *cur = val >> 16; cur += val >= ((UV)1 << (8 * 2));
687 *cur = val >> 8; cur += *cur > 0; 688 *cur = val >> 8; cur += val >= ((UV)1 << (8 * 1));
688 *cur = val ; cur += 1; 689 *cur = val ; cur += 1;
689 690
690 *lenb = 0x80 + cur - lenb - 1; 691 *lenb = 0x80 + cur - lenb - 1;
691 } 692 }
692 693

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines