Commit 3e6402d6 authored by Pfeiffer, Götz's avatar Pfeiffer, Götz
Browse files

Some cleanup and re-formatting in hgen.pl.

parent d09fb65b
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- #!/usr/bin/env perl
if 0; # -*- Mode: perl -*-
# the above is a more portable way to find perl
# ! /usr/bin/perl
# This software is copyrighted by the # This software is copyrighted by the
# Helmholtz-Zentrum Berlin fuer Materialien und Energie GmbH (HZB), # Helmholtz-Zentrum Berlin fuer Materialien und Energie GmbH (HZB),
...@@ -28,29 +26,15 @@ eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- ...@@ -28,29 +26,15 @@ eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
# UPDATES, ENHANCEMENTS OR MODIFICATIONS. # UPDATES, ENHANCEMENTS OR MODIFICATIONS.
#pragmas:
use strict; use strict;
#activate perl-extensions:
#use lib "$ENV{HOME}/pmodules";
#use perl_site;
use FindBin; use FindBin;
use Getopt::Long; use Getopt::Long;
BEGIN use vars qw($opt_help $opt_quiet $opt_multiple $opt_header $opt_part
{ # search the arguments for the "--locallibs" $opt_check);
# option. If it is found, remove the option
# and add $FindBin::Bin to the head of the
# module search-path.
if (exists $ENV{MYPERLLIBS})
{ my @dirs=split(/:/,$ENV{MYPERLLIBS});
unshift @INC,split(/:/,$ENV{MYPERLLIBS});
};
};
use vars qw($opt_help $opt_quiet $opt_multiple $opt_header $opt_part $opt_check);
my $version = "1.6p"; my $version = "1.7";
# debugging: # debugging:
...@@ -64,7 +48,8 @@ if (($#ARGV==0) && ($ARGV[0] eq '-h')) ...@@ -64,7 +48,8 @@ if (($#ARGV==0) && ($ARGV[0] eq '-h'))
exit; exit;
}; };
if (!GetOptions("help","quiet|q", "multiple|m","header|h=s","part|p=s","check|c")) if (!GetOptions("help","quiet|q",
"multiple|m","header|h=s","part|p=s","check|c"))
{ die "parameter error, use \"$0 -h\" to display the online-help\n"; }; { die "parameter error, use \"$0 -h\" to display the online-help\n"; };
if ($opt_help) if ($opt_help)
...@@ -240,14 +225,15 @@ sub process_file ...@@ -240,14 +225,15 @@ sub process_file
} }
else else
{ {
# within comments, scan for commands in the form "@CCC" where C is # within comments, scan for commands in the form "@CCC"
# an upper-case char # where C is an upper-case char
while ($line=~ /\G.*?(\*\/|\@(?:U|IL|EL|ITI|IT|ETI|ET| while ($line=~ /\G.*?(\*\/|\@(?:U|IL|EL|ITI|IT|ETI|ET|
EM|EXI|EX|PS|PE))/gx) EM|EXI|EX|PS|PE))/gx)
{ {
my $cmd = $1; my $cmd = $1;
my $epos= pos($line)-1; my $epos= pos($line)-1;
my $mpos= pos($line)-length($cmd); # save match-position, my $mpos= pos($line)-length($cmd);
# ^^^ save match-position,
if ($cmd eq '*/') # comment-end found if ($cmd eq '*/') # comment-end found
{ if ($uncomment) { if ($uncomment)
{ $old_emit_flag= undef; { $old_emit_flag= undef;
...@@ -370,7 +356,8 @@ sub process_file ...@@ -370,7 +356,8 @@ sub process_file
{ $line= $pre . $line; { $line= $pre . $line;
$pre= undef; $pre= undef;
}; };
if (($emit_flag==1) && ($post) && ($line)) # add_char && last line if (($emit_flag==1) && ($post) && ($line))
# add_char && last line
{ # eval('$line=~ ' . $postre) if ($postre); { # eval('$line=~ ' . $postre) if ($postre);
# the following is less generic but faster: # the following is less generic but faster:
$line=~ s/=[^\)]+$//; $line=~ s/=[^\)]+$//;
...@@ -440,18 +427,18 @@ options: ...@@ -440,18 +427,18 @@ options:
specify the name of the header-file to create specify the name of the header-file to create
-p [number {number ...}] -p [number {number ...}]
specify the parts of the source-file that are to be specify the parts of the source-file that are to be processed, a
processed, a source-file may have several parts (0..19) source-file may have several parts (0..19) that may be intermixed.
that may be intermixed. See also the \@PE()-command See also the \@PE()-command
-c check wether the new header-file differs from the old one. If no -c check wether the new header-file differs from the old one. If no
difference is found, the header file is left intact. Useful when hgen.p difference is found, the header file is left intact. Useful when
is called from within a makefile. hgen.p is called from within a makefile.
-q less messages on the screen -q less messages on the screen
hgen-commands in sourcecode: hgen-commands in sourcecode:
a command starts with a \'\@\' and is followed by 2 to 3 letters. A command A command starts with a \'\@\' and is followed by 2 to 3 letters. A command
must always be splaced within a c-comment. must always be splaced within a c-comment. Example for a command:
Example for a command: /*\@EX(1)*/ is the command 'EX(1)' /*\@EX(1)*/ is the command 'EX(1)'
List of commands: List of commands:
EL exclude line EL exclude line
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment