Patch level : 4.0 486
Files correlati : ba2.exe Ricompilazione Demo : [ ] Commento : Evidenziati gli errori nel dizionario Aggiunta la possibilità di eliminare le label non utilizzate git-svn-id: svn://10.65.10.50/trunk@14303 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1e49c8e58e
commit
eef5ba8ad3
157
ba/ba2700.cpp
157
ba/ba2700.cpp
@ -2,6 +2,7 @@
|
||||
#include <assoc.h>
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
#include <colors.h>
|
||||
#include <defmask.h>
|
||||
#include <diction.h>
|
||||
#include <progind.h>
|
||||
@ -38,7 +39,7 @@ void TDictionary_entry::add_source(const char* orig)
|
||||
{
|
||||
TFilename n(orig); n.lower();
|
||||
const char* src = n.name();
|
||||
if (_src.get_pos(src))
|
||||
if (_src.get_pos(src) < 0)
|
||||
_src.add(src);
|
||||
}
|
||||
}
|
||||
@ -91,6 +92,8 @@ public:
|
||||
bool read(const char* fname);
|
||||
bool write();
|
||||
bool write_if_needed();
|
||||
void zap_sources(const char * module);
|
||||
void pack();
|
||||
TDictionary() : _sort_needed(false), _save_needed(false) { }
|
||||
};
|
||||
|
||||
@ -128,7 +131,8 @@ bool TDictionary::read(const char* fname)
|
||||
if (ok)
|
||||
{
|
||||
TProgind pi(fsize(_filename), "Lettura dizionario", false, true);
|
||||
destroy();
|
||||
|
||||
destroy();
|
||||
TScanner scan(_filename);
|
||||
TString ita;
|
||||
for (int c = 0; scan.ok(); c++)
|
||||
@ -168,6 +172,52 @@ bool TDictionary::read(const char* fname)
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TDictionary::zap_sources(const char * module)
|
||||
{
|
||||
TProgind pi(items(), "Azzeramento sorgenti", false, true);
|
||||
TPointer_array& ref = sorted();
|
||||
const bool zap = module == NULL || *module == '\0';
|
||||
|
||||
for (int i = 0; i < ref.items(); i++)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
|
||||
TDictionary_entry& e = (TDictionary_entry&)ref[i];
|
||||
|
||||
if (zap)
|
||||
e._src.cut(0);
|
||||
else
|
||||
{
|
||||
TToken_string new_src;
|
||||
|
||||
FOR_EACH_TOKEN(e._src, tok)
|
||||
{
|
||||
if (strncmp(tok, module, 2) != 0)
|
||||
new_src.add(tok);
|
||||
}
|
||||
e._src = new_src;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TDictionary::pack()
|
||||
{
|
||||
TProgind pi(items(), "Compattamento dizionario", false, true);
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT((*this), h, k, o)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
|
||||
const TDictionary_entry& e = (const TDictionary_entry&)*o;
|
||||
|
||||
if (e._src.blank())
|
||||
{
|
||||
remove(k);
|
||||
_save_needed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TDictionary::write()
|
||||
{
|
||||
TProgind pi(items(), "Salvataggio dizionario", false, true);
|
||||
@ -243,6 +293,8 @@ protected:
|
||||
|
||||
bool read_dictionary();
|
||||
void fill_index();
|
||||
bool check_translation(const TString & ita, const TString & eng, const char tag);
|
||||
bool good_translation(const TString & ita, const TString & eng, const TString & src);
|
||||
void fill_chapter();
|
||||
|
||||
public:
|
||||
@ -514,14 +566,43 @@ bool TDictionary_mask::read_bin_files(const char* msk)
|
||||
|
||||
void TDictionary_mask::build_dictionary()
|
||||
{
|
||||
bool go = read_txt_files("*.msk");
|
||||
if (go) go = read_txt_files("*.frm");
|
||||
if (go) go = read_txt_files("*.men");
|
||||
if (go) go = read_txt_files("res/resource.ini");
|
||||
if (go) go = read_bin_files("???.exe");
|
||||
TMask m("ba2700a");
|
||||
|
||||
fill_index();
|
||||
fill_chapter();
|
||||
if (m.run() == K_ENTER)
|
||||
{
|
||||
const TString4 module = m.get(F_MODULE);
|
||||
TString16 mask = module;
|
||||
const bool delete_obs = m.get_bool(F_DELETE_OBS);
|
||||
|
||||
if (delete_obs)
|
||||
_dictionary.zap_sources(module);
|
||||
mask << "*.msk";
|
||||
bool go = read_txt_files(mask);
|
||||
if (go)
|
||||
{
|
||||
mask = module; mask << "*.frm";
|
||||
go = read_txt_files(mask);
|
||||
}
|
||||
if (go)
|
||||
{
|
||||
mask = module; mask << "*.men";
|
||||
go = read_txt_files(mask);
|
||||
}
|
||||
if (go) go = read_txt_files("res/resource.ini");
|
||||
if (go)
|
||||
{
|
||||
if (module.full())
|
||||
mask = module;
|
||||
else
|
||||
mask = "??";
|
||||
mask << "?.exe";
|
||||
go = read_bin_files(mask);
|
||||
}
|
||||
if (delete_obs)
|
||||
_dictionary.pack();
|
||||
fill_index();
|
||||
fill_chapter();
|
||||
}
|
||||
}
|
||||
|
||||
void TDictionary_mask::fill_index()
|
||||
@ -545,9 +626,48 @@ void TDictionary_mask::fill_index()
|
||||
alfabeto.set("A");
|
||||
}
|
||||
|
||||
bool TDictionary_mask::check_translation(const TString & ita, const TString & eng, const char tag)
|
||||
{
|
||||
bool ok = true;
|
||||
int p_ita = ita.find(tag);
|
||||
int p_eng = eng.find(tag);
|
||||
|
||||
while (ok && (p_ita >= 0) && (p_eng >= 0))
|
||||
{
|
||||
ok = (p_ita >= 0) && (p_eng >= 0) && (ita[p_ita + 1] == eng[p_eng + 1]);
|
||||
if (ok)
|
||||
{
|
||||
p_ita = ita.find(tag, p_ita + 1);
|
||||
p_eng = eng.find(tag, p_eng + 1);
|
||||
}
|
||||
}
|
||||
ok &= ((p_ita < 0) && (p_eng <0));
|
||||
#ifdef DBG
|
||||
if (!ok)
|
||||
int i = 0;
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDictionary_mask::good_translation(const TString & ita, const TString & eng, const TString & src)
|
||||
{
|
||||
if (eng == "???")
|
||||
return false;
|
||||
if (ita.find('#') >= 0 || eng.find('#') >= 0)
|
||||
return false;
|
||||
if (ita.find('&') >= 0 || eng.find('&') >= 0)
|
||||
return false;
|
||||
if (!check_translation(ita, eng, '@'))
|
||||
return false;
|
||||
if (src.find(".exe") > 0 && !check_translation(ita, eng, '%'))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TDictionary_mask::fill_chapter()
|
||||
{
|
||||
const char letter = get(F_ALFABETO)[0];
|
||||
const bool errors_only = get_bool(F_ERRORS_ONLY);
|
||||
|
||||
TSheet_field& s = sfield(F_CAPITOLO);
|
||||
s.destroy();
|
||||
@ -558,12 +678,19 @@ void TDictionary_mask::fill_chapter()
|
||||
const TDictionary_entry& e = (const TDictionary_entry&)ref[i];
|
||||
if (toupper(e._ita[0]) == letter)
|
||||
{
|
||||
const bool good = good_translation(e._ita, e._eng, e._src);
|
||||
if (errors_only && good)
|
||||
continue;
|
||||
TToken_string& row = s.row(-1);
|
||||
row = e._ita;
|
||||
row.add(e._eng);
|
||||
row.add(e._max_length);
|
||||
row.add(e._src);
|
||||
}
|
||||
if (good)
|
||||
s.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, s.items() - 1);
|
||||
else
|
||||
s.set_back_and_fore_color(REQUIRED_BACK_COLOR, COLOR_RED, s.items() - 1);
|
||||
}
|
||||
}
|
||||
s.force_update();
|
||||
set(F_ENTRIES, s.items());
|
||||
@ -612,12 +739,18 @@ bool TDictionary_mask::on_field_event(TOperable_field& o, TField_event e, long j
|
||||
{
|
||||
TSheet_field& s = (TSheet_field&)o;
|
||||
TToken_string& row = s.row(jolly);
|
||||
const TString& ita = row.get(0);
|
||||
const TString& eng = row.get(1);
|
||||
const TString ita = row.get(0);
|
||||
const TString eng = row.get(1);
|
||||
const int len = row.get_int(2);
|
||||
const TString src = row.get(3);
|
||||
_dictionary.set_translation(ita, eng);
|
||||
if (len > 0 && eng.len() > len)
|
||||
warning_box("La traduzione e' lunga %d caratteri (max. %d)!", eng.len(), len);
|
||||
if (!good_translation(ita, eng, src))
|
||||
s.set_back_and_fore_color(REQUIRED_BACK_COLOR, COLOR_RED, jolly);
|
||||
else
|
||||
s.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, jolly);
|
||||
s.force_update(jolly);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
14
ba/ba2700.h
14
ba/ba2700.h
@ -1,8 +1,12 @@
|
||||
#define F_FILENAME 201
|
||||
#define F_ALFABETO 202
|
||||
#define F_ENTRIES 203
|
||||
#define F_TOTAL 204
|
||||
#define F_CAPITOLO 210
|
||||
#define F_FILENAME 201
|
||||
#define F_ALFABETO 202
|
||||
#define F_ENTRIES 203
|
||||
#define F_TOTAL 204
|
||||
#define F_ERRORS_ONLY 205
|
||||
#define F_CAPITOLO 210
|
||||
|
||||
#define F_MODULE 201
|
||||
#define F_DELETE_OBS 202
|
||||
|
||||
#define F_ITA 101
|
||||
#define F_ENG 102
|
||||
|
@ -39,6 +39,11 @@ BEGIN
|
||||
PROMPT 2 2 "Iniziale "
|
||||
END
|
||||
|
||||
BOOLEAN F_ERRORS_ONLY
|
||||
BEGIN
|
||||
PROMPT 16 2 "Solo righe errate"
|
||||
END
|
||||
|
||||
NUMBER F_ENTRIES 6
|
||||
BEGIN
|
||||
PROMPT 32 2 "Elementi "
|
||||
|
27
ba/ba2700a.uml
Executable file
27
ba/ba2700a.uml
Executable file
@ -0,0 +1,27 @@
|
||||
#include "ba2700.h"
|
||||
|
||||
PAGE "Aggiornamento Dizionario" -1 -1 40 6
|
||||
|
||||
STRING F_MODULE 2
|
||||
BEGIN
|
||||
PROMPT 2 1 "Modulo "
|
||||
END
|
||||
|
||||
BOOLEAN F_DELETE_OBS
|
||||
BEGIN
|
||||
PROMPT 2 3 "Cancella gli obsoleti"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user