Kaydet (Commit) 6a313949 authored tarafından jan Iversen's avatar jan Iversen

genlang macro support for .src files

Added macro detection in .src filter
Updated gDiff and gRun scripts with enhancements

Change-Id: Idddd3ef72e8ccee65d03fe5080e27699ceebb079
üst b14c3a5e
...@@ -39,16 +39,19 @@ class convert_src : public convert_gen ...@@ -39,16 +39,19 @@ class convert_src : public convert_gen
void setCmd(string& syyText); void setCmd(string& syyText);
void startBlock(); void startBlock();
void stopBlock(); void stopBlock();
void defMacro();
void endMacro();
// void setId (char *syyText, bool bIde); // void setId (char *syyText, bool bIde);
// void setText (char *syyText); // void setText (char *syyText);
// void setMacro (char *syyText);
// void setList (char *syyText); // void setList (char *syyText);
// void setListItem (char const *syyText, bool bIsStart); // void setListItem (char const *syyText, bool bIsStart);
// void setNL (char *syyText, bool bMacro); // void setNL (char *syyText, bool bMacro);
private: private:
vector<string> mcStack; vector<string> mcStack;
int miLevel;
bool mbMacroActive;
void doExecute() override; void doExecute() override;
#if 0 #if 0
string msValue; string msValue;
...@@ -58,13 +61,11 @@ class convert_src : public convert_gen ...@@ -58,13 +61,11 @@ class convert_src : public convert_gen
string msGroup; string msGroup;
bool mbEnUs; bool mbEnUs;
bool mbExpectName; bool mbExpectName;
bool mbExpectMacro;
bool mbAutoPush; bool mbAutoPush;
bool mbValuePresent; bool mbValuePresent;
bool mbInList; bool mbInList;
bool mbInListItem; bool mbInListItem;
int miListCount; int miListCount;
int miMacroLevel;
static void trim(string& sText); static void trim(string& sText);
void buildKey(string& sKey); void buildKey(string& sKey);
......
...@@ -29,13 +29,13 @@ using namespace std; ...@@ -29,13 +29,13 @@ using namespace std;
convert_src::convert_src(l10nMem& crMemory) convert_src::convert_src(l10nMem& crMemory)
: convert_gen(crMemory) : convert_gen(crMemory),
miLevel(0),
mbMacroActive(false)
#if 0 #if 0
,
mbExpectValue(false), mbExpectValue(false),
mbEnUs(false), mbEnUs(false),
mbExpectName(false), mbExpectName(false),
mbExpectMacro(false),
mbAutoPush(false), mbAutoPush(false),
mbValuePresent(false), mbValuePresent(false),
mbInList(false), mbInList(false),
...@@ -62,11 +62,11 @@ void convert_src::setValue(string& syyText) ...@@ -62,11 +62,11 @@ void convert_src::setValue(string& syyText)
for (int i = 0; i < stackSize; i++) for (int i = 0; i < stackSize; i++)
cout << mcStack[i] << "\n"; cout << mcStack[i] << "\n";
} }
string subid = (stackSize > 3) ? mcStack[2] : mcStack[0]; string subid = (stackSize > 3) ? mcStack[stackSize - 1] : "";
l10nMem::keyToLower(subid); string stringid = mcStack[stackSize - 2];
l10nMem::keyToLower(stringid);
mcMemory.setSourceKey(miLineNo, msSourceFile, mcStack[1], cleanValue, "", subid, mcStack[stackSize-1], false); mcMemory.setSourceKey(miLineNo, msSourceFile, mcStack[1], cleanValue, "", stringid, subid, false);
mcStack.pop_back();
} }
...@@ -98,19 +98,51 @@ void convert_src::setCmd(string& syyText) ...@@ -98,19 +98,51 @@ void convert_src::setCmd(string& syyText)
void convert_src::startBlock() void convert_src::startBlock()
{ {
unsigned int cnt = 2 * ++miLevel;
while (cnt > mcStack.size())
mcStack.push_back("");
} }
void convert_src::stopBlock() void convert_src::stopBlock()
{ {
if (miLevel > 0)
miLevel--;
// check for correct node/prop relations // check for correct node/prop relations
if (mcStack.size()) if (mcStack.size()) {
mcStack.pop_back(); 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 #if 0
void convert_src::setId(char *syyText, bool bId) void convert_src::setId(char *syyText, bool bId)
{ {
...@@ -134,21 +166,6 @@ void convert_src::setText(char *syyText) ...@@ -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 #if 0
void convert_src::setList(char *syyText) void convert_src::setList(char *syyText)
{ {
......
#!/bin/bash #!/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` for i in `find . -name \*.pot`
do do
echo ">>>>>>>> " $i echo ">>>>>>>> " $i
......
...@@ -118,6 +118,13 @@ f ...@@ -118,6 +118,13 @@ f
<LANG>{SPACE}"=" {
LOCptr->copySource(yytext);
BEGIN(INITIAL);
}
<LANG2>{IDENT} { <LANG2>{IDENT} {
if (LOCptr->setLang(LOCptr->copySource(yytext))) { if (LOCptr->setLang(LOCptr->copySource(yytext))) {
BEGIN(LANG3); BEGIN(LANG3);
...@@ -157,10 +164,13 @@ f ...@@ -157,10 +164,13 @@ f
} }
"#define" |
[mM][eE][nN][uU] | [fF][iI][xX][eE][dD][tT][eE][xX][tT] |
[mM][eE][nN][uU][iI][tT][eE][mM] | [mM][eE][nN][uU] |
[sS][tT][rR][iI][nN][gG] { [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)); LOCptr->setCmd(LOCptr->copySource(yytext));
BEGIN(CMD); BEGIN(CMD);
} }
...@@ -186,8 +196,22 @@ f ...@@ -186,8 +196,22 @@ f
} }
\n {
LOCptr->copySource(yytext);
LOCptr->endMacro();
}
\\[\r]*\n {
LOCptr->copySource(yytext);
LOCptr->defMacro();
}
. { "#include".* |
. {
LOCptr->copySource(yytext); LOCptr->copySource(yytext);
// Just to please compiler. // Just to please compiler.
...@@ -221,18 +245,6 @@ KEYID [a-zA-Z0-9_-]+ ...@@ -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][iI][tT][mM][aA][pP]{SUF} |
{PRE}[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE]{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} | {PRE}[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN]{SUF} |
...@@ -242,7 +254,6 @@ KEYID [a-zA-Z0-9_-]+ ...@@ -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}[dD][oO][cC][kK][iI][nN][gG][wW][iI][nN][dD][oO][wW]{SUF} |
{PRE}[eE][dD][iI][tT]{SUF} | {PRE}[eE][dD][iI][tT]{SUF} |
{PRE}[eE][rR][rR][oO][rR][bB][oO][xX]{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][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}[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} | {PRE}[gG][rR][oO][uU][pP][bB][oO][xX]{SUF} |
...@@ -268,7 +279,6 @@ KEYID [a-zA-Z0-9_-]+ ...@@ -268,7 +279,6 @@ KEYID [a-zA-Z0-9_-]+
{PRE}[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN]{SUF} | {PRE}[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN]{SUF} |
{PRE}[qQ][uU][eE][rR][yY][bB][oO][xX]{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][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][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][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} | {PRE}[sS][pP][iI][nN][fF][iI][eE][lL][dD]{SUF} |
...@@ -281,7 +291,6 @@ KEYID [a-zA-Z0-9_-]+ ...@@ -281,7 +291,6 @@ KEYID [a-zA-Z0-9_-]+
{PRE}[tT][oO][oO][lL][bB][oO][xX][iI][tT][eE][mM]{SUF} | {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}[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][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} { {PRE}[wW][oO][rR][kK][wW][iI][nN][dD][oO][wW]{SUF} {
...@@ -326,14 +335,6 @@ KEYID [a-zA-Z0-9_-]+ ...@@ -326,14 +335,6 @@ KEYID [a-zA-Z0-9_-]+
{PRE}"#define"{SUF} {
yyless(strlen(yytext)-1);
LOCptr->setMacro(yytext);
BEGIN(CMD);
}
{KEYID} { {KEYID} {
LOCptr->setName(yytext); LOCptr->setName(yytext);
} }
......
...@@ -412,7 +412,7 @@ ${MYCMD} --files svx/source/sidebar/area/AreaPropertyPanel.src ...@@ -412,7 +412,7 @@ ${MYCMD} --files svx/source/sidebar/area/AreaPropertyPanel.src
${MYCMD} --files svx/source/sidebar/EmptyPanel.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 ${MYCMD} --files svx/source/sidebar/text/TextPropertyPanel.src
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment