178 lines
4.2 KiB
Perl
Executable File
178 lines
4.2 KiB
Perl
Executable File
#!/usr/sbin/perl
|
|
|
|
#**************************************************************************
|
|
#* *
|
|
#* Copyright (c) 1996 Silicon Graphics, Inc. *
|
|
#* All Rights Reserved *
|
|
#* *
|
|
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
|
|
#* *
|
|
#* The copyright notice above does not evidence any actual of intended *
|
|
#* publication of such source code, and is an unpublished work by Silicon *
|
|
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
|
|
#* the property of Silicon Graphics, Inc. Any use, duplication or *
|
|
#* disclosure not specifically authorized by Silicon Graphics is strictly *
|
|
#* prohibited. *
|
|
#* *
|
|
#* RESTRICTED RIGHTS LEGEND: *
|
|
#* *
|
|
#* Use, duplication or disclosure by the Government is subject to *
|
|
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
|
|
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
|
|
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
|
|
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
|
|
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
|
|
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
|
|
#**************************************************************************
|
|
|
|
# DEMO_parse.pl
|
|
#
|
|
# Routines that parse the .index files
|
|
|
|
1; # Return true
|
|
|
|
# Begin Subroutine
|
|
sub Parse_Demo_Info {
|
|
@noparse = @null;
|
|
&Parse_File($_[0]);
|
|
}
|
|
|
|
sub Parse_File {
|
|
# Set the file to parse
|
|
$file = $_[0];
|
|
|
|
# Clear out the array %demo_info
|
|
%demo_info = "";
|
|
|
|
# Open the document
|
|
open(DOC, "$file");
|
|
# Take each line and parse
|
|
while (<DOC>) {
|
|
if (grep(/\b$DEMO_INFO_END\s*/, $_)) {
|
|
close(DOC);
|
|
return scalar(@demo_info);
|
|
exit;
|
|
}
|
|
$data .= $_;
|
|
|
|
# Remove newline
|
|
chop;
|
|
|
|
if ( &endmatch($_) ) {
|
|
$junk .= $data;
|
|
$data = "";
|
|
}
|
|
|
|
|
|
# Test to see if it is one of the demo_info
|
|
if ( $endtag = &match($_) ) {
|
|
|
|
# If it is, make sure it is not a "noparse" tag
|
|
if (&avoid($_)) {
|
|
|
|
$data = "";
|
|
|
|
#Grab the next line
|
|
$_ = <DOC>;
|
|
|
|
# Remove newline
|
|
chop;
|
|
|
|
# Remove commented lines
|
|
if (grep(/^#/, $_)) {
|
|
$_ = <DOC>;
|
|
}
|
|
|
|
# Keep feeding the lines into the array
|
|
# as long as we don't hit the endtag
|
|
while (!/$endtag((.|\s)*)/){
|
|
|
|
# add the line to the array
|
|
|
|
$key = $endtag;
|
|
$key =~ s/END_//;
|
|
|
|
# Add a newline if its your
|
|
# first time around
|
|
$_ = "\n$_" if (!$times);
|
|
$demo_info{$key} .= "$_\n";
|
|
local($times);
|
|
$times = 1;
|
|
|
|
|
|
# if we somehow hit another tag
|
|
# (the endtag is missing or mispelled)
|
|
# start over, not parsing for
|
|
# the offending tag
|
|
if ((&match($_)) ) {
|
|
$junk .= $demo_info{$key};
|
|
$demo_info{$key} .= "";
|
|
push(@noparse, "$key:");
|
|
&infodemo("$file");
|
|
return scalar(@demo_info);
|
|
}
|
|
|
|
#Grab the next line
|
|
$_ = <DOC>;
|
|
|
|
# Remove newline
|
|
chop;
|
|
|
|
# Remove commented lines
|
|
if (grep(/^#/, $_)) {
|
|
$_ = <DOC>;
|
|
chop;
|
|
}
|
|
}
|
|
} else {
|
|
$_ = <DOC>;
|
|
}
|
|
}
|
|
|
|
}
|
|
close(DOC);
|
|
print ;
|
|
print "<br>\n";
|
|
return scalar(@demo_info);
|
|
}
|
|
|
|
|
|
# Check the line against all possible DEMO_INFO_ELEMENTS
|
|
sub match {
|
|
$line = $_[0];
|
|
foreach $tag ( @DEMO_INFO_ELEMENTS ) {
|
|
$_ = $line;
|
|
if (/\b$tag:\s*/) {
|
|
return "END_$tag";
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
sub endmatch {
|
|
local($tag, $line);
|
|
$line = $_[0];
|
|
foreach $tag ( @DEMO_INFO_ELEMENTS ) {
|
|
$_ = $line;
|
|
if (/\bEND_$tag\s*/) {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
# Check to see if this is a tag we should avoid
|
|
sub avoid {
|
|
local($line, $each);
|
|
$line = $_[0];
|
|
foreach $each ( @noparse ) {
|
|
$_ = $line;
|
|
if (/\b$each\s*/) {
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|