Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kconfig: move sym_escape_string_value() to confdata.c

Now that sym_escape_string_value() is only used in confdata.c
it can be a 'static' function.

Rename it escape_string_value() because it is agnostic about
(struct sym *).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+45 -47
+45 -2
scripts/kconfig/confdata.c
··· 620 620 fprintf(fp, "%s\n", cs->postfix); 621 621 } 622 622 623 + /* The returned pointer must be freed on the caller side */ 624 + static char *escape_string_value(const char *in) 625 + { 626 + const char *p; 627 + char *out; 628 + size_t len; 629 + 630 + len = strlen(in) + strlen("\"\"") + 1; 631 + 632 + p = in; 633 + while (1) { 634 + p += strcspn(p, "\"\\"); 635 + 636 + if (p[0] == '\0') 637 + break; 638 + 639 + len++; 640 + p++; 641 + } 642 + 643 + out = xmalloc(len); 644 + out[0] = '\0'; 645 + 646 + strcat(out, "\""); 647 + 648 + p = in; 649 + while (1) { 650 + len = strcspn(p, "\"\\"); 651 + strncat(out, p, len); 652 + p += len; 653 + 654 + if (p[0] == '\0') 655 + break; 656 + 657 + strcat(out, "\\"); 658 + strncat(out, p++, 1); 659 + } 660 + 661 + strcat(out, "\""); 662 + 663 + return out; 664 + } 665 + 623 666 /* 624 667 * Kconfig configuration printer 625 668 * ··· 691 648 } 692 649 693 650 if (sym->type == S_STRING && escape_string) { 694 - escaped = sym_escape_string_value(val); 651 + escaped = escape_string_value(val); 695 652 val = escaped; 696 653 } 697 654 ··· 745 702 val_prefix = "0x"; 746 703 break; 747 704 case S_STRING: 748 - escaped = sym_escape_string_value(val); 705 + escaped = escape_string_value(val); 749 706 val = escaped; 750 707 default: 751 708 break;
-1
scripts/kconfig/lkc_proto.h
··· 18 18 19 19 struct symbol * sym_lookup(const char *name, int flags); 20 20 struct symbol * sym_find(const char *name); 21 - char *sym_escape_string_value(const char *in); 22 21 void print_symbol_for_listconfig(struct symbol *sym); 23 22 struct symbol ** sym_re_search(const char *pattern); 24 23 const char * sym_type_name(enum symbol_type type);
-44
scripts/kconfig/symbol.c
··· 871 871 return symbol; 872 872 } 873 873 874 - /* The returned pointer must be freed on the caller side */ 875 - char *sym_escape_string_value(const char *in) 876 - { 877 - const char *p; 878 - size_t reslen; 879 - char *res; 880 - size_t l; 881 - 882 - reslen = strlen(in) + strlen("\"\"") + 1; 883 - 884 - p = in; 885 - for (;;) { 886 - l = strcspn(p, "\"\\"); 887 - p += l; 888 - 889 - if (p[0] == '\0') 890 - break; 891 - 892 - reslen++; 893 - p++; 894 - } 895 - 896 - res = xmalloc(reslen); 897 - res[0] = '\0'; 898 - 899 - strcat(res, "\""); 900 - 901 - p = in; 902 - for (;;) { 903 - l = strcspn(p, "\"\\"); 904 - strncat(res, p, l); 905 - p += l; 906 - 907 - if (p[0] == '\0') 908 - break; 909 - 910 - strcat(res, "\\"); 911 - strncat(res, p++, 1); 912 - } 913 - 914 - strcat(res, "\""); 915 - return res; 916 - } 917 - 918 874 struct sym_match { 919 875 struct symbol *sym; 920 876 off_t so, eo;