summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--l10ntools/inc/helpmerge.hxx2
-rw-r--r--l10ntools/inc/xmlparse.hxx3
-rw-r--r--l10ntools/prj/build.lst2
-rwxr-xr-xl10ntools/scripts/propex4
-rw-r--r--l10ntools/source/export.cxx126
-rw-r--r--l10ntools/source/export2.cxx1
-rw-r--r--l10ntools/source/helper.hxx12
-rw-r--r--l10ntools/source/helpmerge.cxx163
-rw-r--r--l10ntools/source/makefile.mk5
-rw-r--r--l10ntools/source/srclex.l3
-rw-r--r--l10ntools/source/xmlparse.cxx5
-rw-r--r--l10ntools/source/xrmmerge.cxx62
12 files changed, 139 insertions, 249 deletions
diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx
index 6a347464cb62..23523c727ece 100644
--- a/l10ntools/inc/helpmerge.hxx
+++ b/l10ntools/inc/helpmerge.hxx
@@ -70,8 +70,6 @@ public:
, const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir );
private:
- static rtl::OString makeAbsolutePath(const rtl::OString& sHelpFile , const rtl::OString& rRoot_in);
-
rtl::OString GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY );
bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const rtl::OString& sLanguage , rtl::OString const & sPath );
diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx
index af6b6d8b8ea5..cd9bc2ba50fd 100644
--- a/l10ntools/inc/xmlparse.hxx
+++ b/l10ntools/inc/xmlparse.hxx
@@ -222,7 +222,6 @@ public:
/// returns file name
rtl::OUString GetName() { return sFileName; }
void SetName( const rtl::OUString &rFilename ) { sFileName = rFilename; }
- void SetFullName( const rtl::OUString &rFullFilename ) { sFullName = rFullFilename; }
const std::vector<rtl::OString> getOrder(){ return order; }
protected:
@@ -233,7 +232,6 @@ protected:
// DATA
rtl::OUString sFileName;
- rtl::OUString sFullName;
const rtl::OString ID, OLDREF, XML_LANG;
@@ -487,7 +485,6 @@ public:
/// parse a file, returns NULL on criticall errors
XMLFile *Execute(
- const rtl::OUString &rFullFileName,
const rtl::OUString &rFileName, // the file name
XMLFile *pXMLFileIn // the XMLFile
);
diff --git a/l10ntools/prj/build.lst b/l10ntools/prj/build.lst
index 3cce7a3eee5f..ed919a5ec078 100644
--- a/l10ntools/prj/build.lst
+++ b/l10ntools/prj/build.lst
@@ -1,4 +1,4 @@
-tr l10ntools : tools LIBXSLT:libxslt BERKELEYDB:berkeleydb LUCENE:lucene NULL
+tr l10ntools : BERKELEYDB:berkeleydb EXPAT:expat LIBXSLT:libxslt LUCENE:lucene sal NULL
tr l10ntools usr1 - all tr_mkout NULL
tr l10ntools\inc nmake - all tr_inc NULL
tr l10ntools\source nmake - all tr_src tr_inc NULL
diff --git a/l10ntools/scripts/propex b/l10ntools/scripts/propex
index d7135cfc0aeb..6a402a213ae5 100755
--- a/l10ntools/scripts/propex
+++ b/l10ntools/scripts/propex
@@ -32,6 +32,7 @@ eval 'exec perl -S $0 ${1+"$@"}'
#
use strict;
+use File::Basename;
use Getopt::Std;
use Cwd;
@@ -40,7 +41,8 @@ getopts("ep:r:i:o:l:", \%options);
unless ( $options{i} =~ m/en_US/ ) {exit 0;}
-my $file = substr ( Cwd::abs_path($options{i}), length(Cwd::abs_path($options{r})) + 1 );
+my ($unsued1, $dir, $unused2) = File::Basename::fileparse($options{i});
+my $file = substr ( Cwd::abs_path($options{i}), length(Cwd::abs_path($dir . $options{r})) + 1 );
$file =~ s|/|\\|g;
open (INFILE, "<$options{i}") || die "propex: cannot open input file: $options{i}";
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 746785a3b202..c57591b3553e 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -31,8 +31,6 @@
#include <cstddef>
#include <cstring>
-#include "comphelper/string.hxx"
-
#include "boost/scoped_ptr.hpp"
#include <stdio.h>
#include <stdlib.h>
@@ -46,9 +44,6 @@
extern "C" { int yyerror( const char * ); }
extern "C" { int YYWarning( const char * ); }
-using comphelper::string::getToken;
-using comphelper::string::getTokenCount;
-
namespace {
rtl::OString sActFileName; //TODO
@@ -166,6 +161,8 @@ int Parse( int nTyp, const char *pTokenText ){
}
void Close(){
global::exporter->pParseQueue->Close();
+ global::exporter.reset();
+ // avoid nontrivial Export dtor being executed during exit
}
int WorkOnTokenSet( int nTyp, char *pTokenText )
@@ -639,8 +636,9 @@ int Export::Execute( int nToken, const char * pToken )
nListIndex = 0;
nListLevel = 0;
}
- if ( (sToken.indexOf( '{' ) != -1) &&
- ( getTokenCount(sToken, '{') > getTokenCount(sToken, '}') ))
+ if (sToken.indexOf( '{' ) != -1
+ && (helper::countOccurrences(sToken, '{')
+ > helper::countOccurrences(sToken, '}')))
{
Parse( LEVELUP, "" );
}
@@ -650,14 +648,16 @@ int Export::Execute( int nToken, const char * pToken )
case LISTASSIGNMENT:
{
bDontWriteOutput = sal_False;
- rtl::OString sTmpToken(
- comphelper::string::remove(sToken, ' ').toAsciiLowerCase());
+ rtl::OString sTmpToken(sToken);
+ helper::searchAndReplaceAll(&sTmpToken, " ", rtl::OString());
+ sTmpToken = sTmpToken.toAsciiLowerCase();
sal_Int32 nPos = sTmpToken.indexOf("[en-us]=");
if (nPos != -1) {
rtl::OString sKey(sTmpToken.copy(0 , nPos));
- sKey = comphelper::string::remove(sKey, ' ');
- sKey = comphelper::string::remove(sKey, '\t');
- rtl::OString sValue = getToken(sToken, 1, '=');
+ helper::searchAndReplaceAll(&sKey, " ", rtl::OString());
+ helper::searchAndReplaceAll(&sKey, "\t", rtl::OString());
+ sal_Int32 n = 0;
+ rtl::OString sValue = sToken.getToken(1, '=', n);
CleanValue( sValue );
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("STRINGLIST")))
@@ -705,9 +705,10 @@ int Export::Execute( int nToken, const char * pToken )
else
{
// new res. is a String- or FilterList
- rtl::OString sKey = getToken(sToken, 0, '[');
- sKey = comphelper::string::remove(sKey, ' ');
- sKey = comphelper::string::remove(sKey, '\t');
+ sal_Int32 n = 0;
+ rtl::OString sKey = sToken.getToken(0, '[', n);
+ helper::searchAndReplaceAll(&sKey, " ", rtl::OString());
+ helper::searchAndReplaceAll(&sKey, "\t", rtl::OString());
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("STRINGLIST")))
nList = LIST_STRING;
@@ -720,7 +721,7 @@ int Export::Execute( int nToken, const char * pToken )
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("UIENTRIES")))
nList = LIST_UIENTRIES;
if ( nList ) {
- rtl::OString sLang = getToken(getToken(sToken, 1, '['), 0, ']');
+ rtl::OString sLang = sToken.getToken(0, ']', n);
CleanValue( sLang );
m_sListLang = sLang;
nListIndex = 0;
@@ -735,8 +736,9 @@ int Export::Execute( int nToken, const char * pToken )
// this is an entry for a String- or FilterList
if ( nList ) {
SetChildWithText();
- rtl::OString sEntry(getToken(sToken, 1, '\"'));
- if ( getTokenCount(sToken, '\"') > 3 )
+ sal_Int32 n = 0;
+ rtl::OString sEntry(sToken.getToken(1, '"', n));
+ if ( helper::countOccurrences(sToken, '"') > 2 )
sEntry += "\"";
if ( sEntry == "\\\"" )
sEntry = "\"";
@@ -756,14 +758,23 @@ int Export::Execute( int nToken, const char * pToken )
CutComment( sToken );
// this is a text line!!!
- rtl::OString sKey = getToken(getToken(sToken, 0, '='), 0, '[');
- sKey = comphelper::string::remove(sKey, ' ');
- sKey = comphelper::string::remove(sKey, '\t');
+ sal_Int32 n = 0;
+ rtl::OString t(sToken.getToken(0, '=', n));
+ n = 0;
+ rtl::OString sKey = t.getToken(0, '[', n);
+ helper::searchAndReplaceAll(&sKey, " ", rtl::OString());
+ helper::searchAndReplaceAll(&sKey, "\t", rtl::OString());
rtl::OString sText( GetText( sToken, nToken ));
rtl::OString sLang;
- if ( getToken(sToken, 0, '=').indexOf('[') != -1 )
+ n = 0;
+ if ( sToken.getToken(0, '=', n).indexOf('[') != -1 )
{
- sLang = getToken(getToken(getToken(sToken, 0, '='), 1, '['), 0, ']');
+ n = 0;
+ t = sToken.getToken(0, '=', n);
+ n = 0;
+ t = t.getToken(1, '[', n);
+ n = 0;
+ sLang = t.getToken(0, ']', n);
CleanValue( sLang );
}
rtl::OString sLangIndex = sLang;
@@ -864,24 +875,30 @@ int Export::Execute( int nToken, const char * pToken )
break;
case APPFONTMAPPING:
{
- using comphelper::string::replace;
-
bDontWriteOutput = sal_False;
// this is a AppfontMapping, so look if its a definition
// of field size
- rtl::OString sKey = getToken(sToken, 0, '=');
- sKey = comphelper::string::remove(sKey, ' ');
- sKey = comphelper::string::remove(sKey, '\t');
- rtl::OString sMapping = getToken(sToken, 1, '=');
- sMapping = getToken(sMapping, 1, '(');
- sMapping = getToken(sMapping, 0, ')');
- sMapping = replace(sMapping, rtl::OString(' '), rtl::OString());
- sMapping = replace(sMapping, rtl::OString('\t'), rtl::OString());
+ sal_Int32 n = 0;
+ rtl::OString sKey = sToken.getToken(0, '=', n);
+ helper::searchAndReplaceAll(&sKey, " ", rtl::OString());
+ helper::searchAndReplaceAll(&sKey, "\t", rtl::OString());
+ rtl::OString sMapping = sToken.getToken(0, '=', n);
+ n = 0;
+ sMapping = sMapping.getToken(1, '(', n);
+ n = 0;
+ sMapping = sMapping.getToken(0, ')', n);
+ helper::searchAndReplaceAll(
+ &sMapping, rtl::OString(' '), rtl::OString());
+ helper::searchAndReplaceAll(
+ &sMapping, rtl::OString('\t'), rtl::OString());
sKey = sKey.toAsciiUpperCase();
- if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("SIZE")))
- pResData->nWidth = getToken(sMapping, 0, ',').toInt32();
- else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("POSSIZE")))
- pResData->nWidth = getToken(sMapping, 2, ',').toInt32();
+ if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("SIZE"))) {
+ n = 0;
+ pResData->nWidth = sMapping.getToken(0, ',', n).toInt32();
+ } else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("POSSIZE"))) {
+ n = 0;
+ pResData->nWidth = sMapping.getToken(2, ',', n).toInt32();
+ }
}
break;
case RSCDEFINELEND:
@@ -892,14 +909,15 @@ int Export::Execute( int nToken, const char * pToken )
while( helper::searchAndReplace(&sToken, "\r", " " ) != -1 ) {};
while( helper::searchAndReplace(&sToken, "\t", " " ) != -1 ) {};
while( helper::searchAndReplace(&sToken, " ", " " ) != -1 ) {};
- rtl::OString sCondition(getToken(sToken, 0, ' '));
+ sal_Int32 n = 0;
+ rtl::OString sCondition(sToken.getToken(0, ' ', n));
if ( sCondition == "#ifndef" ) {
sActPForm = "!defined ";
- sActPForm += getToken(sToken, 1, ' ');
+ sActPForm += sToken.getToken(0, ' ', n);
}
else if ( sCondition == "#ifdef" ) {
sActPForm = "defined ";
- sActPForm += getToken(sToken, 1, ' ');
+ sActPForm += sToken.getToken(0, ' ', n);
}
else if ( sCondition == "#if" ) {
sActPForm = sToken.copy( 4 );
@@ -1117,20 +1135,20 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
rtl::OString Export::GetPairedListID(const rtl::OString& rText)
{
// < "STRING" ; IDENTIFIER ; > ;
+ sal_Int32 n = 0;
return helper::trimAscii(
- getToken(rText, 1, ';').toAsciiUpperCase().replace('\t', ' '));
+ rText.getToken(1, ';', n).toAsciiUpperCase().replace('\t', ' '));
}
rtl::OString Export::GetPairedListString(const rtl::OString& rText)
{
// < "STRING" ; IDENTIFIER ; > ;
- rtl::OString sString(getToken(rText, 0, ';').replace('\t', ' '));
- sString = comphelper::string::stripEnd(sString, ' ');
+ sal_Int32 n = 0;
+ rtl::OString sString(rText.getToken(0, ';', n).replace('\t', ' '));
+ sString = helper::trimAscii(sString);
rtl::OString s1(sString.copy(sString.indexOf('"') + 1));
sString = s1.copy(0, s1.lastIndexOf('"'));
- sString = comphelper::string::stripEnd(sString, ' ');
- sString = comphelper::string::stripStart(sString, ' ');
- return sString;
+ return helper::trimAscii(sString);
}
rtl::OString Export::StripList(const rtl::OString & rText)
@@ -1148,7 +1166,9 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
else {
sGID += ".";
sGID += pResData->sId;
- sGID = comphelper::string::stripEnd(sGID, '.');
+ while (sGID.getLength() != 0 && sGID[sGID.getLength() - 1] == '.') {
+ sGID = sGID.copy(0, sGID.getLength() - 1);
+ }
}
rtl::OString sCur;
@@ -1340,8 +1360,8 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
{
rtl::OString sTmp(rSource.copy(rSource.indexOf("=")));
CleanValue( sTmp );
- sTmp = comphelper::string::remove(sTmp, '\n');
- sTmp = comphelper::string::remove(sTmp, '\r');
+ helper::searchAndReplaceAll(&sTmp, "\n", rtl::OString());
+ helper::searchAndReplaceAll(&sTmp, "\r", rtl::OString());
helper::searchAndReplaceAll(
&sTmp, "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"");
@@ -1350,9 +1370,10 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
helper::searchAndReplaceAll(&sTmp, "\\0x7F", "-=<[0x7F]>=-");
sal_uInt16 nState = TXT_STATE_TEXT;
- for (sal_Int32 i = 1; i < getTokenCount(sTmp, '"'); ++i)
+ for (sal_Int32 i = 1; i <= helper::countOccurrences(sTmp, '"'); ++i)
{
- rtl::OString sToken(getToken(sTmp, i, '"'));
+ sal_Int32 n = 0;
+ rtl::OString sToken(sTmp.getToken(i, '"', n));
if (!sToken.isEmpty()) {
if ( nState == TXT_STATE_TEXT ) {
sReturn += sToken;
@@ -1363,8 +1384,7 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
while (helper::searchAndReplace(&sToken, " ", " ")
!= -1)
{}
- sToken = comphelper::string::stripStart(sToken, ' ');
- sToken = comphelper::string::stripEnd(sToken, ' ');
+ sToken = helper::trimAscii(sToken);
if (!sToken.isEmpty()) {
sReturn += "\\\" ";
sReturn += sToken;
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index 3212f6cc8981..1a1ae9112ece 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -38,7 +38,6 @@
#include <sal/macros.h>
#include <iostream>
#include <iomanip>
-#include <tools/urlobj.hxx>
#include <time.h>
#include <stdlib.h>
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index 48f74a53541b..b2ff952a675a 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -87,6 +87,18 @@ inline bool endsWithAsciiL(
search, searchLength, text.getLength() - searchLength);
}
+inline sal_Int32 countOccurrences(rtl::OString const & text, char c) {
+ sal_Int32 n = 0;
+ for (sal_Int32 i = 0;; ++i) {
+ i = text.indexOf(c, i);
+ if (i == -1) {
+ break;
+ }
+ ++n;
+ }
+ return n;
+}
+
inline rtl::OString trimAscii(rtl::OString const & text) {
sal_Int32 i1 = 0;
while (i1 != text.getLength() && isAsciiWhitespace(text[i1])) {
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index e0c6f1356625..d3895e66c5fe 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -31,7 +31,6 @@
#include <fstream>
#include <functional>
-#include <tools/fsys.hxx>
#include <osl/file.hxx>
// local includes
#include <stdio.h>
@@ -44,13 +43,13 @@
#include <fstream>
#include <vector>
#include <rtl/strbuf.hxx>
-#include <comphelper/string.hxx>
#ifdef WNT
#include <windows.h>
#undef CopyFile
#include <direct.h>
#endif
+#include "common.hxx"
#include "helper.hxx"
#if OSL_DEBUG_LEVEL > 2
@@ -93,16 +92,7 @@ bool HelpParser::CreateSDF(
rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
//TODO: explicit BOM handling?
- rtl::OString fullFilePath = rPrj_in;
- fullFilePath += "\\";
- fullFilePath += makeAbsolutePath( sHelpFile , rRoot_in );
- fullFilePath = fullFilePath.replace('\\', '/');
-
- rtl::OUString strFullPath(
- rtl::OStringToOUString(fullFilePath, RTL_TEXTENCODING_ASCII_US));
-
- //printf( "%s\n", fullFilePath.GetBuffer() );
- std::auto_ptr <XMLFile> file ( aParser.Execute( strFullPath , sXmlFile, pXmlFile ) );
+ std::auto_ptr <XMLFile> file ( aParser.Execute( sXmlFile, pXmlFile ) );
if(file.get() == NULL)
{
@@ -121,7 +111,8 @@ bool HelpParser::CreateSDF(
return false;
}
- rtl::OString sActFileName = makeAbsolutePath( sHelpFile , rRoot_in );
+ rtl::OString sActFileName(
+ common::pathnameToken(sHelpFile.getStr(), rRoot_in.getStr()));
XMLHashMap* aXMLStrHM = file->GetStrings();
LangHashMap* pElem;
@@ -189,21 +180,6 @@ bool HelpParser::CreateSDF(
return sal_True;
}
-rtl::OString HelpParser::makeAbsolutePath(const rtl::OString& sHelpFile, const rtl::OString& rRoot_in)
-{
- DirEntry aEntry(rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
- aEntry.ToAbs();
- rtl::OUString sFullEntry(aEntry.GetFull());
- aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
- aEntry += DirEntry( rRoot_in );
- rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(), osl_getThreadTextEncoding()));
- rtl::OString sActFileName(rtl::OUStringToOString(
- sFullEntry.copy(sPrjEntry.getLength() + 1),
- osl_getThreadTextEncoding()));
-
- return sActFileName.replace('/', '\\');
-}
-
bool HelpParser::Merge( const rtl::OString &rSDFFile, const rtl::OString &rDestinationFile ,
const rtl::OString& rLanguage , MergeDataFile& aMergeDataFile )
{
@@ -217,10 +193,7 @@ bool HelpParser::Merge( const rtl::OString &rSDFFile, const rtl::OString &rDesti
rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
//TODO: explicit BOM handling?
- OUString sOUHelpFile( sXmlFile );
- DirEntry aFile( sXmlFile );
-
- XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
+ XMLFile* xmlfile = ( aParser.Execute( sXmlFile, new XMLFile( rtl::OUString('0') ) ) );
hasNoError = MergeSingleFile( xmlfile , aMergeDataFile , rLanguage , rDestinationFile );
delete xmlfile;
return hasNoError;
@@ -268,10 +241,7 @@ bool HelpParser::Merge(
rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
//TODO: explicit BOM handling?
- OUString sOUHelpFile( sXmlFile );
- DirEntry aFile( sXmlFile );
-
- XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
+ XMLFile* xmlfile = aParser.Execute( sXmlFile, new XMLFile( rtl::OUString('0') ) );
xmlfile->Extract();
if( xmlfile == NULL)
@@ -329,127 +299,38 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
ProcessHelp( aLangHM , sLanguage, &pResData , aMergeDataFile );
}
-
- // Init temp and target file
- rtl::OString sTempFile;
- rtl::OString sTargetFile( sPath );
- rtl::OString sTempFileCopy;
-
- static const rtl::OString INPATH = Export::GetEnv("INPATH");
- sTempFile = Export::getRandomName(sPath, INPATH);
- sTempFileCopy = Export::getRandomName(sPath, INPATH);
- // Write in the temp file
- file->Write ( sTempFile );
-
- DirEntry aTmp( sTempFile );
- DirEntry aTmp2( sTempFileCopy );
- DirEntry aTar( sTargetFile );
-
- if( !Export::CopyFile( sTempFile , sTempFileCopy ) )
- {
-#if defined(UNX)
- sleep( 3 );
-#else
- Sleep( 3 );
-#endif
- if( !Export::CopyFile( sTempFile , sTempFileCopy ) )
- {
- cerr << "ERROR: Can not copy file from " << sTempFile.getStr() << " to " << sTempFileCopy.getStr() << "\n";
- return false;
- }
- }
-
- FileStat aFSTest( aTar );
- if( aFSTest.GetSize() < 1 )
- {
- remove( sTargetFile.getStr() );
- }
- int rc;
-#if defined(UNX)
- rc = rename( sTempFile.getStr() , sTargetFile.getStr() );
-#else
- rc = MoveFileEx( sTempFile.getStr() , sTargetFile.getStr(), MOVEFILE_REPLACE_EXISTING );
-#endif
- FileStat aFS( aTar );
-
- //cout << "mv " << sTempFile.GetBuffer() << " " << sTargetFile.GetBuffer() << "\n";
- //cout << "rc -> " << rc << " filesize -> " << aFS.GetSize() << "\n";
-// Windows rename returns -1 if the file already exits
-//#ifdef UNX
- if( rc < 0 || aFS.GetSize() < 1 )
-//#else
-// if( aFS.GetSize() < 1 )
-//#endif
- {
-#if defined(UNX)
- sleep( 3 );
-#else
- Sleep( 3 );
-#endif
- aFSTest.Update( aTar );
- if( aFSTest.GetSize() < 1 )
- {
- remove( sTargetFile.getStr() );
- }
-#if defined(UNX)
- rc = rename( sTempFileCopy.getStr() , sTargetFile.getStr() );
-#else
- rc = MoveFileEx( sTempFileCopy.getStr() , sTargetFile.getStr() , MOVEFILE_REPLACE_EXISTING );
-#endif
- aFS.Update( aTar );
-
- //cout << "mv2 " << sTempFileCopy.GetBuffer() << " " << sTargetFile.GetBuffer() << "\n";
- //cout << "rc -> " << rc << " filesize -> " << aFS.GetSize() << "\n";
-
-// Windows rename returns -1 if the file already exits
-//#ifdef WNT
-// if( aFS.GetSize() < 1 )
-//#else
- if( rc < 0 || aFS.GetSize() < 1 )
-//#endif
- {
- cerr << "ERROR: helpex Can't rename file " << sTempFileCopy.getStr() << " to " << sTargetFile.getStr() << " rename rc=" << rc << " filesize=" << aFS.GetSize() << "\n";
- aTmp.Kill();
- aTmp2.Kill();
- if( aFS.GetSize() < 1 )
- aTar.Kill();
- return false;
- }
- }
- aTmp.Kill();
- aTmp2.Kill();
-
+ file->Write(sPath);
return true;
}
rtl::OString HelpParser::GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY )
{
rtl::OString testpath = rPathX;
- static const rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
- testpath = comphelper::string::stripEnd(testpath, '/');
- testpath = comphelper::string::stripEnd(testpath, '\\');
- testpath += sDelimiter;
+ if (!helper::endsWith(testpath, "/")) {
+ testpath += "/";
+ }
testpath += sCur;
- testpath += sDelimiter;
+ testpath += "/";
rtl::OString sRelativePath( rPathY );
- sRelativePath = comphelper::string::stripStart(sRelativePath, '/');
- sRelativePath = comphelper::string::stripStart(sRelativePath, '\\');
+ if (sRelativePath.getLength() != 0 && sRelativePath[0] == '/') {
+ sRelativePath = sRelativePath.copy(1);
+ }
testpath += sRelativePath;
- testpath += sDelimiter;
+ testpath += "/";
return testpath;
}
void HelpParser::MakeDir(const rtl::OString& rPath)
{
- rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(),
- RTL_TEXTENCODING_ASCII_US));
- rtl::OString sTPath(comphelper::string::replace(rPath, sDelimiter, rtl::OString('/')));
- sal_uInt16 cnt = comphelper::string::getTokenCount(sTPath, '/');
+ rtl::OString sTPath(rPath);
+ helper::searchAndReplaceAll(&sTPath, "\\", "/");
+ sal_Int32 cnt = helper::countOccurrences(sTPath, '/');
rtl::OStringBuffer sCreateDir;
- for (sal_uInt16 i = 0; i < cnt; ++i)
+ for (sal_uInt16 i = 0; i <= cnt; ++i)
{
- sCreateDir.append(comphelper::string::getToken(sTPath, i , '/'));
- sCreateDir.append(sDelimiter);
+ sal_Int32 n = 0;
+ sCreateDir.append(sTPath.getToken(i , '/', n));
+ sCreateDir.append('/');
#ifdef WNT
_mkdir( sCreateDir.getStr() );
#else
diff --git a/l10ntools/source/makefile.mk b/l10ntools/source/makefile.mk
index 02b0696fa729..db60289be394 100644
--- a/l10ntools/source/makefile.mk
+++ b/l10ntools/source/makefile.mk
@@ -75,7 +75,6 @@ APP1TARGET= transex3
APP1OBJS= $(OBJ)$/src_yy_wrapper.obj
APP1RPATH= NONE
APP1STDLIBS+= \
- $(COMPHELPERLIB) \
$(SALLIB)
APP1LIBS+= $(LB)$/$(TARGET).lib
@@ -86,8 +85,6 @@ APP2OBJS= $(OBJ)$/helpmerge.obj $(OBJ)$/xmlparse.obj $(OBJ)$/export2.obj $(OBJ)
APP2RPATH= NONE
APP2STDLIBS+= \
$(EXPATASCII3RDLIB) \
- $(TOOLSLIB) \
- $(COMPHELPERLIB) \
$(SALLIB)
# extractor and merger for *.lng and *.lng
@@ -116,8 +113,6 @@ APP7TARGET= xrmex
APP7OBJS= $(OBJ)$/xrmmerge.obj $(OBJ)$/xrm_yy_wrapper.obj $(OBJ)$/merge.obj $(OBJ)$/export2.obj
APP7RPATH= NONE
APP7STDLIBS+= \
- $(TOOLSLIB) \
- $(COMPHELPERLIB) \
$(SALLIB)
# localizer for l10n framework
diff --git a/l10ntools/source/srclex.l b/l10ntools/source/srclex.l
index 12de543f85b7..40ae022e1b26 100644
--- a/l10ntools/source/srclex.l
+++ b/l10ntools/source/srclex.l
@@ -233,8 +233,9 @@ void yyerror( char *s )
}
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
+ int e;
yyin = init(argc, argv);
yylex();
+ e = GetError();
Close();
- return GetError();
}
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 51e38e6f029b..24dedf095832 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -466,7 +466,7 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ){
elem=pos->second;
if ( (*elem)[ language ] )
{
- fprintf(stdout,"Error: Duplicated entry. ID = %s LANG = %s in File %s\n", id.getStr(), language.getStr(), rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_ASCII_US).getStr() );
+ fprintf(stdout,"Error: Duplicated entry. ID = %s LANG = %s in File %s\n", id.getStr(), language.getStr(), rtl::OUStringToOString(sFileName, RTL_TEXTENCODING_ASCII_US).getStr() );
exit( -1 );
}
(*elem)[ language ]=pElement;
@@ -1113,7 +1113,7 @@ void SimpleXMLParser::Default(
}
/*****************************************************************************/
-XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFullFileName , const rtl::OUString &rFileName, XMLFile* pXMLFileIn )
+XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFileName, XMLFile* pXMLFileIn )
/*****************************************************************************/
{
aErrorInformation.eCode = XML_ERROR_NONE;
@@ -1150,7 +1150,6 @@ XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFullFileName , const rt
pXMLFile = pXMLFileIn;
pXMLFile->SetName( rFileName );
- pXMLFile->SetFullName( rFullFileName );
pCurNode = pXMLFile;
pCurData = NULL;
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 00e8993c6e15..1e25534b4d4b 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -30,11 +30,9 @@
#include <cstring>
-#include <comphelper/string.hxx>
#include <stdio.h>
-#include <tools/fsys.hxx>
-// local includes
+#include "common.hxx"
#include "export.hxx"
#include "helper.hxx"
#include "xrmmerge.hxx"
@@ -209,22 +207,10 @@ extern FILE *GetXrmFile()
sInputFileName.getStr());
}
else {
- // this is a valid file which can be opened, so
- // create path to project root
- DirEntry aEntry( rtl::OStringToOUString( sInputFileName, 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('/', '\\');
-
+ if (!bMergeMode) {
+ sActFileName = common::pathnameToken(
+ sInputFileName.getStr(), sPrjRoot.getStr());
+ }
return pFile;
}
}
@@ -404,7 +390,8 @@ rtl::OString XRMResParser::GetAttribute( const rtl::OString &rToken, const rtl::
if ( nPos != -1 )
{
sTmp = sTmp.copy( nPos );
- rtl::OString sId = comphelper::string::getToken(sTmp, 1, '\"');
+ sal_Int32 n = 0;
+ rtl::OString sId = sTmp.getToken(1, '"', n);
return sId;
}
return "";
@@ -422,14 +409,7 @@ void XRMResParser::Error( const rtl::OString &rError )
void XRMResParser::ConvertStringToDBFormat( rtl::OString &rString )
/*****************************************************************************/
{
- rtl::OString sResult;
- do {
- sResult = rString;
- rString = comphelper::string::stripStart(rString, _LF);
- rString = comphelper::string::stripStart(rString, '\t');
- rString = comphelper::string::stripEnd(rString, '\t');
- } while ( sResult != rString );
-
+ rString = helper::trimAscii(rString);
helper::searchAndReplaceAll(&rString, "\t", "\\t");
}
@@ -500,9 +480,7 @@ void XRMResExport::WorkOnDesc(
)
/*****************************************************************************/
{
- DirEntry aEntry( rtl::OStringToOUString( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
- aEntry.ToAbs();
- rtl::OString sDescFileName(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
+ rtl::OString sDescFileName(sInputFileName);
helper::searchAndReplaceAll(&sDescFileName, "description.xml", "");
sDescFileName += GetAttribute( rOpenTag, "xlink:href" );
int size;
@@ -559,7 +537,7 @@ void XRMResExport::EndOfText(
sCur = aLanguages[ n ];
rtl::OString sAct = pResData->sText[ sCur ];
- sAct = comphelper::string::remove(sAct, 0x0A);
+ helper::searchAndReplaceAll(&sAct, "\x0A", rtl::OString());
rtl::OString sOutput( sPrj ); sOutput += "\t";
sOutput += sPath;
@@ -667,17 +645,25 @@ void XRMResMerge::WorkOnDesc(
Output( sAdditionalLine );
- DirEntry aEntry( rtl::OStringToOUString( sOutputFile, RTL_TEXTENCODING_ASCII_US ));
- aEntry.ToAbs();
- rtl::OString sOutputDescFile(rtl::OUStringToOString(aEntry.GetPath().GetFull(), RTL_TEXTENCODING_ASCII_US));
- rtl::OString sDel(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
- sOutputDescFile += sDel;
- sOutputDescFile += sLocDescFilename;
+ sal_Int32 i = sOutputFile.lastIndexOf('/');
+ if (i == -1) {
+ std::cerr
+ << "Error: output file " << sOutputFile.getStr()
+ << " does not contain any /\n";
+ throw false; //TODO
+ }
+ rtl::OString sOutputDescFile(
+ sOutputFile.copy(0, i + 1) + sLocDescFilename);
helper::searchAndReplaceAll(&sText, "\\n", "\n");
ofstream file(sOutputDescFile.getStr());
if (file.is_open()) {
file << sText.getStr();
file.close();
+ } else {
+ std::cerr
+ << "Error: cannot write "
+ << sOutputDescFile.getStr() << '\n';
+ throw false; //TODO
}
}
}