sbsv1/abld/genutil/output.pm
author jascui
Wed, 17 Nov 2010 13:45:48 +0800
changeset 689 b70d8ea6cf75
parent 599 fa7a3cc6effd
permissions -rw-r--r--
Updating release text and product version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Text formatting module
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
package Output;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
require Exporter;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
@ISA=qw(Exporter);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
@EXPORT=qw(
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
	OutSetLength OutSetPostWrap OutFormat Output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
	OutText
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
my $Len=80;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
my $PreWrap="\\";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
my $PreWrapLen=length($PreWrap);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
my $PostWrap=' ';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
my $PostWrapLen=length($PostWrap);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
my $Buf='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
my $Text='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
sub OutSetLength ($) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
	if ($_[0]) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
		$Len=$_[0];
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
		return $Len;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
	$Len=80;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
sub OutSetPreWrap ($) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
	$PreWrap=$_[0];
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
	$PreWrapLen=length($PreWrap);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
sub OutSetPostWrap ($) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
	$PostWrap=$_[0];
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
	$PostWrapLen=length($PostWrap);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
sub OutFormat (@) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
	my $Item;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
	foreach $Item (@_) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
		$Buf.=$Item;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
sub OutWrite () {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
	my @Buf=();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
	my $CurLen=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
	if ($Buf=~/^(\s)/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
		# output any starting spaces or tabs
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
		$Text.=$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
		$CurLen=length($1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
	while ($Buf=~/([^ "\t\n\r\f]*"[^"\t\n\r\f]+"[^ "\t\n\r\f]*|[^ "\t\n\r\f]+)/go) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
		# get the elements of $Buf into @Buf
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
		push @Buf, $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
	$Buf='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
	my $Elem;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
	foreach $Elem (@Buf) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
		my $ElemLen=length($Elem);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
		if (($CurLen+$ElemLen+$PreWrapLen) > $Len) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
			# $Len doesn't account for the newline character
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
			# wrap the line if adding another element will take it over the prescribed length
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
			$Text.="$PreWrap\n$PostWrap";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
			$CurLen=$PostWrapLen;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
		elsif ($CurLen>$PostWrapLen) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
			# add a space to the line if they're are already elements in the line
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
			$Text.=' ';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
			$CurLen++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
		# add element to the line
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
		$Text.=$Elem;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
		$CurLen+=$ElemLen;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	# finish with a newline
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	$Text.="\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
sub Output (@) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
	OutWrite if $Buf;	# output the formatted text before doing any more output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
	my $Item;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
	foreach $Item (@_) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
		$Text.=$Item;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
sub OutText () {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
	my $temp=$Text;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
	$Text='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
	$temp;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
1;