Mikolaj Zalewski : move stringtable dumping to StringTable class
Alexandre Julliard
julliard at winehq.org
Fri Jun 19 08:36:18 CDT 2009
Module: tools
Branch: master
Commit: a99d9e478d9ae8be51ee02bab1b2c74cae3890a2
URL: http://source.winehq.org/git/tools.git/?a=commit;h=a99d9e478d9ae8be51ee02bab1b2c74cae3890a2
Author: Mikolaj Zalewski <mikolajz at tygrys.dom>
Date: Fri Feb 29 20:30:08 2008 +0100
move stringtable dumping to StringTable class
---
php/lib_res.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
php/resource.php | 40 +++++-----------------------------------
2 files changed, 52 insertions(+), 37 deletions(-)
diff --git a/php/lib_res.php b/php/lib_res.php
index ff27c42..8b401fc 100644
--- a/php/lib_res.php
+++ b/php/lib_res.php
@@ -50,13 +50,27 @@ function dump_unicode($unistr, $quoted = TRUE)
|| ($unistr[$i] >= ord('A') && $unistr[$i] < ord('Z'))
|| $unistr[$i] == ord(' '))
echo chr($unistr[$i]);
- else
+ else if ($unistr[$i] == 10) {
+ echo "<span class=\"resmeta\">\\n</span>";
+ if ($i < count($unistr) - 1)
+ echo "<br/>\n";
+ } else if ($unistr[$i] == 0) {
+ echo "<span class=\"resmeta\">\\0</span>";
+ } else
echo "&#x".dechex($unistr[$i]).";";
}
if ($quoted)
echo """;
}
+function dump_unicode_or_empty($uni_str)
+{
+ if ($uni_str)
+ dump_unicode($uni_str);
+ else
+ echo "<span class=\"resmeta\">empty</span>";
+}
+
class ResFile
{
var $file;
@@ -192,10 +206,11 @@ class StringTable extends Resource
{
var $strings;
- function StringTable($header, $data)
+ function StringTable($header, $data, $table_id)
{
$this->Resource($header);
$this->strings = array();
+ $this->table_id = $table_id;
for ($i = 0; $i < 16; $i++)
{
$len = get_word($data);
@@ -213,6 +228,36 @@ class StringTable extends Resource
{
return $this->strings[$id];
}
+
+ function dump($master_res = NULL)
+ {
+ for ($i=0; $i<16; $i++) {
+ $extra = "";
+
+ $uni_str = $this->getString($i);
+ if ($master_res)
+ {
+ $master_uni_str = $master_res->getString($i);
+ if ((!$master_uni_str && $uni_str) || ($master_uni_str && !$uni_str))
+ $extra = " style=\"background-color: #ffb8d0\"";
+ }
+
+ echo "<tr$extra><td valign=\"top\">".(($this->table_id-1)*16+$i)."</td>";
+ echo "<td>";
+
+ dump_unicode_or_empty($uni_str);
+
+ if ($master_res)
+ {
+ echo "</td><td>";
+ dump_unicode_or_empty($master_uni_str);
+ }
+ echo "</td></tr>\n";
+ }
+
+ }
+
+ var $table_id;
}
function dump_header($header)
diff --git a/php/resource.php b/php/resource.php
index 4e0da68..7797923 100644
--- a/php/resource.php
+++ b/php/resource.php
@@ -33,18 +33,17 @@ $res_lang = update_lang_from_resfile($lang, $resfile);
$resdata = $resources->loadResource($type, $id, get_lang_binid($res_lang), is_lang_ignore_sublang($lang));
if (!$resdata)
die("Resource not found in *.res file\n");
-$res = new StringTable($resdata[0], $resdata[1]);
+$res = new StringTable($resdata[0], $resdata[1], $id);
+$master_res = NULL;
if ($compare)
{
$resdata = $resources->loadResource($type, $id, $MASTER_LANGUAGE_BINID);
if (!$resdata)
- {
echo ("<b>Can't compare with master language as resource not found</b>\n");
- }
- $master_res = new StringTable($resdata[0], $resdata[1]);
+ else
+ $master_res = new StringTable($resdata[0], $resdata[1], $id);
}
-
unset($resdata);
?>
@@ -53,14 +52,6 @@ unset($resdata);
<tr style="background-color: #e0e0ff"><th colspan="3">String table #<?php echo $id?></th></tr>
<?php
-function dump_unicode_or_empty($uni_str)
-{
- if ($uni_str)
- dump_unicode($uni_str);
- else
- echo "<span class=\"resmeta\">empty</span>";
-}
-
if (!$compare)
{
echo "<tr style=\"background-color: #e8e8ff\"><td colspan=\"2\" style=\"text-align: right\">";
@@ -78,29 +69,8 @@ else
echo "<tr style=\"background-color: #e8e8ff\"><td>id</td><td>".get_lang_name($lang)."</td><td>".get_lang_name($MASTER_LANGUAGE)."</td></tr>";
}
-for ($i=0; $i<16; $i++) {
- $extra = "";
+$res->dump($master_res);
- $uni_str = $res->getString($i);
- if ($compare)
- {
- $master_uni_str = $master_res->getString($i);
- if ((!$master_uni_str && $uni_str) || ($master_uni_str && !$uni_str))
- $extra = " style=\"background-color: #ffb8d0\"";
- }
-
- echo "<tr$extra><td valign=\"top\">".(($id-1)*16+$i)."</td>";
- echo "<td>";
-
- dump_unicode_or_empty($uni_str);
-
- if ($compare)
- {
- echo "</td><td>";
- dump_unicode_or_empty($master_uni_str);
- }
- echo "</td></tr>\n";
-}
?>
</table>
</body>
More information about the wine-cvs
mailing list