MCPcopy Create free account
hub / github.com/git/git / decode_b_segment

Function decode_b_segment

mailinfo.c:414–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414static int decode_b_segment(struct strbuf *out, const struct strbuf *b_seg)
415{
416 /* Decode in..ep, possibly in-place to ot */
417 int c, pos = 0, acc = 0;
418 const char *in = b_seg->buf;
419 strbuf_grow(out, b_seg->len);
420
421 while ((c = *in++) != 0) {
422 if (c == '+')
423 c = 62;
424 else if (c == '/')
425 c = 63;
426 else if ('A' <= c && c <= 'Z')
427 c -= 'A';
428 else if ('a' <= c && c <= 'z')
429 c -= 'a' - 26;
430 else if ('0' <= c && c <= '9')
431 c -= '0' - 52;
432 else
433 continue; /* garbage */
434 switch (pos++) {
435 case 0:
436 acc = (c << 2);
437 break;
438 case 1:
439 strbuf_addch(out, (acc | (c >> 4)));
440 acc = (c & 15) << 4;
441 break;
442 case 2:
443 strbuf_addch(out, (acc | (c >> 2)));
444 acc = (c & 3) << 6;
445 break;
446 case 3:
447 strbuf_addch(out, (acc | c));
448 acc = pos = 0;
449 break;
450 }
451 }
452 return 0;
453}
454
455static int convert_to_utf8(struct mailinfo *mi,
456 struct strbuf *line, const char *charset)

Callers 2

decode_headerFunction · 0.70
decode_transfer_encodingFunction · 0.70

Calls 2

strbuf_growFunction · 0.85
strbuf_addchFunction · 0.85

Tested by

no test coverage detected