MCPcopy Create free account
hub / github.com/apple/foundationdb / de4514

Function de4514

flow/TLSConfig.actor.cpp:395–479  ·  view source on GitHub ↗

Does not handle "raw" form (e.g. #28C4D1), only escaped text

Source from the content-addressed store, hash-verified

393
394// Does not handle "raw" form (e.g. #28C4D1), only escaped text
395static std::string de4514(std::string const& input, int start, int& out_end) {
396 std::string output;
397
398 if (input[start] == '#' || input[start] == ' ') {
399 out_end = start;
400 return output;
401 }
402
403 int space_count = 0;
404
405 for (int p = start; p < input.size();) {
406 switch (input[p]) {
407 case '\\': // Handle escaped sequence
408
409 // Backslash escaping nothing!
410 if (p == input.size() - 1) {
411 out_end = p;
412 goto FIN;
413 }
414
415 switch (input[p + 1]) {
416 case ' ':
417 case '"':
418 case '#':
419 case '+':
420 case ',':
421 case ';':
422 case '<':
423 case '=':
424 case '>':
425 case '|':
426 case '\\':
427 output += input[p + 1];
428 p += 2;
429 space_count = 0;
430 continue;
431
432 default:
433 // Backslash escaping pair of hex digits requires two characters
434 if (p == input.size() - 2) {
435 out_end = p;
436 goto FIN;
437 }
438
439 try {
440 output += hexValue(input[p + 1]) * 16 + hexValue(input[p + 2]);
441 p += 3;
442 space_count = 0;
443 continue;
444 } catch (...) {
445 out_end = p;
446 goto FIN;
447 }
448 }
449
450 case '"':
451 case '+':
452 case ',':

Callers 1

RuleMethod · 0.70

Calls 3

hexValueFunction · 0.70
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected