-#!/usr/bin/perl\r
-\r
-#\r
-# Copyright (c) 2004 Massachusetts Institute of Technology\r
-#\r
-# Permission is hereby granted, free of charge, to any person\r
-# obtaining a copy of this software and associated documentation\r
-# files (the "Software"), to deal in the Software without\r
-# restriction, including without limitation the rights to use, copy,\r
-# modify, merge, publish, distribute, sublicense, and/or sell copies\r
-# of the Software, and to permit persons to whom the Software is\r
-# furnished to do so, subject to the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be\r
-# included in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
-# SOFTWARE.\r
-#\r
-\r
-\r
-# This is a simple script that is used for generating C code from CSV\r
-#files. We expect three arguments, the <input> which is the .csv file\r
-#to be parsed, a <config> which is a configuration file and the\r
-#<output>. \r
-\r
-# The configuration file is a perl file which defines the following\r
-#variables :\r
-\r
-# $skip_lines : the number of lines to skip in the csv. The default is 0\r
-\r
-# @pquote : an array of boolean integers that specify whether or not\r
-# to quote the specific field using double quotes. The default is to\r
-# not quote anything.\r
-\r
-# $file_prefix : the prefix for the file\r
-\r
-# $record_prefix : the prefix for each record\r
-\r
-# $field_sep : the field separator. The default is ','\r
-\r
-# $record_postfix : the postfix for each record\r
-\r
-# $record_sep : A record separator. Only shows up between records.\r
-\r
-# $file_postfix : the postfix for the entire file\r
-\r
-use Text::ParseWords;\r
-\r
-sub do_nothingus {\r
-}\r
-\r
-if($#ARGV != 2) {\r
- print "Usage: ccsv.pl <input-filename> <config-filename> <output-filename>\n";\r
- die;\r
-}\r
-\r
-$infn=$ARGV[0];\r
-$cfgfn=$ARGV[1];\r
-$outfn=$ARGV[2];\r
-\r
-$skip_lines = 0;\r
-@pquote = {};\r
-$file_prefix = "";\r
-$record_prefix = "";\r
-$field_sep = ",";\r
-$record_postfix = "";\r
-$record_sep = "\n";\r
-$file_postfix = "";\r
-$record_parser = \&do_nothingus;\r
-\r
-($inbase) = ($infn =~ m/^(\w*)/);\r
-\r
-do $cfgfn;\r
-\r
-open(IN, "<".$infn) or die "Can't open input file:".$infn;\r
-open(OUT, ">".$outfn) or die "Can't open output file:".$outfn;\r
-\r
-print OUT $file_prefix;\r
-\r
-$first_line = 1;\r
-\r
-while(<IN>) {\r
- chomp $_;\r
- if (m/^\#/) {\r
- # ignore\r
- } elsif ($skip_lines > 0) {\r
- $skip_lines--;\r
- } else {\r
- if($first_line == 0){\r
- print OUT $record_sep;\r
- } else {\r
- $first_line = 0;\r
- }\r
-\r
- @fields = &parse_line(',',0,$_);\r
- for(@fields) {\r
- chomp;\r
- s/^\s*//;\r
- }\r
-\r
- &$record_parser(\@fields);\r
-\r
- print OUT $record_prefix;\r
- for(my $i=0; $i <= $#fields; $i++) {\r
- print OUT $field_sep if $i != 0;\r
- print OUT 'L"' if $pquote[$i] == 1;\r
- print OUT $fields[$i];\r
- print OUT '"' if $pquote[$i] == 1;\r
- }\r
- print OUT $record_postfix;\r
- }\r
-}\r
-\r
-print OUT $file_postfix;\r
-\r
-close INF;\r
-close OUT;\r
+#!/usr/bin/perl
+
+#
+# Copyright (c) 2004 Massachusetts Institute of Technology
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+
+# This is a simple script that is used for generating C code from CSV
+#files. We expect three arguments, the <input> which is the .csv file
+#to be parsed, a <config> which is a configuration file and the
+#<output>.
+
+# The configuration file is a perl file which defines the following
+#variables :
+
+# $skip_lines : the number of lines to skip in the csv. The default is 0
+
+# @pquote : an array of boolean integers that specify whether or not
+# to quote the specific field using double quotes. The default is to
+# not quote anything.
+
+# $file_prefix : the prefix for the file
+
+# $record_prefix : the prefix for each record
+
+# $field_sep : the field separator. The default is ','
+
+# $record_postfix : the postfix for each record
+
+# $record_sep : A record separator. Only shows up between records.
+
+# $file_postfix : the postfix for the entire file
+
+use Text::ParseWords;
+
+sub do_nothingus {
+}
+
+if($#ARGV != 2) {
+ print "Usage: ccsv.pl <input-filename> <config-filename> <output-filename>\n";
+ die;
+}
+
+$infn=$ARGV[0];
+$cfgfn=$ARGV[1];
+$outfn=$ARGV[2];
+
+$skip_lines = 0;
+@pquote = {};
+$file_prefix = "";
+$record_prefix = "";
+$finc = "";
+$field_sep = ",";
+$record_postfix = "";
+$record_sep = "\n";
+$file_postfix = "";
+$record_parser = \&do_nothingus;
+
+($inbase) = ($infn =~ m/^(\w*)/);
+
+do $cfgfn;
+
+open(IN, "<".$infn) or die "Can't open input file:".$infn;
+open(OUT, ">".$outfn) or die "Can't open output file:".$outfn;
+
+$first_line = 1;
+
+while(<IN>) {
+ chomp $_;
+ if (m/^\#/) {
+ if (m/^\#\@/) {
+ ($inc) = m/^\#\@(.*)/;
+ $finc = $finc.$inc."\n";
+ } else {
+ # ignore
+ }
+ } elsif ($skip_lines > 0) {
+ $skip_lines--;
+ } else {
+ if($first_line == 0){
+ print OUT $record_sep;
+ } else {
+ $file_prefix =~ s/\$finc/$finc/;
+ print OUT $file_prefix;
+ $first_line = 0;
+ }
+
+ @fields = &parse_line(',',0,$_);
+ for(@fields) {
+ chomp;
+ s/^\s*//;
+ }
+
+ &$record_parser(\@fields);
+
+ print OUT $record_prefix;
+ for(my $i=0; $i <= $#fields; $i++) {
+ print OUT $field_sep if $i != 0;
+ print OUT 'L"' if $pquote[$i] == 1;
+ print OUT $fields[$i];
+ print OUT '"' if $pquote[$i] == 1;
+ }
+ print OUT $record_postfix;
+ }
+}
+
+if ($first_line == 1) {
+ print OUT $file_prefix;
+}
+
+print OUT $file_postfix;
+
+close INF;
+close OUT;
-#\r
-# Copyright (c) 2004 Massachusetts Institute of Technology\r
-#\r
-# Permission is hereby granted, free of charge, to any person\r
-# obtaining a copy of this software and associated documentation\r
-# files (the "Software"), to deal in the Software without\r
-# restriction, including without limitation the rights to use, copy,\r
-# modify, merge, publish, distribute, sublicense, and/or sell copies\r
-# of the Software, and to permit persons to whom the Software is\r
-# furnished to do so, subject to the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be\r
-# included in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
-# SOFTWARE.\r
-#\r
-\r
-$file_prefix = <<EOS;\r
-/*\r
-This file was autogenerated from:\r
- $cfgfn\r
- $infn\r
-\r
-Do not modify directly.\r
-*/\r
-#include<kconfig.h>\r
-\r
-kconf_schema schema_$inbase\[] = {\r
-EOS\r
-\r
-$record_prefix = "{";\r
-\r
-$record_sep = ",\n";\r
-\r
-$record_postfix = "}";\r
-\r
-$file_postfix = <<EOS;\r
-\r
-};\r
-\r
-\r
-EOS\r
-\r
-$skip_lines = 1;\r
-\r
-@pquote = (1,0,0,1);\r
-\r
-sub rec_handler {\r
- $arr = shift;\r
- if($$arr[1] =~ "KC_STRING") {\r
- $$arr[2] =~ s/\[\~\]/\\0/g;\r
- $$arr[2] = "(khm_int64) L\"".$$arr[2]."\"";\r
- }\r
-\r
- $$arr[3] = "";\r
-}\r
-\r
-$record_parser = \&rec_handler;\r
+#
+# Copyright (c) 2004 Massachusetts Institute of Technology
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+$file_prefix = <<EOS;
+/*
+This file was autogenerated from:
+ $cfgfn
+ $infn
+
+Do not modify directly.
+*/
+#include<kconfig.h>
+
+\$finc
+
+kconf_schema schema_$inbase\[] = {
+EOS
+
+$record_prefix = "{";
+
+$record_sep = ",\n";
+
+$record_postfix = "}";
+
+$file_postfix = <<EOS;
+
+};
+
+
+EOS
+
+$skip_lines = 1;
+
+@pquote = (1,0,0,1);
+
+sub rec_handler {
+ $arr = shift;
+ if($$arr[1] =~ "KC_STRING") {
+ $$arr[2] =~ s/\[\~\]/\\0/g;
+ $$arr[2] = "(khm_int64) L\"".$$arr[2]."\"";
+ }
+
+ $$arr[3] = "";
+}
+
+$record_parser = \&rec_handler;