Author: jani
Date: Sun Feb 10 12:40:27 2013
New Revision: 1444535
URL: http://svn.apache.org/r1444535
Log:
test that extraction content match (.src)
Modified:
openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx?rev=1444535&r1=1444534&r2=1444535&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx Sun Feb 10
12:40:27 2013
@@ -48,7 +48,8 @@ void convert_src::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
convert_src_impl::convert_src_impl(const std::string& srSourceFile, l10nMem&
crMemory, bool brVerbose)
- : convert_gen(srSourceFile, crMemory,
brVerbose)
+ : convert_gen(srSourceFile, crMemory,
brVerbose),
+
mbNoKey(false)
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx?rev=1444535&r1=1444534&r2=1444535&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx Sun Feb 10
12:40:27 2013
@@ -51,6 +51,7 @@ class convert_src_impl : public convert_
private:
std::vector<std::string> mcStack;
std::string msCollector;
+ bool mbNoKey;
void extract();
void insert();
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx?rev=1444535&r1=1444534&r2=1444535&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx Sun Feb 10
12:40:27 2013
@@ -67,6 +67,7 @@ void convert_src_impl::pushKey(std::stri
sKey = sText.substr(nL, nE - nL);
mcStack.push_back(sKey);
+ mbNoKey = false;
}
@@ -82,6 +83,7 @@ void convert_src_impl::popKey(std::strin
// check for correct node/prop relations
if (mcStack.size())
mcStack.pop_back();
+ mbNoKey = false;
}
@@ -93,6 +95,8 @@ void convert_src_impl::pushNoKey(std::st
if (mbMergeMode)
writeSourceFile(msCollector + sText);
msCollector.clear();
+ mbNoKey = true;
+ mcStack.push_back("dummy");
}
@@ -108,11 +112,19 @@ void convert_src_impl::registerKey(std::
writeSourceFile(msCollector + sText);
msCollector.clear();
+ // do we expect a delayed key
+ if (!mbNoKey)
+ return;
+ mbNoKey = false;
+
// locate id
for (nL = 0; sText[nL] != '=' && sText[nL] != '\n'; ++nL) ;
for (++nL; sText[nL] == ' ' || sText[nL] == '\t'; ++nL) ;
for (nE = nL; sText[nE] != ' ' && sText[nE] != '\t' && sText[nE] != '\n' &&
nE < (int)sText.size(); ++nE) ;
sKey = sText.substr(nL, nE - nL);
+
+ // put key on stack instead of dummy
+ mcStack.pop_back();
mcStack.push_back(sKey);
}
@@ -135,7 +147,8 @@ void convert_src_impl::saveData(std::str
// locate key and extract it
for (nL = 0; nL < (int)mcStack.size(); ++nL)
- sKey += (nL > 0 ? "." : "") + mcStack[nL];
+ if (mcStack[nL] != "dummy")
+ sKey += (nL > 0 ? "." : "") + mcStack[nL];
// locate id
for (nL = 0; sText[nL] != '\"' && nL < (int)sText.size(); ++nL) ;
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l?rev=1444535&r1=1444534&r2=1444535&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l Sun Feb 10
12:40:27 2013
@@ -59,52 +59,74 @@
/******************* R U L E S D E F I N I T I O N S *******************/
%%
-[tT][aA][bB][dD][iI][aA][lL][oO][gG][^\{]* {
+[bB][iI][tT][mM][aA][pP][ ]+[a-zA-Z]+[^\{]* |
+[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE][ ]+[a-zA-Z]+[^\{]* |
+[eE][dD][iI][tT][ ]+[a-zA-Z]+[^\{]* |
+[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]* |
+[cC][oO][nN][tT][rR][oO][lL][ ]+[a-zA-Z]+[^\{]* |
+[eE][rR][rR][oO][rR][bB][oO][xX][ ]+[a-zA-Z]+[^\{]* |
+[fF][iI][xX][eE][dD][tT][eE][xX][tT][ ]+[a-zA-Z]+[^\{]* |
+[iI][mM][aA][gG][eE][ ]+[a-zA-Z]+[^\{]* |
+[iI][mM][aA][gG][eE][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]* |
+[iI][tT][eE][mM][lL][iI][sS][tT][ ]+[a-zA-Z]+[^\{]* |
+[hH][eE][lL][pP][bB][uU][tT][oO][mM][ ]+[a-zA-Z]+[^\{]* |
+[mM][eE][nN][uU][ ]+[a-zA-Z]+[^\{]* |
+[mM][eE][nN][uU][iI][tT][eE][mM][ ]+[a-zA-Z]+[^\{]* |
+[mM][oO][dD][aA][lL][dD][iI][aA][lL][oO][gG][ ]+[a-zA-Z]+[^\{]* |
+[mM][uU][lL][tT][iI][lL][iI][nN][eE][dD][iI][tT][ ]+[a-zA-Z]+[^\{]* |
+[pP][aA][gG][eE][iI][tT][eE][mM][ ]+[a-zA-Z]+[^\{]* |
+[pP][aA][gG][eE][lL][iI][sS][tT][ ]+[a-zA-Z]+[^\{]* |
+[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]* |
+[sS][tT][rR][iI][nN][gG][ ]+[a-zA-Z]+[^\{]* |
+[tT][aA][bB][cC][oO][nN][tT][rR][oO][lL][ ]+[a-zA-Z]+[^\{]* |
+[tT][aA][bB][dD][iI][aA][lL][oO][gG][ ]+[a-zA-Z]+[^\{]* |
+[tT][aA][bB][pP][aA][gG][eE][ ]+[a-zA-Z]+[^\{]* {
std::string text(yytext);
convert_src::mcpImpl->pushKey(text);
}
-[tT][aA][bB][cC][oO][nN][tT][rR][oO][lL][^\{]* {
- std::string text(yytext);
- convert_src::mcpImpl->pushKey(text);
-}
-
-[tT][aA][bB][pP][aA][gG][eE][^\{]* {
- std::string text(yytext);
- convert_src::mcpImpl->pushKey(text);
-}
-
-[fF][iI][xX][eE][dD][tT][eE][xX][tT][^\{]* {
- std::string text(yytext);
- convert_src::mcpImpl->pushKey(text);
-}
-[sS][tT][rR][iI][nN][gG][^\{]* {
- std::string text(yytext);
- convert_src::mcpImpl->pushKey(text);
-}
-
-[pP][aA][gG][eE][lL][iI][sS][tT][^\{]* {
- std::string text(yytext);
- convert_src::mcpImpl->pushNoKey(text);
-}
-[pP][aA][gG][eE][iI][tT][eE][mM][^\{]* {
+[bB][iI][tT][mM][aA][pP][ \t\n]+"{" |
+[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE][ \t\n]+"{" |
+[eE][dD][iI][tT][ \t\n]+"{" |
+[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN][ \t\n]"{" |
+[cC][oO][nN][tT][rR][oO][lL][ \t\n]+"{" |
+[eE][rR][rR][oO][rR][bB][oO][xX][ \t\n]+"{" |
+[fF][iI][xX][eE][dD][tT][eE][xX][tT][ \t\n]+"{" |
+[iI][mM][aA][gG][eE][ \t\n]+"{" |
+[iI][mM][aA][gG][eE][bB][uU][tT][tT][oO][nN][ \t\n]+"{" |
+[iI][tT][eE][mM][lL][iI][sS][tT][ \t\n=]+"{" |
+[hH][eE][lL][pP][bB][uU][tT][oO][mM][ \t\n]+"{" |
+[mM][eE][nN][uU][ \t\n]+"{" |
+[mM][eE][nN][uU][iI][tT][eE][mM][ \t\n]+"{" |
+[mM][oO][dD][aA][lL][dD][iI][aA][lL][oO][gG][ \t\n]+"{" |
+[mM][uU][lL][tT][iI][lL][iI][nN][eE][dD][iI][tT][ \t\n]+"{" |
+[pP][aA][gG][eE][iI][tT][eE][mM][ \t\n]+"{" |
+[pP][aA][gG][eE][lL][iI][sS][tT][ \t\n]+"{" |
+[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN][ \t\n]+"{" |
+[sS][tT][rR][iI][nN][gG][ \t\n]+"{" |
+[tT][aA][bB][cC][oO][nN][tT][rR][oO][lL][ \t\n]+"{" |
+[tT][aA][bB][dD][iI][aA][lL][oO][gG][ \t\n]+"{" |
+[tT][aA][bB][pP][aA][gG][eE][ \t\n]+"{" {
std::string text(yytext);
convert_src::mcpImpl->pushNoKey(text);
}
-[iI][dD][eE][nN][tT][iI][fF][iI][eE][rR][^;]* {
+[hH][eE][lL][pP][iI][dD][ \t]+'='[ \t]+[a-zA-Z]+[^;]* |
+[iI][dD][eE][nN][tT][iI][fF][iI][eE][rR][ \t]*"="[ \t]*[a-zA-Z]+[^;]* {
std::string text(yytext);
convert_src::mcpImpl->registerKey(text);
}
-[tT][eE][xX][tT][^\n]* {
+[mM][eE][sS][sS][aA][gG][eE][ \t]*"["[ \t]*"en-US"[ \t]*"]"[ \t]+"="[^\n]*
|
+[qQ][uU][iI][cC][kK][hH][eE][lL][pP][tT][eE][xX][tT][ \t]*"["[ \t]*"en-US"[
\t]*"]"[ \t]+"="[^\n]* |
+[tT][eE][xX][tT][ \t]*"["[ \t]*"en-US"[ \t]*"]"[ \t]+"="[^\n]*
{
std::string text(yytext);
convert_src::mcpImpl->saveData(text);
}
-"};" {
+"}"[ ]*";" {
std::string text(yytext);
convert_src::mcpImpl->popKey(text);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1444535&r1=1444534&r2=1444535&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Sun Feb 10
12:40:27 2013
@@ -54,10 +54,6 @@ l10nMem_entry::~l10nMem_entry()
/********************** I M P L E M E N T A T I O N **********************/
l10nMem::l10nMem()
{
- mcMemory.push_back(l10nMem_entry("file1", "module1",
- "key", "da", "hovsa"));
- mcMemory.push_back(l10nMem_entry("file1", "module1",
- "key", "ja", "hovsa"));
}
@@ -73,14 +69,15 @@ l10nMem::~l10nMem()
void l10nMem::save(const std::string& srTargetFile)
{
int i;
- std::ofstream outputFile(srTargetFile.c_str(), std::ios::binary);
+ std::string sFile = srTargetFile + ".cnv";
+ std::ofstream outputFile(sFile.c_str(), std::ios::binary);
if (!outputFile.is_open())
throw std::string("Could not open ")+srTargetFile;
for (i = 0; i < (int)mcMemory.size(); ++i)
- outputFile << msCurrentModuleName << "\t" << msCurrentSourceFileName <<
"\t"
+ outputFile << mcMemory[i].msModuleName << "\t" <<
mcMemory[i].msSourceFile << "\t"
<< mcMemory[i].msKey << "\t" << mcMemory[i].msLanguage <<
"\t"
<< mcMemory[i].msText << std::endl;
// JIX