File tree Expand file tree Collapse file tree 4 files changed +24
-23
lines changed Expand file tree Collapse file tree 4 files changed +24
-23
lines changed Original file line number Diff line number Diff line change @@ -647,17 +647,16 @@ static void check_conf(struct menu *menu)
647
647
switch (input_mode ) {
648
648
case listnewconfig :
649
649
if (sym -> name ) {
650
- const char * str ;
650
+ const char * val = sym_get_string_value (sym );
651
+ char * escaped = NULL ;
651
652
652
653
if (sym -> type == S_STRING ) {
653
- str = sym_get_string_value (sym );
654
- str = sym_escape_string_value (str );
655
- printf ("%s%s=%s\n" , CONFIG_ , sym -> name , str );
656
- free ((void * )str );
657
- } else {
658
- str = sym_get_string_value (sym );
659
- printf ("%s%s=%s\n" , CONFIG_ , sym -> name , str );
654
+ escaped = sym_escape_string_value (val );
655
+ val = escaped ;
660
656
}
657
+
658
+ printf ("%s%s=%s\n" , CONFIG_ , sym -> name , val );
659
+ free (escaped );
661
660
}
662
661
break ;
663
662
case helpnewconfig :
Original file line number Diff line number Diff line change @@ -728,21 +728,22 @@ static struct conf_printer header_printer_cb =
728
728
static void conf_write_symbol (FILE * fp , struct symbol * sym ,
729
729
struct conf_printer * printer , void * printer_arg )
730
730
{
731
- const char * str ;
731
+ const char * val ;
732
+ char * escaped = NULL ;
732
733
733
- switch (sym -> type ) {
734
- case S_UNKNOWN :
735
- break ;
736
- case S_STRING :
737
- str = sym_get_string_value (sym );
738
- str = sym_escape_string_value (str );
739
- printer -> print_symbol (fp , sym , str , printer_arg );
740
- free ((void * )str );
741
- break ;
742
- default :
743
- str = sym_get_string_value (sym );
744
- printer -> print_symbol (fp , sym , str , printer_arg );
734
+ if (sym -> type == S_UNKNOWN )
735
+ return ;
736
+
737
+ val = sym_get_string_value (sym );
738
+
739
+ if (sym -> type == S_STRING ) {
740
+ escaped = sym_escape_string_value (val );
741
+ val = escaped ;
745
742
}
743
+
744
+ printer -> print_symbol (fp , sym , val , printer_arg );
745
+
746
+ free (escaped );
746
747
}
747
748
748
749
static void
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
18
18
19
19
struct symbol * sym_lookup (const char * name , int flags );
20
20
struct symbol * sym_find (const char * name );
21
- const char * sym_escape_string_value (const char * in );
21
+ char * sym_escape_string_value (const char * in );
22
22
struct symbol * * sym_re_search (const char * pattern );
23
23
const char * sym_type_name (enum symbol_type type );
24
24
void sym_calc_value (struct symbol * sym );
Original file line number Diff line number Diff line change @@ -871,7 +871,8 @@ struct symbol *sym_find(const char *name)
871
871
return symbol ;
872
872
}
873
873
874
- const char * sym_escape_string_value (const char * in )
874
+ /* The returned pointer must be freed on the caller side */
875
+ char * sym_escape_string_value (const char * in )
875
876
{
876
877
const char * p ;
877
878
size_t reslen ;
You can’t perform that action at this time.
0 commit comments