
Module: ppl/ppl Branch: master Commit: 1b3c2d0ceffdcf1779f57988c8490f4b238cfabe URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=1b3c2d0ceffdc...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Tue Feb 21 08:42:44 2012 +0100
Explicitly state the array size. New option --decl-only.
---
utils/text2cxxarray.in | 37 ++++++++++++++++++++++++++----------- 1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/utils/text2cxxarray.in b/utils/text2cxxarray.in index 1a26225..b79b7b5 100644 --- a/utils/text2cxxarray.in +++ b/utils/text2cxxarray.in @@ -38,25 +38,40 @@ Usage: text2cxxarray [OPTIONS] [FILE ...]
[OPTIONS] --name=NAME Use NAME as the array name. + --definition Emit a defining declaration. -h, --help Display this help message. EOF exit 1; }
my $array_name = "a"; +my $decl_only = 0;
GetOptions( - 'name=s' => $array_name, - 'help|h' => &usage, + 'name=s' => $array_name, + 'decl-only' => $decl_only, + 'help|h' => &usage, ) || usage();
-print "extern const char* const $array_name" . "[] = {\n"; -while (<>) { - chop; - s/\/\\/g; - s/\t/\t/g; - s/"/\"/g; - print " "$_",\n"; +@lines = <>; + +my $size = 1; +foreach (@lines) { + $size = $size+1; +} + +print "extern const char* const $array_name" . "[$size]"; + +if (! $decl_only) { + print " = {\n"; + foreach (@lines) { + chop; + s/\/\\/g; + s/\t/\t/g; + s/"/\"/g; + print " "$_",\n"; + } + print " 0"; + print "}"; } -print " 0"; -print "};\n"; +print ";\n";