diff options
Diffstat (limited to 'oox/source/token/namespaces.pl')
-rw-r--r-- | oox/source/token/namespaces.pl | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/oox/source/token/namespaces.pl b/oox/source/token/namespaces.pl index 3c741fa7b2af..7c602f70128d 100644 --- a/oox/source/token/namespaces.pl +++ b/oox/source/token/namespaces.pl @@ -25,17 +25,19 @@ # #************************************************************************* -$ARGV0 = shift @ARGV; -$ARGV1 = shift @ARGV; -$ARGV2 = shift @ARGV; -$ARGV3 = shift @ARGV; +# operation mode (1 = identifiers, 2 = names, 3 = plain) +$op = shift @ARGV; +die "Error: invalid operation" unless( $op >= 1 && $op <= 3); -# parse input file +# number of bits to shift the namespace identifier +$shift = 16; + +if( $op == 1 ) { + print( "const size_t NMSP_SHIFT = $shift;\n" ); +} -open( INFILE, $ARGV0 ) or die "cannot open input file: $!"; -my %namespaces; -while( <INFILE> ) -{ +$i = 1; +while( <> ) { # trim newline chomp( $_ ); # trim leading/trailing whitespace @@ -44,36 +46,14 @@ while( <INFILE> ) # trim comments $_ =~ s/^#.*//; # skip empty lines - if( $_ ) - { + if( $_ ) { # check for valid characters - $_ =~ /^([a-zA-Z]+)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data"; - $namespaces{$1} = $2; + $_ =~ /^([a-zA-Z]+)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid entry: '$_'"; + # generate output + $id = $i << $shift; + if( $op == 1 ) { print( "const sal_Int32 NMSP_$1 = $i << NMSP_SHIFT;\n" ); } + elsif( $op == 2 ) { print( "{ $id, \"$2\" },\n" ); } + elsif( $op == 3 ) { print( "$id $1 $2\n" ); } + ++$i; } } -close( INFILE ); - -# generate output files - -open( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!"; -open( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!"; -open( TXTFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!"; - -# number of bits to shift the namespace identifier -$shift = 16; - -print ( IDFILE "const size_t NMSP_SHIFT = $shift;\n" ); - -$i = 1; -foreach( keys( %namespaces ) ) -{ - print( IDFILE "const sal_Int32 NMSP_$_ = $i << NMSP_SHIFT;\n" ); - $id = $i << $shift; - print( NAMEFILE "{ $id, \"$namespaces{$_}\" },\n" ); - print( TXTFILE "$id $_ $namespaces{$_}\n" ); - ++$i; -} - -close( IDFILE ); -close( nameFILE ); -close( TXTFILE ); |