From 6a3139493857631784f64419048ee258cd0c4493 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Mon, 2 May 2016 16:50:50 +0000 Subject: genlang macro support for .src files Added macro detection in .src filter Updated gDiff and gRun scripts with enhancements Change-Id: Idddd3ef72e8ccee65d03fe5080e27699ceebb079 --- l10ntools/inc/gConvSrc.hxx | 7 +++-- l10ntools/source/gConvSrc.cxx | 65 +++++++++++++++++++++++++++---------------- l10ntools/source/gDiff.sh | 9 +++++- l10ntools/source/gLexSrc.l | 57 ++++++++++++++++++------------------- l10ntools/source/gRun.sh | 2 +- 5 files changed, 83 insertions(+), 57 deletions(-) (limited to 'l10ntools') diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx index 77922c9a36db..605fffb95d4b 100644 --- a/l10ntools/inc/gConvSrc.hxx +++ b/l10ntools/inc/gConvSrc.hxx @@ -39,16 +39,19 @@ class convert_src : public convert_gen void setCmd(string& syyText); void startBlock(); void stopBlock(); + void defMacro(); + void endMacro(); // void setId (char *syyText, bool bIde); // void setText (char *syyText); -// void setMacro (char *syyText); // void setList (char *syyText); // void setListItem (char const *syyText, bool bIsStart); // void setNL (char *syyText, bool bMacro); private: vector mcStack; + int miLevel; + bool mbMacroActive; void doExecute() override; #if 0 string msValue; @@ -58,13 +61,11 @@ class convert_src : public convert_gen string msGroup; bool mbEnUs; bool mbExpectName; - bool mbExpectMacro; bool mbAutoPush; bool mbValuePresent; bool mbInList; bool mbInListItem; int miListCount; - int miMacroLevel; static void trim(string& sText); void buildKey(string& sKey); diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx index 20085a01fb35..213a3d25434c 100644 --- a/l10ntools/source/gConvSrc.cxx +++ b/l10ntools/source/gConvSrc.cxx @@ -29,13 +29,13 @@ using namespace std; convert_src::convert_src(l10nMem& crMemory) - : convert_gen(crMemory) + : convert_gen(crMemory), + miLevel(0), + mbMacroActive(false) #if 0 - , mbExpectValue(false), mbEnUs(false), mbExpectName(false), - mbExpectMacro(false), mbAutoPush(false), mbValuePresent(false), mbInList(false), @@ -62,11 +62,11 @@ void convert_src::setValue(string& syyText) for (int i = 0; i < stackSize; i++) cout << mcStack[i] << "\n"; } - string subid = (stackSize > 3) ? mcStack[2] : mcStack[0]; - l10nMem::keyToLower(subid); + string subid = (stackSize > 3) ? mcStack[stackSize - 1] : ""; + string stringid = mcStack[stackSize - 2]; + l10nMem::keyToLower(stringid); - mcMemory.setSourceKey(miLineNo, msSourceFile, mcStack[1], cleanValue, "", subid, mcStack[stackSize-1], false); - mcStack.pop_back(); + mcMemory.setSourceKey(miLineNo, msSourceFile, mcStack[1], cleanValue, "", stringid, subid, false); } @@ -98,19 +98,51 @@ void convert_src::setCmd(string& syyText) void convert_src::startBlock() { + unsigned int cnt = 2 * ++miLevel; + + while (cnt > mcStack.size()) + mcStack.push_back(""); } void convert_src::stopBlock() { + if (miLevel > 0) + miLevel--; + // check for correct node/prop relations - if (mcStack.size()) - mcStack.pop_back(); + if (mcStack.size()) { + if (miLevel) { + mcStack.pop_back(); + mcStack.pop_back(); + } + else + mcStack.clear(); + } } +void convert_src::defMacro() +{ + if (!miLevel) + miLevel++; + mbMacroActive = true; +} + + + +void convert_src::endMacro() +{ + if (mbMacroActive) { + mbMacroActive = false; + miLevel = 0; + mcStack.clear(); + } +} + + #if 0 void convert_src::setId(char *syyText, bool bId) { @@ -134,21 +166,6 @@ void convert_src::setText(char *syyText) -#if 0 -void convert_src::setMacro(char *syyText) -{ - msCmd = copySource(syyText); - mbExpectName = - mbExpectMacro = - mbAutoPush = true; - miMacroLevel = mcStack.size(); - mcStack.push_back(""); - trim(msCmd); -} -#endif - - - #if 0 void convert_src::setList(char *syyText) { diff --git a/l10ntools/source/gDiff.sh b/l10ntools/source/gDiff.sh index 56c0dbd4e0e2..f54060284535 100755 --- a/l10ntools/source/gDiff.sh +++ b/l10ntools/source/gDiff.sh @@ -1,6 +1,13 @@ #!/bin/bash -cd workdir/jan +cd workdir/pot +find . > /tmp/jix1 +cd ../jan +find . > /tmp/jix2 + +echo ">>>>> FILELIST DIFF >>>" +diff /tmp/jix1 /tmp/jix2 + for i in `find . -name \*.pot` do echo ">>>>>>>> " $i diff --git a/l10ntools/source/gLexSrc.l b/l10ntools/source/gLexSrc.l index e3c98a95e4d0..3c9b2adf76a2 100644 --- a/l10ntools/source/gLexSrc.l +++ b/l10ntools/source/gLexSrc.l @@ -118,6 +118,13 @@ f +{SPACE}"=" { + LOCptr->copySource(yytext); + BEGIN(INITIAL); +} + + + {IDENT} { if (LOCptr->setLang(LOCptr->copySource(yytext))) { BEGIN(LANG3); @@ -157,10 +164,13 @@ f } - -[mM][eE][nN][uU] | -[mM][eE][nN][uU][iI][tT][eE][mM] | -[sS][tT][rR][iI][nN][gG] { +"#define" | +[fF][iI][xX][eE][dD][tT][eE][xX][tT] | +[mM][eE][nN][uU] | +[mM][eE][nN][uU][iI][tT][eE][mM] | +[rR][eE][sS][oO][uU][rR][cC][eE] | +[sS][tT][rR][iI][nN][gG] | +[wW][iI][nN][dD][oO][wW] { LOCptr->setCmd(LOCptr->copySource(yytext)); BEGIN(CMD); } @@ -186,8 +196,22 @@ f } +\n { + LOCptr->copySource(yytext); + LOCptr->endMacro(); +} + + + +\\[\r]*\n { + LOCptr->copySource(yytext); + LOCptr->defMacro(); +} + + -. { +"#include".* | +. { LOCptr->copySource(yytext); // Just to please compiler. @@ -221,18 +245,6 @@ KEYID [a-zA-Z0-9_-]+ -\n { - LOCptr->setNL(yytext, false); -} - - - -\\[\r]*\n { - LOCptr->setNL(yytext, true); -} - - - {PRE}[bB][iI][tT][mM][aA][pP]{SUF} | {PRE}[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE]{SUF} | {PRE}[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN]{SUF} | @@ -242,7 +254,6 @@ KEYID [a-zA-Z0-9_-]+ {PRE}[dD][oO][cC][kK][iI][nN][gG][wW][iI][nN][dD][oO][wW]{SUF} | {PRE}[eE][dD][iI][tT]{SUF} | {PRE}[eE][rR][rR][oO][rR][bB][oO][xX]{SUF} | -{PRE}[fF][iI][xX][eE][dD][tT][eE][xX][tT]{SUF} | {PRE}[fF][iI][xX][eE][dD][lL][iI][nN][eE]{SUF} | {PRE}[fF][lL][oO][aA][tT][iI][nN][gG][wW][iI][nN][dD][oO][wW]{SUF} | {PRE}[gG][rR][oO][uU][pP][bB][oO][xX]{SUF} | @@ -268,7 +279,6 @@ KEYID [a-zA-Z0-9_-]+ {PRE}[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN]{SUF} | {PRE}[qQ][uU][eE][rR][yY][bB][oO][xX]{SUF} | {PRE}[rR][aA][dD][iI][oO][bB][uU][tT][tT][oO][nN]{SUF} | -{PRE}[rR][eE][sS][oO][uU][rR][cC][eE]{SUF} | {PRE}[sS][fF][xX][sS][tT][yY][lL][eE][fF][aA][mM][iI][lL][iI][eS][sS]{SUF} | {PRE}[sS][fF][xX][sS][tT][yY][lL][eE][fF][aA][mM][iI][lL][yY][iI][tT][eE][mM]{SUF} | {PRE}[sS][pP][iI][nN][fF][iI][eE][lL][dD]{SUF} | @@ -281,7 +291,6 @@ KEYID [a-zA-Z0-9_-]+ {PRE}[tT][oO][oO][lL][bB][oO][xX][iI][tT][eE][mM]{SUF} | {PRE}[tT][rR][iI][sS][tT][aA][tT][eE][bB][oO][xX]{SUF} | {PRE}[wW][aA][rR][nN][iI][nN][gG][bB][oO][xX]{SUF} | -{PRE}[wW][iI][nN][dD][oO][wW]{SUF} | {PRE}[wW][oO][rR][kK][wW][iI][nN][dD][oO][wW]{SUF} { @@ -326,14 +335,6 @@ KEYID [a-zA-Z0-9_-]+ -{PRE}"#define"{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setMacro(yytext); - BEGIN(CMD); -} - - - {KEYID} { LOCptr->setName(yytext); } diff --git a/l10ntools/source/gRun.sh b/l10ntools/source/gRun.sh index 4187122e3ef6..d20ce3d09289 100755 --- a/l10ntools/source/gRun.sh +++ b/l10ntools/source/gRun.sh @@ -412,7 +412,7 @@ ${MYCMD} --files svx/source/sidebar/area/AreaPropertyPanel.src ${MYCMD} --files svx/source/sidebar/EmptyPanel.src -${MYCMD} --files svx/source/sidebar/line/LinePropertyPanel.src +#${MYCMD} --files svx/source/sidebar/line/LinePropertyPanel.src ${MYCMD} --files svx/source/sidebar/text/TextPropertyPanel.src -- cgit