imgtools/buildrom/tools/CONVERT.PL
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 #
       
     2 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 # parameter %1 is the string which is to occur around (i.e. before and after) the language names in the rest of the parameters to convert to 2-digit language codes
       
    16 # parameter %2 is the command to execute
       
    17 # parameters %3 onwards are the parameters to %2
       
    18 # example:
       
    19 # perl -w CONVERT.PL # echo the language code for french is #french#
       
    20 
       
    21 $conversionDelimiter=shift;
       
    22 open(E32STD_H, "< \\epoc32\\include\\E32STD.H") or die "\\epoc32\\include\\E32STD.H could not be opened";
       
    23 while ($line=<E32STD_H>)
       
    24 	{
       
    25 	if ($line=~/\benum\s+TLanguage\b(.*)$/)
       
    26 		{
       
    27 		$line=$1;
       
    28 		while (1)
       
    29 			{
       
    30 			if ($line=~/\{(.*)$/)
       
    31 				{
       
    32 				$line=$1;
       
    33 				last;
       
    34 				}
       
    35 			$line=<E32STD_H>;
       
    36 			}
       
    37 		$last=0;
       
    38 		$languageCode=0;
       
    39 		while (1)
       
    40 			{
       
    41 			if ($line=~/^(.*?)\}/)
       
    42 				{
       
    43 				$line=$1;
       
    44 				$last=1;
       
    45 				}
       
    46 			while ($line=~/^.*?ELang(\w+)\b(.*)$/)
       
    47 				{
       
    48 				$languageNameInLowerCase=lc $1;
       
    49 				$line=$2;
       
    50 				if ($line=~/^=(\d+)(.*)$/)
       
    51 					{
       
    52 					$languageCode=$1;
       
    53 					$line=$2;
       
    54 					}
       
    55 				$languageData{$languageNameInLowerCase}=$languageCode;
       
    56 				++$languageCode;
       
    57 				}
       
    58 			if ($last)
       
    59 				{
       
    60 				last;
       
    61 				}
       
    62 			$line=<E32STD_H>;
       
    63 			}
       
    64 		last;
       
    65 		}
       
    66 	}
       
    67 close(E32STD_H);
       
    68 for ($i=$#ARGV; $i>=0; --$i)
       
    69 	{
       
    70 	if ($ARGV[$i]=~/^(.*?)$conversionDelimiter(.*?)$conversionDelimiter(.*)$/)
       
    71 		{
       
    72 		$bitBefore=$1;
       
    73 		$languageNameInLowerCase=lc $2;
       
    74 		$bitAfter=$3;
       
    75 		defined $languageData{$languageNameInLowerCase} or die "The language \"$languageNameInLowerCase\" is not defined in \\epoc32\\include\\E32STD.H";
       
    76 		$ARGV[$i]=sprintf("$bitBefore%02d$bitAfter", $languageData{$languageNameInLowerCase});
       
    77 		}
       
    78 	}
       
    79 system("@ARGV");
       
    80