MCPcopy Create free account
hub / github.com/coreboot/coreboot / escape_string_value

Function escape_string_value

util/kconfig/confdata.c:662–702  ·  view source on GitHub ↗

The returned pointer must be freed on the caller side */

Source from the content-addressed store, hash-verified

660
661/* The returned pointer must be freed on the caller side */
662static char *escape_string_value(const char *in)
663{
664 const char *p;
665 char *out;
666 size_t len;
667
668 len = strlen(in) + strlen("\"\"") + 1;
669
670 p = in;
671 while (1) {
672 p += strcspn(p, "\"\\");
673
674 if (p[0] == '\0')
675 break;
676
677 len++;
678 p++;
679 }
680
681 out = xmalloc(len);
682 out[0] = '\0';
683
684 strcat(out, "\"");
685
686 p = in;
687 while (1) {
688 len = strcspn(p, "\"\\");
689 strncat(out, p, len);
690 p += len;
691
692 if (p[0] == '\0')
693 break;
694
695 strcat(out, "\\");
696 strncat(out, p++, 1);
697 }
698
699 strcat(out, "\"");
700
701 return out;
702}
703
704enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
705

Callers 3

__print_symbolFunction · 0.85
print_symbol_for_cFunction · 0.85

Calls 5

strlenFunction · 0.85
strcatFunction · 0.85
strncatFunction · 0.85
xmallocFunction · 0.70
strcspnFunction · 0.50

Tested by

no test coverage detected