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 -*-
if 0;
# the above is a more portable way to find perl
# ! /usr/bin/perl
#!/usr/bin/env perl
# -*- Mode: perl -*-
# This software is copyrighted by the
# Helmholtz-Zentrum Berlin fuer Materialien und Energie GmbH (HZB),
......@@ -28,29 +26,15 @@ eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
# UPDATES, ENHANCEMENTS OR MODIFICATIONS.
#pragmas:
use strict;
#activate perl-extensions:
#use lib "$ENV{HOME}/pmodules";
#use perl_site;
use FindBin;
use Getopt::Long;
BEGIN
{ # search the arguments for the "--locallibs"
# 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);
use vars qw($opt_help $opt_quiet $opt_multiple $opt_header $opt_part
$opt_check);
my $version = "1.6p";
my $version = "1.7";
# debugging:
......@@ -64,7 +48,8 @@ if (($#ARGV==0) && ($ARGV[0] eq '-h'))
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"; };
if ($opt_help)
......@@ -240,14 +225,15 @@ sub process_file
}
else
{
# within comments, scan for commands in the form "@CCC" where C is
# an upper-case char
# within comments, scan for commands in the form "@CCC"
# where C is an upper-case char
while ($line=~ /\G.*?(\*\/|\@(?:U|IL|EL|ITI|IT|ETI|ET|
EM|EXI|EX|PS|PE))/gx)
{
my $cmd = $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 ($uncomment)
{ $old_emit_flag= undef;
......@@ -370,7 +356,8 @@ sub process_file
{ $line= $pre . $line;
$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);
# the following is less generic but faster:
$line=~ s/=[^\)]+$//;
......@@ -440,18 +427,18 @@ options:
specify the name of the header-file to create
-p [number {number ...}]
specify the parts of the source-file that are to be
processed, a source-file may have several parts (0..19)
that may be intermixed. See also the \@PE()-command
specify the parts of the source-file that are to be processed, a
source-file may have several parts (0..19) that may be intermixed.
See also the \@PE()-command
-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
is called from within a makefile.
difference is found, the header file is left intact. Useful when
hgen.p is called from within a makefile.
-q less messages on the screen
hgen-commands in sourcecode:
a command starts with a \'\@\' and is followed by 2 to 3 letters. A command
must always be splaced within a c-comment.
Example for a command: /*\@EX(1)*/ is the command 'EX(1)'
A command starts with a \'\@\' and is followed by 2 to 3 letters. A command
must always be splaced within a c-comment. Example for a command:
/*\@EX(1)*/ is the command 'EX(1)'
List of commands:
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