summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-08 22:07:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-08 22:07:23 +0100
commite960410674fc6761025ca1a63f88352a7049fbb5 (patch)
treee593107b2c9c699d53a2e01c34450829527b48b6 /l10ntools
parentaa11b4c86e4b41be542623b7d98a3fb8e5d30745 (diff)
Various more l10ntools clean up
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/export.hxx22
-rw-r--r--l10ntools/inc/gsicheck.hxx20
-rw-r--r--l10ntools/inc/xmlparse.hxx24
-rw-r--r--l10ntools/source/cfgmerge.cxx154
-rw-r--r--l10ntools/source/export.cxx553
-rw-r--r--l10ntools/source/export2.cxx49
-rw-r--r--l10ntools/source/gsicheck.cxx17
-rw-r--r--l10ntools/source/helpex.cxx12
-rw-r--r--l10ntools/source/helpmerge.cxx12
-rw-r--r--l10ntools/source/lngmerge.cxx5
-rw-r--r--l10ntools/source/localize.cxx50
-rw-r--r--l10ntools/source/srciter.cxx5
-rw-r--r--l10ntools/source/srclex.l70
-rw-r--r--l10ntools/source/xmlparse.cxx53
-rw-r--r--l10ntools/source/xrmmerge.cxx2
15 files changed, 351 insertions, 697 deletions
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 52efd998376e..d8d2acdd0e2c 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -31,6 +31,7 @@
#include "sal/config.h"
+#include <cstddef>
#include <fstream>
#include <comphelper/string.hxx>
@@ -40,7 +41,6 @@
#include <l10ntools/directory.hxx>
#endif
-#include <tools/fsys.hxx>
#include <osl/file.hxx>
#include <osl/file.h>
@@ -87,11 +87,11 @@ class ExportList
{
private:
ExportListBase maList;
- sal_uLong nSourceLanguageListEntryCount;
+ std::size_t nSourceLanguageListEntryCount;
public:
ExportList() { nSourceLanguageListEntryCount = 0; }
- sal_uLong GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; }
+ std::size_t GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; }
void NewSourceLanguageListEntry() { nSourceLanguageListEntryCount++; }
size_t size() const { return maList.size(); }
void push_back( ExportListEntry* item ) { maList.push_back( item ); }
@@ -272,15 +272,14 @@ private:
sal_Bool bDefine; // cur. res. in a define?
sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend
- sal_uLong nLevel; // res. recursiv? how deep?
+ std::size_t nLevel; // res. recursiv? how deep?
sal_uInt16 nList; // cur. res. is String- or FilterList
rtl::OString m_sListLang;
- sal_uLong nListIndex;
- sal_uLong nListLevel;
+ std::size_t nListIndex;
+ std::size_t nListLevel;
bool bSkipFile;
rtl::OString sProject;
rtl::OString sRoot;
- sal_Bool bEnableExport;
sal_Bool bMergeMode;
rtl::OString sMergeSrc;
rtl::OString sLastListLine;
@@ -319,9 +318,7 @@ public:
static rtl::OString getRandomName(const rtl::OString& rPrefix, const rtl::OString & sPostfix);
static void getCurrentDir( std::string& dir );
- static rtl::OString GetTimeStamp();
static rtl::OString GetNativeFile( rtl::OString const & sSource );
- static DirEntry GetTempFile();
static void DumpExportList(const rtl::OString& rListName,
ExportList& aList);
@@ -360,11 +357,8 @@ private:
void CutComment( rtl::OString &rText );
public:
- Export(const rtl::OString &rOutput, sal_Bool bWrite,
- const rtl::OString &rPrj, const rtl::OString &rPrjRoot, const rtl::OString& rFile);
- Export(const rtl::OString &rOutput, sal_Bool bWrite,
- const rtl::OString &rPrj, const rtl::OString &rPrjRoot,
- const rtl::OString &rMergeSource, const rtl::OString& rFile );
+ Export(const rtl::OString &rOutput);
+ Export(const rtl::OString &rMergeSource, const rtl::OString &rOutput);
~Export();
void Init();
diff --git a/l10ntools/inc/gsicheck.hxx b/l10ntools/inc/gsicheck.hxx
index 46b3709032f8..467925e46767 100644
--- a/l10ntools/inc/gsicheck.hxx
+++ b/l10ntools/inc/gsicheck.hxx
@@ -29,9 +29,13 @@
#ifndef _GSICHECK_HXX_
#define _GSICHECK_HXX_
-#include "tagtest.hxx"
+#include "sal/config.h"
+
+#include <cstddef>
#include <vector>
+#include "tagtest.hxx"
+
//
// class GSILine
//
@@ -42,7 +46,7 @@ class GSILine
private:
ParserMessageList aMessages;
LineFormat aFormat;
- sal_uLong nLineNumber;
+ std::size_t nLineNumber;
rtl::OString aUniqId;
rtl::OString aLineType;
@@ -59,9 +63,9 @@ private:
public:
rtl::OString data_;
- GSILine( const rtl::OString &rLine, sal_uLong nLine );
+ GSILine( const rtl::OString &rLine, std::size_t nLine );
LineFormat GetLineFormat() const { return aFormat; }
- sal_uLong GetLineNumber() const { return nLineNumber; }
+ std::size_t GetLineNumber() const { return nLineNumber; }
rtl::OString const GetUniqId() const { return aUniqId; }
rtl::OString const GetLineType() const { return aLineType; }
@@ -90,7 +94,7 @@ public:
// class GSIBlock
//
-typedef ::std::vector< GSILine* > GSIBlock_Impl;
+typedef std::vector< GSILine* > GSIBlock_Impl;
class LazyStream;
@@ -116,11 +120,11 @@ private:
public:
GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowSusp );
~GSIBlock();
- void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() );
- void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() );
+ void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId = rtl::OString() );
+ void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId = rtl::OString() );
void InsertLine( GSILine* pLine, const rtl::OString &rSourceLang);
void SetReferenceLine( GSILine* pLine );
- sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags );
+ sal_Bool CheckSyntax( std::size_t nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags );
void WriteError( LazyStream &aErrOut, sal_Bool bRequireSourceLine );
void WriteCorrect( LazyStream &aOkOut, sal_Bool bRequireSourceLine );
diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx
index 94b5e918f863..af6b6d8b8ea5 100644
--- a/l10ntools/inc/xmlparse.hxx
+++ b/l10ntools/inc/xmlparse.hxx
@@ -29,16 +29,19 @@
#ifndef BOOTSTRP_XMLPARSE_HXX
#define BOOTSTRP_XMLPARSE_HXX
+#include "sal/config.h"
+
+#include <cstddef>
+#include <vector>
+
#include <signal.h>
#include <expat.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
+#include "boost/unordered_map.hpp"
#include "export.hxx"
#include "xmlutil.hxx"
-#include <fstream>
-#include <iostream>
-
class XMLParentNode;
class XMLElement;
@@ -46,11 +49,6 @@ class XMLElement;
using namespace ::rtl;
using namespace std;
-#include <boost/unordered_map.hpp>
-#include <deque> /* std::deque*/
-#include <iterator> /* std::iterator*/
-#include <list> /* std::list*/
-#include <vector> /* std::vector*/
#define XML_NODE_TYPE_FILE 0x001
#define XML_NODE_TYPE_ELEMENT 0x002
#define XML_NODE_TYPE_DATA 0x003
@@ -90,7 +88,7 @@ public:
}
};
-typedef ::std::vector< XMLAttribute* > XMLAttributeList;
+typedef std::vector< XMLAttribute* > XMLAttributeList;
//-------------------------------------------------------------------------
@@ -128,7 +126,7 @@ public:
virtual ~XMLChildNode(){};
};
-typedef ::std::vector< XMLChildNode* > XMLChildNodeList;
+typedef std::vector< XMLChildNode* > XMLChildNodeList;
//-------------------------------------------------------------------------
@@ -212,7 +210,7 @@ public:
void Extract( XMLFile *pCur = NULL );
XMLHashMap* GetStrings(){return XMLStrings;}
- sal_Bool Write( rtl::OString const &rFilename );
+ void Write( rtl::OString const &rFilename );
sal_Bool Write( ofstream &rStream , XMLNode *pCur = NULL );
bool CheckExportStatus( XMLParentNode *pCur = NULL );// , int pos = 0 );
@@ -447,8 +445,8 @@ public:
*/
struct XMLError {
XML_Error eCode; // the error code
- sal_uLong nLine; // error line number
- sal_uLong nColumn; // error column number
+ std::size_t nLine; // error line number
+ std::size_t nColumn; // error column number
rtl::OUString sMessage; // readable error message
};
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index 9503a3fc30d4..60872d8ade6d 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -26,6 +26,7 @@
*
************************************************************************/
+#include "common.hxx"
#include "sal/config.h"
#include <cstdio>
@@ -33,11 +34,10 @@
#include <cstring>
#include "boost/scoped_ptr.hpp"
-#include "osl/process.h"
-#include "rtl/uri.hxx"
#include <comphelper/string.hxx>
+#include "common.hxx"
#include "helper.hxx"
#include "export.hxx"
#include "cfgmerge.hxx"
@@ -63,55 +63,51 @@ boost::scoped_ptr< CfgParser > parser;
}
void handleArguments(int argc, char ** argv) {
- enum State {
- STATE_NONE, STATE_INPUT, STATE_OUTPUT, STATE_PRJ, STATE_ROOT,
- STATE_MERGESRC, STATE_LANGUAGES };
- State state = STATE_NONE;
- for (int i = 1; i < argc; ++i) {
- if (std::strcmp(argv[i], "-i") == 0) {
- state = STATE_INPUT;
- } else if (std::strcmp(argv[i], "-o") == 0) {
- state = STATE_OUTPUT;
- } else if (std::strcmp(argv[i], "-p") == 0) {
- state = STATE_PRJ;
- } else if (std::strcmp(argv[i], "-r") == 0) {
- state = STATE_ROOT;
- } else if (std::strcmp(argv[i], "-m") == 0) {
- state = STATE_MERGESRC;
- } else if (std::strcmp(argv[i], "-e") == 0) {
- state = STATE_NONE;
+ for (int i = 1; i != argc; ++i) {
+ if (std::strcmp(argv[i], "-e") == 0) {
global::errorLog = false;
- } else if (std::strcmp(argv[i], "-l") == 0) {
- state = STATE_LANGUAGES;
- } else {
- switch (state) {
- default:
+ } else if (std::strcmp(argv[i], "-i") == 0) {
+ if (++i == argc) {
global::inputPathname = 0; // no valid command line
- goto done;
- case STATE_INPUT:
- global::inputPathname = argv[i];
break;
- case STATE_OUTPUT:
- global::outputPathname = argv[i];
+ }
+ global::inputPathname = argv[i];
+ } else if (std::strcmp(argv[i], "-l") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_PRJ:
- global::prj = argv[i];
+ }
+ Export::sLanguages = argv[i];
+ } else if (std::strcmp(argv[i], "-m") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_ROOT:
- global::prjRoot = argv[i];
+ }
+ global::mergeSrc = argv[i];
+ global::mergeMode = true;
+ } else if (std::strcmp(argv[i], "-o") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_MERGESRC:
- global::mergeSrc = argv[i];
- global::mergeMode = true;
+ }
+ global::outputPathname = argv[i];
+ } else if (std::strcmp(argv[i], "-p") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_LANGUAGES:
- Export::sLanguages = argv[i];
+ }
+ global::prj = argv[i];
+ } else if (std::strcmp(argv[i], "-r") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
}
- state = STATE_NONE;
+ global::prjRoot = argv[i];
+ } else {
+ global::inputPathname = 0; // no valid command line
+ break;
}
}
-done:
if (global::inputPathname == 0 || global::outputPathname == 0) {
std::fprintf(
stderr,
@@ -145,85 +141,16 @@ FILE * init(int argc, char ** argv) {
std::exit(EXIT_FAILURE);
}
- // Skip UTF-8 BOM:
- unsigned char buf[3];
- if (std::fread(buf, 1, 3, pFile) != 3 ||
- buf[0] != 0xEF || buf[1] != 0xBB || buf[2] != 0xBF)
- {
- std::rewind(pFile);
- }
-
if (global::mergeMode) {
global::parser.reset(
new CfgMerge(
global::mergeSrc, global::outputPathname,
global::inputPathname));
} else {
- rtl::OUString cwd;
- if (osl_getProcessWorkingDir(&cwd.pData) != osl_Process_E_None) {
- std::fprintf(stderr, "Error: Cannot determine cwd\n");
- std::exit(EXIT_FAILURE);
- }
- rtl::OUString full;
- if (!rtl_convertStringToUString(
- &full.pData, global::inputPathname,
- rtl_str_getLength(global::inputPathname),
- osl_getThreadTextEncoding(),
- (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
- {
- std::fprintf(
- stderr, "Error: Cannot convert input pathname to UTF-16\n");
- std::exit(EXIT_FAILURE);
- }
- if (osl::FileBase::getAbsoluteFileURL(cwd, full, full)
- != osl::FileBase::E_None)
- {
- std::fprintf(
- stderr,
- "Error: Cannot convert input pathname to absolute URL\n");
- std::exit(EXIT_FAILURE);
- }
- if (global::prjRoot == 0) {
- std::fprintf(stderr, "Error: No project root argument\n");
- std::exit(EXIT_FAILURE);
- }
- rtl::OUString base;
- if (!rtl_convertStringToUString(
- &base.pData, global::prjRoot,
- rtl_str_getLength(global::prjRoot),
- osl_getThreadTextEncoding(),
- (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
- {
- std::fprintf(
- stderr, "Error: Cannot convert project root to UTF-16\n");
- std::exit(EXIT_FAILURE);
- }
- base = rtl::Uri::convertRelToAbs(full, base);
- if (full.getLength() <= base.getLength() || base.isEmpty()
- || base[base.getLength() - 1] != '/'
- || full[base.getLength() - 1] != '/')
- {
- std::fprintf(
- stderr, "Error: Cannot extract suffix from input pathname\n");
- std::exit(EXIT_FAILURE);
- }
- full = full.copy(base.getLength()).replace('/', '\\');
- rtl::OString suffix;
- if (!full.convertToString(
- &suffix, osl_getThreadTextEncoding(),
- (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
- | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
- {
- std::fprintf(
- stderr, "Error: Cannot convert suffix from UTF-16\n");
- std::exit(EXIT_FAILURE);
- }
global::parser.reset(
- new CfgExport(global::outputPathname, global::prj, suffix));
+ new CfgExport(
+ global::outputPathname, global::prj,
+ common::pathnameToken(global::inputPathname, global::prjRoot)));
}
return pFile;
@@ -572,8 +499,6 @@ void CfgExport::WorkOnRessourceEnd()
sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
- rtl::OString sTimeStamp( Export::GetTimeStamp());
-
for (size_t n = 0; n < aLanguages.size(); n++)
{
rtl::OString sCur = aLanguages[ n ];
@@ -594,7 +519,6 @@ void CfgExport::WorkOnRessourceEnd()
sOutput += "\t";
sOutput += sText; sOutput += "\t\t\t\t";
- sOutput += sTimeStamp;
pOutputStream << sOutput.getStr() << '\n';
}
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 238184aefcfa..566dd8792567 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -28,16 +28,17 @@
#include "sal/config.h"
+#include <cstddef>
#include <cstring>
+#include "boost/scoped_ptr.hpp"
#include <stdio.h>
#include <stdlib.h>
-#include <tools/fsys.hxx>
+#include "common.hxx"
#include "export.hxx"
#include "helper.hxx"
#include "tokens.h"
#include <iostream>
-#include <vector>
#include <rtl/strbuf.hxx>
#include <comphelper/string.hxx>
@@ -47,249 +48,129 @@ using comphelper::string::getTokenCount;
extern "C" { int yyerror( const char * ); }
extern "C" { int YYWarning( const char * ); }
-Export *pExport = 0L;
-
-// defines to parse command line
-#define STATE_NON 0x0001
-#define STATE_INPUT 0x0002
-#define STATE_OUTPUT 0x0003
-#define STATE_PRJ 0x0004
-#define STATE_ROOT 0x0005
-#define STATE_MERGESRC 0x0006
-#define STATE_ERRORLOG 0x0007
-#define STATE_BREAKHELP 0x0008
-#define STATE_UNMERGE 0x0009
-#define STATE_LANGUAGES 0X000A
-
-// set of global variables
-typedef ::std::vector< rtl::OString > FileList;
-FileList aInputFileList;
-sal_Bool bEnableExport;
-sal_Bool bMergeMode;
-sal_Bool bErrorLog;
-sal_Bool bBreakWhenHelpText;
-sal_Bool bUnmerge;
-sal_Bool bUTF8;
-rtl::OString sPrj;
-rtl::OString sPrjRoot;
-rtl::OString sActFileName;
-rtl::OString sOutputFile;
-rtl::OString sMergeSrc;
-rtl::OString sFile;
-MergeDataFile *pMergeDataFile;
+namespace {
-extern "C" {
-// the whole interface to lexer is in this extern "C" section
+rtl::OString sActFileName; //TODO
+MergeDataFile * pMergeDataFile = 0; //TODO
+namespace global {
-/*****************************************************************************/
-extern char *GetOutputFile( int argc, char* argv[])
-/*****************************************************************************/
-{
- bEnableExport = sal_False;
- bMergeMode = sal_False;
- bErrorLog = sal_True;
- bBreakWhenHelpText = sal_False;
- bUnmerge = sal_False;
- bUTF8 = sal_True;
- sPrj = "";
- sPrjRoot = "";
- sActFileName = "";
- Export::sLanguages = "";
- Export::sForcedLanguages = "";
- sal_uInt16 nState = STATE_NON;
- sal_Bool bInput = sal_False;
-
- // parse command line
- for( int i = 1; i < argc; i++ ) {
- rtl::OString sSwitch( argv[ i ] );
-
- if (sSwitch == "-i" || sSwitch == "-I" ) {
- nState = STATE_INPUT; // next tokens specifies source files
- }
- else if (sSwitch == "-o" || sSwitch == "-O" ) {
- nState = STATE_OUTPUT; // next token specifies the dest file
- }
- else if (sSwitch == "-p" || sSwitch == "-P" ) {
- nState = STATE_PRJ; // next token specifies the cur. project
- }
+bool mergeMode = false;
+bool errorLog = true;
+char const * prj = 0;
+char const * prjRoot = 0;
+char const * inputPathname = 0;
+char const * outputPathname = 0;
+char const * mergeSrc;
+boost::scoped_ptr< Export > exporter;
- else if (sSwitch == "-r" || sSwitch == "-R" ) {
- nState = STATE_ROOT; // next token specifies path to project root
- }
- else if (sSwitch == "-m" || sSwitch == "-M" ) {
- nState = STATE_MERGESRC; // next token specifies the merge database
- }
- else if (sSwitch == "-e" || sSwitch == "-E" ) {
- nState = STATE_ERRORLOG;
- bErrorLog = sal_False;
- }
- else if (sSwitch == "-b" || sSwitch == "-B" ) {
- nState = STATE_BREAKHELP;
- bBreakWhenHelpText = sal_True;
- }
- else if (sSwitch == "-u" || sSwitch == "-U" ) {
- nState = STATE_UNMERGE;
- bUnmerge = sal_True;
- bMergeMode = sal_True;
- }
- else if ( sSwitch == "-l" || sSwitch == "-L" ) {
- nState = STATE_LANGUAGES;
- }
- else {
- switch ( nState ) {
- case STATE_NON: {
- return NULL; // no valid command line
- }
- case STATE_INPUT: {
- aInputFileList.push_back( argv[ i ] );
- bInput = sal_True; // min. one source file found
- }
+}
+
+void handleArguments(int argc, char ** argv) {
+ for (int i = 1; i != argc; ++i) {
+ if (std::strcmp(argv[i], "-e") == 0) {
+ global::errorLog = false;
+ } else if (std::strcmp(argv[i], "-i") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_OUTPUT: {
- sOutputFile = rtl::OString(argv[i]); // the dest. file
- }
+ }
+ global::inputPathname = argv[i];
+ } else if (std::strcmp(argv[i], "-l") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_PRJ: {
- sPrj = rtl::OString(argv[i]);
- }
+ }
+ Export::sLanguages = argv[i];
+ } else if (std::strcmp(argv[i], "-m") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_ROOT: {
- sPrjRoot = rtl::OString(argv[i]); // path to project root
- }
+ }
+ global::mergeSrc = argv[i];
+ global::mergeMode = true;
+ } else if (std::strcmp(argv[i], "-o") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_MERGESRC: {
- sMergeSrc = rtl::OString(argv[i]);
- bMergeMode = sal_True; // activate merge mode, cause merge database found
- }
+ }
+ global::outputPathname = argv[i];
+ } else if (std::strcmp(argv[i], "-p") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
- case STATE_LANGUAGES: {
- Export::sLanguages = rtl::OString(argv[i]);
- }
+ }
+ global::prj = argv[i];
+ } else if (std::strcmp(argv[i], "-r") == 0) {
+ if (++i == argc) {
+ global::inputPathname = 0; // no valid command line
break;
}
+ global::prjRoot = argv[i];
+ } else {
+ global::inputPathname = 0; // no valid command line
+ break;
}
}
- if( bUnmerge )
- sMergeSrc = rtl::OString();
- if ( bInput ) {
- // command line is valid
- bEnableExport = sal_True;
- char *pReturn = new char[ sOutputFile.getLength() + 1 ];
- std::strcpy( pReturn, sOutputFile.getStr()); // #100211# - checked
- return pReturn;
+ if (global::inputPathname == 0 || global::outputPathname == 0) {
+ std::fprintf(
+ stderr,
+ ("Syntax: transex3 [-p Prj] [-r PrjRoot] -i FileIn -o FileOut"
+ " [-m DataBase] [-e] [-l l1,l2,...]\n"
+ " Prj: Project\n"
+ " PrjRoot: Path to project root (../.. etc.)\n"
+ " FileIn: Source files (*.src)\n"
+ " FileOut: Destination file (*.*)\n"
+ " DataBase: Mergedata (*.sdf)\n"
+ " -e: Disable writing errorlog\n"
+ " -l: Restrict the handled languages; l1, l2, ... are elements of"
+ " (de, en-US, ...)\n"));
+ std::exit(EXIT_FAILURE);
}
-
- // command line is not valid
- return NULL;
+ Export::InitLanguages();
}
-/*****************************************************************************/
-int InitExport( char *pOutput , char* pFilename )
-/*****************************************************************************/
-{
- // instanciate Export
- rtl::OString sOutput( pOutput );
- rtl::OString sFilename( pFilename );
- if ( bMergeMode && !bUnmerge )
- {
- // merge mode enabled, so read database
- pExport = new Export(sOutput, bEnableExport, sPrj, sPrjRoot,
- sMergeSrc , sFilename );
- }
- else
- {
- // no merge mode, only export
- pExport = new Export(sOutput, bEnableExport, sPrj, sPrjRoot,
- sFilename );
- }
- return 1;
}
-/*****************************************************************************/
-int EndExport()
-/*****************************************************************************/
-{
- delete pExport;
- return 1;
-}
+extern "C" {
-extern const char* getFilename()
-{
- return aInputFileList[0].getStr();
-}
-/*****************************************************************************/
-extern FILE *GetNextFile()
-/*****************************************************************************/
-{
- // look for next valid filename in input file list
- while ( !aInputFileList.empty() )
- {
- rtl::OString sFileName(aInputFileList[0]);
+FILE * init(int argc, char ** argv) {
+ handleArguments(argc, argv);
- rtl::OString sOrigFile( sFileName );
+ FILE * pFile = std::fopen(global::inputPathname, "r");
+ if (pFile == 0) {
+ std::fprintf(
+ stderr, "Error: Cannot open file \"%s\"\n",
+ global::inputPathname);
+ std::exit(EXIT_FAILURE);
+ }
- sFileName = Export::GetNativeFile( sFileName );
- aInputFileList.erase( aInputFileList.begin() );
+ if (global::mergeMode) {
+ global::exporter.reset(
+ new Export(global::mergeSrc, global::outputPathname));
+ } else {
+ sActFileName =
+ common::pathnameToken(global::inputPathname, global::prjRoot);
+ global::exporter.reset(new Export(global::outputPathname));
+ }
- if ( sFileName.isEmpty() ) {
- fprintf( stderr, "ERROR: Could not precompile File %s\n",
- sOrigFile.getStr());
- return GetNextFile();
- }
+ global::exporter->Init();
- //TODO: explict BOM handling?
-
- // able to open file?
- FILE *pFile = fopen( sFileName.getStr(), "r" );
- if ( !pFile )
- fprintf( stderr, "Error: Could not open File %s\n",
- sFileName.getStr());
- else {
- // this is a valid file which can be opened, so
- // create path to project root
- DirEntry aEntry(rtl::OStringToOUString(sOrigFile,
- RTL_TEXTENCODING_ASCII_US));
- aEntry.ToAbs();
- rtl::OString sFullEntry(rtl::OUStringToOString(aEntry.GetFull(),
- RTL_TEXTENCODING_ASCII_US));
- aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
- aEntry += DirEntry( sPrjRoot );
- rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(),
- RTL_TEXTENCODING_ASCII_US));
-
- // create file name, beginnig with project root
- // (e.g.: source\ui\src\menue.src)
- sActFileName = sFullEntry.copy(sPrjEntry.getLength() + 1);
-
-
- sActFileName = sActFileName.replace('/', '\\');
- sFile = sActFileName;
-
- if ( pExport ) {
- // create instance of class export
- pExport->Init();
- }
- // return the valid file handle
- return pFile;
- }
- }
- // this means the file could not be opened
- return NULL;
+ return pFile;
}
int Parse( int nTyp, const char *pTokenText ){
- pExport->Execute( nTyp , pTokenText );
+ global::exporter->Execute( nTyp , pTokenText );
return 1;
}
void Close(){
- pExport->pParseQueue->Close();
+ global::exporter->pParseQueue->Close();
}
int WorkOnTokenSet( int nTyp, char *pTokenText )
{
- pExport->pParseQueue->Push( QueueEntry( nTyp , rtl::OString(pTokenText) ) );
+ global::exporter->pParseQueue->Push( QueueEntry( nTyp , rtl::OString(pTokenText) ) );
return 1;
}
@@ -301,7 +182,7 @@ int SetError()
/*****************************************************************************/
{
// set error at global instance of class Export
- pExport->SetError();
+ global::exporter->SetError();
return 1;
}
}
@@ -312,7 +193,7 @@ int GetError()
/*****************************************************************************/
{
// get error at global instance of class Export
- if ( pExport->GetError())
+ if (global::exporter->GetError())
return 1;
return sal_False;
}
@@ -379,9 +260,7 @@ sal_Bool ResData::SetId( const rtl::OString& rId, sal_uInt16 nLevel )
// class Export
//
-Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
- const rtl::OString &rPrj, const rtl::OString &rPrjRoot,
- const rtl::OString& rFile)
+Export::Export(const rtl::OString &rOutput)
:
pWordTransformer( NULL ),
bDefine( sal_False ),
@@ -391,37 +270,28 @@ Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
nListIndex( 0 ),
nListLevel( 0 ),
bSkipFile( false ),
- sProject( sPrj ),
- sRoot( sPrjRoot ),
- bEnableExport( bWrite ),
- bMergeMode( bUnmerge ),
+ sProject( global::prj ),
+ sRoot( global::prjRoot ),
+ bMergeMode( false ),
bError( sal_False ),
bReadOver( sal_False ),
bDontWriteOutput( sal_False ),
- sFilename( rFile )
+ sFilename( global::inputPathname )
{
pParseQueue = new ParserQueue( *this );
- (void) rPrj;
- (void) rPrjRoot;
- (void) rFile;
if( !isInitialized ) InitLanguages();
// used when export is enabled
// open output stream
- if ( bEnableExport ) {
- aOutput.open(
- rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
- if (!aOutput.is_open()) {
- fprintf(stderr, "ERROR : Can't open file %s\n", rOutput.getStr());
- exit ( -1 );
- }
+ aOutput.open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
+ if (!aOutput.is_open()) {
+ fprintf(stderr, "ERROR : Can't open file %s\n", rOutput.getStr());
+ exit ( -1 );
}
}
-Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
- const rtl::OString &rPrj, const rtl::OString &rPrjRoot,
- const rtl::OString &rMergeSource, const rtl::OString& rFile)
+Export::Export(const rtl::OString &rMergeSource, const rtl::OString &rOutput)
:
pWordTransformer( NULL ),
bDefine( sal_False ),
@@ -431,29 +301,21 @@ Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
nListIndex( 0 ),
nListLevel( 0 ),
bSkipFile( false ),
- sProject( sPrj ),
- sRoot( sPrjRoot ),
- bEnableExport( bWrite ),
+ sProject( global::prj ),
+ sRoot( global::prjRoot ),
bMergeMode( sal_True ),
sMergeSrc( rMergeSource ),
bError( sal_False ),
bReadOver( sal_False ),
bDontWriteOutput( sal_False ),
- sFilename( rFile )
+ sFilename( global::inputPathname )
{
- (void) rPrj;
- (void) rPrjRoot;
- (void) rFile;
pParseQueue = new ParserQueue( *this );
if( !isInitialized ) InitLanguages( bMergeMode );
// used when merge is enabled
// open output stream
- if ( bEnableExport ) {
- aOutput.open(
- rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
- }
-
+ aOutput.open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
}
/*****************************************************************************/
@@ -479,16 +341,14 @@ Export::~Export()
{
if( pParseQueue )
delete pParseQueue;
- // close output stream
- if ( bEnableExport )
- aOutput.close();
+ aOutput.close();
for ( size_t i = 0, n = aResStack.size(); i < n; ++i )
delete aResStack[ i ];
aResStack.clear();
- if ( bMergeMode && !bUnmerge ) {
+ if ( bMergeMode ) {
if ( !pMergeDataFile )
- pMergeDataFile = new MergeDataFile(sMergeSrc, sFile, bErrorLog);
+ pMergeDataFile = new MergeDataFile(sMergeSrc, global::inputPathname, global::errorLog);
delete pMergeDataFile;
}
@@ -937,11 +797,6 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "HELPTEXT" ) {
SetChildWithText();
pResData->bHelpText = sal_True;
- if ( bBreakWhenHelpText )
- {
- YYWarning("\"HelpText\" found in source");
- SetError();
- }
if ( bMergeMode )
PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, sLangIndex, pResData );
else
@@ -1131,9 +986,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
return sal_True;
}
- if ( bUnmerge )
- return sal_True;
-
// mandatory to export: en-US
if (( !pResData->sText[ SOURCE_LANGUAGE ].isEmpty())
@@ -1157,7 +1009,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
rtl::OString sXQHText;
rtl::OString sXTitle;
- rtl::OString sTimeStamp(Export::GetTimeStamp());
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
@@ -1198,28 +1049,25 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
else
sXText = pResData->sText[ sCur ];
- if ( bEnableExport ) {
- rtl::OString sOutput( sProject ); sOutput += "\t";
- if ( !sRoot.isEmpty())
- sOutput += sActFileName;
- sOutput += "\t0\t";
- sOutput += pResData->sResTyp; sOutput += "\t";
- sOutput += sGID; sOutput += "\t";
- sOutput += sLID; sOutput += "\t";
- sOutput += pResData->sHelpId; sOutput += "\t";
- sOutput += pResData->sPForm; sOutput += "\t";
- sOutput += rtl::OString::valueOf(static_cast<sal_Int64>(pResData->nWidth)); sOutput += "\t";
- sOutput += sCur; sOutput += "\t";
-
-
- sOutput += sXText; sOutput += "\t";
- sOutput += sXHText; sOutput += "\t";
- sOutput += sXQHText; sOutput+= "\t";
- sOutput += sXTitle; sOutput += "\t";
- sOutput += sTimeStamp;
-
- aOutput << sOutput.getStr() << '\n';
- }
+ rtl::OString sOutput( sProject ); sOutput += "\t";
+ if ( !sRoot.isEmpty())
+ sOutput += sActFileName;
+ sOutput += "\t0\t";
+ sOutput += pResData->sResTyp; sOutput += "\t";
+ sOutput += sGID; sOutput += "\t";
+ sOutput += sLID; sOutput += "\t";
+ sOutput += pResData->sHelpId; sOutput += "\t";
+ sOutput += pResData->sPForm; sOutput += "\t";
+ sOutput += rtl::OString::valueOf(static_cast<sal_Int64>(pResData->nWidth)); sOutput += "\t";
+ sOutput += sCur; sOutput += "\t";
+
+
+ sOutput += sXText; sOutput += "\t";
+ sOutput += sXHText; sOutput += "\t";
+ sOutput += sXQHText; sOutput+= "\t";
+ sOutput += sXTitle; sOutput += "\t";
+
+ aOutput << sOutput.getStr() << '\n';
if ( bCreateNew ) {
pResData->sText[ sCur ] = "";
@@ -1302,7 +1150,6 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
sGID = comphelper::string::stripEnd(sGID, '.');
}
- rtl::OString sTimeStamp(Export::GetTimeStamp());
rtl::OString sCur;
for ( size_t i = 0; pExportList != NULL && i < pExportList->size(); i++ )
{
@@ -1314,42 +1161,37 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
sCur = aLanguages[ n ];
if (!(*pEntry)[ SOURCE_LANGUAGE ].isEmpty())
{
- if ( bEnableExport )
- {
- rtl::OString sText((*pEntry)[ SOURCE_LANGUAGE ] );
-
- // Strip PairList Line String
- if (rTyp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("pairedlist")))
- {
- sLID = GetPairedListID( sText );
- if (!(*pEntry)[ sCur ].isEmpty())
- sText = (*pEntry)[ sCur ];
- sText = GetPairedListString( sText );
- }
- else
- {
- sText = StripList( (*pEntry)[ sCur ] );
- if( sText == "\\\"" )
- sText = "\"";
- }
+ rtl::OString sText((*pEntry)[ SOURCE_LANGUAGE ] );
- rtl::OStringBuffer sOutput(sProject);
- sOutput.append('\t');
- if ( !sRoot.isEmpty())
- sOutput.append(sActFileName);
- sOutput.append("\t0\t");
- sOutput.append(rTyp).append('\t');
- sOutput.append(sGID).append('\t');
- sOutput.append(sLID).append("\t\t");
- sOutput.append(pResData->sPForm).append("\t0\t");
- sOutput.append(sCur).append('\t');
+ // Strip PairList Line String
+ if (rTyp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("pairedlist")))
+ {
+ sLID = GetPairedListID( sText );
+ if (!(*pEntry)[ sCur ].isEmpty())
+ sText = (*pEntry)[ sCur ];
+ sText = GetPairedListString( sText );
+ }
+ else
+ {
+ sText = StripList( (*pEntry)[ sCur ] );
+ if( sText == "\\\"" )
+ sText = "\"";
+ }
- sOutput.append(sText).append("\t\t\t\t");
- sOutput.append(sTimeStamp);
+ rtl::OStringBuffer sOutput(sProject);
+ sOutput.append('\t');
+ if ( !sRoot.isEmpty())
+ sOutput.append(sActFileName);
+ sOutput.append("\t0\t");
+ sOutput.append(rTyp).append('\t');
+ sOutput.append(sGID).append('\t');
+ sOutput.append(sLID).append("\t\t");
+ sOutput.append(pResData->sPForm).append("\t0\t");
+ sOutput.append(sCur).append('\t');
- aOutput << sOutput.makeStringAndClear().getStr() << '\n';
+ sOutput.append(sText).append("\t\t\t\t");
- }
+ aOutput << sOutput.makeStringAndClear().getStr() << '\n';
}
}
if ( bCreateNew )
@@ -1547,48 +1389,44 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
void Export::WriteToMerged(const rtl::OString &rText , bool bSDFContent)
{
- if ( !bDontWriteOutput || !bUnmerge )
- {
- rtl::OString sText(rText);
- while (helper::searchAndReplace(&sText, " \n", "\n") != -1) {}
- if (pParseQueue->bNextIsM && bSDFContent && sText.getLength() > 2) {
- for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
- if (sText[n] == '\n' && sText[n - 1] != '\\') {
- sText = sText.replaceAt(n++, 0, "\\");
- }
+ rtl::OString sText(rText);
+ while (helper::searchAndReplace(&sText, " \n", "\n") != -1) {}
+ if (pParseQueue->bNextIsM && bSDFContent && sText.getLength() > 2) {
+ for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
+ if (sText[n] == '\n' && sText[n - 1] != '\\') {
+ sText = sText.replaceAt(n++, 0, "\\");
}
- } else if (pParseQueue->bLastWasM && sText.getLength() > 2) {
- for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
- if (sText[n] == '\n' && sText[n - 1] != '\\') {
- sText = sText.replaceAt(n++, 0, "\\");
- }
- if (sText[n] == '\n') {
- pParseQueue->bMflag = true;
- }
+ }
+ } else if (pParseQueue->bLastWasM && sText.getLength() > 2) {
+ for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
+ if (sText[n] == '\n' && sText[n - 1] != '\\') {
+ sText = sText.replaceAt(n++, 0, "\\");
}
- } else if (pParseQueue->bCurrentIsM && bSDFContent
- && sText.getLength() > 2)
- {
- for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
- if (sText[n] == '\n' && sText[n - 1] != '\\') {
- sText = sText.replaceAt(n++, 0, "\\");
- pParseQueue->bMflag = true;
- }
+ if (sText[n] == '\n') {
+ pParseQueue->bMflag = true;
}
- } else if (pParseQueue->bMflag) {
- for (sal_Int32 n = 1; n < sText.getLength(); ++n) {
- if (sText[n] == '\n' && sText[n - 1] != '\\') {
- sText = sText.replaceAt(n++, 0, "\\");
- }
+ }
+ } else if (pParseQueue->bCurrentIsM && bSDFContent && sText.getLength() > 2)
+ {
+ for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
+ if (sText[n] == '\n' && sText[n - 1] != '\\') {
+ sText = sText.replaceAt(n++, 0, "\\");
+ pParseQueue->bMflag = true;
}
- } for (sal_Int32 i = 0; i < sText.getLength(); ++i) {
- if (sText[i] == '\n') {
- aOutput << '\n';
- } else {
- char cChar = sText[i];
- aOutput << cChar;
+ }
+ } else if (pParseQueue->bMflag) {
+ for (sal_Int32 n = 1; n < sText.getLength(); ++n) {
+ if (sText[n] == '\n' && sText[n - 1] != '\\') {
+ sText = sText.replaceAt(n++, 0, "\\");
}
}
+ } for (sal_Int32 i = 0; i < sText.getLength(); ++i) {
+ if (sText[i] == '\n') {
+ aOutput << '\n';
+ } else {
+ char cChar = sText[i];
+ aOutput << cChar;
+ }
}
}
@@ -1678,9 +1516,6 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
case LIST_PAIRED:
case LIST_ITEM :
{
- if ( bUnmerge )
- return sal_True;
-
ExportList *pList = NULL;
switch ( nTyp ) {
case LIST_STRING : {
@@ -1800,7 +1635,7 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
// search for merge data
if ( !pMergeDataFile ){
- pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
+ pMergeDataFile = new MergeDataFile( sMergeSrc, global::inputPathname, global::errorLog );
// Init Languages
if( Export::sLanguages.equalsIgnoreAsciiCase("ALL") )
@@ -1901,7 +1736,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
/*****************************************************************************/
{
if ( !pMergeDataFile ){
- pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
+ pMergeDataFile = new MergeDataFile( sMergeSrc, global::inputPathname, global::errorLog );
// Init Languages
if (Export::sLanguages.equalsIgnoreAsciiCase("ALL"))
@@ -1961,8 +1796,8 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pResData->sId = "1";
PFormEntrys *pEntrys;
- sal_uLong nLIndex = 0;
- sal_uLong nMaxIndex = 0;
+ std::size_t nLIndex = 0;
+ std::size_t nMaxIndex = 0;
if ( pList )
nMaxIndex = pList->GetSourceLanguageListEntryCount();
pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
@@ -2120,7 +1955,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
nListIndex++;
- sal_uLong nMaxIndex = 0;
+ std::size_t nMaxIndex = 0;
if ( pList )
nMaxIndex = pList->GetSourceLanguageListEntryCount();
rtl::OString sLine;
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index cd61d92385bf..12d1a5a74e58 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -337,17 +337,6 @@ void Export::InitForcedLanguages( bool bMergeMode ){
while ( nIndex >= 0 );
}
-rtl::OString Export::GetTimeStamp()
-{
-// return "xx.xx.xx";
- char buf[20];
- Time aTime( Time::SYSTEM );
-
- snprintf(buf, sizeof(buf), "%8d %02d:%02d:%02d", int(Date( Date::SYSTEM).GetDate()),
- int(aTime.GetHour()), int(aTime.GetMin()), int(aTime.GetSec()));
- return rtl::OString(buf);
-}
-
/*****************************************************************************/
rtl::OString Export::GetNativeFile( rtl::OString const & sSource )
/*****************************************************************************/
@@ -413,42 +402,4 @@ rtl::OString Export::getRandomName(const rtl::OString& rPrefix, const rtl::OStri
return sRandStr.makeStringAndClear();
}
-/*****************************************************************************/
-DirEntry Export::GetTempFile()
-/*****************************************************************************/
-{
- rtl::OUString* sTempFilename = new rtl::OUString();
-
- // Create a temp file
- int nRC = osl::FileBase::createTempFile( 0 , 0 , sTempFilename );
- if( nRC ) printf(" osl::FileBase::createTempFile RC = %d",nRC);
-
- rtl::OUString strTmp( *sTempFilename );
-
- INetURLObject::DecodeMechanism eMechanism = INetURLObject::DECODE_TO_IURI;
- rtl::OUString sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
- rtl::OString sTmp(rtl::OUStringToOString(sDecodedStr , RTL_TEXTENCODING_UTF8));
-
-#if defined(WNT)
- sTmp = comphelper::string::replace(sTmp,
- rtl::OString(RTL_CONSTASCII_STRINGPARAM("file:///")),
- rtl::OString());
- sTmp = sTmp.replace('/', '\\');
-#else
- // Set file permission to 644
- const sal_uInt64 nPerm = osl_File_Attribute_OwnRead | osl_File_Attribute_OwnWrite |
- osl_File_Attribute_GrpRead | osl_File_Attribute_OthRead ;
-
- nRC = osl::File::setAttributes( *sTempFilename , nPerm );
- if( nRC ) printf(" osl::File::setAttributes RC = %d",nRC);
-
- sTmp = comphelper::string::replace(sTmp,
- rtl::OString(RTL_CONSTASCII_STRINGPARAM("file://")),
- rtl::OString());
-#endif
- DirEntry aDirEntry( sTmp );
- delete sTempFilename;
- return aDirEntry;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index aa6f0de125dd..9fec6bf425e0 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -28,6 +28,7 @@
#include "sal/config.h"
+#include <cstddef>
#include <fstream>
#include <string>
@@ -47,7 +48,7 @@ using comphelper::string::getTokenCount;
/*****************************************************************************/
void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
- rtl::OString const & aContext, sal_Bool bPrintContext, sal_uLong nLine, rtl::OString aUniqueId = rtl::OString() )
+ rtl::OString const & aContext, sal_Bool bPrintContext, std::size_t nLine, rtl::OString aUniqueId = rtl::OString() )
/*****************************************************************************/
{
fprintf( stdout, "%s %s, Line %lu", aType.getStr(), aPrefix.getStr(), nLine );
@@ -62,7 +63,7 @@ void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::O
/*****************************************************************************/
void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
- rtl::OString const & aContext, sal_Bool bPrintContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() )
+ rtl::OString const & aContext, sal_Bool bPrintContext, std::size_t nLine, rtl::OString const & aUniqueId = rtl::OString() )
/*****************************************************************************/
{
PrintMessage( "Error:", aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
@@ -136,7 +137,7 @@ void LazyStream::LazyOpen()
//
/*****************************************************************************/
-GSILine::GSILine( const rtl::OString &rLine, sal_uLong nLine )
+GSILine::GSILine( const rtl::OString &rLine, std::size_t nLine )
/*****************************************************************************/
: nLineNumber( nLine )
, bOK( sal_True )
@@ -302,7 +303,7 @@ void GSIBlock::SetReferenceLine( GSILine* pLine )
/*****************************************************************************/
void GSIBlock::PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
- rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId )
+ rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
::PrintMessage( aType, aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
@@ -310,7 +311,7 @@ void GSIBlock::PrintMessage( rtl::OString const & aType, rtl::OString const & aM
/*****************************************************************************/
void GSIBlock::PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
- rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId )
+ rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
PrintMessage( "Error:", aMsg, aPrefix, aContext, nLine, aUniqueId );
@@ -455,7 +456,7 @@ sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource )
/*****************************************************************************/
-sal_Bool GSIBlock::CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags )
+sal_Bool GSIBlock::CheckSyntax( std::size_t nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags )
/*****************************************************************************/
{
static LingTest aTester;
@@ -912,12 +913,12 @@ int _cdecl main( int argc, char *argv[] )
GSILine* pReferenceLine = NULL;
- sal_uLong nReferenceLine = 0;
+ std::size_t nReferenceLine = 0;
GSILine* pGSILine = NULL;
rtl::OString aOldId("No Valid ID"); // just set to something which can never be an ID
GSIBlock *pBlock = NULL;
- sal_uLong nLine = 0;
+ std::size_t nLine = 0;
while (!aGSI.eof())
{
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index 02f091603e3c..d966dc648273 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -26,6 +26,10 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <iostream>
+
#include <stdio.h>
#include <stdlib.h>
@@ -216,8 +220,8 @@ int _cdecl main( int argc, char *argv[] )
ifstream aFStream( sInputFile.copy( 1 ).getStr() , ios::in );
if( !aFStream ){
- cerr << "ERROR: - helpex - Can't open the file " << sInputFile.copy( 1 ).getStr() << "\n";
- exit(-1);
+ std::cerr << "ERROR: - helpex - Can't open the file " << sInputFile.copy( 1 ).getStr() << "\n";
+ std::exit(EXIT_FAILURE);
}
vector<rtl::OString> filelist;
@@ -244,7 +248,7 @@ int _cdecl main( int argc, char *argv[] )
for( vector<rtl::OString>::iterator pos = filelist.begin() ; pos != filelist.end() ; ++pos )
{
sHelpFile = *pos;
- cout << ".";cout.flush();
+ std::cout << ".\n";
HelpParser aParser( sHelpFile , bUTF8 , true );
hasNoError = aParser.Merge( sSDFFile , sOutputFileX , sOutputFileY , true , aLanguages , aMergeDataFile , bCreateDir );
@@ -252,7 +256,7 @@ int _cdecl main( int argc, char *argv[] )
}
}
} else
- cerr << "helpex ERROR: Wrong input parameters!\n";
+ std::cerr << "helpex ERROR: Wrong input parameters!\n";
if( hasNoError )
return 0;
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index a66ae391853c..e0c6f1356625 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -127,10 +127,6 @@ bool HelpParser::CreateSDF(
LangHashMap* pElem;
XMLElement* pXMLElement = NULL;
- OUString sOUTimeStamp(
- rtl::OStringToOUString(
- Export::GetTimeStamp(), RTL_TEXTENCODING_ASCII_US));
-
OUStringBuffer sBuffer;
const OUString sOUPrj( rPrj_in.getStr() , rPrj_in.getLength() , RTL_TEXTENCODING_ASCII_US );
const OUString sOUActFileName(sActFileName.getStr() , sActFileName.getLength() , RTL_TEXTENCODING_ASCII_US );
@@ -180,7 +176,6 @@ bool HelpParser::CreateSDF(
sBuffer.append('\t');
sBuffer.append( data );
sBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\t\t\t\t"));
- sBuffer.append( sOUTimeStamp );
rtl::OString sOut(rtl::OUStringToOString(sBuffer.makeStringAndClear().getStr() , RTL_TEXTENCODING_UTF8));
if( !data.isEmpty() )
aSDFStream << sOut.getStr() << '\n';
@@ -344,12 +339,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
sTempFile = Export::getRandomName(sPath, INPATH);
sTempFileCopy = Export::getRandomName(sPath, INPATH);
// Write in the temp file
- bool hasNoError = file->Write ( sTempFile );
- if( !hasNoError )
- {
- cerr << "ERROR: file->Write failed\n";
- return false;
- }
+ file->Write ( sTempFile );
DirEntry aTmp( sTempFile );
DirEntry aTmp2( sTempFileCopy );
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 4619bf3aff7b..059a046f4c76 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -28,6 +28,7 @@
#include "sal/config.h"
+#include <cstddef>
#include <fstream>
#include <string>
@@ -148,7 +149,6 @@ void LngParser::WriteSDF(std::ofstream &aSDFStream,
sal_Bool bExport = true;
if ( bExport ) {
- rtl::OString sTimeStamp( Export::GetTimeStamp());
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
@@ -164,7 +164,6 @@ void LngParser::WriteSDF(std::ofstream &aSDFStream,
sOutput += rID; sOutput += "\t\t\t\t0\t";
sOutput += sCur; sOutput += "\t";
sOutput += sAct; sOutput += "\t\t\t\t";
- sOutput += sTimeStamp;
aSDFStream << sOutput.getStr() << '\n';
}
}
@@ -237,7 +236,7 @@ sal_Bool LngParser::Merge(
while ( nPos < pLines->size()) {
OStringHashMap Text;
rtl::OString sID( sGroup );
- sal_uLong nLastLangPos = 0;
+ std::size_t nLastLangPos = 0;
ResData *pResData = new ResData( "", sID , sSource );
pResData->sResTyp = "LngText";
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 725e683ea33a..cdb4ae186e14 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -28,6 +28,7 @@
#include "sal/config.h"
+#include <cstddef>
#include <fstream>
#include "srciter.hxx"
@@ -38,11 +39,52 @@
#include <iostream>
#include "tools/errcode.hxx"
#include "tools/fsys.hxx"
+#include "tools/urlobj.hxx"
#include "helper.hxx"
using namespace std;
+namespace {
+
+DirEntry GetTempFile()
+{
+ rtl::OUString* sTempFilename = new rtl::OUString();
+
+ // Create a temp file
+ int nRC = osl::FileBase::createTempFile( 0 , 0 , sTempFilename );
+ if( nRC ) printf(" osl::FileBase::createTempFile RC = %d",nRC);
+
+ rtl::OUString strTmp( *sTempFilename );
+
+ INetURLObject::DecodeMechanism eMechanism = INetURLObject::DECODE_TO_IURI;
+ rtl::OUString sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
+ rtl::OString sTmp(rtl::OUStringToOString(sDecodedStr , RTL_TEXTENCODING_UTF8));
+
+#if defined(WNT)
+ sTmp = comphelper::string::replace(sTmp,
+ rtl::OString(RTL_CONSTASCII_STRINGPARAM("file:///")),
+ rtl::OString());
+ sTmp = sTmp.replace('/', '\\');
+#else
+ // Set file permission to 644
+ const sal_uInt64 nPerm = osl_File_Attribute_OwnRead | osl_File_Attribute_OwnWrite |
+ osl_File_Attribute_GrpRead | osl_File_Attribute_OthRead ;
+
+ nRC = osl::File::setAttributes( *sTempFilename , nPerm );
+ if( nRC ) printf(" osl::File::setAttributes RC = %d",nRC);
+
+ sTmp = comphelper::string::replace(sTmp,
+ rtl::OString(RTL_CONSTASCII_STRINGPARAM("file://")),
+ rtl::OString());
+#endif
+ DirEntry aDirEntry( sTmp );
+ delete sTempFilename;
+ return aDirEntry;
+}
+
+}
+
namespace transex3
{
@@ -326,7 +368,7 @@ void SourceTreeLocalizer::WorkOnFile(
{
rtl::OString sRoot( GetProjectRootRel());
- DirEntry aTemp( Export::GetTempFile());
+ DirEntry aTemp(GetTempFile());
rtl::OString sTempFile(rtl::OUStringToOString(aTemp.GetFull(), RTL_TEXTENCODING_ASCII_US));
rtl::OString sDel;
@@ -395,7 +437,7 @@ void SourceTreeLocalizer::WorkOnFile(
sal_Bool SourceTreeLocalizer::CheckNegativeList( const rtl::OString &rFileName )
/*****************************************************************************/
{
- sal_uLong nIndex = 0;
+ std::size_t nIndex = 0;
sal_Bool bReturn = sal_True;
rtl::OString sDelimiter(rtl::OUStringToOString(
@@ -426,7 +468,7 @@ sal_Bool SourceTreeLocalizer::CheckNegativeList( const rtl::OString &rFileName )
sal_Bool SourceTreeLocalizer::CheckPositiveList( const rtl::OString &rFileName )
/*****************************************************************************/
{
- sal_uLong nIndex = 0;
+ std::size_t nIndex = 0;
sal_Bool bReturn = sal_False;
rtl::OString sDelimiter(rtl::OUStringToOString(
@@ -489,7 +531,7 @@ void SourceTreeLocalizer::WorkOnFileType(
void SourceTreeLocalizer::WorkOnDirectory(const rtl::OString &rDirectory)
{
//printf("Working on Directory %s\n",rDirectory.getStr());
- sal_uLong nIndex = 0;
+ std::size_t nIndex = 0;
rtl::OString sExtension( ExeTable[ nIndex ][ 0 ] );
rtl::OString sExecutable( ExeTable[ nIndex ][ 1 ] );
rtl::OString sParameter( ExeTable[ nIndex ][ 2 ] );
diff --git a/l10ntools/source/srciter.cxx b/l10ntools/source/srciter.cxx
index 9c18fd5fe837..85475cae6f6b 100644
--- a/l10ntools/source/srciter.cxx
+++ b/l10ntools/source/srciter.cxx
@@ -26,6 +26,9 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <cstddef>
#include "srciter.hxx"
#include <stdio.h>
@@ -104,7 +107,7 @@ void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory )
aDirectory.readDirectory();
OnExecuteDirectory( aDirectory.getFullName() );
if ( aDirectory.getSubDirectories().size() )
- for ( sal_uLong i=0;i < aDirectory.getSubDirectories().size();i++ )
+ for ( std::size_t i=0;i < aDirectory.getSubDirectories().size();i++ )
ExecuteDirectory( aDirectory.getSubDirectories()[ i ] );
}
}
diff --git a/l10ntools/source/srclex.l b/l10ntools/source/srclex.l
index d357d5c084f9..d65f33c24dd3 100644
--- a/l10ntools/source/srclex.l
+++ b/l10ntools/source/srclex.l
@@ -33,16 +33,10 @@
/* external functions (C++ code, declared as extren "C" */
extern int WorkOnTokenSet( int, char* );
-extern int InitExport( char * , char * );
-extern int Parse( int nTyp, char *pTokenText );
-extern int EndExport();
+extern FILE * init(int, char **);
extern int SetError();
extern int GetError();
-extern char *GetOutputFile( int argc, char* argv[]);
-extern FILE *GetNextFile();
-extern int isQuiet();
extern void Close();
-extern char* getFilename();
/* forwards */
void YYWarning();
@@ -216,15 +210,6 @@ void YYWarning();
int yywrap(void)
/*****************************************************************************/
{
- FILE *pFile;
- pFile = GetNextFile();
- if ( pFile ) {
- yyin = pFile;
- yylineno = 0;
- return 0;
- }
-
- /* end of input reached */
return 1;
}
@@ -245,54 +230,13 @@ void yyerror( char *s )
SetError();
}
-/*****************************************************************************/
int
-#ifdef WNT
+#if defined WNT
_cdecl
#endif
-main( int argc, char* argv[])
-/*****************************************************************************/
-{
- /* error level */
- int nRetValue = 0;
- char *pOutput;
- FILE *pFile;
-
- pOutput = GetOutputFile( argc, argv );
-
- if ( !pOutput ) {
- fprintf( stdout, "Syntax:TRANSEX[-p Prj][-r PrjRoot]-i FileIn...[-o FileOut][-m DataBase][-e][-b][-u][-L l1,l2,...]\n" );
- fprintf( stdout, " Prj: Project\n" );
- fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" );
- fprintf( stdout, " FileIn: Source files (*.src)\n" );
- fprintf( stdout, " FileOut: Destination file (*.*)\n" );
- fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
- fprintf( stdout, " -QQ: quiet output\n" );
- fprintf( stdout, " -e: Disable writing errorlog\n" );
- fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
- fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
- fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
- fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
- return 1;
- }
-
- InitExport( pOutput , getFilename() );
- pFile = GetNextFile();
- if ( !pFile )
- return 1;
-
- yyin = pFile;
-
- /* create global instance of class Export */
-
- /* start parser */
- yylex();
- Close();
-
- /* get error info. and end export */
- nRetValue = GetError();
- EndExport();
-
- /* return error level */
- return nRetValue;
+main(int argc, char ** argv) {
+ yyin = init(argc, argv);
+ yylex();
+ Close();
+ return GetError();
}
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index d6010960c2ff..c21d9e526132 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -239,51 +239,18 @@ sal_uInt16 XMLFile::GetNodeType()
return XML_NODE_TYPE_FILE;
}
-/*****************************************************************************/
-sal_Bool XMLFile::Write( rtl::OString const &aFilename )
-/*****************************************************************************/
+void XMLFile::Write( rtl::OString const &aFilename )
{
-
- if ( !aFilename.isEmpty()) {
- // retry harder if there is a NFS problem,
- for( int x = 1 ; x < 3 ; x++ ){ // this looks strange...yes!
- ofstream aFStream( aFilename.getStr() , ios::out | ios::trunc );
-
- if( !aFStream ) // From time to time the stream can not be opened the first time on NFS volumes,
- { // I wasn't able to track this down. I think this is an NFS issue .....
- TimeValue aTime;
- aTime.Seconds = 3;
- aTime.Nanosec = 0;
-
- osl::Thread::wait( aTime );
- }
- else
- {
- // write out
- Write( aFStream );
- aFStream.close();
-
- // check!
- DirEntry aTarget( aFilename );
- FileStat aFileStat( aTarget );
-
- if( aFileStat.GetSize() < 1 )
- {
- //retry
- aTarget.Kill();
- }
- else
- {
- //everything ok!
- return true;
- }
- }
- }
- cerr << "ERROR: - helpex - Can't create file " << aFilename.getStr() << "\nPossible reason: Disk full ? Mounted NFS volume broken ? Wrong permissions ?\n";
- exit( -1 );
+ std::ofstream s(
+ aFilename.getStr(), std::ios_base::out | std::ios_base::trunc);
+ if (!s.is_open()) {
+ std::cerr
+ << "Error: helpex cannot create file " << aFilename.getStr()
+ << '\n';
+ std::exit(EXIT_FAILURE);
}
- cerr << "ERROR: - helpex - Empty file name\n";
- exit( -1 );
+ Write(s);
+ s.close();
}
void XMLFile::WriteString( ofstream &rStream, const rtl::OUString &sString )
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 1ad773dea085..00e8993c6e15 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -553,7 +553,6 @@ void XRMResExport::EndOfText(
{
if ( pResData )
{
- rtl::OString sTimeStamp( Export::GetTimeStamp());
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ )
{
@@ -578,7 +577,6 @@ void XRMResExport::EndOfText(
sOutput += sAct;
sOutput += "\t\t\t\t";
- sOutput += sTimeStamp;
sOutput = sOutput.replace('\0', '_');
if( sAct.getLength() > 1 )