Module: tools Branch: master Commit: 8583aa5ba38bc760408b49248f36b75d905445d8 URL: http://source.winehq.org/git/tools.git/?a=commit;h=8583aa5ba38bc760408b49248...
Author: Mikolaj Zalewski mikolajz@tygrys.dom Date: Wed Feb 13 21:22:33 2008 +0100
add option to compare stringtables
---
php/resfile.php | 6 ++++- php/resource.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/php/resfile.php b/php/resfile.php index facf721..cff3948 100644 --- a/php/resfile.php +++ b/php/resfile.php @@ -50,8 +50,12 @@ foreach ($msgs as $value) } else { + if (strpos($value, "Error: ") === 0) + $extra = "&compare"; + else + $extra = ""; $value = preg_replace("/STRINGTABLE ([0-9]+)/", - "<a href="resource.php?lang=$lang&resfile=$resfile&type=6&id=".$m[1]."">". + "<a href="resource.php?lang=$lang&resfile=$resfile&type=6&id=".$m[1]."$extra">". "STRINGTABLE #".$m[1]." (strings $id0..$id1)</a>", $value); } diff --git a/php/resource.php b/php/resource.php index 2d9602d..0783ff1 100644 --- a/php/resource.php +++ b/php/resource.php @@ -6,6 +6,7 @@ $lang = validate_lang($_REQUEST['lang']); $resfile = validate_resfile($_REQUEST['resfile']); $type = validate_type($_REQUEST['type']); $id = validate_id($_REQUEST['id']); +$compare = isset($_REQUEST['compare']);
$norm_fn = preg_replace("/[^A-Za-z0-9]/", "-", $resfile); $file = fopen("$DATAROOT/dumps/$norm_fn/$lang-$type-$id", "r"); @@ -15,9 +16,31 @@ $msgs = array(); <body> <h1>File <?php echo $resfile?> - <?php echo get_lang_name($lang) ?> language - Resource <?php echo "$id ($type)"?></h1>
-<table style="background-color: #f8f8ff"> -<tr style="background-color: #f0f0ff"><th colspan="2">String table #<?php echo $id?></th></tr> +<table style="background-color: #f0f0ff"> +<tr style="background-color: #e0e0ff"><th colspan="3">String table #<?php echo $id?></th></tr> <?php + +if (!$compare) +{ + echo "<tr style="background-color: #e8e8ff"><td colspan="2" style="text-align: right">"; + echo "<small><a href="resource.php?lang=".urlencode($lang)."&resfile=".urlencode($resfile)."&type=".urlencode($type)."&id=".urlencode($id)."&compare">"; + echo "Compare with ".get_lang_name($MASTER_LANGUAGE)." >></a></small>"; + echo "</td></tr>"; +} +else +{ + $master_file = fopen("$DATAROOT/dumps/$norm_fn/$MASTER_LANGUAGE-$type-$id", "r"); + $master_content = fgets($master_file, 262144); + fclose($master_file); + + echo "<tr style="background-color: #e8e8ff"><td colspan="3" style="text-align: right">"; + echo "<small><a href="resource.php?lang=".urlencode($lang)."&resfile=".urlencode($resfile)."&type=".urlencode($type)."&id=".urlencode($id)."">"; + echo "<< Hide compare with ".get_lang_name($MASTER_LANGUAGE)."</a></small>"; + echo "</td></tr>"; + + echo "<tr style="background-color: #e8e8ff"><td>id</td><td>".get_lang_name($lang)."</td><td>".get_lang_name($MASTER_LANGUAGE)."</td></tr>""; +} + $content = fgets($file, 262144);
function get_hex(&$content) @@ -32,9 +55,19 @@ function get_hex(&$content) }
for ($i=0; $i<16; $i++) { - echo "<tr><td valign="top">".(($id-1)*16+$i)."</td>"; - echo "<td>"; + $extra = ""; + $left = hexdec(get_hex($content)); + if ($compare) + { + $master_left = hexdec(get_hex($master_content)); + if ((!$master_left && $left) || ($master_left && !$left)) + $extra = " style="background-color: #ffb8d0""; + } + + echo "<tr$extra><td valign="top">".(($id-1)*16+$i)."</td>"; + echo "<td>"; + if ($left == 0) { echo "<i style="color: #7f7fff">empty</i>"; @@ -50,6 +83,27 @@ for ($i=0; $i<16; $i++) { } echo ""\n"; } + + if ($compare) + { + echo "</td><td>"; + $left = $master_left; + if ($left == 0) + { + echo "<i style="color: #7f7fff">empty</i>"; + } + else + { + echo """; + while ($left > 0) + { + $hex = get_hex($master_content); + echo "&#x".$hex.";"; + $left--; + } + echo ""\n"; + } + } echo "</td></tr>\n"; } ?>