@@ -161,7 +161,6 @@ static int conf_touch_dep(const char *name)
161
161
162
162
struct conf_printer {
163
163
void (* print_symbol )(FILE * , struct symbol * , const char * , void * );
164
- void (* print_comment )(FILE * , const char * , void * );
165
164
};
166
165
167
166
static void conf_warning (const char * fmt , ...)
@@ -594,6 +593,36 @@ int conf_read(const char *name)
594
593
return 0 ;
595
594
}
596
595
596
+ struct comment_style {
597
+ const char * decoration ;
598
+ const char * prefix ;
599
+ const char * postfix ;
600
+ };
601
+
602
+ static const struct comment_style comment_style_pound = {
603
+ .decoration = "#" ,
604
+ .prefix = "#" ,
605
+ .postfix = "#" ,
606
+ };
607
+
608
+ static const struct comment_style comment_style_c = {
609
+ .decoration = " *" ,
610
+ .prefix = "/*" ,
611
+ .postfix = " */" ,
612
+ };
613
+
614
+ static void conf_write_heading (FILE * fp , const struct comment_style * cs )
615
+ {
616
+ fprintf (fp , "%s\n" , cs -> prefix );
617
+
618
+ fprintf (fp , "%s Automatically generated file; DO NOT EDIT.\n" ,
619
+ cs -> decoration );
620
+
621
+ fprintf (fp , "%s %s\n" , cs -> decoration , rootmenu .prompt -> text );
622
+
623
+ fprintf (fp , "%s\n" , cs -> postfix );
624
+ }
625
+
597
626
/*
598
627
* Kconfig configuration printer
599
628
*
@@ -625,30 +654,9 @@ kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
625
654
fprintf (fp , "%s%s=%s\n" , CONFIG_ , sym -> name , value );
626
655
}
627
656
628
- static void
629
- kconfig_print_comment (FILE * fp , const char * value , void * arg )
630
- {
631
- const char * p = value ;
632
- size_t l ;
633
-
634
- for (;;) {
635
- l = strcspn (p , "\n" );
636
- fprintf (fp , "#" );
637
- if (l ) {
638
- fprintf (fp , " " );
639
- xfwrite (p , l , 1 , fp );
640
- p += l ;
641
- }
642
- fprintf (fp , "\n" );
643
- if (* p ++ == '\0' )
644
- break ;
645
- }
646
- }
647
-
648
657
static struct conf_printer kconfig_printer_cb =
649
658
{
650
659
.print_symbol = kconfig_print_symbol ,
651
- .print_comment = kconfig_print_comment ,
652
660
};
653
661
654
662
/*
@@ -697,32 +705,9 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
697
705
698
706
}
699
707
700
- static void
701
- header_print_comment (FILE * fp , const char * value , void * arg )
702
- {
703
- const char * p = value ;
704
- size_t l ;
705
-
706
- fprintf (fp , "/*\n" );
707
- for (;;) {
708
- l = strcspn (p , "\n" );
709
- fprintf (fp , " *" );
710
- if (l ) {
711
- fprintf (fp , " " );
712
- xfwrite (p , l , 1 , fp );
713
- p += l ;
714
- }
715
- fprintf (fp , "\n" );
716
- if (* p ++ == '\0' )
717
- break ;
718
- }
719
- fprintf (fp , " */\n" );
720
- }
721
-
722
708
static struct conf_printer header_printer_cb =
723
709
{
724
710
.print_symbol = header_print_symbol ,
725
- .print_comment = header_print_comment ,
726
711
};
727
712
728
713
static void conf_write_symbol (FILE * fp , struct symbol * sym ,
@@ -746,20 +731,6 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
746
731
free (escaped );
747
732
}
748
733
749
- static void
750
- conf_write_heading (FILE * fp , struct conf_printer * printer , void * printer_arg )
751
- {
752
- char buf [256 ];
753
-
754
- snprintf (buf , sizeof (buf ),
755
- "\n"
756
- "Automatically generated file; DO NOT EDIT.\n"
757
- "%s\n" ,
758
- rootmenu .prompt -> text );
759
-
760
- printer -> print_comment (fp , buf , printer_arg );
761
- }
762
-
763
734
/*
764
735
* Write out a minimal config.
765
736
* All values that has default values are skipped as this is redundant.
@@ -876,7 +847,7 @@ int conf_write(const char *name)
876
847
if (!out )
877
848
return 1 ;
878
849
879
- conf_write_heading (out , & kconfig_printer_cb , NULL );
850
+ conf_write_heading (out , & comment_style_pound );
880
851
881
852
if (!conf_get_changed ())
882
853
sym_clear_all_valid ();
@@ -1080,8 +1051,8 @@ int conf_write_autoconf(int overwrite)
1080
1051
return 1 ;
1081
1052
}
1082
1053
1083
- conf_write_heading (out , & kconfig_printer_cb , NULL );
1084
- conf_write_heading (out_h , & header_printer_cb , NULL );
1054
+ conf_write_heading (out , & comment_style_pound );
1055
+ conf_write_heading (out_h , & comment_style_c );
1085
1056
1086
1057
for_all_symbols (i , sym ) {
1087
1058
sym_calc_value (sym );
0 commit comments