diff options
author | jan iversen <jani@documentfoundation.org> | 2016-03-15 01:54:42 +0100 |
---|---|---|
committer | jan iversen <jani@documentfoundation.org> | 2016-03-15 02:05:54 +0100 |
commit | 885eb42469f9191f7df270dfd1c8bda5dcec0e2f (patch) | |
tree | 4697a33f6673969fd5cf781cf070b05aa0c3ca1c | |
parent | 2848692ff421d3b450e33c72234a370d6e6ad9ef (diff) |
genLang update
Decoration removed
Indent etc. updated to LO standard
License in generate pot files changed to LO standard.
this commit is a pure text edit, NO functional changes.
Change-Id: Ie0a26d3cff470dd5f91241ca6b962b17851c9d5b
33 files changed, 1747 insertions, 2162 deletions
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx index b9507ace74e2..710d0ff848cf 100644 --- a/l10ntools/inc/gConv.hxx +++ b/l10ntools/inc/gConv.hxx @@ -16,7 +16,6 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCON_HXX #define GCON_HXX #include <iostream> @@ -24,58 +23,59 @@ class convert_gen { -public: - static convert_gen *mcImpl; + public: + static convert_gen *mcImpl; + + convert_gen(l10nMem& cMemory); + virtual ~convert_gen(); - convert_gen(l10nMem& cMemory); - virtual ~convert_gen(); + // Create instance + static convert_gen& createInstance(l10nMem& cMemory, + const std::string& sSourceDir, + const std::string& sTargetDir, + const std::string& sSourceFile); - // Create instance - static convert_gen& createInstance(l10nMem& cMemory, - const std::string& sSourceDir, - const std::string& sTargetDir, - const std::string& sSourceFile); + // do extract/merge + bool execute(const bool bMerge, const bool bKid); - // do extract/merge - bool execute(const bool bMerge, const bool bKid); + // all converters MUST implement this function + virtual void execute() = 0; - // all converters MUST implement this function - virtual void execute() = 0; + // ONLY po should implement these functions + virtual void startSave(const std::string& sLanguage, + const std::string& sFile); + virtual void save(const std::string& sFileName, + const std::string& sKey, + const std::string& sENUStext, + const std::string& sText, + bool bFuzzy); + virtual void endSave(); + static bool checkAccess(std::string& sFile); + static bool createDir(std::string& sDir, std::string& sFile); - // ONLY po should implement these functions - virtual void startSave(const std::string& sLanguage, - const std::string& sFile); - virtual void save(const std::string& sFileName, - const std::string& sKey, - const std::string& sENUStext, - const std::string& sText, - bool bFuzzy); - virtual void endSave(); - static bool checkAccess(std::string& sFile); - static bool createDir(std::string& sDir, std::string& sFile); + // utility functions for converters + void lexRead(char *sBuf, int *nResult, int nMax_size); + std::string& copySource(char const *yyText, bool bDoClear = true); - // utility functions for converters - void lexRead(char *sBuf, int *nResult, int nMax_size); - std::string& copySource(char const *yyText, bool bDoClear = true); + protected: + // generic variables + bool mbMergeMode; + bool mbLoadMode; + std::string msSourcePath; + std::string msTargetPath; + std::string msSourceFile; + l10nMem& mcMemory; + std::string msCollector; + int miLineNo; + std::string msSourceBuffer, msCopyText; + int miSourceReadIndex; -protected: - // generic variables - bool mbMergeMode; - bool mbLoadMode; - std::string msSourcePath; - std::string msTargetPath; - std::string msSourceFile; - l10nMem& mcMemory; - std::string msCollector; - int miLineNo; - std::string msSourceBuffer, msCopyText; - int miSourceReadIndex; + bool prepareFile(); - bool prepareFile(); + // utility functions for converters + void writeSourceFile(const std::string& line); - // utility functions for converters - void writeSourceFile(const std::string& line); -private: - std::ofstream mcOutputFile; + private: + std::ofstream mcOutputFile; }; #endif diff --git a/l10ntools/inc/gConvDB.hxx b/l10ntools/inc/gConvDB.hxx index 51c837741739..23151836779d 100644 --- a/l10ntools/inc/gConvDB.hxx +++ b/l10ntools/inc/gConvDB.hxx @@ -16,34 +16,24 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONDN_HXX #define GCONDN_HXX #include "gConv.hxx" -/***************************************************************************** - ************************** G C O N D B . H X X ************************** - ***************************************************************************** - * This is the class header for loading/writing internal "object" files - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_db : public convert_gen { - public: - convert_db(l10nMem& crMemory); - virtual ~convert_db(); + public: + convert_db(l10nMem& crMemory); + ~convert_db(); - private: - static const int NUMFIELD = 16; - std::string msFields[NUMFIELD]; - int miSize; + private: + static const int NUMFIELD = 16; + std::string msFields[NUMFIELD]; + int miSize; - void execute() override; - bool collectLine(); + void execute() override; + bool collectLine(); }; #endif diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx index 33fc4ef73d0d..ab120d916b66 100644 --- a/l10ntools/inc/gConvPo.hxx +++ b/l10ntools/inc/gConvPo.hxx @@ -23,49 +23,40 @@ -/***************************************************************************** - ************************** G C O N P O . H X X ************************** - ***************************************************************************** - * This is the class header for .po conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_po : public convert_gen { - public: - bool mbExpectId; - bool mbExpectStr; - - - convert_po(l10nMem& crMemory); - virtual ~convert_po(); - - void startLook (); - void setValue (char *syyText, int iLineCnt); - void setFuzzy (); - void setKey (char *syyText); - void setMsgId (); - void setMsgStr (); - void handleNL (); - - private: - std::string msId; - std::string msStr; - std::string msKey; - bool mbFuzzy; - std::filebuf outBuffer; - - void execute() override; - - void startSave(const std::string& sLanguage, - const std::string& sFile) override; - void save(const std::string& sFileName, - const std::string& sKey, - const std::string& sENUStext, - const std::string& sText, - bool bFuzzy) override; - void endSave() override; + public: + bool mbExpectId; + bool mbExpectStr; + + + convert_po(l10nMem& crMemory); + ~convert_po(); + + void startLook (); + void setValue (char *syyText, int iLineCnt); + void setFuzzy (); + void setKey (char *syyText); + void setMsgId (); + void setMsgStr (); + void handleNL (); + + private: + std::string msId; + std::string msStr; + std::string msKey; + bool mbFuzzy; + std::filebuf outBuffer; + + void execute() override; + + void startSave(const std::string& sLanguage, + const std::string& sFile) override; + void save(const std::string& sFileName, + const std::string& sKey, + const std::string& sENUStext, + const std::string& sText, + bool bFuzzy) override; + void endSave() override; }; #endif diff --git a/l10ntools/inc/gConvProp.hxx b/l10ntools/inc/gConvProp.hxx index b2b9bd1de696..9e7f6e7b4758 100644 --- a/l10ntools/inc/gConvProp.hxx +++ b/l10ntools/inc/gConvProp.hxx @@ -16,30 +16,19 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONPROP_HXX #define GCONPROP_HXX #include "gConv.hxx" -/***************************************************************************** - ************************ G C O N P R O P . H X X ************************ - ***************************************************************************** - * This is the class header for .proporties conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_prop : public convert_gen { - public: - convert_prop(l10nMem& crMemory); - virtual ~convert_prop(); - + public: + convert_prop(l10nMem& crMemory); + ~convert_prop(); - private: - void execute() override; + private: + void execute() override; }; #endif diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx index 669430f90f2a..8df5d6c79330 100644 --- a/l10ntools/inc/gConvSrc.hxx +++ b/l10ntools/inc/gConvSrc.hxx @@ -16,60 +16,51 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONSRCHXX #define GCONSRCHXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N S R C . H X X ************************* - ***************************************************************************** - * This is the class header for .src conversion - *****************************************************************************/ - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_src : public convert_gen { - public: - bool mbExpectValue; + public: + bool mbExpectValue; - convert_src(l10nMem& crMemory); - virtual ~convert_src(); + convert_src(l10nMem& crMemory); + ~convert_src(); - void setValue (char *syyText, char *sbuildValue); - void setLang (char *syyText, bool bEnUs); - void setId (char *syyText, bool bIde); - void setText (char *syyText); - void setName (char *syyText); - void setCmd (char *syyText); - void setMacro (char *syyText); - void setList (char *syyText); - void setListItem (char const *syyText, bool bIsStart); - void setNL (char *syyText, bool bMacro); - void startBlock (char *syyText); - void stopBlock (char *syyText); + void setValue (char *syyText, char *sbuildValue); + void setLang (char *syyText, bool bEnUs); + void setId (char *syyText, bool bIde); + void setText (char *syyText); + void setName (char *syyText); + void setCmd (char *syyText); + void setMacro (char *syyText); + void setList (char *syyText); + void setListItem (char const *syyText, bool bIsStart); + void setNL (char *syyText, bool bMacro); + void startBlock (char *syyText); + void stopBlock (char *syyText); - private: - std::vector<std::string> mcStack; - std::string msValue; - std::string msName; - std::string msTextName; - std::string msCmd; - bool mbEnUs; - bool mbExpectName; - bool mbExpectMacro; - bool mbAutoPush; - bool mbValuePresent; - bool mbInList; - bool mbInListItem; - int miListCount; - int miMacroLevel; - void execute() override; - void trim(std::string& sText); - void buildKey(std::string& sKey); - void insertLanguagePart(std::string& sKey, std::string& sTextType); + private: + std::vector<std::string> mcStack; + std::string msValue; + std::string msName; + std::string msTextName; + std::string msCmd; + bool mbEnUs; + bool mbExpectName; + bool mbExpectMacro; + bool mbAutoPush; + bool mbValuePresent; + bool mbInList; + bool mbInListItem; + int miListCount; + int miMacroLevel; + void execute() override; + void trim(std::string& sText); + void buildKey(std::string& sKey); + void insertLanguagePart(std::string& sKey, std::string& sTextType); }; #endif diff --git a/l10ntools/inc/gConvTree.hxx b/l10ntools/inc/gConvTree.hxx index a0ecb20b0730..0807069fdbec 100644 --- a/l10ntools/inc/gConvTree.hxx +++ b/l10ntools/inc/gConvTree.hxx @@ -16,60 +16,47 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONTREE_HXX #define GCONTREE_HXX #include "gConv.hxx" -/***************************************************************************** - ************************ G C O N T R E E . H X X ************************ - ***************************************************************************** - * This is the class header for .tree conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_tree : public convert_gen { - public: - typedef enum - { - STATE_TAG_NONE, - STATE_TAG_HELPSEC, - STATE_TAG_NODE, - STATE_TAG_TOPIC, - STATE_TAG_VALUE - } STATE_TAG; - typedef enum - { - STATE_VAL_NONE, - STATE_VAL_APPL, - STATE_VAL_ID, - STATE_VAL_TITLE - } STATE_VAL; - - convert_tree(l10nMem& crMemory); - virtual ~convert_tree(); - - void setString (char *yytext); - void setState (char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL); - void setValue (char *yytext); - std::string& copySourceSpecial (char *yytext, int iType); - void writeSourceFile (std::string& sText, int inx); - - - private: - std::string msLine; - std::string msId; - std::string msAppl; - std::ofstream *mcOutputFiles; - STATE_TAG meStateTag; - STATE_VAL meStateVal; - int miCntLanguages; - - void execute() override; + public: + typedef enum { + STATE_TAG_NONE, + STATE_TAG_HELPSEC, + STATE_TAG_NODE, + STATE_TAG_TOPIC, + STATE_TAG_VALUE + } STATE_TAG; + typedef enum { + STATE_VAL_NONE, + STATE_VAL_APPL, + STATE_VAL_ID, + STATE_VAL_TITLE + } STATE_VAL; + + convert_tree(l10nMem& crMemory); + ~convert_tree(); + + void setString (char *yytext); + void setState (char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL); + void setValue (char *yytext); + std::string& copySourceSpecial (char *yytext, int iType); + void writeSourceFile (std::string& sText, int inx); + + private: + std::string msLine; + std::string msId; + std::string msAppl; + std::ofstream *mcOutputFiles; + STATE_TAG meStateTag; + STATE_VAL meStateVal; + int miCntLanguages; + + void execute() override; }; #endif diff --git a/l10ntools/inc/gConvUlf.hxx b/l10ntools/inc/gConvUlf.hxx index dc7c75fd2788..234c60e4aada 100644 --- a/l10ntools/inc/gConvUlf.hxx +++ b/l10ntools/inc/gConvUlf.hxx @@ -16,37 +16,26 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONULF_HXX #define GCONULF_HXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N U L F . H X X ************************* - ***************************************************************************** - * This is the class header for .ulf conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_ulf : public convert_gen { - public: - convert_ulf(l10nMem& crMemory); - virtual ~convert_ulf(); - - void setKey(char *syyText); - void setText(char *syyText, bool bIsEnUs); - void setValue(char *syyText); + public: + convert_ulf(l10nMem& crMemory); + ~convert_ulf(); - private: - std::string msKey; + void setKey(char *syyText); + void setText(char *syyText, bool bIsEnUs); + void setValue(char *syyText); + private: + std::string msKey; - void execute() override; - void handleLines(); + void execute() override; + void handleLines(); }; #endif diff --git a/l10ntools/inc/gConvXcs.hxx b/l10ntools/inc/gConvXcs.hxx index 40cb2ca06433..3444907c5beb 100644 --- a/l10ntools/inc/gConvXcs.hxx +++ b/l10ntools/inc/gConvXcs.hxx @@ -16,37 +16,27 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONXCS_HXX #define GCONXCS_HXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N X C S . H X X ************************* - ***************************************************************************** - * This is the class header for .xcs conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_xcs : public convert_gen { - public: - convert_xcs(l10nMem& crMemory); - virtual ~convert_xcs(); + public: + convert_xcs(l10nMem& crMemory); + ~convert_xcs(); - void setKey(char *syyText); - void unsetKey(char *syyText); - void startCollectData(char *syyText); - void stopCollectData(char *syyText); + void setKey(char *syyText); + void unsetKey(char *syyText); + void startCollectData(char *syyText); + void stopCollectData(char *syyText); - private: - std::string msKey; - bool mbCollectingData; + private: + std::string msKey; + bool mbCollectingData; - void execute() override; + void execute() override; }; #endif diff --git a/l10ntools/inc/gConvXcu.hxx b/l10ntools/inc/gConvXcu.hxx index c19f9901fbea..3e49f5285396 100644 --- a/l10ntools/inc/gConvXcu.hxx +++ b/l10ntools/inc/gConvXcu.hxx @@ -16,45 +16,35 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONXCU_HXX #define GCONXCU_HXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N X C U . H X X ************************* - ***************************************************************************** - * This is the class header for .xcu conversion - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class xcu_stack_entry; class convert_xcu : public convert_gen { - public: - bool mbNoCollectingData; + public: + bool mbNoCollectingData; - convert_xcu(l10nMem& crMemory); - virtual ~convert_xcu(); + convert_xcu(l10nMem& crMemory); + ~convert_xcu(); - void pushKey(char *syyText); - void popKey(char *syyText); + void pushKey(char *syyText); + void popKey(char *syyText); - void startCollectData(char *syyText); - void stopCollectData(char *syyText); - void copySpecial(char *syyText); - void copyNL(char *syyText); - void addLevel(); + void startCollectData(char *syyText); + void stopCollectData(char *syyText); + void copySpecial(char *syyText); + void copyNL(char *syyText); + void addLevel(); - private: - std::vector<std::string> mcStack; - int miLevel; - bool mbNoTranslate; + private: + std::vector<std::string> mcStack; + int miLevel; + bool mbNoTranslate; - void execute() override; + void execute() override; }; #endif diff --git a/l10ntools/inc/gConvXhp.hxx b/l10ntools/inc/gConvXhp.hxx index d59a00b911a5..c33e3b7abfc4 100644 --- a/l10ntools/inc/gConvXhp.hxx +++ b/l10ntools/inc/gConvXhp.hxx @@ -16,62 +16,50 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONXHP_HXX #define GCONXHP_HXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N X H P . H X X ************************* - ***************************************************************************** - * This is the class definition header xhp converter - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_xhp : public convert_gen { - public: - convert_xhp(l10nMem& crMemory); - virtual ~convert_xhp(); - - void setString(char *yytext); - void openTag(char *yytext); - void closeTag(char *yytext); - void closeTagNOvalue(char *yytext); - void setId(char *yytext); - void setLang(char *yytext); - void setRef(char *yytext); - void openTransTag(char *yytext); - void closeTransTag(char *yytext); - void stopTransTag(char *yytext); - void startComment(char *yytext); - void stopComment(char *yytext); - void handleSpecial(char *yytext); - void handleDataEnd(char *yytext); - void duplicate(char *yytext); - std::string& copySourceSpecial(char *yytext, int iType); - void writeSourceFile(std::string& sText, int inx); + public: + convert_xhp(l10nMem& crMemory); + ~convert_xhp(); - private: - typedef enum - { - VALUE_NOT_USED, - VALUE_IS_TAG, - VALUE_IS_TAG_TRANS, - VALUE_IS_VALUE, - VALUE_IS_VALUE_TAG - } STATE; - STATE meExpectValue, mePushValue; - std::string msKey, msPushCollect; - std::string msLine; + void setString(char *yytext); + void openTag(char *yytext); + void closeTag(char *yytext); + void closeTagNOvalue(char *yytext); + void setId(char *yytext); + void setLang(char *yytext); + void setRef(char *yytext); + void openTransTag(char *yytext); + void closeTransTag(char *yytext); + void stopTransTag(char *yytext); + void startComment(char *yytext); + void stopComment(char *yytext); + void handleSpecial(char *yytext); + void handleDataEnd(char *yytext); + void duplicate(char *yytext); + std::string& copySourceSpecial(char *yytext, int iType); + void writeSourceFile(std::string& sText, int inx); - std::string *msLangText; - std::ofstream *mcOutputFiles; - int miCntLanguages; - void execute() override; + private: + typedef enum { + VALUE_NOT_USED, + VALUE_IS_TAG, + VALUE_IS_TAG_TRANS, + VALUE_IS_VALUE, + VALUE_IS_VALUE_TAG + } STATE; + STATE meExpectValue, mePushValue; + std::string msKey, msPushCollect; + std::string msLine; + std::string *msLangText; + std::ofstream *mcOutputFiles; + int miCntLanguages; + void execute() override; }; #endif diff --git a/l10ntools/inc/gConvXrm.hxx b/l10ntools/inc/gConvXrm.hxx index 4928bace8f6f..cb6e4a7bf5b8 100644 --- a/l10ntools/inc/gConvXrm.hxx +++ b/l10ntools/inc/gConvXrm.hxx @@ -16,41 +16,31 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef GCONXRM_HXX #define GCONXRM_HXX #include "gConv.hxx" -/***************************************************************************** - ************************* G C O N X R M . H X X ************************* - ***************************************************************************** - * This is the class definition header xrm converter - *****************************************************************************/ - - - -/******************** C L A S S D E F I N I T I O N ********************/ class convert_xrm : public convert_gen { - public: - bool mbNoCollectingData; - convert_xrm(l10nMem& crMemory); - virtual ~convert_xrm(); - - void setId(char *yytext); - void setLang(char *yytext); - void setTag(char *yytext); - void startCollectData(char *yytext); - void stopCollectData(char *yytext); - - private: - std::string msKey; - bool mbIsTag; - bool mbIsLang; - std::string msTag; - - void execute() override; + public: + bool mbNoCollectingData; + convert_xrm(l10nMem& crMemory); + ~convert_xrm(); + + void setId(char *yytext); + void setLang(char *yytext); + void setTag(char *yytext); + void startCollectData(char *yytext); + void stopCollectData(char *yytext); + + private: + std::string msKey; + bool mbIsTag; + bool mbIsLang; + std::string msTag; + + void execute() override; }; #endif diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx index 94e76c9c8d0f..3cfd9f051746 100644 --- a/l10ntools/inc/gL10nMem.hxx +++ b/l10ntools/inc/gL10nMem.hxx @@ -24,116 +24,110 @@ class l10nMem_file_entry; class l10nMem_lang_list_entry; class l10nMem { -public: - l10nMem(); - ~l10nMem(); + public: + l10nMem(); + ~l10nMem(); - typedef enum - { - ENTRY_DELETED, - ENTRY_ADDED, - ENTRY_CHANGED, - ENTRY_NORMAL - } ENTRY_STATE; + typedef enum { + ENTRY_DELETED, + ENTRY_ADDED, + ENTRY_CHANGED, + ENTRY_NORMAL + } ENTRY_STATE; - static int showError(const std::string& sText, int iLineNo = 0); - static void showWarning(const std::string& sText, int iLineNo = 0); - static void showDebug(const std::string& sText, int iLineNo = 0); - static void showVerbose(const std::string& sText, int iLineNo = 0); - static void keyToUpper(std::string& sKey); + static int showError(const std::string& sText, int iLineNo = 0); + static void showWarning(const std::string& sText, int iLineNo = 0); + static void showDebug(const std::string& sText, int iLineNo = 0); + static void showVerbose(const std::string& sText, int iLineNo = 0); + static void keyToUpper(std::string& sKey); - void setModuleName(const std::string& sModuleName); - const std::string& getModuleName(void); - void setLanguage(const std::string& sLanguage, - bool bCreate); - void setConvert(bool bConvert, - bool bStrict); - void setVerbose(const bool doVerbose); - void setDebug(const bool doDebug); + void setModuleName(const std::string& sModuleName); + const std::string& getModuleName(void); + void setLanguage(const std::string& sLanguage, + bool bCreate); + void setConvert(bool bConvert, + bool bStrict); + void setVerbose(const bool doVerbose); + void setDebug(const bool doDebug); + void loadEntryKey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sOrgText, + const std::string& sText, + bool bIsFuzzy); + void setSourceKey(int iLineNo, + const std::string& sFilename, + const std::string& sKey, + const std::string& sText, + bool bMustExist); - void loadEntryKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sOrgText, - const std::string& sText, - bool bIsFuzzy); + void saveTemplates(const std::string& sTargetDir, + bool bKid, + bool bForce); + void saveLanguages(l10nMem& cMem, + const std::string& sTargetDir, + bool bForce); + void dumpMem(const std::string& sTargetDir); + int prepareMerge(); + bool getMergeLang(std::string& sLang, + std::string& sText); + void showNOconvert(); + bool isError(); + void convertToInetString(std::string& sText); + void convertFromInetString(std::string& sText); - void setSourceKey(int iLineNo, - const std::string& sFilename, - const std::string& sKey, - const std::string& sText, - bool bMustExist); + private: + bool mbVerbose; + bool mbDebug; + bool mbInError; + std::string msModuleName; + int miCurFileInx; + int miCurLangInx; + int miCurENUSinx; + bool mbNeedWrite; + bool mbConvertMode; + bool mbStrictMode; + std::vector<l10nMem_enus_entry> mcENUSlist; + std::vector<l10nMem_file_entry> mcFileList; + std::vector<l10nMem_lang_list_entry> mcLangList; - void saveTemplates(const std::string& sTargetDir, - bool bKid, - bool bForce); - void saveLanguages(l10nMem& cMem, - const std::string& sTargetDir, - bool bForce); - void dumpMem(const std::string& sTargetDir); - - int prepareMerge(); - bool getMergeLang(std::string& sLang, - std::string& sText); - void showNOconvert(); - bool isError(); - - void convertToInetString(std::string& sText); - void convertFromInetString(std::string& sText); - -private: - bool mbVerbose; - bool mbDebug; - bool mbInError; - std::string msModuleName; - int miCurFileInx; - int miCurLangInx; - int miCurENUSinx; - bool mbNeedWrite; - bool mbConvertMode; - bool mbStrictMode; - std::vector<l10nMem_enus_entry> mcENUSlist; - std::vector<l10nMem_file_entry> mcFileList; - std::vector<l10nMem_lang_list_entry> mcLangList; - - void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText); - bool needWrite(const std::string sFileName, bool bForce); - bool convFilterWarning(const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId); - void convEntryKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - const std::string& sMsgStr, - bool bIsFuzzy); - void saveTemplates(l10nMem& cMem, - const std::string& sTargetDir, - bool bKid, - bool bForce); - - void loadENUSkey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId); - void loadLangKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - const std::string& sMsgStr, - bool bFuzzy); - void reorganize(bool bConvert); - bool locateKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - bool bThrow); - void addKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - l10nMem::ENTRY_STATE eStat); - bool findFileName(const std::string& sSourceFile); + void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText); + bool needWrite(const std::string sFileName, bool bForce); + bool convFilterWarning(const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId); + void convEntryKey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + const std::string& sMsgStr, + bool bIsFuzzy); + void saveTemplates(l10nMem& cMem, + const std::string& sTargetDir, + bool bKid, + bool bForce); + void loadENUSkey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId); + void loadLangKey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + const std::string& sMsgStr, + bool bFuzzy); + void reorganize(bool bConvert); + bool locateKey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + bool bThrow); + void addKey(int iLineNo, + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + l10nMem::ENTRY_STATE eStat); + bool findFileName(const std::string& sSourceFile); }; #endif diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx index d9bb973f73c6..74f05ba2e068 100644 --- a/l10ntools/source/gConv.cxx +++ b/l10ntools/source/gConv.cxx @@ -45,12 +45,13 @@ #endif + convert_gen * convert_gen::mcImpl = NULL; -/********************** I M P L E M E N T A T I O N **********************/ -convert_gen::convert_gen(l10nMem& cMemory) - : mcMemory(cMemory) + +convert_gen::convert_gen(l10nMem& cMemory) + : mcMemory(cMemory) { mcImpl = this; } @@ -60,68 +61,66 @@ convert_gen::~convert_gen() convert_gen& convert_gen::createInstance(l10nMem& cMemory, - const std::string& sSourceDir, - const std::string& sTargetDir, - const std::string& sSourceFile) + const std::string& sSourceDir, + const std::string& sTargetDir, + const std::string& sSourceFile) { - // did the user give a .xxx with the source file ? - int nInx = sSourceFile.rfind("."); - if (nInx == (int)std::string::npos) - throw l10nMem::showError("source file: "+sSourceFile+" missing extension"); - - // find correct conversion class and create correct object - std::string sExtension = sSourceFile.substr(nInx+1); - convert_gen *x; - if (sExtension == "hrc") x = new convert_src(cMemory); - else if (sExtension == "src") x = new convert_src(cMemory); - else if (sExtension == "po") x = new convert_po(cMemory); - else if (sExtension == "pot") x = new convert_po(cMemory); - else if (sExtension == "tree") x = new convert_tree(cMemory); - else if (sExtension == "ulf") x = new convert_ulf(cMemory); - else if (sExtension == "xcu") x = new convert_xcu(cMemory); - else if (sExtension == "xhp") x = new convert_xhp(cMemory); - else if (sExtension == "xrm") x = new convert_xrm(cMemory); - else if (sExtension == "properties") x = new convert_prop(cMemory); - else throw l10nMem::showError("unknown extension on source file: "+sSourceFile); - - // and set environment - x->msSourceFile = sSourceFile; - x->msTargetPath = sTargetDir; - x->msSourcePath = sSourceDir + sSourceFile; - return *x; + // did the user give a .xxx with the source file ? + int nInx = sSourceFile.rfind("."); + if (nInx == (int)std::string::npos) + throw l10nMem::showError("source file: "+sSourceFile+" missing extension"); + + // find correct conversion class and create correct object + std::string sExtension = sSourceFile.substr(nInx+1); + convert_gen *x; + if (sExtension == "hrc") x = new convert_src(cMemory); + else if (sExtension == "src") x = new convert_src(cMemory); + else if (sExtension == "po") x = new convert_po(cMemory); + else if (sExtension == "pot") x = new convert_po(cMemory); + else if (sExtension == "tree") x = new convert_tree(cMemory); + else if (sExtension == "ulf") x = new convert_ulf(cMemory); + else if (sExtension == "xcu") x = new convert_xcu(cMemory); + else if (sExtension == "xhp") x = new convert_xhp(cMemory); + else if (sExtension == "xrm") x = new convert_xrm(cMemory); + else if (sExtension == "properties") x = new convert_prop(cMemory); + else throw l10nMem::showError("unknown extension on source file: "+sSourceFile); + + // and set environment + x->msSourceFile = sSourceFile; + x->msTargetPath = sTargetDir; + x->msSourcePath = sSourceDir + sSourceFile; + return *x; } -/********************** I M P L E M E N T A T I O N **********************/ bool convert_gen::execute(const bool bMerge, const bool bKid) { - mbMergeMode = bMerge; + mbMergeMode = bMerge; - if (bKid) - throw l10nMem::showError("not implemented"); + if (bKid) + throw l10nMem::showError("not implemented"); - // and load file - if (!prepareFile()) - return false; + // and load file + if (!prepareFile()) + return false; - // and execute conversion - execute(); + // and execute conversion + execute(); - return true; + return true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_gen::startSave(const std::string& sLanguage, const std::string& sFile) { - std::string x; + std::string x; - x = sLanguage; - x = sFile; - throw l10nMem::showError("startSave called with non .po file"); + x = sLanguage; + x = sFile; + throw l10nMem::showError("startSave called with non .po file"); } @@ -132,189 +131,166 @@ void convert_gen::save(const std::string& sFileName, const std::string& sText, bool bFuzzy) { - std::string x; + std::string x; - if (bFuzzy) - x = sFileName + sKey + sENUStext + sText; - throw l10nMem::showError("save called with non .po file"); + if (bFuzzy) + x = sFileName + sKey + sENUStext + sText; + throw l10nMem::showError("save called with non .po file"); } void convert_gen::endSave() { - throw l10nMem::showError("endSave called with non .po file"); + throw l10nMem::showError("endSave called with non .po file"); } -/********************** I M P L E M E N T A T I O N **********************/ bool convert_gen::checkAccess(std::string& sFile) { - return (OS_ACCESS(sFile.c_str(), 0) == 0); + return (OS_ACCESS(sFile.c_str(), 0) == 0); } -/********************** I M P L E M E N T A T I O N **********************/ bool convert_gen::createDir(std::string& sDir, std::string& sFile) { - std::string sNewDir(sDir); - int newPos, oldPos; - + std::string sNewDir(sDir); + int newPos, oldPos; - for (oldPos = 0;; oldPos = newPos +1) - { - newPos = sFile.find_first_of("/\\", oldPos); - if (newPos == (int)std::string::npos) - break; + for (oldPos = 0;; oldPos = newPos +1) { + newPos = sFile.find_first_of("/\\", oldPos); + if (newPos == (int)std::string::npos) + break; - sNewDir += sFile.substr(oldPos, newPos-oldPos) + "/"; + sNewDir += sFile.substr(oldPos, newPos-oldPos) + "/"; - if (!checkAccess(sNewDir)) - { - OS_MKDIR(sNewDir.c_str()); + if (!checkAccess(sNewDir)) { + OS_MKDIR(sNewDir.c_str()); + } } - - } - - - return true; + return true; } -/********************** I M P L E M E N T A T I O N **********************/ bool convert_gen::prepareFile() { - std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary); + std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary); - if (!inputFile.is_open()) - { - if (mbLoadMode) - { - l10nMem::showWarning("Cannot open file (" + msSourcePath + ")"); - return false; + if (!inputFile.is_open()) { + if (mbLoadMode) { + l10nMem::showWarning("Cannot open file (" + msSourcePath + ")"); + return false; + } + else + throw l10nMem::showError("Cannot open file (" + msSourcePath + ") for reading"); } - else - throw l10nMem::showError("Cannot open file (" + msSourcePath + ") for reading"); - } - - // get length of file: - miSourceReadIndex = 0; - inputFile.seekg (0, std::ios::end); - msSourceBuffer.resize((unsigned int)inputFile.tellg()); - inputFile.seekg (0, std::ios::beg); - - // get size, prepare std::string and read whole file - inputFile.read(const_cast<char *>(msSourceBuffer.c_str()), msSourceBuffer.size()); - if ((unsigned int)inputFile.gcount() != msSourceBuffer.size()) - throw l10nMem::showError("cannot read whole file"); - inputFile.close(); - - if (mbMergeMode && !mbLoadMode) - { - // close previous file - if (mcOutputFile.is_open()) - mcOutputFile.close(); - - // open output file - mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary); - if (mcOutputFile.is_open()) - return true; - if (convert_gen::createDir(msTargetPath, msSourceFile)) - { - mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary); - if (mcOutputFile.is_open()) - return true; + // get length of file: + miSourceReadIndex = 0; + inputFile.seekg (0, std::ios::end); + msSourceBuffer.resize((unsigned int)inputFile.tellg()); + inputFile.seekg (0, std::ios::beg); + + // get size, prepare std::string and read whole file + inputFile.read(const_cast<char *>(msSourceBuffer.c_str()), msSourceBuffer.size()); + if ((unsigned int)inputFile.gcount() != msSourceBuffer.size()) + throw l10nMem::showError("cannot read whole file"); + inputFile.close(); + + if (mbMergeMode && !mbLoadMode) { + // close previous file + if (mcOutputFile.is_open()) + mcOutputFile.close(); + + // open output file + mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary); + if (mcOutputFile.is_open()) + return true; + + if (convert_gen::createDir(msTargetPath, msSourceFile)) { + mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary); + if (mcOutputFile.is_open()) + return true; + } + throw l10nMem::showError("Cannot open file (" + msTargetPath+msSourceFile + ") for writing"); } - throw l10nMem::showError("Cannot open file (" + msTargetPath+msSourceFile + ") for writing"); - } - - return true; + return true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_gen::lexRead(char *sBuf, int *nResult, int nMax_size) { - // did we hit eof - if (miSourceReadIndex == -1) - { - *nResult = 0; - return; - } - - // assume we can copy all that are left. - *nResult = msSourceBuffer.size() - miSourceReadIndex; - - // space enough for the whole line ? - if (*nResult <= nMax_size) - { -// msSourceBuffer.copy(sBuf, *nResult, miSourceReadIndex); - l10nMem::showDebug(sBuf); - miSourceReadIndex = -1; - } - else - { -// msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex); - *nResult = nMax_size; - miSourceReadIndex += nMax_size; - } + // did we hit eof + if (miSourceReadIndex == -1) { + *nResult = 0; + return; + } + + // assume we can copy all that are left. + *nResult = msSourceBuffer.size() - miSourceReadIndex; + + // space enough for the whole line ? + if (*nResult <= nMax_size) { + // msSourceBuffer.copy(sBuf, *nResult, miSourceReadIndex); + l10nMem::showDebug(sBuf); + miSourceReadIndex = -1; + } + else { + // msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex); + *nResult = nMax_size; + miSourceReadIndex += nMax_size; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_gen::writeSourceFile(const std::string& line) { - if (!line.size()) - return; + if (!line.size()) + return; - if (mcOutputFile.is_open()) - mcOutputFile.write(line.c_str(), line.size()); + if (mcOutputFile.is_open()) + mcOutputFile.write(line.c_str(), line.size()); } -/********************** I M P L E M E N T A T I O N **********************/ std::string& convert_gen::copySource(char const *yyText, bool bDoClear) { - int nL; + int nL; - if (!yyText) - { - msCopyText.clear(); - return msCopyText; - } - msCopyText = yyText; - - // write text for merge - if (mbMergeMode) - writeSourceFile(msCopyText); - - if (bDoClear) - msCollector.clear(); - else - msCollector += msCopyText; - - // remove any CR - for (nL = 0; nL < (int)msCopyText.size(); ++nL) - { - if (msCopyText[nL] == '\r') - { - msCopyText.erase(nL, 1); - --nL; - continue; + if (!yyText) { + msCopyText.clear(); + return msCopyText; } - if (msCopyText[nL] == '\n') - ++miLineNo; - } + msCopyText = yyText; - return msCopyText; + // write text for merge + if (mbMergeMode) + writeSourceFile(msCopyText); + + if (bDoClear) + msCollector.clear(); + else + msCollector += msCopyText; + + // remove any CR + for (nL = 0; nL < (int)msCopyText.size(); ++nL) { + if (msCopyText[nL] == '\r') { + msCopyText.erase(nL, 1); + --nL; + continue; + } + if (msCopyText[nL] == '\n') + ++miLineNo; + } + + return msCopyText; } diff --git a/l10ntools/source/gConvDB.cxx b/l10ntools/source/gConvDB.cxx index c0931eb87a89..80940ad14a57 100644 --- a/l10ntools/source/gConvDB.cxx +++ b/l10ntools/source/gConvDB.cxx @@ -29,63 +29,58 @@ convert_db::~convert_db() {} -/********************** I M P L E M E N T A T I O N **********************/ void convert_db::execute() { - std::string newKey; - int i; + std::string newKey; + int i; - msSourceBuffer += '\n'; - miSize = msSourceBuffer.size() -1; - miLineNo = 0; + msSourceBuffer += '\n'; + miSize = msSourceBuffer.size() -1; + miLineNo = 0; - while (collectLine()) - { - newKey = msFields[4]; - if (msFields[5].size()) - newKey += "." + msFields[5]; - if (msFields[3].size()) - newKey += "." + msFields[3]; + while (collectLine()) { + newKey = msFields[4]; + if (msFields[5].size()) + newKey += "." + msFields[5]; + if (msFields[3].size()) + newKey += "." + msFields[3]; - for (; (i = msFields[1].find('\\')) != (int)std::string::npos;) - msFields[1][i] = '/'; + for (; (i = msFields[1].find('\\')) != (int)std::string::npos;) + msFields[1][i] = '/'; - // handle en-US or lang - mcMemory.loadEntryKey(miLineNo, msFields[1], newKey, msFields[10], msFields[10], false); - } + // handle en-US or lang + mcMemory.loadEntryKey(miLineNo, msFields[1], newKey, msFields[10], msFields[10], false); + } } -/********************** I M P L E M E N T A T I O N **********************/ + bool convert_db::collectLine() { - int i, iStart; - bool bLineEnd; - - ++miLineNo; - - for (i = 0; i < NUMFIELD; ++i) - msFields[i].clear(); - - if (miSourceReadIndex >= miSize) - return false; - - for (i = 0, bLineEnd = false, iStart = miSourceReadIndex; !bLineEnd; ++miSourceReadIndex) - { - if (msSourceBuffer[miSourceReadIndex] == '\r' || - msSourceBuffer[miSourceReadIndex] == '\n' || - miSourceReadIndex == miSize) - bLineEnd = true; - if (msSourceBuffer[miSourceReadIndex] == '\t' || bLineEnd) - { - if (i >= NUMFIELD) - { - l10nMem::showError("TOO many fields", miLineNo); - } - msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart); - iStart = miSourceReadIndex +1; - } - } - return true; + int i, iStart; + bool bLineEnd; + + ++miLineNo; + + for (i = 0; i < NUMFIELD; ++i) + msFields[i].clear(); + + if (miSourceReadIndex >= miSize) + return false; + + for (i = 0, bLineEnd = false, iStart = miSourceReadIndex; !bLineEnd; ++miSourceReadIndex) { + if (msSourceBuffer[miSourceReadIndex] == '\r' || + msSourceBuffer[miSourceReadIndex] == '\n' || + miSourceReadIndex == miSize) + bLineEnd = true; + if (msSourceBuffer[miSourceReadIndex] == '\t' || bLineEnd) { + if (i >= NUMFIELD) { + l10nMem::showError("TOO many fields", miLineNo); + } + msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart); + iStart = miSourceReadIndex +1; + } + } + return true; } diff --git a/l10ntools/source/gConvPo.cxx b/l10ntools/source/gConvPo.cxx index e540d70f28f5..e43d1bf0ddc1 100644 --- a/l10ntools/source/gConvPo.cxx +++ b/l10ntools/source/gConvPo.cxx @@ -27,220 +27,192 @@ -/***************************************************************************** - ********************** G C O N P O W R A P . C X X ********************** - ***************************************************************************** - * This includes the c code generated by flex - *****************************************************************************/ - - - -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_po::convert_po(l10nMem& crMemory) : convert_gen(crMemory), mbExpectId(false), mbExpectStr(false), mbFuzzy(false) { - // Po files are handled special - mbLoadMode = true; + // Po files are handled special + mbLoadMode = true; } -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_po::~convert_po() { } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace PoWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_po *)convert_gen_impl::mcImpl) -//#include "gConPo_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::startLook() { - std::string sFileName, sNewKey; - int i; + std::string sFileName, sNewKey; + int i; - if (!msKey.size() || !msId.size()) - return; + if (!msKey.size() || !msId.size()) + return; - // split key into filename and real key - i = msKey.find("#"); - sFileName = msKey.substr(0, i); - sNewKey = msKey.substr(i+1); + // split key into filename and real key + i = msKey.find("#"); + sFileName = msKey.substr(0, i); + sNewKey = msKey.substr(i+1); - // load in db - if (msId.size()) - mcMemory.loadEntryKey(miLineNo, sFileName, sNewKey, msId, msStr, mbFuzzy); + // load in db + if (msId.size()) + mcMemory.loadEntryKey(miLineNo, sFileName, sNewKey, msId, msStr, mbFuzzy); - // and prepare for new entry - msKey.clear(); - msId.clear(); - msStr.clear(); + // and prepare for new entry + msKey.clear(); + msId.clear(); + msStr.clear(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::setValue(char *syyText, int iLineCnt) { - if (mbExpectId) - msId = syyText; - if (mbExpectStr) - msStr = syyText; - mbExpectId = - mbExpectStr = false; - miLineNo += iLineCnt; + if (mbExpectId) + msId = syyText; + if (mbExpectStr) + msStr = syyText; + mbExpectId = + mbExpectStr = false; + miLineNo += iLineCnt; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::setFuzzy() { - mbFuzzy = true; + mbFuzzy = true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::setKey(char *syyText) { - int i; + int i; - // Activate "look for msg" mode. - startLook(); + // Activate "look for msg" mode. + startLook(); - // skip "#:" and any blanks - for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ; - msKey = syyText; + // skip "#:" and any blanks + for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ; + msKey = syyText; - // remove trailing blanks - for (i = msKey.size() -1; msKey[i] == '\r' || msKey[i] == ' ' || msKey[i] == '\t'; --i) ; - msKey.erase(i+1); + // remove trailing blanks + for (i = msKey.size() -1; msKey[i] == '\r' || msKey[i] == ' ' || msKey[i] == '\t'; --i) ; + msKey.erase(i+1); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::setMsgId() { - mbExpectId = true; + mbExpectId = true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::setMsgStr() { - mbExpectStr = true; + mbExpectStr = true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::handleNL() { - ++miLineNo; + ++miLineNo; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::execute() { - if (mbMergeMode) - throw l10nMem::showError("Merge not implemented"); + if (mbMergeMode) + throw l10nMem::showError("Merge not implemented"); -// PoWrap::yylex(); - startLook(); + // PoWrap::yylex(); + startLook(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::startSave(const std::string& sLanguage, const std::string& sFile) { - std::string sFilePath = msTargetPath + sLanguage + sFile; - outBuffer.open(sFilePath.c_str(), std::ios::out); - - if (!outBuffer.is_open()) - throw l10nMem::showError("Cannot open " + sFilePath + " for writing"); - - l10nMem::showDebug("writing file (" + sFilePath + ")"); - - std::ostream outFile(&outBuffer); - - // Set license header - outFile << "#*************************************************************" << std::endl - << "#*" << std::endl - << "#* Licensed to the Apache Software Foundation (ASF) under one" << std::endl - << "#* or more contributor license agreements. See the NOTICE file" << std::endl - << "#* distributed with this work for additional information" << std::endl - << "#* regarding copyright ownership. The ASF licenses this file" << std::endl - << "#* to you under the Apache License, Version 2.0 (the" << std::endl - << "#* \"License\"); you may not use this file except in compliance" << std::endl - << "#* with the License. You may obtain a copy of the License at" << std::endl - << "#*" << std::endl - << "#* http://www.apache.org/licenses/LICENSE-2.0" << std::endl - << "#*" << std::endl - << "#* Unless required by applicable law or agreed to in writing," << std::endl - << "#* software distributed under the License is distributed on an" << std::endl - << "#* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY" << std::endl - << "#* KIND, either express or implied. See the License for the" << std::endl - << "#* specific language governing permissions and limitations" << std::endl - << "#* under the License." << std::endl - << "#*" << std::endl - << "#************************************************************" << std::endl - << "msgid \"\"" << std::endl - << "msgstr \"\"" << std::endl - << "\"Project-Id-Version: AOO-4-xx\\n\"" << std::endl - << "\"POT-Creation-Date: \\n\"" << std::endl - << "\"PO-Revision-Date: \\n\"" << std::endl - << "\"Last-Translator: genLang (build process)\\n\"" << std::endl - << "\"Language-Team: \\n\"" << std::endl - << "\"MIME-Version: 1.0\\n\"" << std::endl - << "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl - << "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl - << "\"X-Generator: genLang\\n\"" << std::endl - << std::endl; + std::string sFilePath = msTargetPath + sLanguage + sFile; + outBuffer.open(sFilePath.c_str(), std::ios::out); + + if (!outBuffer.is_open()) + throw l10nMem::showError("Cannot open " + sFilePath + " for writing"); + + l10nMem::showDebug("writing file (" + sFilePath + ")"); + + std::ostream outFile(&outBuffer); + + // Set license header + outFile << "#*************************************************************" << std::endl + << "#*" << std::endl + << "#* This file is part of the LibreOffice project. " << std::endl + << "#*" << std::endl + << "#* This Source Code Form is subject to the terms of the " << std::endl + << "#* Mozilla Public License, v. 2.0. If a copy of the MPL was " << std::endl + << "#* not distributed with this file, You can obtain one at " << std::endl + << "#* http://mozilla.org/MPL/2.0/." << std::endl + << "#*" << std::endl + << "#* This file incorporates work covered by the following " << std::endl + << "#* license notice :" << std::endl + << "#*" << std::endl + << "#* Licensed to the Apache Software Foundation (ASF) under one " << std::endl + << "#* or more contributor license agreements. See the NOTICE file" << std::endl + << "#* distributed with this work for additional information " << std::endl + << "#* regarding copyright ownership. The ASF licenses this file " << std::endl + << "#* to you under the Apache License, Version 2.0 " << std::endl + << "#* (the \"License\"); you may not use this file except in " << std::endl + << "#* compliance with the License.You may obtain a copy of the " << std::endl + << "#* License at http ://www.apache.org/licenses/LICENSE-2.0 . " << std::endl + << "#*" << std::endl + << "#************************************************************" << std::endl + << "msgid \"\"" << std::endl + << "msgstr \"\"" << std::endl + << "\"Project-Id-Version: AOO-4-xx\\n\"" << std::endl + << "\"POT-Creation-Date: \\n\"" << std::endl + << "\"PO-Revision-Date: \\n\"" << std::endl + << "\"Last-Translator: genLang (build process)\\n\"" << std::endl + << "\"Language-Team: \\n\"" << std::endl + << "\"MIME-Version: 1.0\\n\"" << std::endl + << "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl + << "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl + << "\"X-Generator: genLang\\n\"" << std::endl + << std::endl; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_po::save(const std::string& sFileName, const std::string& sKey, const std::string& sENUStext, const std::string& sText, bool bFuzzy) { - std::ostream outFile(&outBuffer); + std::ostream outFile(&outBuffer); - outFile << std::endl << "#: " << sFileName << "#" << sKey << std::endl; - if (bFuzzy) - outFile << "#, fuzzy" << std::endl; - outFile << "msgid \"" << sENUStext << "\"" << std::endl - << "msgstr \"" << sText << "\"" << std::endl; + outFile << std::endl << "#: " << sFileName << "#" << sKey << std::endl; + if (bFuzzy) + outFile << "#, fuzzy" << std::endl; + outFile << "msgid \"" << sENUStext << "\"" << std::endl + << "msgstr \"" << sText << "\"" << std::endl; } -/********************** I M P L E M E N T A T I O N **********************/ + void convert_po::endSave() { - outBuffer.close(); + outBuffer.close(); } diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx index e75173778942..c1f6bfa3428f 100644 --- a/l10ntools/source/gConvProp.cxx +++ b/l10ntools/source/gConvProp.cxx @@ -26,20 +26,18 @@ convert_prop::convert_prop(l10nMem& crMemory) : convert_gen(crMemory) { -// throw l10nMem::showError(std::string("convert_prop not implemented")); + // throw l10nMem::showError(std::string("convert_prop not implemented")); } -/********************** I M P L E M E N T A T I O N **********************/ convert_prop::~convert_prop() { } -/********************** I M P L E M E N T A T I O N **********************/ void convert_prop::execute() { - throw l10nMem::showError(std::string("convert_prop::execute not implemented")); + throw l10nMem::showError(std::string("convert_prop::execute not implemented")); } diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx index 08fe48556e26..6b49cc53dedb 100644 --- a/l10ntools/source/gConvSrc.cxx +++ b/l10ntools/source/gConvSrc.cxx @@ -44,304 +44,264 @@ convert_src::~convert_src() -/********************** I M P L E M E N T A T I O N **********************/ -//namespace SrcWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_src *)convert_gen_impl::mcImpl) -//#include "gConSrc_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::execute() { -// SrcWrap::yylex(); + // SrcWrap::yylex(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setValue(char *syyText, char *sbuildValue) { - copySource(syyText); - - if (mbInList && !mbInListItem) - { - setListItem("", true); - setListItem("", false); - } - msValue = sbuildValue; - mbValuePresent = true; - mbExpectValue = false; + copySource(syyText); + + if (mbInList && !mbInListItem) { + setListItem("", true); + setListItem("", false); + } + msValue = sbuildValue; + mbValuePresent = true; + mbExpectValue = false; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setLang(char *syyText, bool bEnUs) { - std::string useText = copySource(syyText) + " is no en-US language"; + std::string useText = copySource(syyText) + " is no en-US language"; - mbEnUs = bEnUs; - if (!bEnUs && mbExpectValue) - l10nMem::showError(useText); + mbEnUs = bEnUs; + if (!bEnUs && mbExpectValue) + l10nMem::showError(useText); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setId(char *syyText, bool bId) { - copySource(syyText); - if (bId || !mcStack.back().size()) - mbExpectName = mbAutoPush = true; + copySource(syyText); + if (bId || !mcStack.back().size()) + mbExpectName = mbAutoPush = true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setText(char *syyText) { - msTextName = copySource(syyText); - mbExpectValue = true; - mbEnUs = false; - trim(msTextName); + msTextName = copySource(syyText); + mbExpectValue = true; + mbEnUs = false; + trim(msTextName); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setName(char *syyText) { - std::string useText = copySource(syyText); - - trim(useText); - if (mbExpectName) - { - mbExpectName = false; - if (!mbAutoPush) - msName = useText; - else - { - mbAutoPush = false; - if (mcStack.size()) - mcStack.pop_back(); - mcStack.push_back(useText); + std::string useText = copySource(syyText); + + trim(useText); + if (mbExpectName) { + mbExpectName = false; + if (!mbAutoPush) + msName = useText; + else { + mbAutoPush = false; + if (mcStack.size()) + mcStack.pop_back(); + mcStack.push_back(useText); + } } - } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setCmd(char *syyText) { - msCmd = copySource(syyText); - mbExpectName = true; - mbInList = false; - trim(msCmd); + msCmd = copySource(syyText); + mbExpectName = true; + mbInList = false; + trim(msCmd); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setMacro(char *syyText) { - msCmd = copySource(syyText); - mbExpectName = - mbExpectMacro = - mbAutoPush = true; - miMacroLevel = mcStack.size(); - mcStack.push_back(""); - trim(msCmd); + msCmd = copySource(syyText); + mbExpectName = + mbExpectMacro = + mbAutoPush = true; + miMacroLevel = mcStack.size(); + mcStack.push_back(""); + trim(msCmd); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setList(char *syyText) { - msCmd = copySource(syyText); - miListCount = 0; - mbInList = true; - trim(msCmd); + msCmd = copySource(syyText); + miListCount = 0; + mbInList = true; + trim(msCmd); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setNL(char *syyText, bool bMacro) { - int nL; - std::string sKey; - - copySource(syyText); - - if (msTextName.size() && mbValuePresent && mbEnUs) - { - // locate key and extract it - buildKey(sKey); - - for (nL = -1;;) - { - nL = msValue.find("\\\"", nL+1); - if (nL == (int)std::string::npos) - break; - msValue.erase(nL,1); - } - for (nL = -1;;) - { - nL = msValue.find("\\\\", nL+1); - if (nL == (int)std::string::npos) - break; - msValue.erase(nL,1); + int nL; + std::string sKey; + + copySource(syyText); + + if (msTextName.size() && mbValuePresent && mbEnUs) { + // locate key and extract it + buildKey(sKey); + + for (nL = -1;;) { + nL = msValue.find("\\\"", nL+1); + if (nL == (int)std::string::npos) + break; + msValue.erase(nL,1); + } + for (nL = -1;;) { + nL = msValue.find("\\\\", nL+1); + if (nL == (int)std::string::npos) + break; + msValue.erase(nL,1); + } + + sKey += "." + msCmd + "." + msTextName; + if (msValue.size() && msValue != "-") { + mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, msValue, mbMergeMode); + if (mbMergeMode) + insertLanguagePart(sKey, msTextName); + } } - sKey += "." + msCmd + "." + msTextName; - if (msValue.size() && msValue != "-") - { - mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, msValue, mbMergeMode); - if (mbMergeMode) - insertLanguagePart(sKey, msTextName); + if (!bMacro && mbExpectMacro) { + while ((int)mcStack.size() > miMacroLevel) + mcStack.pop_back(); + mbEnUs = + mbExpectMacro = false; } - } - - if (!bMacro && mbExpectMacro) - { - while ((int)mcStack.size() > miMacroLevel) - mcStack.pop_back(); - mbEnUs = - mbExpectMacro = false; - } - - mbValuePresent = - mbExpectName = - mbAutoPush = false; - msValue.clear(); - msTextName.clear(); + + mbValuePresent = + mbExpectName = + mbAutoPush = false; + msValue.clear(); + msTextName.clear(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::startBlock(char *syyText) { - copySource(syyText); + copySource(syyText); - mcStack.push_back(msName); - msName.clear(); + mcStack.push_back(msName); + msName.clear(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::stopBlock(char *syyText) { - copySource(syyText); + copySource(syyText); - // check for correct node/prop relations - if (mcStack.size()) - mcStack.pop_back(); + // check for correct node/prop relations + if (mcStack.size()) + mcStack.pop_back(); - mbInList = - mbEnUs = false; + mbInList = + mbEnUs = false; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::setListItem(char const *syyText, bool bIsStart) { - copySource(syyText); - - if (bIsStart) - { - if (!miListCount) - { - mcStack.pop_back(); - msName = "dummy"; - mcStack.push_back(msName); + copySource(syyText); + + if (bIsStart) { + if (!miListCount) { + mcStack.pop_back(); + msName = "dummy"; + mcStack.push_back(msName); + } + msTextName = "item"; + mbExpectValue = + mbExpectName = + mbInListItem = true; + msName.clear(); } - msTextName = "item"; - mbExpectValue = - mbExpectName = - mbInListItem = true; - msName.clear(); - } - else - { - if (mbInListItem) + else { - std::stringstream ssBuf; - std::string myKey; - - - ++miListCount; - mcStack.pop_back(); - if (mbExpectName) - { - ssBuf << miListCount; - msName = "item" + ssBuf.str(); - } - mcStack.push_back(msName); - mbInListItem = - mbExpectName = false; - - // check key or add seq. - buildKey(myKey); + if (mbInListItem) { + std::stringstream ssBuf; + std::string myKey; + + ++miListCount; + mcStack.pop_back(); + if (mbExpectName) { + ssBuf << miListCount; + msName = "item" + ssBuf.str(); + } + mcStack.push_back(msName); + mbInListItem = + mbExpectName = false; + + // check key or add seq. + buildKey(myKey); + } } - } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::trim(std::string& sText) { - int nL; + int nL; - while (sText[0] == ' ' || sText[0] == '\t') - sText.erase(0,1); - for (nL = sText.size(); sText[nL-1] == ' ' || sText[nL-1] == '\t'; --nL); - if (nL != (int)sText.size()) - sText.erase(nL); + while (sText[0] == ' ' || sText[0] == '\t') + sText.erase(0,1); + for (nL = sText.size(); sText[nL-1] == ' ' || sText[nL-1] == '\t'; --nL); + if (nL != (int)sText.size()) + sText.erase(nL); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::buildKey(std::string& sKey) { - int nL; + int nL; - sKey.clear(); - for (nL = 0; nL < (int)mcStack.size(); ++nL) - if (mcStack[nL].size()) - sKey += (sKey.size() ? "." : "") + mcStack[nL]; + sKey.clear(); + for (nL = 0; nL < (int)mcStack.size(); ++nL) + if (mcStack[nL].size()) + sKey += (sKey.size() ? "." : "") + mcStack[nL]; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_src::insertLanguagePart(std::string& sKey, std::string& sTextType) { - std::string sLang, sText, sTagText; + std::string sLang, sText, sTagText; - // just to please compiler - sKey = sKey; + // just to please compiler + sKey = sKey; - // prepare to read all languages - mcMemory.prepareMerge(); - for (; mcMemory.getMergeLang(sLang, sText);) - { - // Prepare tag start and end - sTagText = sTextType + "[ " + sLang + " ] = \"" + sText + "\" ;" + - (mbExpectMacro ? "\\" : "") + "\n"; - writeSourceFile(sTagText); - } + // prepare to read all languages + mcMemory.prepareMerge(); + for (; mcMemory.getMergeLang(sLang, sText);) { + // Prepare tag start and end + sTagText = sTextType + "[ " + sLang + " ] = \"" + sText + "\" ;" + + (mbExpectMacro ? "\\" : "") + "\n"; + writeSourceFile(sTagText); + } } diff --git a/l10ntools/source/gConvTree.cxx b/l10ntools/source/gConvTree.cxx index cac25a44ecfc..a452240ff94d 100644 --- a/l10ntools/source/gConvTree.cxx +++ b/l10ntools/source/gConvTree.cxx @@ -31,197 +31,167 @@ convert_tree::convert_tree(l10nMem& crMemory) miCntLanguages(0) { - // tree files are written through a local routine - mbLoadMode = true; + // tree files are written through a local routine + mbLoadMode = true; } -/********************** I M P L E M E N T A T I O N **********************/ convert_tree::~convert_tree() { - if (mcOutputFiles) - { - for (int i = 0; i < miCntLanguages; ++i) - mcOutputFiles[i].close(); - delete[] mcOutputFiles; - } + if (mcOutputFiles) { + for (int i = 0; i < miCntLanguages; ++i) + mcOutputFiles[i].close(); + delete[] mcOutputFiles; + } } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace TreeWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_tree *)convert_gen_impl::mcImpl) -//#include "gConTree_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_tree::execute() { - std::string sLang; - std::string sFile, sFile2; - - if (mbMergeMode) - throw l10nMem::showError("Merge not implemented"); - - // prepare list with languages - if (mbMergeMode) - { - miCntLanguages = mcMemory.prepareMerge(); - mcOutputFiles = new std::ofstream[miCntLanguages]; - - for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i) - { - sFile2 = sLang + "/" + msSourceFile; - sFile = msTargetPath + sFile2; - mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); - if (!mcOutputFiles[i].is_open()) - { - if (!convert_gen::createDir(msTargetPath, sFile2)) - throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing"); - - mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); - if (!mcOutputFiles[i].is_open()) - throw l10nMem::showError("Cannot open file (" + sFile + ") for writing"); - } + std::string sLang; + std::string sFile, sFile2; + + if (mbMergeMode) + throw l10nMem::showError("Merge not implemented"); + + // prepare list with languages + if (mbMergeMode) { + miCntLanguages = mcMemory.prepareMerge(); + mcOutputFiles = new std::ofstream[miCntLanguages]; + + for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i) { + sFile2 = sLang + "/" + msSourceFile; + sFile = msTargetPath + sFile2; + mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); + if (!mcOutputFiles[i].is_open()) { + if (!convert_gen::createDir(msTargetPath, sFile2)) + throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing"); + + mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); + if (!mcOutputFiles[i].is_open()) + throw l10nMem::showError("Cannot open file (" + sFile + ") for writing"); + } + } } - } - // run analyzer -// TreeWrap::yylex(); + // run analyzer + // TreeWrap::yylex(); - // dump last line - copySourceSpecial(nullptr,3); + // dump last line + copySourceSpecial(nullptr,3); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_tree::setString(char *yytext) { - switch (meStateVal) - { - case STATE_VAL_NONE: - copySourceSpecial(yytext, 0); - break; - - case STATE_VAL_APPL: - msAppl = copySourceSpecial(yytext, 0); - break; - - case STATE_VAL_ID: - msId = copySourceSpecial(yytext, 0); - msId.erase(msId.size()-1); - break; - - case STATE_VAL_TITLE: - std::string sText = copySourceSpecial(yytext, 1); - sText.erase(sText.size()-1); - mcMemory.setSourceKey(miLineNo, msSourceFile, msId, sText, mbMergeMode); - break; - } - meStateVal = STATE_VAL_NONE; + switch (meStateVal) { + case STATE_VAL_NONE: + copySourceSpecial(yytext, 0); + break; + + case STATE_VAL_APPL: + msAppl = copySourceSpecial(yytext, 0); + break; + + case STATE_VAL_ID: + msId = copySourceSpecial(yytext, 0); + msId.erase(msId.size()-1); + break; + + case STATE_VAL_TITLE: + std::string sText = copySourceSpecial(yytext, 1); + sText.erase(sText.size()-1); + mcMemory.setSourceKey(miLineNo, msSourceFile, msId, sText, mbMergeMode); + break; + } + meStateVal = STATE_VAL_NONE; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_tree::setState(char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL) { - copySourceSpecial(yytext, 0); - msCollector.clear(); - meStateTag = eNewStateTag; - meStateVal = eNewStateVAL; + copySourceSpecial(yytext, 0); + msCollector.clear(); + meStateTag = eNewStateTag; + meStateVal = eNewStateVAL; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_tree::setValue(char *yytext) { - mcMemory.setSourceKey(miLineNo, msSourceFile, msId, msCollector, mbMergeMode); - copySourceSpecial(yytext, 2); + mcMemory.setSourceKey(miLineNo, msSourceFile, msId, msCollector, mbMergeMode); + copySourceSpecial(yytext, 2); - meStateTag = STATE_TAG_NONE; - meStateVal = STATE_VAL_NONE; + meStateTag = STATE_TAG_NONE; + meStateVal = STATE_VAL_NONE; } -/********************** I M P L E M E N T A T I O N **********************/ std::string& convert_tree::copySourceSpecial(char *yytext, int iType) { - std::string& sText = copySource(yytext, false); - std::string sLang, sTemp; - int i; - - // Handling depends on iType - switch (iType) - { - case 0: // Used for tokens that are to be copied 1-1, - if (mbMergeMode) - { - msLine += yytext; - if (*yytext == '\n') - { - for (i = 0; i < miCntLanguages; ++i) - writeSourceFile(msLine, i); - msLine.clear(); - } - } - break; - - case 1: // Used for title token, are to replaced with languages - if (mbMergeMode) - { - mcMemory.prepareMerge(); - for (i = 0; i < miCntLanguages; ++i) - { - writeSourceFile(msLine, i); - mcMemory.getMergeLang(sLang, sTemp); - writeSourceFile(sTemp,i); - } - msLine.clear(); - } - break; - - case 2: // Used for token at end of value, language text are to be inserted and then token written - if (mbMergeMode) - { - mcMemory.prepareMerge(); - for (i = 0; i < miCntLanguages; ++i) - { - writeSourceFile(msLine, i); - mcMemory.getMergeLang(sLang, sTemp); - writeSourceFile(sTemp,i); - std::string sYY(yytext); - writeSourceFile(sYY, i); - } - msLine.clear(); - } - break; - - case 3: // Used for EOF - if (mbMergeMode) - { - for (i = 0; i < miCntLanguages; ++i) - writeSourceFile(msLine, i); - } - break; - } - return sText; + std::string& sText = copySource(yytext, false); + std::string sLang, sTemp; + int i; + + // Handling depends on iType + switch (iType) { + case 0: // Used for tokens that are to be copied 1-1, + if (mbMergeMode) { + msLine += yytext; + if (*yytext == '\n') { + for (i = 0; i < miCntLanguages; ++i) + writeSourceFile(msLine, i); + msLine.clear(); + } + } + break; + + case 1: // Used for title token, are to replaced with languages + if (mbMergeMode) { + mcMemory.prepareMerge(); + for (i = 0; i < miCntLanguages; ++i) { + writeSourceFile(msLine, i); + mcMemory.getMergeLang(sLang, sTemp); + writeSourceFile(sTemp,i); + } + msLine.clear(); + } + break; + + case 2: // Used for token at end of value, language text are to be inserted and then token written + if (mbMergeMode) { + mcMemory.prepareMerge(); + for (i = 0; i < miCntLanguages; ++i) { + writeSourceFile(msLine, i); + mcMemory.getMergeLang(sLang, sTemp); + writeSourceFile(sTemp,i); + std::string sYY(yytext); + writeSourceFile(sYY, i); + } + msLine.clear(); + } + break; + + case 3: // Used for EOF + if (mbMergeMode) { + for (i = 0; i < miCntLanguages; ++i) + writeSourceFile(msLine, i); + } + break; + } + return sText; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_tree::writeSourceFile(std::string& sText, int inx) { - if (sText.size() && mcOutputFiles[inx].is_open()) - mcOutputFiles[inx].write(sText.c_str(), sText.size()); + if (sText.size() && mcOutputFiles[inx].is_open()) + mcOutputFiles[inx].write(sText.c_str(), sText.size()); } diff --git a/l10ntools/source/gConvUlf.cxx b/l10ntools/source/gConvUlf.cxx index d8d5651011bc..2e13ee424372 100644 --- a/l10ntools/source/gConvUlf.cxx +++ b/l10ntools/source/gConvUlf.cxx @@ -29,68 +29,52 @@ convert_ulf::~convert_ulf() {} -/********************** I M P L E M E N T A T I O N **********************/ -//namespace UlfWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_ulf *)convert_gen_impl::mcImpl) -//#include "gConUlf_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_ulf::execute() { -// UlfWrap::yylex(); + // UlfWrap::yylex(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_ulf::setKey(char *syyText) { - std::string sText = copySource(syyText); + std::string sText = copySource(syyText); - // locate key (is any) - msKey = sText.substr(1,sText.size()-2); + // locate key (is any) + msKey = sText.substr(1,sText.size()-2); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_ulf::setText(char *syyText, bool bIsEnUs) { - std::string sText = copySource(syyText) + " is not en-US"; + std::string sText = copySource(syyText) + " is not en-US"; - if (!bIsEnUs) - l10nMem::showError(sText); + if (!bIsEnUs) + l10nMem::showError(sText); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_ulf::setValue(char *syyText) { - std::string sLang, sText = copySource(syyText); - int nL; - - sText.erase(0,1); - nL = sText.rfind("\""); - sText.erase(nL); - - mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode); - - if (mbMergeMode) - { - // prepare to read all languages - mcMemory.prepareMerge(); - for (; mcMemory.getMergeLang(sLang, sText);) - { - // Prepare tag - sText = "\n" + sLang + " = \"" + sText + "\""; - writeSourceFile(sText); + std::string sLang, sText = copySource(syyText); + int nL; + + sText.erase(0,1); + nL = sText.rfind("\""); + sText.erase(nL); + + mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode); + + if (mbMergeMode) { + // prepare to read all languages + mcMemory.prepareMerge(); + for (; mcMemory.getMergeLang(sLang, sText);) { + // Prepare tag + sText = "\n" + sLang + " = \"" + sText + "\""; + writeSourceFile(sText); + } } - } } diff --git a/l10ntools/source/gConvXcs.cxx b/l10ntools/source/gConvXcs.cxx index 45b41e287adc..5067fbfcd0a0 100644 --- a/l10ntools/source/gConvXcs.cxx +++ b/l10ntools/source/gConvXcs.cxx @@ -32,121 +32,102 @@ convert_xcs::convert_xcs(l10nMem& crMemory) -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_xcs::~convert_xcs() { } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace XcsWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_xcs *)convert_gen_impl::mcImpl) -//#include "gConXcs_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcs::execute() { - if (mbMergeMode) - throw l10nMem::showError("Merge not implemented"); + if (mbMergeMode) + throw l10nMem::showError("Merge not implemented"); - // currently no .xcs files generate en-US translation, so stop trying -// XcsWrap::yylex(); + // currently no .xcs files generate en-US translation, so stop trying + // XcsWrap::yylex(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcs::setKey(char *syyText) { - int nL; - std::string sHead, sText = copySource(syyText); - - // is it to be translated - if (sText.find("oor:localized=") == std::string::npos) - return; - - // locate key (is any) - nL = sText.find("oor:name=\""); - if (nL == (int)std::string::npos) - return; - sHead = sText.substr(nL+10); - nL = sHead.find("\""); - msKey = sHead.substr(0,nL); + int nL; + std::string sHead, sText = copySource(syyText); + + // is it to be translated + if (sText.find("oor:localized=") == std::string::npos) + return; + + // locate key (is any) + nL = sText.find("oor:name=\""); + if (nL == (int)std::string::npos) + return; + sHead = sText.substr(nL+10); + nL = sHead.find("\""); + msKey = sHead.substr(0,nL); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcs::unsetKey(char *syyText) { - copySource(syyText); + copySource(syyText); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcs::startCollectData(char *syyText) { - copySource(syyText); - if (!msKey.size()) - return; + copySource(syyText); + if (!msKey.size()) + return; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcs::stopCollectData(char *syyText) { - std::string sHead, sKey, sLang, sText, sCollectedText = copySource(syyText, false); - int nL; - - - // get type of tag - msCollector += sCollectedText; - nL = msCollector.find("<p"); - if (nL != (int)std::string::npos) - sHead = msCollector.substr(nL+1, 1); - else - { - nL = msCollector.find("<h"); - sHead = msCollector.substr(nL+1, 2); - } - - // locate key and extract it - nL = msCollector.find("id=") +4; - sKey = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); - nL = msCollector.find("xml:lang=\"") + 10; - sLang = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); - nL = msCollector.find(">") +1; - sText = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); - msCollector.clear(); - - if (mbMergeMode) - { -#if 0 - // get all languages (includes en-US) - std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey); - std::string sNewLine; - nL = cExtraLangauges.size(); - - for (int i = 0; i < nL; ++i) - { - sNewLine = "\n<" + sHead + " id=\"" + sKey + "\"" + " xml:lang=\"" + - cExtraLangauges[i]->msLanguage + "\">" + - cExtraLangauges[i]->msText + - "</" + sHead + ">"; - - writeSourceFile(sNewLine); + std::string sHead, sKey, sLang, sText, sCollectedText = copySource(syyText, false); + int nL; + + + // get type of tag + msCollector += sCollectedText; + nL = msCollector.find("<p"); + if (nL != (int)std::string::npos) + sHead = msCollector.substr(nL+1, 1); + else { + nL = msCollector.find("<h"); + sHead = msCollector.substr(nL+1, 2); } + + // locate key and extract it + nL = msCollector.find("id=") +4; + sKey = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); + nL = msCollector.find("xml:lang=\"") + 10; + sLang = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); + nL = msCollector.find(">") +1; + sText = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL); + msCollector.clear(); + + if (mbMergeMode) { +#if 0 + // get all languages (includes en-US) + std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey); + std::string sNewLine; + nL = cExtraLangauges.size(); + + for (int i = 0; i < nL; ++i) { + sNewLine = "\n<" + sHead + " id=\"" + sKey + "\"" + " xml:lang=\"" + + cExtraLangauges[i]->msLanguage + "\">" + + cExtraLangauges[i]->msText + + "</" + sHead + ">"; + + writeSourceFile(sNewLine); + } #endif - } + } - mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText, mbMergeMode); - mbCollectingData = false; + mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText, mbMergeMode); + mbCollectingData = false; } diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx index ff7e7f62eaeb..ccf1a953b4ed 100644 --- a/l10ntools/source/gConvXcu.cxx +++ b/l10ntools/source/gConvXcu.cxx @@ -31,177 +31,148 @@ convert_xcu::convert_xcu(l10nMem& crMemory) -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_xcu::~convert_xcu() { } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace XcuWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_xcu *)convert_gen_impl::mcImpl) -//#include "gConXcu_yy.c" -//} - - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::execute() { -// XcuWrap::yylex(); + // XcuWrap::yylex(); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::pushKey(char *syyText) { - std::string sKey, sTag = copySource(syyText); - int nL, nE; - - // find key in tag - nL = sTag.find("oor:name=\""); - if (nL != (int)std::string::npos) - { - // find end of key - nL += 10; - nE = sTag.find("\"", nL); - if (nE != (int)std::string::npos) - sKey = sTag.substr(nL, nE - nL); - } - mcStack.push_back(sKey); + std::string sKey, sTag = copySource(syyText); + int nL, nE; + + // find key in tag + nL = sTag.find("oor:name=\""); + if (nL != (int)std::string::npos) { + // find end of key + nL += 10; + nE = sTag.find("\"", nL); + if (nE != (int)std::string::npos) + sKey = sTag.substr(nL, nE - nL); + } + mcStack.push_back(sKey); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::popKey(char *syyText) { - copySource(syyText); + copySource(syyText); - // check for correct node/prop relations - if (mcStack.size()) - mcStack.pop_back(); + // check for correct node/prop relations + if (mcStack.size()) + mcStack.pop_back(); - mbNoTranslate = false; + mbNoTranslate = false; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::startCollectData(char *syyText) { - int nL; - std::string sTag = copySource(syyText); - - if (mbNoTranslate) - return; - - // locate object name - nL = sTag.find("xml:lang=\""); - if (nL != (int)std::string::npos) - { - // test langauge - nL += 10; - if (sTag.substr(nL,5) == "en-US") - mbNoCollectingData = false; - else if (sTag.substr(nL,14) == "x-no-translate") - mbNoTranslate = true; - else - { - std::string sErr = sTag.substr(nL,5) + " is not en-US"; - l10nMem::showError(sErr); + int nL; + std::string sTag = copySource(syyText); + + if (mbNoTranslate) + return; + + // locate object name + nL = sTag.find("xml:lang=\""); + if (nL != (int)std::string::npos) { + // test langauge + nL += 10; + if (sTag.substr(nL,5) == "en-US") + mbNoCollectingData = false; + else if (sTag.substr(nL,14) == "x-no-translate") + mbNoTranslate = true; + else { + std::string sErr = sTag.substr(nL,5) + " is not en-US"; + l10nMem::showError(sErr); + } } - } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::stopCollectData(char *syyText) { - int nL; - std::string useKey, useText = msCollector; - - copySource(syyText); - - // time to do something ? - if (mbNoCollectingData || mbNoTranslate) - return; - - // remove any newline - for (nL = 0;;) - { - nL = useText.find("\n"); - if (nL == (int)std::string::npos) - break; - useText.erase(nL,1); - } - - mbNoCollectingData = true; - - if (useText.size()) - { - // locate key and extract it - for (nL = 0; nL < (int)mcStack.size(); ++nL) - useKey += (useKey.size() ? "." : "" ) + mcStack[nL]; - mcMemory.setSourceKey(miLineNo, msSourceFile, useKey, useText, mbMergeMode); - } - - if (mbMergeMode) - { - std::string sLang, sText, sNewLine; - - - // prepare to read all languages - mcMemory.prepareMerge(); - for (; mcMemory.getMergeLang(sLang, sText);) - { - sNewLine = "\n<value xml:lang=\"" + sLang + "\">" + sText + "</value>"; - mcMemory.convertToInetString(sNewLine); - writeSourceFile(sNewLine); + int nL; + std::string useKey, useText = msCollector; + + copySource(syyText); + + // time to do something ? + if (mbNoCollectingData || mbNoTranslate) + return; + + // remove any newline + for (nL = 0;;) { + nL = useText.find("\n"); + if (nL == (int)std::string::npos) + break; + useText.erase(nL,1); + } + + mbNoCollectingData = true; + + if (useText.size()) { + // locate key and extract it + for (nL = 0; nL < (int)mcStack.size(); ++nL) + useKey += (useKey.size() ? "." : "" ) + mcStack[nL]; + mcMemory.setSourceKey(miLineNo, msSourceFile, useKey, useText, mbMergeMode); + } + + if (mbMergeMode) { + std::string sLang, sText, sNewLine; + + // prepare to read all languages + mcMemory.prepareMerge(); + for (; mcMemory.getMergeLang(sLang, sText);) { + sNewLine = "\n<value xml:lang=\"" + sLang + "\">" + sText + "</value>"; + mcMemory.convertToInetString(sNewLine); + writeSourceFile(sNewLine); + } } - } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::copySpecial(char *syyText) { - int nx = msCollector.size(); - std::string sText = copySource(syyText, mbNoCollectingData); - - if (!mbNoCollectingData) - { - msCollector.erase(nx); - mcMemory.convertFromInetString(sText); - msCollector += sText; - } + int nx = msCollector.size(); + std::string sText = copySource(syyText, mbNoCollectingData); + + if (!mbNoCollectingData) { + msCollector.erase(nx); + mcMemory.convertFromInetString(sText); + msCollector += sText; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::copyNL(char *syyText) { - int nX = msCollector.size(); - std::string sText = copySource(syyText, mbNoCollectingData); - - if (!mbNoCollectingData) - { - msCollector.erase(nX); - msCollector += ' '; - } + int nX = msCollector.size(); + std::string sText = copySource(syyText, mbNoCollectingData); + + if (!mbNoCollectingData) { + msCollector.erase(nX); + msCollector += ' '; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xcu::addLevel() { - ++miLevel; + ++miLevel; } diff --git a/l10ntools/source/gConvXhp.cxx b/l10ntools/source/gConvXhp.cxx index b10b0381a176..0297c6310d07 100644 --- a/l10ntools/source/gConvXhp.cxx +++ b/l10ntools/source/gConvXhp.cxx @@ -28,402 +28,356 @@ convert_xhp::convert_xhp(l10nMem& crMemory) mcOutputFiles(nullptr), miCntLanguages(0) { - // xhp files are written through a local routine - mbLoadMode = true; + // xhp files are written through a local routine + mbLoadMode = true; } -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_xhp::~convert_xhp() { - if (mcOutputFiles) - { - for (int i = 0; i < miCntLanguages; ++i) - mcOutputFiles[i].close(); - delete[] mcOutputFiles; - } - if (msLangText) - delete[] msLangText; + if (mcOutputFiles) { + for (int i = 0; i < miCntLanguages; ++i) + mcOutputFiles[i].close(); + delete[] mcOutputFiles; + } + if (msLangText) + delete[] msLangText; } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace XhpWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_xhp *)convert_gen_impl::mcImpl) -//#include "gConXhp_yy.c" -//} - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::execute() { - std::string sLang; - std::string sFile, sFile2; - - // prepare list with languages - miCntLanguages = mcMemory.prepareMerge(); - if (mbMergeMode) - { - mcOutputFiles = new std::ofstream[miCntLanguages]; - msLangText = new std::string[miCntLanguages]; - - for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i) - { - sFile2 = sLang + "/text/" + mcMemory.getModuleName().substr(5) + "/" + msSourceFile; - sFile = msTargetPath + sFile2; - mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); - if (!mcOutputFiles[i].is_open()) - { - if (!convert_gen::createDir(msTargetPath, sFile2)) - throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing"); - - mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); - if (!mcOutputFiles[i].is_open()) - throw l10nMem::showError("Cannot open file (" + sFile + ") for writing"); - } - msLangText[i] = "xml-lang=\"" + sLang + "\""; + std::string sLang; + std::string sFile, sFile2; + + // prepare list with languages + miCntLanguages = mcMemory.prepareMerge(); + if (mbMergeMode) { + mcOutputFiles = new std::ofstream[miCntLanguages]; + msLangText = new std::string[miCntLanguages]; + + for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i) { + sFile2 = sLang + "/text/" + mcMemory.getModuleName().substr(5) + "/" + msSourceFile; + sFile = msTargetPath + sFile2; + mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); + if (!mcOutputFiles[i].is_open()) { + if (!convert_gen::createDir(msTargetPath, sFile2)) + throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing"); + + mcOutputFiles[i].open(sFile.c_str(), std::ios::binary); + if (!mcOutputFiles[i].is_open()) + throw l10nMem::showError("Cannot open file (" + sFile + ") for writing"); + } + msLangText[i] = "xml-lang=\"" + sLang + "\""; + } } - } - // run analyzer -// XhpWrap::yylex(); + // run analyzer + // XhpWrap::yylex(); - // dump last line - copySourceSpecial(nullptr,3); + // dump last line + copySourceSpecial(nullptr,3); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::setString(char *yytext) { - copySourceSpecial(yytext, 0); + copySourceSpecial(yytext, 0); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::openTag(char *yytext) { - if (meExpectValue == VALUE_IS_VALUE) - { - meExpectValue = VALUE_IS_VALUE_TAG; -//FIX msCollector += "\\"; - } - copySourceSpecial(yytext, 0); + if (meExpectValue == VALUE_IS_VALUE) { + meExpectValue = VALUE_IS_VALUE_TAG; + //FIX msCollector += "\\"; + } + copySourceSpecial(yytext, 0); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::closeTag(char *yytext) { - STATE newState = meExpectValue; - - switch (meExpectValue) - { - case VALUE_IS_VALUE_TAG: - newState = VALUE_IS_VALUE; -//FIX msCollector += "\\"; - break; - - case VALUE_IS_TAG_TRANS: - if (msKey.size()) - newState = VALUE_IS_VALUE; - break; - - case VALUE_IS_TAG: - msKey.clear(); - newState = VALUE_NOT_USED; - break; - case VALUE_NOT_USED: - case VALUE_IS_VALUE: - break; - } - copySourceSpecial(yytext, 0); - meExpectValue = newState; + STATE newState = meExpectValue; + + switch (meExpectValue) { + case VALUE_IS_VALUE_TAG: + newState = VALUE_IS_VALUE; + //FIX msCollector += "\\"; + break; + + case VALUE_IS_TAG_TRANS: + if (msKey.size()) + newState = VALUE_IS_VALUE; + break; + + case VALUE_IS_TAG: + msKey.clear(); + newState = VALUE_NOT_USED; + break; + + case VALUE_NOT_USED: + case VALUE_IS_VALUE: + break; + } + copySourceSpecial(yytext, 0); + meExpectValue = newState; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::closeTagNOvalue(char *yytext) { - copySourceSpecial(yytext, 0); - if (meExpectValue == VALUE_IS_VALUE_TAG) - meExpectValue = VALUE_IS_VALUE; - else - meExpectValue = VALUE_NOT_USED; + copySourceSpecial(yytext, 0); + if (meExpectValue == VALUE_IS_VALUE_TAG) + meExpectValue = VALUE_IS_VALUE; + else + meExpectValue = VALUE_NOT_USED; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::setId(char *yytext) { - int nL, nE; - std::string& sText = copySourceSpecial(yytext, 0); - - - nL = sText.find("\""); - nE = sText.find("\"", nL+1); - if (nL == (int)std::string::npos || nE == (int)std::string::npos) - return; - - switch (meExpectValue) - { - case VALUE_IS_TAG: - case VALUE_IS_TAG_TRANS: - msKey = sText.substr(nL+1, nE - nL -1) + msKey; - break; - - case VALUE_IS_VALUE_TAG: - case VALUE_NOT_USED: - case VALUE_IS_VALUE: - break; - } + int nL, nE; + std::string& sText = copySourceSpecial(yytext, 0); + + + nL = sText.find("\""); + nE = sText.find("\"", nL+1); + if (nL == (int)std::string::npos || nE == (int)std::string::npos) + return; + + switch (meExpectValue) { + case VALUE_IS_TAG: + case VALUE_IS_TAG_TRANS: + msKey = sText.substr(nL+1, nE - nL -1) + msKey; + break; + + case VALUE_IS_VALUE_TAG: + case VALUE_NOT_USED: + case VALUE_IS_VALUE: + break; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::setLang(char *yytext) { - int nL, nE; - std::string sLang; - std::string& sText = copySourceSpecial(yytext, 1); - - - nL = sText.find("\""); - nE = sText.find("\"", nL+1); - if (nL == (int)std::string::npos || nE == (int)std::string::npos) - return; - - switch (meExpectValue) - { - case VALUE_IS_TAG: - sLang = sText.substr(nL+1, nE - nL -1); - if (sLang == "en-US") - meExpectValue = VALUE_IS_TAG_TRANS; - else - l10nMem::showError(sLang + " is no en-US language"); - break; - - case VALUE_IS_VALUE_TAG: - msCollector.erase(msCollector.size() - sText.size() -1); - break; - - case VALUE_NOT_USED: - case VALUE_IS_TAG_TRANS: - case VALUE_IS_VALUE: - break; - } + int nL, nE; + std::string sLang; + std::string& sText = copySourceSpecial(yytext, 1); + + + nL = sText.find("\""); + nE = sText.find("\"", nL+1); + if (nL == (int)std::string::npos || nE == (int)std::string::npos) + return; + + switch (meExpectValue) { + case VALUE_IS_TAG: + sLang = sText.substr(nL+1, nE - nL -1); + if (sLang == "en-US") + meExpectValue = VALUE_IS_TAG_TRANS; + else + l10nMem::showError(sLang + " is no en-US language"); + break; + + case VALUE_IS_VALUE_TAG: + msCollector.erase(msCollector.size() - sText.size() -1); + break; + + case VALUE_NOT_USED: + case VALUE_IS_TAG_TRANS: + case VALUE_IS_VALUE: + break; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::setRef(char *yytext) { - int nL, nE; - std::string& sText = copySourceSpecial(yytext, 0); - - - nL = sText.find("\""); - nE = sText.find("\"", nL+1); - if (nL == (int)std::string::npos || nE == (int)std::string::npos) - return; - - switch (meExpectValue) - { - case VALUE_IS_TAG: - case VALUE_IS_TAG_TRANS: - msKey += "." + sText.substr(nL+1, nE - nL -1); - break; - - case VALUE_IS_VALUE_TAG: - case VALUE_NOT_USED: - case VALUE_IS_VALUE: - break; - } + int nL, nE; + std::string& sText = copySourceSpecial(yytext, 0); + + + nL = sText.find("\""); + nE = sText.find("\"", nL+1); + if (nL == (int)std::string::npos || nE == (int)std::string::npos) + return; + + switch (meExpectValue) { + case VALUE_IS_TAG: + case VALUE_IS_TAG_TRANS: + msKey += "." + sText.substr(nL+1, nE - nL -1); + break; + + case VALUE_IS_VALUE_TAG: + case VALUE_NOT_USED: + case VALUE_IS_VALUE: + break; + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::openTransTag(char *yytext) { - copySourceSpecial(yytext, 0); - msKey.clear(); - meExpectValue = VALUE_IS_TAG; + copySourceSpecial(yytext, 0); + msKey.clear(); + meExpectValue = VALUE_IS_TAG; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::closeTransTag(char *yytext) { - int iType = 0; + int iType = 0; - if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) - { - if (msCollector.size() && msCollector != "-") - mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, msCollector, mbMergeMode); - msKey.clear(); - iType = 2; - } - meExpectValue = VALUE_NOT_USED; - copySourceSpecial(yytext, iType); + if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) { + if (msCollector.size() && msCollector != "-") + mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, msCollector, mbMergeMode); + msKey.clear(); + iType = 2; + } + meExpectValue = VALUE_NOT_USED; + copySourceSpecial(yytext, iType); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::stopTransTag(char *yytext) { - copySourceSpecial(yytext, 0); - meExpectValue = VALUE_NOT_USED; + copySourceSpecial(yytext, 0); + meExpectValue = VALUE_NOT_USED; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::startComment(char *yytext) { - mePushValue = meExpectValue; - msPushCollect = msCollector; - meExpectValue = VALUE_NOT_USED; - copySourceSpecial(yytext, 0); + mePushValue = meExpectValue; + msPushCollect = msCollector; + meExpectValue = VALUE_NOT_USED; + copySourceSpecial(yytext, 0); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::stopComment(char *yytext) { - copySourceSpecial(yytext, 0); - meExpectValue = mePushValue; - msCollector = msPushCollect; + copySourceSpecial(yytext, 0); + meExpectValue = mePushValue; + msCollector = msPushCollect; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::handleSpecial(char *yytext) { - if (meExpectValue != VALUE_IS_VALUE || meExpectValue != VALUE_IS_VALUE_TAG) - { - std::string sText(yytext); - mcMemory.convertFromInetString(sText); - msCollector += sText; - } - else - copySourceSpecial(yytext, 0); + if (meExpectValue != VALUE_IS_VALUE || meExpectValue != VALUE_IS_VALUE_TAG) { + std::string sText(yytext); + mcMemory.convertFromInetString(sText); + msCollector += sText; + } + else + copySourceSpecial(yytext, 0); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::handleDataEnd(char *yytext) { - int nX = msCollector.size(); - copySourceSpecial(yytext, 0); + int nX = msCollector.size(); + copySourceSpecial(yytext, 0); - if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) - msCollector.erase(nX); + if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) + msCollector.erase(nX); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::duplicate(char *yytext) { - copySourceSpecial(yytext, 0); + copySourceSpecial(yytext, 0); - if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) - msCollector += msCollector[msCollector.size()-1]; + if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG) + msCollector += msCollector[msCollector.size()-1]; } -/********************** I M P L E M E N T A T I O N **********************/ std::string& convert_xhp::copySourceSpecial(char *yytext, int iType) { - bool doingValue = (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG); - std::string& sText = copySource(yytext, !doingValue); - std::string sLang; - int i; - - - // Do NOT write data while collecting a value (will be replaced by language text) - if (doingValue) + bool doingValue = (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG); + std::string& sText = copySource(yytext, !doingValue); + std::string sLang; + int i; + + + // Do NOT write data while collecting a value (will be replaced by language text) + if (doingValue) + return sText; + + // Handling depends o + switch (iType) { + case 0: // Used for tokens that are to be copied 1-1, + if (mbMergeMode) { + msLine += yytext; + if (*yytext == '\n') { + for (i = 0; i < miCntLanguages; ++i) + writeSourceFile(msLine, i); + msLine.clear(); + } + } + break; + + case 1: // Used for language token, are to replaced with languages + if (mbMergeMode) { + for (i = 0; i < miCntLanguages; ++i) { + writeSourceFile(msLine, i); + writeSourceFile(msLangText[i], i); + } + msLine.clear(); + } + break; + + case 2: // Used for token at end of value, language text are to be inserted and then token written + if (mbMergeMode) { + mcMemory.prepareMerge(); + for (i = 0; i < miCntLanguages; ++i) { + writeSourceFile(msLine, i); + mcMemory.getMergeLang(sLang, sText); + writeSourceFile(sText,i); + std::string sYY(yytext); + writeSourceFile(sYY, i); + } + msLine.clear(); + } + break; + + case 3: // Used for EOF + if (mbMergeMode) { + for (i = 0; i < miCntLanguages; ++i) + writeSourceFile(msLine, i); + } + break; + } return sText; - - // Handling depends o - switch (iType) - { - case 0: // Used for tokens that are to be copied 1-1, - if (mbMergeMode) - { - msLine += yytext; - if (*yytext == '\n') - { - for (i = 0; i < miCntLanguages; ++i) - writeSourceFile(msLine, i); - msLine.clear(); - } - } - break; - - case 1: // Used for language token, are to replaced with languages - if (mbMergeMode) - { - for (i = 0; i < miCntLanguages; ++i) - { - writeSourceFile(msLine, i); - writeSourceFile(msLangText[i], i); - } - msLine.clear(); - } - break; - - case 2: // Used for token at end of value, language text are to be inserted and then token written - if (mbMergeMode) - { - mcMemory.prepareMerge(); - for (i = 0; i < miCntLanguages; ++i) - { - writeSourceFile(msLine, i); - mcMemory.getMergeLang(sLang, sText); - writeSourceFile(sText,i); - std::string sYY(yytext); - writeSourceFile(sYY, i); - } - msLine.clear(); - } - break; - - case 3: // Used for EOF - if (mbMergeMode) - { - for (i = 0; i < miCntLanguages; ++i) - writeSourceFile(msLine, i); - } - break; - } - return sText; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xhp::writeSourceFile(std::string& sText, int inx) { - if (sText.size() && mcOutputFiles[inx].is_open()) - mcOutputFiles[inx].write(sText.c_str(), sText.size()); + if (sText.size() && mcOutputFiles[inx].is_open()) + mcOutputFiles[inx].write(sText.c_str(), sText.size()); } diff --git a/l10ntools/source/gConvXrm.cxx b/l10ntools/source/gConvXrm.cxx index 0e71bf272936..55a341d5b184 100644 --- a/l10ntools/source/gConvXrm.cxx +++ b/l10ntools/source/gConvXrm.cxx @@ -34,133 +34,112 @@ convert_xrm::convert_xrm(l10nMem& crMemory) -/************ I N T E R F A C E I M P L E M E N T A T I O N ************/ convert_xrm::~convert_xrm() { } -/********************** I M P L E M E N T A T I O N **********************/ -//namespace XrmWrap -//{ -//#define IMPLptr convert_gen_impl::mcImpl -//#define LOCptr ((convert_xrm *)convert_gen_impl::mcImpl) -//#include "gConXrm_yy.c" -//} - - -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::execute() { -//// XrmWrap::yylex(); + //// XrmWrap::yylex(); - // write last part of file. - if (mbMergeMode) - writeSourceFile(msCollector); + // write last part of file. + if (mbMergeMode) + writeSourceFile(msCollector); } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::setId(char *yytext) { - std::string& sText = copySource(yytext, mbNoCollectingData); - int nL, nE; + std::string& sText = copySource(yytext, mbNoCollectingData); + int nL, nE; - if (mbIsTag) - { - nL = sText.find("\""); - nE = sText.find("\"", nL+1); - if (nL == (int)std::string::npos || nE == (int)std::string::npos) - return; + if (mbIsTag) { + nL = sText.find("\""); + nE = sText.find("\"", nL+1); + if (nL == (int)std::string::npos || nE == (int)std::string::npos) + return; - msKey = sText.substr(nL+1, nE - nL -1); - } + msKey = sText.substr(nL+1, nE - nL -1); + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::setLang(char *yytext) { - std::string& sText = copySource(yytext, mbNoCollectingData); - std::string sLang; - int nL, nE; - - - if (mbIsTag) - { - nL = sText.find("\""); - nE = sText.find("\"", nL+1); - if (nL == (int)std::string::npos || nE == (int)std::string::npos) - return; - - sLang = sText.substr(nL+1, nE - nL -1); - if (sLang == "en-US") - mbIsLang = true; - else - l10nMem::showError(sLang + " is no en-US language"); - } + std::string& sText = copySource(yytext, mbNoCollectingData); + std::string sLang; + int nL, nE; + + + if (mbIsTag) { + nL = sText.find("\""); + nE = sText.find("\"", nL+1); + if (nL == (int)std::string::npos || nE == (int)std::string::npos) + return; + + sLang = sText.substr(nL+1, nE - nL -1); + if (sLang == "en-US") + mbIsLang = true; + else + l10nMem::showError(sLang + " is no en-US language"); + } } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::setTag(char *yytext) { - msTag = copySource(yytext); + msTag = copySource(yytext); - msKey.clear(); - mbIsLang = false; - mbIsTag = true; + msKey.clear(); + mbIsLang = false; + mbIsTag = true; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::startCollectData(char *yytext) { - copySource(yytext, mbNoCollectingData); + copySource(yytext, mbNoCollectingData); - if (mbIsTag && mbIsLang && msKey.size()) - mbNoCollectingData = false; + if (mbIsTag && mbIsLang && msKey.size()) + mbNoCollectingData = false; - mbIsTag = mbIsLang = false; + mbIsTag = mbIsLang = false; } -/********************** I M P L E M E N T A T I O N **********************/ void convert_xrm::stopCollectData(char *yytext) { - std::string sTagText, sTagEnd, sLang, sText = msCollector; - - copySource(yytext); - if (!mbNoCollectingData) - { - mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode); - mbNoCollectingData = true; - if (mbMergeMode) - { - sTagEnd = "</" + msTag.substr(1,msTag.size()-2) + ">\n"; - msTag += "id=\"" + msKey + "\" xml:lang=\""; - - // prepare to read all languages - mcMemory.prepareMerge(); - for (; mcMemory.getMergeLang(sLang, sText);) - { - // replace \" with " - for (int i = 0; (i = sText.find("\\\"", i)) != (int)std::string::npos;) - sText.erase(i,1); - - // Prepare tag start and end - sTagText = msTag + sLang + "\">" + sText + sTagEnd; - writeSourceFile(sTagText); - } + std::string sTagText, sTagEnd, sLang, sText = msCollector; + + copySource(yytext); + if (!mbNoCollectingData) { + mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode); + mbNoCollectingData = true; + if (mbMergeMode) { + sTagEnd = "</" + msTag.substr(1,msTag.size()-2) + ">\n"; + msTag += "id=\"" + msKey + "\" xml:lang=\""; + + // prepare to read all languages + mcMemory.prepareMerge(); + for (; mcMemory.getMergeLang(sLang, sText);) { + // replace \" with " + for (int i = 0; (i = sText.find("\\\"", i)) != (int)std::string::npos;) + sText.erase(i,1); + + // Prepare tag start and end + sTagText = msTag + sLang + "\">" + sText + sTagEnd; + writeSourceFile(sTagText); + } + } + msKey.clear(); } - msKey.clear(); - } - mbIsTag = false; + mbIsTag = false; } diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx index 604a6d6b08ec..0d8277baaf1f 100644 --- a/l10ntools/source/gL10nMem.cxx +++ b/l10ntools/source/gL10nMem.cxx @@ -29,108 +29,106 @@ l10nMem *myMem; class l10nMem_lang_list_entry { -public: - l10nMem_lang_list_entry(const std::string& sName) : - msName(sName), - mbChanged(false) - {} + public: + l10nMem_lang_list_entry(const std::string& sName) + : msName(sName), + mbChanged(false) + {} - ~l10nMem_lang_list_entry() {}; + ~l10nMem_lang_list_entry() {}; - std::string msName; // language Name - bool mbChanged; // used for "convert", true if language is modified + std::string msName; // language Name + bool mbChanged; // used for "convert", true if language is modified }; class l10nMem_file_entry { -public: - l10nMem_file_entry(const std::string& sFileName, int iStart) - : - msFileName(sFileName), - miStart(iStart), - miEnd(iStart) - { - // Store fileName without relative path - int i = msFileName.rfind("/"); - if (i == (int)std::string::npos) - msPureName = msFileName; - else - msPureName = msFileName.substr(i + 1); - } - ~l10nMem_file_entry() {}; + public: + l10nMem_file_entry(const std::string& sFileName, int iStart) + : msFileName(sFileName), + miStart(iStart), + miEnd(iStart) + { + // Store fileName without relative path + int i = msFileName.rfind("/"); + if (i == (int)std::string::npos) + msPureName = msFileName; + else + msPureName = msFileName.substr(i + 1); + } + ~l10nMem_file_entry() {}; - std::string msFileName; // file Name with relative path - std::string msPureName; // just filename - int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS) - int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS) + std::string msFileName; // file Name with relative path + std::string msPureName; // just filename + int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS) + int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS) }; class l10nMem_lang_entry { -public: - l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy) - : - msMsgStr(sMsgStr), - mbFuzzy(bFuzzy) - {} - ~l10nMem_lang_entry() {}; + public: + l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy) + : msMsgStr(sMsgStr), + mbFuzzy(bFuzzy) + {} + ~l10nMem_lang_entry() {}; - std::string msMsgStr; // translated text from po file - bool mbFuzzy; // fuzzy flag + std::string msMsgStr; // translated text from po file + bool mbFuzzy; // fuzzy flag }; class l10nMem_enus_entry { -public: - l10nMem_enus_entry(const std::string& sKey, - const std::string& sMsgId, - int iLineNo, - int iFileInx, - int iLangSize, - l10nMem::ENTRY_STATE eState) - : - msMsgId(sMsgId), - meState(eState), - miFileInx(iFileInx), - miLineNo(iLineNo) - { - int i; - - // add dummy language entries - for (i = 0; i < iLangSize; ++i) - mcLangText.push_back(l10nMem_lang_entry("", false)); - - // convert key to upper case - msKey = sKey; - l10nMem::keyToUpper(msKey); - } - - ~l10nMem_enus_entry() {}; - - std::string msKey; // key in po file and source file - std::string msMsgId; // en-US text from source file - l10nMem::ENTRY_STATE meState; // status information - int miFileInx; // index of file name - int miLineNo; // line number - std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId) + public: + l10nMem_enus_entry(const std::string& sKey, + const std::string& sMsgId, + int iLineNo, + int iFileInx, + int iLangSize, + l10nMem::ENTRY_STATE eState) + : msMsgId(sMsgId), + meState(eState), + miFileInx(iFileInx), + miLineNo(iLineNo) + { + int i; + + // add dummy language entries + for (i = 0; i < iLangSize; ++i) + mcLangText.push_back(l10nMem_lang_entry("", false)); + + // convert key to upper case + msKey = sKey; + l10nMem::keyToUpper(msKey); + } + + ~l10nMem_enus_entry() {}; + + std::string msKey; // key in po file and source file + std::string msMsgId; // en-US text from source file + l10nMem::ENTRY_STATE meState; // status information + int miFileInx; // index of file name + int miLineNo; // line number + std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId) }; + l10nMem::l10nMem() - : mbVerbose(false), - mbDebug(false), - mbInError(false), - miCurFileInx(0), - miCurLangInx(0), - miCurENUSinx(0), - mbNeedWrite(false), - mbConvertMode(false), - mbStrictMode(false) + : mbVerbose(false), + mbDebug(false), + mbInError(false), + miCurFileInx(0), + miCurLangInx(0), + miCurENUSinx(0), + mbNeedWrite(false), + mbConvertMode(false), + mbStrictMode(false) { myMem = this; mcFileList.push_back(l10nMem_file_entry("-genLang-", 0)); @@ -172,8 +170,8 @@ void l10nMem::showDebug(const std::string& sText, int iLineNo) void l10nMem::showVerbose(const std::string& sText, int iLineNo) { - if (myMem->mbVerbose) - myMem->formatAndShowText("INFO", iLineNo, sText); + if (myMem->mbVerbose) + myMem->formatAndShowText("INFO", iLineNo, sText); } @@ -200,7 +198,7 @@ const std::string& l10nMem::getModuleName() void l10nMem::setLanguage(const std::string& sLanguage, - bool bCreate) + bool bCreate) { int i, iSize; @@ -208,8 +206,7 @@ void l10nMem::setLanguage(const std::string& sLanguage, miCurFileInx = 0; // With no languages selected only en-US is generated - if (!sLanguage.size()) - { + if (!sLanguage.size()) { miCurLangInx = 0; return; } @@ -221,8 +218,7 @@ void l10nMem::setLanguage(const std::string& sLanguage, // check if language is already loaded iSize = mcLangList.size(); for (miCurLangInx = 0; miCurLangInx < iSize && mcLangList[miCurLangInx].msName != sLanguage; ++miCurLangInx); - if (miCurLangInx < iSize) - { + if (miCurLangInx < iSize) { if (bCreate) throw showError("loading " + sLanguage + " twice"); return; @@ -244,7 +240,7 @@ void l10nMem::setLanguage(const std::string& sLanguage, void l10nMem::setConvert(bool bConvert, - bool bStrict) + bool bStrict) { // regular load or convert of old po files mbConvertMode = bConvert; @@ -268,11 +264,11 @@ void l10nMem::setDebug(bool doDebug) void l10nMem::loadEntryKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - const std::string& sMsgStr, - bool bIsFuzzy) + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + const std::string& sMsgStr, + bool bIsFuzzy) { if (mbConvertMode) convEntryKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy); @@ -327,7 +323,7 @@ void l10nMem::setSourceKey(int iLineNo, void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForce) { -// int iEsize = mcENUSlist.size(); + // int iEsize = mcENUSlist.size(); std::string sFileName = msModuleName + ".pot"; // Dummy to satisfy compiler @@ -367,8 +363,8 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool bForce) { -// int iE, iEsize = mcENUSlist.size(); -// int iEsize = mcENUSlist.size(); + // int iE, iEsize = mcENUSlist.size(); + // int iEsize = mcENUSlist.size(); int iL, iLsize = mcLangList.size(); std::string sFileName = msModuleName + ".po"; @@ -769,12 +765,14 @@ void l10nMem::loadENUSkey(int iLineNo, addKey(iLineNo, sSourceFile, sKey, sMsgId, ENTRY_DELETED); } + + void l10nMem::loadLangKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - const std::string& sMsgStr, - bool bFuzzy) + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + const std::string& sMsgStr, + bool bFuzzy) { if (!locateKey(iLineNo, sSourceFile, sKey, sMsgId, true)) throw l10nMem::showError(".po file contains unknown filename: " + sSourceFile + " or key: " + sKey); @@ -794,13 +792,11 @@ void l10nMem::reorganize(bool bConvert) // Check number of changes - for (iE = 1; iE < iEsize; ++iE) - { + for (iE = 1; iE < iEsize; ++iE) { l10nMem_enus_entry& cur = mcENUSlist[iE]; if (cur.meState == l10nMem::ENTRY_ADDED) listAdd.push_back(iE); - if (cur.meState == l10nMem::ENTRY_DELETED) - { + if (cur.meState == l10nMem::ENTRY_DELETED) { if (bConvert) cur.meState = l10nMem::ENTRY_NORMAL; else @@ -814,11 +810,9 @@ void l10nMem::reorganize(bool bConvert) // loop through added text and see if key match deleted text iEsize = listAdd.size(); iDsize = listDel.size(); - for (iE = 0; iE < iEsize; ++iE) - { + for (iE = 0; iE < iEsize; ++iE) { l10nMem_enus_entry& curAdd = mcENUSlist[listAdd[iE]]; - for (iD = 0; iD < iDsize; ++iD) - { + for (iD = 0; iD < iDsize; ++iD) { l10nMem_enus_entry& curE = mcENUSlist[listDel[iD]]; if (curE.miFileInx != curAdd.miFileInx) @@ -843,10 +837,10 @@ void l10nMem::reorganize(bool bConvert) bool l10nMem::locateKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - bool bThrow) + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + bool bThrow) { std::string sUpperKey(sKey); int i, iSize = sUpperKey.size(); @@ -857,8 +851,7 @@ bool l10nMem::locateKey(int iLineNo, return false; // convert key to upper case - for (i = 0; i < iSize; ++i) - { + for (i = 0; i < iSize; ++i) { ch = sUpperKey[i]; if (ch == ' ' || ch == '*' || ch == '+' || ch == '%') sUpperKey[i] = '_'; @@ -867,8 +860,7 @@ bool l10nMem::locateKey(int iLineNo, } // Fast check, to see if next key is the one (normal with load and source without change) - if (++miCurENUSinx < (int)mcENUSlist.size()) - { + if (++miCurENUSinx < (int)mcENUSlist.size()) { l10nMem_enus_entry& nowEntry = mcENUSlist[miCurENUSinx]; if (nowEntry.msMsgId == sMsgId && nowEntry.msKey == sUpperKey) return true; @@ -878,8 +870,7 @@ bool l10nMem::locateKey(int iLineNo, l10nMem_file_entry& cCur = mcFileList[miCurFileInx]; // Find match with key and text - for (miCurENUSinx = cCur.miStart; miCurENUSinx <= cCur.miEnd; ++miCurENUSinx) - { + for (miCurENUSinx = cCur.miStart; miCurENUSinx <= cCur.miEnd; ++miCurENUSinx) { l10nMem_enus_entry& cEntry = mcENUSlist[miCurENUSinx]; if (cEntry.msMsgId == sMsgId && cEntry.msKey == sUpperKey) return true; @@ -893,14 +884,13 @@ bool l10nMem::locateKey(int iLineNo, void l10nMem::addKey(int iLineNo, - const std::string& sSourceFile, - const std::string& sKey, - const std::string& sMsgId, - l10nMem::ENTRY_STATE eStat) + const std::string& sSourceFile, + const std::string& sKey, + const std::string& sMsgId, + l10nMem::ENTRY_STATE eStat) { // check file - if (!findFileName(sSourceFile)) - { + if (!findFileName(sSourceFile)) { // prepare for new entry miCurENUSinx = mcENUSlist.size(); miCurFileInx = mcFileList.size(); @@ -913,8 +903,7 @@ void l10nMem::addKey(int iLineNo, mcLangList.size(), eStat)); mcFileList[miCurFileInx].miEnd = miCurENUSinx; } - else - { + else { int iFsize = mcFileList.size(); l10nMem_file_entry& curF = mcFileList[miCurFileInx]; std::vector<l10nMem_enus_entry>::iterator it = mcENUSlist.begin(); @@ -923,10 +912,9 @@ void l10nMem::addKey(int iLineNo, curF.miEnd++; miCurENUSinx = curF.miEnd; mcENUSlist.insert(it + curF.miEnd, - l10nMem_enus_entry(sKey, sMsgId, iLineNo, miCurFileInx, - mcLangList.size(), eStat)); - for (int i = miCurFileInx + 1; i < iFsize; ++i) - { + l10nMem_enus_entry(sKey, sMsgId, iLineNo, miCurFileInx, + mcLangList.size(), eStat)); + for (int i = miCurFileInx + 1; i < iFsize; ++i) { l10nMem_file_entry& curF2 = mcFileList[i]; if (curF2.miStart >= curF.miEnd) curF2.miStart++; @@ -951,8 +939,7 @@ bool l10nMem::findFileName(const std::string& sSourceFile) miCurFileInx < iSize && mcFileList[miCurFileInx].msFileName != sSourceFile && mcFileList[miCurFileInx].msPureName != sSourceFile; ++miCurFileInx); - if (miCurFileInx == iSize) - { + if (miCurFileInx == iSize) { miCurFileInx = 0; return false; } @@ -968,8 +955,7 @@ void l10nMem::keyToUpper(std::string& sKey) int i, iSize; iSize = sKey.size(); - for (i = 0; i < iSize; ++i) - { + for (i = 0; i < iSize; ++i) { char ch = sKey[i]; if (ch == ' ' || ch == '*' || ch == '+' || ch == '%') sKey[i] = '_'; @@ -977,7 +963,3 @@ void l10nMem::keyToUpper(std::string& sKey) sKey[i] = toupper(ch); } } - - - - diff --git a/l10ntools/source/gLang.cxx b/l10ntools/source/gLang.cxx index d4bb18fa21af..8119171be290 100644 --- a/l10ntools/source/gLang.cxx +++ b/l10ntools/source/gLang.cxx @@ -362,8 +362,7 @@ void handler::runConvert() mcMemory.setConvert(true, false); // loop through all source files, and extract messages from each file - for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) - { + for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) { // tell system l10nMem::showDebug("genLang compare template " + *siSource); @@ -373,8 +372,7 @@ void handler::runConvert() mcMemory.showNOconvert(); - for (siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang) - { + for (siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang) { std::string sFilePath = *siLang + "/"; // get converter and extract files @@ -405,8 +403,7 @@ void handler::runExtract() mcMemory.setConvert(false, false); // loop through all source files, and extract messages from each file - for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) - { + for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) { // tell system l10nMem::showDebug("genLang extracting text from file " + *siSource); @@ -429,8 +426,7 @@ void handler::runMerge(bool bKid) mcMemory.setConvert(false, false); // loop through all source files, and extract messages from each file - for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) - { + for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource) { // tell system l10nMem::showDebug("genLang merging translated text to file " + *siSource); diff --git a/l10ntools/source/gLexPo.l b/l10ntools/source/gLexPo.l index ae4db4f08acc..9faf94f53029 100644 --- a/l10ntools/source/gLexPo.l +++ b/l10ntools/source/gLexPo.l @@ -16,7 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - + /* white-space # translator-comments @@ -32,8 +32,8 @@ msgstr "Error desconegut del sistema" */ - -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + + %top{ #include <string> #include <vector> @@ -58,9 +58,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -79,53 +79,48 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) %e 1200 %n 500 -/*********************** H E L P E R M A C R O S ***********************/ SPACE [ \t]* -/******************* R U L E S D E F I N I T I O N S *******************/ %% "\"" { - char c, buildValue[8000]; - int j, i, iLineCnt; - - // loop across multiple "..." and combine them, while keeping the source - for (j = -1, iLineCnt = i = 0; (c = yytext[i]) == '\"';) - { - // build current "..." - for (; (buildValue[++j] = yytext[++i] = c = yyinput()) != '\"';) - if (yytext[i] == '\\') - buildValue[++j] = yytext[++i] = yyinput(); - --j; - - if (!LOCptr->mbExpectId && !LOCptr->mbExpectStr) - break; - - // skip rest of line - for (; (c = yytext[++i] = yyinput()) == ' ' || yytext[i] == '\t' || yytext[i] == '\n';) - if (yytext[i] == '\n') - ++iLineCnt; - } - - if (LOCptr->mbExpectId || LOCptr->mbExpectStr) - { - if (yytext[i] != EOF) - { - unput(yytext[i]); + char c, buildValue[8000]; + int j, i, iLineCnt; + + // loop across multiple "..." and combine them, while keeping the source + for (j = -1, iLineCnt = i = 0; (c = yytext[i]) == '\"';) { + // build current "..." + for (; (buildValue[++j] = yytext[++i] = c = yyinput()) != '\"';) + if (yytext[i] == '\\') + buildValue[++j] = yytext[++i] = yyinput(); + --j; + + if (!LOCptr->mbExpectId && !LOCptr->mbExpectStr) + break; + + // skip rest of line + for (; (c = yytext[++i] = yyinput()) == ' ' || yytext[i] == '\t' || yytext[i] == '\n';) + if (yytext[i] == '\n') + ++iLineCnt; + } + + if (LOCptr->mbExpectId || LOCptr->mbExpectStr) { + if (yytext[i] != EOF) { + unput(yytext[i]); + } + buildValue[j+1] = '\0'; + LOCptr->setValue(buildValue, iLineCnt); } - buildValue[j+1] = '\0'; - LOCptr->setValue(buildValue, iLineCnt); - } } "#,"{SPACE}.*[fF][uU][zZ][zZ][yY] { - LOCptr->setFuzzy(); + LOCptr->setFuzzy(); } "#:".* { - LOCptr->setKey(yytext); + LOCptr->setKey(yytext); } @@ -133,26 +128,26 @@ SPACE [ \t]* "#*".* | "# ".* | "#~".* { - // special comment, just skip + // special comment, just skip } [mM][sS][gG][iI][dD]{SPACE} { - LOCptr->setMsgId(); + LOCptr->setMsgId(); } [mM][sS][gG][sS][tT][rR]{SPACE} { - LOCptr->setMsgStr(); + LOCptr->setMsgStr(); } \n { - LOCptr->handleNL(); + LOCptr->handleNL(); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } @@ -163,8 +158,7 @@ SPACE [ \t]* void dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } - diff --git a/l10ntools/source/gLexSrc.l b/l10ntools/source/gLexSrc.l index b9c0c3b9a84f..ea8c152d5837 100644 --- a/l10ntools/source/gLexSrc.l +++ b/l10ntools/source/gLexSrc.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -61,14 +61,13 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) /* --- The following options are for future use (maybe) */ /* yyclass= --> subClass yyFlexLexer to allow own functions */ /* c++ --> generate C++ classes */ -%option prefix="src" 8bit noyywrap never-interactive +%option prefix="src" 8bit noyywrap never-interactive %array %p 24000 %e 1200 %n 500 -/*********************** H E L P E R M A C R O S ***********************/ %x CMD PRE ^[ \t]* SUF [ \t\r\n\\] @@ -77,105 +76,102 @@ SPACE [ \t]* IDENT ([(a-zA-Z0-9_][ a-zA-Z0-9_\-\+\*(,&]*[a-zA-Z0-9)_]|[a-zA-Z0-9_]) KEYID [a-zA-Z0-9_-]+ -/******************* R U L E S D E F I N I T I O N S *******************/ %% "/*" { - int i = 1; - for (;;) - { - while (yytext[i] != '*') - yytext[++i] = yyinput(); - yytext[++i] = yyinput(); - if (yytext[i] == '/') - break; - } - yytext[i+1] = '\0'; - - IMPLptr->copySource(yytext); + int i = 1; + for (;;) { + while (yytext[i] != '*') + yytext[++i] = yyinput(); + yytext[++i] = yyinput(); + if (yytext[i] == '/') + break; + } + yytext[i+1] = '\0'; + + IMPLptr->copySource(yytext); } "//".* { - IMPLptr->copySource(yytext); + IMPLptr->copySource(yytext); } "\"" { - char buildValue[8000]; - int j, i; - - // loop across multiple "..." and combine them, while keeping the source - buildValue[0] = yytext[0]; - for (j = i = 0; yytext[i] != ';' ;) - { - // build current "..." - for (; (buildValue[++j] = yytext[++i] = yyinput()) != '\"';) - if (yytext[i] == '\\') - buildValue[++j] = yytext[++i] = yyinput(); - --j; - // Look for termination or continuation - if (LOCptr->mbExpectValue) - for (; (yytext[++i] = yyinput()) != ';' && yytext[i] != '\"';) ; - else - break; - } - yytext[++i] = - buildValue[j+1] = '\0'; - LOCptr->setValue(yytext, &buildValue[1]); + char buildValue[8000]; + int j, i; + + // loop across multiple "..." and combine them, while keeping the source + buildValue[0] = yytext[0]; + for (j = i = 0; yytext[i] != ';' ;) { + // build current "..." + for (; (buildValue[++j] = yytext[++i] = yyinput()) != '\"';) + if (yytext[i] == '\\') + buildValue[++j] = yytext[++i] = yyinput(); + --j; + // Look for termination or continuation + if (LOCptr->mbExpectValue) + for (; (yytext[++i] = yyinput()) != ';' && yytext[i] != '\"';) ; + else + break; + } + yytext[++i] = + buildValue[j+1] = '\0'; + LOCptr->setValue(yytext, &buildValue[1]); } "{" { - LOCptr->startBlock(yytext); + LOCptr->startBlock(yytext); } "}"{SPACE}";"* { - LOCptr->stopBlock(yytext); + LOCptr->stopBlock(yytext); } {PRE}"<"{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setListItem(yytext, true); + yyless(strlen(yytext)-1); + LOCptr->setListItem(yytext, true); } ">"{SPACE}";"{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setListItem(yytext, false); + yyless(strlen(yytext)-1); + LOCptr->setListItem(yytext, false); } \n { - LOCptr->setNL(yytext, false); + LOCptr->setNL(yytext, false); } \\[\r]*\n { - LOCptr->setNL(yytext, true); + LOCptr->setNL(yytext, true); } "["{SPACE}en-US{SPACE}"]" { - LOCptr->setLang(yytext, true); + LOCptr->setLang(yytext, true); } "["{SPACE}{KEYID}{SPACE}"]" { - LOCptr->setLang(yytext, false); + LOCptr->setLang(yytext, false); } @@ -233,38 +229,38 @@ KEYID [a-zA-Z0-9_-]+ {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} { - yyless(strlen(yytext)-1); - LOCptr->setCmd(yytext); - BEGIN(CMD); + yyless(strlen(yytext)-1); + LOCptr->setCmd(yytext); + BEGIN(CMD); } <CMD>{IDENT} { - LOCptr->setName(yytext); - BEGIN(INITIAL); + LOCptr->setName(yytext); + BEGIN(INITIAL); } <CMD>[ \t=]+ { - IMPLptr->copySource(yytext); + IMPLptr->copySource(yytext); } <CMD>.|\n|\r { - yyless(0); - BEGIN(INITIAL); + yyless(0); + BEGIN(INITIAL); } {PRE}[hH][eE][lL][pP][iI][dD]{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setId(yytext, false); + yyless(strlen(yytext)-1); + LOCptr->setId(yytext, false); } {PRE}[sS][tT][yY][lL][eE][fF][aA][mM][iI][lL][yY]{SUF} | {PRE}[iI][dD][eE][nN][tT][iI][fF][iI][eE][rR]{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setId(yytext, true); + yyless(strlen(yytext)-1); + LOCptr->setId(yytext, true); } @@ -275,8 +271,8 @@ KEYID [a-zA-Z0-9_-]+ {PRE}[qQ][uU][iI][cC][kK][hH][eE][lL][pP][tT][eE][xX][tT]{SUFT} | {PRE}[tT][eE][xX][tT]{SUFT} | {PRE}[tT][iI][tT][lL][eE]{SUFT} { - yyless(strlen(yytext)-1); - LOCptr->setText(yytext); + yyless(strlen(yytext)-1); + LOCptr->setText(yytext); } @@ -284,40 +280,40 @@ KEYID [a-zA-Z0-9_-]+ {PRE}[fF][iI][lL][tT][eE][rR][lL][iI][sS][tT]{SUFT} | {PRE}[iI][tT][eE][mM][lL][iI][sS][tT]{SUFT} | {PRE}[sS][tT][yY][lL][eE][fF][aA][mM][iI][lL][yY][lL][iI][sS][tT]{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setList(yytext); + yyless(strlen(yytext)-1); + LOCptr->setList(yytext); } {PRE}[pP][aA][iI][rR][eE][dD][lL][iI][sS][tT]{SUFT} | {PRE}[sS][tT][rR][iI][nN][gG][lL][iI][sS][tT]{SUFT} { - yyless(strlen(yytext)-1); - LOCptr->setList(yytext); + yyless(strlen(yytext)-1); + LOCptr->setList(yytext); } {PRE}"#define"{SUF} { - yyless(strlen(yytext)-1); - LOCptr->setMacro(yytext); - BEGIN(CMD); + yyless(strlen(yytext)-1); + LOCptr->setMacro(yytext); + BEGIN(CMD); } {KEYID} { - LOCptr->setName(yytext); + LOCptr->setName(yytext); } . { - IMPLptr->copySource(yytext); + IMPLptr->copySource(yytext); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } %% @@ -326,7 +322,7 @@ KEYID [a-zA-Z0-9_-]+ void src_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexTree.l b/l10ntools/source/gLexTree.l index 095f681f9dcc..6c5b9089b62b 100644 --- a/l10ntools/source/gLexTree.l +++ b/l10ntools/source/gLexTree.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -61,7 +61,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) /* --- The following options are for future use (maybe) */ /* yyclass= --> subClass yyFlexLexer to allow own functions */ /* c++ --> generate C++ classes */ -%option prefix="tree" 8bit noyywrap never-interactive +%option prefix="tree" 8bit noyywrap never-interactive %array %p 24000 %e 1200 @@ -69,81 +69,79 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -/*********************** H E L P E R M A C R O S ***********************/ SP [ \t]* IDENT [\.a-zA-Z0-9_-]+ -/******************* R U L E S D E F I N I T I O N S *******************/ %% "\"" { - int j; + int j; - // build current "..." - for (j = -1; (yytext[++j] = yyinput()) != '\"';) - if (yytext[j] == '\\') - yytext[++j] = yyinput(); + // build current "..." + for (j = -1; (yytext[++j] = yyinput()) != '\"';) + if (yytext[j] == '\\') + yytext[++j] = yyinput(); - yytext[j+1] = '\0'; - LOCptr->setString(yytext); + yytext[j+1] = '\0'; + LOCptr->setString(yytext); } \> { - LOCptr->setState(yytext, convert_tree::STATE_TAG_VALUE, convert_tree::STATE_VAL_NONE); + LOCptr->setState(yytext, convert_tree::STATE_TAG_VALUE, convert_tree::STATE_VAL_NONE); } "id=" { - LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_ID); + LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_ID); } "application=" { - LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_APPL); + LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_APPL); } "title=" { - LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_TITLE); + LOCptr->setState(yytext, convert_tree::STATE_TAG_NONE, convert_tree::STATE_VAL_TITLE); } "<help_section " { - LOCptr->setState(yytext, convert_tree::STATE_TAG_HELPSEC, convert_tree::STATE_VAL_NONE); + LOCptr->setState(yytext, convert_tree::STATE_TAG_HELPSEC, convert_tree::STATE_VAL_NONE); } "<node " { - LOCptr->setState(yytext, convert_tree::STATE_TAG_NODE, convert_tree::STATE_VAL_NONE); + LOCptr->setState(yytext, convert_tree::STATE_TAG_NODE, convert_tree::STATE_VAL_NONE); } "<topic " { - LOCptr->setState(yytext, convert_tree::STATE_TAG_TOPIC, convert_tree::STATE_VAL_NONE); + LOCptr->setState(yytext, convert_tree::STATE_TAG_TOPIC, convert_tree::STATE_VAL_NONE); } "</topic" { - LOCptr->setValue(yytext); + LOCptr->setValue(yytext); } .|\n { - LOCptr->copySourceSpecial(yytext, 0); + LOCptr->copySourceSpecial(yytext, 0); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } @@ -154,7 +152,7 @@ IDENT [\.a-zA-Z0-9_-]+ void tree_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexUlf.l b/l10ntools/source/gLexUlf.l index 45bc99cf49ca..5980b3d8122f 100644 --- a/l10ntools/source/gLexUlf.l +++ b/l10ntools/source/gLexUlf.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -67,65 +67,62 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) %e 1200 %n 500 -/*********************** H E L P E R M A C R O S ***********************/ PRE ^[ \t]* SUF [ \t\r\n] SUFT [ \t\r\n\[] SPACE [ \t]* IDENT ([a-zA-Z0-9][ a-zA-Z0-9_\-\+\*]*[a-zA-Z0-9]|[0-9]) KEYID [a-zA-Z0-9_-]+ -/******************* R U L E S D E F I N I T I O N S *******************/ %% "/*" { - int i = 1; - for (;;) - { - while (yytext[i] != '*') - yytext[++i] = yyinput(); - yytext[++i] = yyinput(); - if (yytext[i] == '/') - break; - } - yytext[i+1] = '\0'; - - IMPLptr->copySource(yytext); + int i = 1; + for (;;) { + while (yytext[i] != '*') + yytext[++i] = yyinput(); + yytext[++i] = yyinput(); + if (yytext[i] == '/') + break; + } + yytext[i+1] = '\0'; + + IMPLptr->copySource(yytext); } "\"".* { - LOCptr->setValue(yytext); + LOCptr->setValue(yytext); } "["[^\]]+"]" { - LOCptr->setKey(yytext); + LOCptr->setKey(yytext); } "en-US"[ \t]*"=" { - LOCptr->setText(yytext, true); + LOCptr->setText(yytext, true); } [a-zA-Z_\-]+[ \t]*"=" { - LOCptr->setText(yytext, false); + LOCptr->setText(yytext, false); } - + .|\n { - IMPLptr->copySource(yytext); + IMPLptr->copySource(yytext); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } %% @@ -133,7 +130,7 @@ KEYID [a-zA-Z0-9_-]+ void ulf_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexXcs.l b/l10ntools/source/gLexXcs.l index 1b4a3b408a5e..cd4cec8532b0 100644 --- a/l10ntools/source/gLexXcs.l +++ b/l10ntools/source/gLexXcs.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -42,9 +42,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -68,31 +68,30 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -/******************* R U L E S D E F I N I T I O N S *******************/ %% "<prop"[^>]*> { - LOCptr->setKey(yytext); + LOCptr->setKey(yytext); } "</prop>" { - LOCptr->unsetKey(yytext); + LOCptr->unsetKey(yytext); } - + "<value"[^>]*> { - LOCptr->startCollectData(yytext); + LOCptr->startCollectData(yytext); } "</value>" { - LOCptr->stopCollectData(yytext); + LOCptr->stopCollectData(yytext); } .|\n { - IMPLptr->copySource(yytext); + IMPLptr->copySource(yytext); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } %% @@ -100,7 +99,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) void xcs_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexXcu.l b/l10ntools/source/gLexXcu.l index 9359e383871b..9b7a52063359 100644 --- a/l10ntools/source/gLexXcu.l +++ b/l10ntools/source/gLexXcu.l @@ -16,9 +16,9 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -69,32 +69,30 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -/*********************** H E L P E R M A C R O S ***********************/ SPACE [ \t]* NAME .*"oor:name="\"[^\"]+\"{SPACE} FIN [^/>]*">" -/******************* R U L E S D E F I N I T I O N S *******************/ %% "component-data" { - LOCptr->addLevel(); - IMPLptr->copySource(yytext, false); + LOCptr->addLevel(); + IMPLptr->copySource(yytext, false); } "<oor:component-data"{NAME} { - LOCptr->addLevel(); - LOCptr->pushKey(yytext); + LOCptr->addLevel(); + LOCptr->pushKey(yytext); } "<prop"{NAME}{FIN} | "<node"{NAME}{FIN} { - LOCptr->pushKey(yytext); + LOCptr->pushKey(yytext); } @@ -102,18 +100,18 @@ FIN [^/>]*">" "</oor:component-data" | "</prop" | "</node" { - LOCptr->popKey(yytext); + LOCptr->popKey(yytext); } "<value xml:lang="\"[^\"]+\"[^>]*">" { - LOCptr->startCollectData(yytext); + LOCptr->startCollectData(yytext); } "</value>" { - LOCptr->stopCollectData(yytext); + LOCptr->stopCollectData(yytext); } @@ -123,23 +121,23 @@ FIN [^/>]*">" ">" | "<" | """ { - LOCptr->copySpecial(yytext); + LOCptr->copySpecial(yytext); } ({SPACE}\n{SPACE})+ { - LOCptr->copyNL(yytext); + LOCptr->copyNL(yytext); } . { - IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData); + IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } @@ -150,7 +148,7 @@ FIN [^/>]*">" void xcu_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexXhp.l b/l10ntools/source/gLexXhp.l index 46b07643fb95..1bd5c0c2be23 100644 --- a/l10ntools/source/gLexXhp.l +++ b/l10ntools/source/gLexXhp.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -68,84 +68,82 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -/*********************** H E L P E R M A C R O S ***********************/ SP [ \t]* IDENT [\.a-zA-Z0-9_-]+ -/******************* R U L E S D E F I N I T I O N S *******************/ %% \" { - LOCptr->setString(yytext); + LOCptr->setString(yytext); } \< { - LOCptr->openTag(yytext); + LOCptr->openTag(yytext); } \/\> { - LOCptr->closeTagNOvalue(yytext); + LOCptr->closeTagNOvalue(yytext); } \> { - LOCptr->closeTag(yytext); + LOCptr->closeTag(yytext); } "id="{SP}\"{SP}{IDENT}{SP}\" { - LOCptr->setId(yytext); + LOCptr->setId(yytext); } "xml-lang="{SP}\"{SP}{IDENT}{SP}\" { - LOCptr->setLang(yytext); + LOCptr->setLang(yytext); } "oldref="{SP}\"{SP}{IDENT}{SP}\" { - LOCptr->setRef(yytext); + LOCptr->setRef(yytext); } "<title " | "<bookmark " | "<paragraph " { - LOCptr->openTransTag(yytext); + LOCptr->openTransTag(yytext); } "</title>" | "</bookmark>" | "</paragraph>" { - LOCptr->closeTransTag(yytext); + LOCptr->closeTransTag(yytext); } "<comment>" { - LOCptr->startComment(yytext); + LOCptr->startComment(yytext); } "</comment>" { - LOCptr->stopComment(yytext); + LOCptr->stopComment(yytext); } "localize=\"false\"" { - LOCptr->stopTransTag(yytext); + LOCptr->stopTransTag(yytext); } @@ -154,28 +152,28 @@ IDENT [\.a-zA-Z0-9_-]+ ">" | "<" | """ { - LOCptr->handleSpecial(yytext); + LOCptr->handleSpecial(yytext); } \r*\n\t* { - LOCptr->handleDataEnd(yytext); + LOCptr->handleDataEnd(yytext); } \\ { - LOCptr->duplicate(yytext); + LOCptr->duplicate(yytext); } .|\n { - LOCptr->copySourceSpecial(yytext, 0); + LOCptr->copySourceSpecial(yytext, 0); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } @@ -186,7 +184,7 @@ IDENT [\.a-zA-Z0-9_-]+ void xhp_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } diff --git a/l10ntools/source/gLexXrm.l b/l10ntools/source/gLexXrm.l index e8bbf23c3e16..140edf1e0000 100644 --- a/l10ntools/source/gLexXrm.l +++ b/l10ntools/source/gLexXrm.l @@ -18,7 +18,7 @@ */ -/*************** O V E R W R I T I N G F U N C T I O N S ***************/ + %top{ #include <string> #include <vector> @@ -43,9 +43,9 @@ %{ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } %} @@ -66,30 +66,28 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) %e 1200 %n 500 -/*********************** H E L P E R M A C R O S ***********************/ IDENT [a-zA-Z0-9_-]* NAME \"{IDENT}\" SP [ \t]* -/******************* R U L E S D E F I N I T I O N S *******************/ %% "id"{SP}"="{SP}{NAME} { - LOCptr->setId(yytext); + LOCptr->setId(yytext); } "lang"{SP}"="{SP}{NAME} { - LOCptr->setLang(yytext); + LOCptr->setLang(yytext); } "<title " | "<h"[0-9]" " | "<p " { - LOCptr->setTag(yytext); + LOCptr->setTag(yytext); } @@ -97,23 +95,23 @@ SP [ \t]* "</title>"[ \t\r]*[\n] | "</h"[0-9]">"[ \t\r]*[\n] | "</p>"[ \t\r]*[\n] { - LOCptr->stopCollectData(yytext); + LOCptr->stopCollectData(yytext); } ">" { - LOCptr->startCollectData(yytext); + LOCptr->startCollectData(yytext); } .|\n { - IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData); + IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData); - // Just to please compiler. - if (false) - REJECT; + // Just to please compiler. + if (false) + REJECT; } @@ -121,7 +119,7 @@ SP [ \t]* void xrm_dummyJustForCompiler() { - char *txt = NULL; -// yy_flex_strlen(txt); - yyunput(0, txt); + char *txt = NULL; + // yy_flex_strlen(txt); + yyunput(0, txt); } |