From cab138003128e8bb0713b69f42278b68c4d51ea0 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 9 Jan 2006 05:30:59 +0100 Subject: [PATCH] Obsolete $start and $gotone; tune newlines; simply line matching --- doc/tools/code2doc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/tools/code2doc b/doc/tools/code2doc index a1f31c1e6..edc04b18b 100755 --- a/doc/tools/code2doc +++ b/doc/tools/code2doc @@ -17,7 +17,7 @@ getopts("hv") or usage($HELP); $opt_v and usage("Copyleft (c) 2006, Russ Rowan (See `COPYING')"); usage($HELP) if $opt_h or @ARGV < 1; -my ($found, $start, $first, $gotone, $idpath); +my ($found, $first, $idpath); $idpath = ''; while (<>) { @@ -25,7 +25,7 @@ while (<>) # IDENT, /*:: ... */ # IDENT = value, /*:: ... */ # type ident; /*:: ... */ - if ($_ =~ /^(\s|[^\s=]+)*[\s*]([A-Za-z0-9_]+)(\s+=\s+[^,;]+)?[,;]\s*\/\*::\s*(.*)\s+\*\/$/) + if (/^(\s|[^\s=]+)*[\s*]([A-Za-z0-9_]+)(\s+=\s+[^,;]+)?[,;]\s*\/\*::\s*(.*)\s+\*\/$/) { print "\nid:[$idpath$2]::\n\t$4\n"; next; @@ -33,25 +33,23 @@ while (<>) if ($found) { - if ($_ =~ /^\s+\*\s$/) { next if $first; $_ =~ s/\s\*// if not $first; } - if ($_ =~ /^\s\*+\/$/ or $_ !~ /^\s/) { $found = undef; next; } + if (/^\s+\*\s$/) { next if $first; $_ =~ s/\s\*// if not $first; } + if (/^\s\*+\/$/ or $_ !~ /^\s/) { $found = undef; next; } $_ =~ s/^(\s*)\s\*\s/$1/; - $found = 'sorta' if $_ =~ s/\s*\*\/$/\n/; $first = undef; + $found = 'sorta' if s/\s*\*\/$/\n/; $first = undef; } - elsif ($_ =~ /^\s*\/\*\*\s(.*)/) + elsif (/^\s*\/\*\*\s(.*)/) { $_ = $1; $first = 1; - print STDOUT "\n\n" if $start; - if ($_ =~ s/\s*\*\/$//) { $found = 'sorta'; } else { $found = $.; } - if ($_ =~ /struct:[[]([^\]]+)[\]]/) { $idpath = "$1."; } else { $idpath = ''; } - if ($_ =~ /::/) { $_ = "$_\n\n"; } + if (/\s*\*\/$/) { $found = 'sorta'; } else { $found = $.; } + if (/struct:[[]([^\]]+)[\]]/) { $idpath = "$1."; } else { $idpath = ''; } + if (/::/) { $_ = "\n$_\n\n"; } else { my $dash; for (my $x = 0; $x < length($_); $x++) { $dash .= '-'; } - $_ = "$_\n$dash\n\n"; + $_ = "\n$_\n$dash\n\n"; } } - print STDOUT "\n" and $gotone = undef if $gotone and $gotone < $.; next if not $found; $found = undef if $found eq 'sorta'; - print STDOUT $_ and $start = 1; + print STDOUT $_; }