summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]cli_ure/version/version.txt24
-rw-r--r--idlc/inc/idlc/idlctypes.hxx2
-rw-r--r--idlc/inc/idlc/options.hxx17
-rw-r--r--idlc/source/astexpression.cxx21
-rw-r--r--idlc/source/idlcmain.cxx19
-rw-r--r--idlc/source/options.cxx539
-rw-r--r--idlc/source/preproc/eval.c15
-rw-r--r--idlc/source/preproc/lex.c10
-rw-r--r--idlc/source/preproc/unix.c1
-rwxr-xr-x[-rw-r--r--]offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl0
-rw-r--r--offapi/com/sun/star/util/PathSubstitution.idl82
-rw-r--r--registry/tools/checksingleton.cxx459
-rw-r--r--registry/tools/fileurl.cxx90
-rw-r--r--registry/tools/fileurl.hxx43
-rw-r--r--registry/tools/makefile.mk8
-rw-r--r--registry/tools/options.cxx153
-rw-r--r--registry/tools/options.hxx67
-rw-r--r--registry/tools/regcompare.cxx1557
-rw-r--r--registry/tools/regmerge.cxx277
-rw-r--r--registry/tools/regview.cxx72
-rw-r--r--sal/osl/unx/file.cxx3
-rw-r--r--sal/osl/unx/file_misc.cxx6
-rw-r--r--sal/osl/unx/file_path_helper.cxx80
-rw-r--r--sal/osl/unx/process_impl.cxx19
-rw-r--r--sal/osl/unx/profile.c1
-rw-r--r--sal/osl/unx/socket.c39
-rw-r--r--sal/rtl/source/alloc.c1541
-rw-r--r--sal/rtl/source/alloc_arena.c37
-rw-r--r--sal/rtl/source/alloc_cache.c53
-rwxr-xr-xsal/rtl/source/alloc_fini.cxx (renamed from sal/rtl/source/memory_fini.cxx)23
-rw-r--r--sal/rtl/source/alloc_global.c10
-rw-r--r--sal/rtl/source/alloc_impl.h24
-rw-r--r--sal/rtl/source/makefile.mk9
-rw-r--r--store/source/lockbyte.cxx3
-rw-r--r--store/source/lockbyte.hxx2
-rw-r--r--store/source/object.hxx2
-rw-r--r--store/source/storbase.cxx3
-rw-r--r--store/source/stordir.hxx2
-rwxr-xr-x[-rw-r--r--]unoil/climaker/version.txt6
39 files changed, 1840 insertions, 3479 deletions
diff --git a/cli_ure/version/version.txt b/cli_ure/version/version.txt
index 8cbdedf654d4..b5ec562837f6 100644..100755
--- a/cli_ure/version/version.txt
+++ b/cli_ure/version/version.txt
@@ -25,23 +25,23 @@
#
#*************************************************************************
-CLI_URETYPES_NEW_VERSION=1.0.7.0
-CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.6.0
-CLI_URETYPES_POLICY_VERSION=7.0.0.0
+CLI_URETYPES_NEW_VERSION=1.0.8.0
+CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.7.0
+CLI_URETYPES_POLICY_VERSION=8.0.0.0
CLI_URETYPES_POLICY_ASSEMBLY=policy.1.0.cli_uretypes
-CLI_BASETYPES_NEW_VERSION=1.0.18.0
-CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.17.0
-CLI_BASETYPES_POLICY_VERSION=18.0.0.0
+CLI_BASETYPES_NEW_VERSION=1.0.19.0
+CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.18.0
+CLI_BASETYPES_POLICY_VERSION=19.0.0.0
CLI_BASETYPES_POLICY_ASSEMBLY=policy.1.0.cli_basetypes
-CLI_URE_NEW_VERSION=1.0.21.0
-CLI_URE_OLD_VERSION=1.0.0.0-1.0.20.0
-CLI_URE_POLICY_VERSION=21.0.0.0
+CLI_URE_NEW_VERSION=1.0.22.0
+CLI_URE_OLD_VERSION=1.0.0.0-1.0.21.0
+CLI_URE_POLICY_VERSION=22.0.0.0
CLI_URE_POLICY_ASSEMBLY=policy.1.0.cli_ure
-CLI_CPPUHELPER_NEW_VERSION=1.0.21.0
-CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.20.0
-CLI_CPPUHELPER_POLICY_VERSION=21.0.0.0
+CLI_CPPUHELPER_NEW_VERSION=1.0.22.0
+CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.21.0
+CLI_CPPUHELPER_POLICY_VERSION=22.0.0.0
CLI_CPPUHELPER_POLICY_ASSEMBLY=policy.1.0.cli_cppuhelper
diff --git a/idlc/inc/idlc/idlctypes.hxx b/idlc/inc/idlc/idlctypes.hxx
index 47eaa802b28d..41451ee9060f 100644
--- a/idlc/inc/idlc/idlctypes.hxx
+++ b/idlc/inc/idlc/idlctypes.hxx
@@ -32,7 +32,9 @@
#include <hash_map>
#include <list>
#include <vector>
+#include <string>
#include <set>
+
#include <sal/types.h>
#include <rtl/ustring.hxx>
diff --git a/idlc/inc/idlc/options.hxx b/idlc/inc/idlc/options.hxx
index 7eba788a4ea9..383150bd4b40 100644
--- a/idlc/inc/idlc/options.hxx
+++ b/idlc/inc/idlc/options.hxx
@@ -50,18 +50,29 @@ public:
class Options
{
public:
- Options();
+ explicit Options(char const * progname);
~Options();
+ static bool checkArgument(std::vector< std::string > & rArgs, char const * arg, size_t len);
+ static bool checkCommandFile(std::vector< std::string > & rArgs, char const * filename);
+
+ bool initOptions(std::vector< std::string > & rArgs)
+ throw(IllegalArgument);
+ bool badOption(char const * reason, std::string const & rArg)
+ throw(IllegalArgument);
+ bool setOption(char const * option, std::string const & rArg);
+
+#if 0 /* @@@ */
sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
throw( IllegalArgument );
+#endif /* @@@ */
::rtl::OString prepareHelp();
::rtl::OString prepareVersion();
const ::rtl::OString& getProgramName() const;
- sal_Bool isValid(const ::rtl::OString& option);
- const ::rtl::OString getOption(const ::rtl::OString& option)
+ bool isValid(const ::rtl::OString& option);
+ const ::rtl::OString& getOption(const ::rtl::OString& option)
throw( IllegalArgument );
const StringVector& getInputFiles() const { return m_inputFiles; }
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index a93c13ecf8ba..357da1ab362e 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_idlc.hxx"
+
#include <idlc/astexpression.hxx>
#include <idlc/astconstant.hxx>
#include <idlc/astscope.hxx>
@@ -34,6 +35,7 @@
#include <limits.h>
#include <float.h>
+#include <memory> // auto_ptr<>
#undef MAXCHAR
#define MAXCHAR 127
@@ -927,7 +929,6 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek)
AstExprValue* AstExpression::eval_bin_op(EvalKind ek)
{
- AstExprValue *retval = NULL;
ExprType eType = ET_double;
if ( m_combOperator == EC_mod )
@@ -950,7 +951,7 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek)
if (m_subExpr2->getExprValue() == NULL)
return NULL;
- retval = new AstExprValue();
+ std::auto_ptr< AstExprValue > retval(new AstExprValue());
retval->et = eType;
switch (m_combOperator)
@@ -971,20 +972,18 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek)
break;
case EC_div:
if (m_subExpr2->getExprValue()->u.dval == 0.0)
- return NULL;
+ return NULL;
retval->u.dval = m_subExpr1->getExprValue()->u.dval / m_subExpr2->getExprValue()->u.dval;
break;
default:
return NULL;
}
- return retval;
+ return retval.release();
}
AstExprValue* AstExpression::eval_bit_op(EvalKind ek)
{
- AstExprValue *retval = NULL;
-
if (ek != EK_const && ek != EK_positive_int)
return NULL;
if (m_subExpr1 == NULL || m_subExpr2 == NULL)
@@ -1002,7 +1001,7 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek)
if (m_subExpr2->getExprValue() == NULL)
return NULL;
- retval = new AstExprValue;
+ std::auto_ptr< AstExprValue > retval(new AstExprValue());
retval->et = ET_long;
switch (m_combOperator)
@@ -1026,13 +1025,11 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek)
return NULL;
}
- return retval;
+ return retval.release();
}
AstExprValue* AstExpression::eval_un_op(EvalKind ek)
{
- AstExprValue *retval = NULL;
-
if (m_exprValue != NULL)
return m_exprValue;
@@ -1047,7 +1044,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek)
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- retval = new AstExprValue();
+ std::auto_ptr< AstExprValue > retval(new AstExprValue());
retval->et = ET_double;
switch (m_combOperator)
@@ -1068,7 +1065,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek)
return NULL;
}
- return retval;
+ return retval.release();
}
AstExprValue* AstExpression::eval_symbol(EvalKind ek)
diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx
index 006131f727df..cc2963f5f446 100644
--- a/idlc/source/idlcmain.cxx
+++ b/idlc/source/idlcmain.cxx
@@ -27,26 +27,35 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_idlc.hxx"
-#include <idlc/idlc.hxx>
+
+#include "idlc/idlc.hxx"
#include "sal/main.h"
+#include <string.h>
+
using namespace ::rtl;
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
{
- Options options;
+ std::vector< std::string > args;
+ for (int i = 1; i < argc; i++)
+ {
+ if (!Options::checkArgument (args, argv[i], strlen(argv[i])))
+ return (1);
+ }
+ Options options(argv[0]);
try
{
- if (!options.initOptions(argc, argv))
- exit(1);
+ if (!options.initOptions(args))
+ return (0);
}
catch( IllegalArgument& e)
{
fprintf(stderr, "Illegal argument: %s\n%s",
e.m_message.getStr(),
options.prepareVersion().getStr());
- exit(99);
+ return (99);
}
setIdlc(&options);
diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx
index edf8648c31c3..310afa2a4d60 100644
--- a/idlc/source/options.cxx
+++ b/idlc/source/options.cxx
@@ -28,9 +28,17 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_idlc.hxx"
+#include "idlc/options.hxx"
+
+#include "osl/diagnose.h"
+#include "rtl/string.hxx"
+#include "rtl/strbuf.hxx"
+
#include <stdio.h>
-#include /*MSVC trouble: <cstring>*/ <string.h>
-#include <idlc/options.hxx>
+#include <string.h>
+
+using rtl::OString;
+using rtl::OStringBuffer;
#ifdef SAL_UNX
#define SEPARATOR '/'
@@ -38,9 +46,8 @@
#define SEPARATOR '\\'
#endif
-using namespace rtl;
-
-Options::Options(): m_stdin(false), m_verbose(false), m_quiet(false)
+Options::Options(char const * progname)
+ : m_program(progname), m_stdin(false), m_verbose(false), m_quiet(false)
{
}
@@ -48,275 +55,282 @@ Options::~Options()
{
}
-sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile)
- throw( IllegalArgument )
+// static
+bool Options::checkArgument (std::vector< std::string > & rArgs, char const * arg, size_t len)
{
- sal_Bool ret = sal_True;
- sal_uInt16 j=0;
-
- if (!bCmdFile)
+ bool result = ((arg != 0) && (len > 0));
+ OSL_PRECOND(result, "idlc::Options::checkArgument(): invalid arguments");
+ if (result)
+ {
+ switch(arg[0])
{
- bCmdFile = sal_True;
-
- OString name(av[0]);
- sal_Int32 index = name.lastIndexOf(SEPARATOR);
- m_program = name.copy((index > 0 ? index+1 : 0));
-
- if (ac < 2)
+ case '@':
+ if ((result = (len > 1)) == true)
+ {
+ // "@<cmdfile>"
+ result = Options::checkCommandFile (rArgs, &(arg[1]));
+ }
+ break;
+ case '-':
+ if ((result = (len > 1)) == true)
+ {
+ // "-<option>"
+ switch (arg[1])
{
- fprintf(stderr, "%s", prepareHelp().getStr());
- ret = sal_False;
+ case 'O':
+ case 'I':
+ case 'D':
+ {
+ // "-<option>[<param>]
+ std::string option(&(arg[0]), 2);
+ rArgs.push_back(option);
+ if (len > 2)
+ {
+ // "-<option><param>"
+ std::string param(&(arg[2]), len - 2);
+ rArgs.push_back(param);
+ }
+ break;
+ }
+ default:
+ // "-<option>" ([long] option, w/o param)
+ rArgs.push_back(std::string(arg, len));
+ break;
}
+ }
+ break;
+ default:
+ // "<param>"
+ rArgs.push_back(std::string(arg, len));
+ break;
+ }
+ }
+ return (result);
+}
- j = 1;
- } else
+// static
+bool Options::checkCommandFile (std::vector< std::string > & rArgs, char const * filename)
+{
+ FILE * fp = fopen(filename, "r");
+ if (fp == 0)
{
- j = 0;
+ fprintf(stderr, "ERROR: can't open command file \"%s\"\n", filename);
+ return (false);
}
- char *s=NULL;
- for (; j < ac; j++)
+ std::string buffer;
+ buffer.reserve(256);
+
+ bool quoted = false;
+ int c = EOF;
+ while ((c = fgetc(fp)) != EOF)
{
- if (av[j][0] == '-')
+ switch(c)
{
- switch (av[j][1])
- {
- case 'O':
- if (av[j][2] == '\0')
- {
- if (j < ac - 1 && av[j+1][0] != '-')
- {
- j++;
- s = av[j];
- } else
- {
- OString tmp("'-O', please check");
- if (j <= ac - 1)
- {
- tmp += " your input '" + OString(av[j+1]) + "'";
- }
-
- throw IllegalArgument(tmp);
- }
- } else
- {
- s = av[j] + 2;
- }
-
- m_options["-O"] = OString(s);
- break;
- case 'I':
- {
- if (av[j][2] == '\0')
- {
- if (j < ac - 1 && av[j+1][0] != '-')
- {
- j++;
- s = av[j];
- } else
- {
- OString tmp("'-I', please check");
- if (j <= ac - 1)
- {
- tmp += " your input '" + OString(av[j+1]) + "'";
- }
-
- throw IllegalArgument(tmp);
- }
- } else
- {
- s = av[j] + 2;
- }
+ case '\"':
+ quoted = !quoted;
+ break;
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ if (!quoted)
+ {
+ if (!buffer.empty())
+ {
+ // append current argument.
+ if (!Options::checkArgument(rArgs, buffer.c_str(), buffer.size()))
+ {
+ (void) fclose(fp);
+ return (false);
+ }
+ buffer.clear();
+ }
+ break;
+ }
+ default:
+ // quoted white-space fall through
+ buffer.push_back(sal::static_int_cast<char>(c));
+ break;
+ }
+ }
+ if (!buffer.empty())
+ {
+ // append unterminated argument.
+ if (!Options::checkArgument(rArgs, buffer.c_str(), buffer.size()))
+ {
+ (void) fclose(fp);
+ return (false);
+ }
+ buffer.clear();
+ }
+ return (fclose(fp) == 0);
+}
- OString inc(s);
- if ( inc.indexOf(';') > 0 )
- {
- OString tmp(s);
- sal_Int32 nIndex = 0;
- inc = OString();
- do inc = inc + " -I\"" + tmp.getToken( 0, ';', nIndex ) +"\""; while( nIndex != -1 );
- } else
- inc = OString("-I\"") + s + "\"";
+bool Options::badOption(char const * reason, std::string const & rArg) throw(IllegalArgument)
+{
+ OStringBuffer message;
+ if (reason != 0)
+ {
+ message.append(reason); message.append(" option '"); message.append(rArg.c_str()); message.append("'");
+ throw IllegalArgument(message.makeStringAndClear());
+ }
+ return false;
+}
- if (m_options.count("-I") > 0)
- {
- OString tmp(m_options["-I"]);
- tmp = tmp + " " + inc;
- m_options["-I"] = tmp;
- } else
- {
- m_options["-I"] = inc;
- }
- }
- break;
- case 'D':
- if (av[j][2] == '\0')
- {
- if (j < ac - 1 && av[j+1][0] != '-')
- {
- j++;
- s = av[j];
- } else
- {
- OString tmp("'-D', please check");
- if (j <= ac - 1)
- {
- tmp += " your input '" + OString(av[j+1]) + "'";
- }
+bool Options::setOption(char const * option, std::string const & rArg)
+{
+ bool result = (0 == strcmp(option, rArg.c_str()));
+ if (result)
+ m_options[rArg.c_str()] = OString(rArg.c_str(), rArg.size());
+ return (result);
+}
- throw IllegalArgument(tmp);
- }
- } else
- {
- s = av[j];
- }
+bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument)
+{
+ std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
+ for (; first != last; ++first)
+ {
+ if ((*first)[0] != '-')
+ {
+ OString filename((*first).c_str(), (*first).size());
+ OString tmp(filename.toAsciiLowerCase());
+ if (tmp.lastIndexOf(".idl") != (tmp.getLength() - 4))
+ {
+ throw IllegalArgument("'" + filename + "' is not a valid input file, only '*.idl' files will be accepted");
+ }
+ m_inputFiles.push_back(filename);
+ continue;
+ }
- if (m_options.count("-D") > 0)
- {
- OString tmp(m_options["-D"]);
- tmp = tmp + " " + s;
- m_options["-D"] = tmp;
- } else
- m_options["-D"] = OString(s);
- break;
- case 'C':
- if (av[j][2] != '\0')
- {
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- }
- if (m_options.count("-C") == 0)
- m_options["-C"] = OString(av[j]);
- break;
- case 'c':
- if (av[j][2] == 'i' && av[j][3] == 'd' && av[j][4] == '\0')
- {
- if (m_options.count("-cid") == 0)
- m_options["-cid"] = OString(av[j]);
- } else
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- break;
- case 'v':
- if ( 0 == strcmp( &av[j][1], "verbose" ) )
- {
- m_verbose = true;
- }
- else
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- break;
- case 'q':
- if ( 0 == strcmp( &av[j][1], "quiet" ) )
- {
- m_quiet = true;
- }
- else
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- break;
- case 'w':
- if (av[j][2] == 'e' && av[j][3] == '\0') {
- if (m_options.count("-we") == 0)
- m_options["-we"] = OString(av[j]);
- } else {
- if (av[j][2] == '\0') {
- if (m_options.count("-w") == 0)
- m_options["-w"] = OString(av[j]);
- } else
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- }
- break;
- case 'h':
- case '?':
- if (av[j][2] != '\0')
- {
- throw IllegalArgument(OString(av[j]) + ", please check your input");
- } else
- {
- fprintf(stdout, "%s", prepareHelp().getStr());
- exit(0);
- }
- case 's':
- if (/*MSVC trouble: std::*/strcmp(&av[j][2], "tdin") == 0)
- {
- m_stdin = true;
- break;
- }
- // fall through
- default:
- throw IllegalArgument("the option is unknown" + OString(av[j]));
- }
- } else
+ std::string const option(*first);
+ switch((*first)[1])
+ {
+ case 'O':
+ {
+ if (!((++first != last) && ((*first)[0] != '-')))
{
- if (av[j][0] == '@')
- {
- FILE* cmdFile = fopen(av[j]+1, "r");
- if( cmdFile == NULL )
- {
- fprintf(stderr, "%s", prepareHelp().getStr());
- ret = sal_False;
- } else
- {
- int rargc=0;
- char* rargv[512];
- char buffer[512]="";
-
- int i=0;
- int found = 0;
- char c;
- while ( fscanf(cmdFile, "%c", &c) != EOF )
- {
- if (c=='\"') {
- if (found) {
- found=0;
- } else {
- found=1;
- continue;
- }
- } else {
- if (c!=13 && c!=10) {
- if (found || c!=' ') {
- buffer[i++]=c;
- continue;
- }
- }
- if (i==0)
- continue;
- }
- buffer[i]='\0';
- found=0;
- i=0;
- rargv[rargc]= strdup(buffer);
- rargc++;
- buffer[0]='\0';
- }
- if (buffer[0] != '\0') {
- buffer[i]='\0';
- rargv[rargc]= strdup(buffer);
- rargc++;
- }
- fclose(cmdFile);
-
- ret = initOptions(rargc, rargv, bCmdFile);
-
- long ii = 0;
- for (ii=0; ii < rargc; ii++)
- {
- free(rargv[ii]);
- }
- }
- } else
- {
- OString name(av[j]);
- name = name.toAsciiLowerCase();
- if ( name.lastIndexOf(".idl") != (name.getLength() - 4) )
- {
- throw IllegalArgument("'" + OString(av[j]) +
- "' is not a valid input file, only '*.idl' files will be accepted");
- }
- m_inputFiles.push_back(av[j]);
- }
+ return badOption("invalid", option);
+ }
+ OString param((*first).c_str(), (*first).size());
+ m_options["-O"] = param;
+ break;
+ }
+ case 'I':
+ {
+ if (!((++first != last) && ((*first)[0] != '-')))
+ {
+ return badOption("invalid", option);
+ }
+ OString param((*first).c_str(), (*first).size());
+ {
+ // quote param token(s).
+ OStringBuffer buffer;
+ sal_Int32 k = 0;
+ do
+ {
+ OStringBuffer token; token.append("-I\""); token.append(param.getToken(0, ';', k)); token.append("\"");
+ if (buffer.getLength() > 0)
+ buffer.append(' ');
+ buffer.append(token);
+ } while (k != -1);
+ param = buffer.makeStringAndClear();
+ }
+ if (m_options.count("-I") > 0)
+ {
+ // append param.
+ OStringBuffer buffer(m_options["-I"]);
+ buffer.append(' '); buffer.append(param);
+ param = buffer.makeStringAndClear();
+ }
+ m_options["-I"] = param;
+ break;
+ }
+ case 'D':
+ {
+ if (!((++first != last) && ((*first)[0] != '-')))
+ {
+ return badOption("invalid", option);
+ }
+ OString param("-D"); param += OString((*first).c_str(), (*first).size());
+ if (m_options.count("-D") > 0)
+ {
+ OStringBuffer buffer(m_options["-D"]);
+ buffer.append(' '); buffer.append(param);
+ param = buffer.makeStringAndClear();
}
+ m_options["-D"] = param;
+ break;
+ }
+ case 'C':
+ {
+ if (!setOption("-C", option))
+ {
+ return badOption("invalid", option);
+ }
+ break;
+ }
+ case 'c':
+ {
+ if (!setOption("-cid", option))
+ {
+ return badOption("invalid", option);
+ }
+ break;
+ }
+ case 'q':
+ {
+ if (!setOption("-quiet", option))
+ {
+ return badOption("invalid", option);
+ }
+ m_quiet = true;
+ break;
+ }
+ case 'v':
+ {
+ if (!setOption("-verbose", option))
+ {
+ return badOption("invalid", option);
+ }
+ m_verbose = true;
+ break;
+ }
+ case 'w':
+ {
+ if (!(setOption("-w", option) || setOption("-we", option)))
+ {
+ return badOption("invalid", option);
+ }
+ break;
+ }
+ case 'h':
+ case '?':
+ {
+ if (!(setOption("-h", option) || setOption("-?", option)))
+ {
+ return badOption("invalid", option);
+ }
+ {
+ (void) fprintf(stdout, "%s", prepareHelp().getStr());
+ return (false);
+ }
+ // break; // Unreachable
+ }
+ case 's':
+ {
+ if (!setOption("-stdin", option))
+ {
+ return badOption("invalid", option);
+ }
+ m_stdin = true;
+ break;
+ }
+ default:
+ return badOption("unknown", option);
}
-
- return ret;
+ }
+ return (true);
}
OString Options::prepareHelp()
@@ -361,19 +375,18 @@ const OString& Options::getProgramName() const
return m_program;
}
-sal_Bool Options::isValid(const OString& option)
+bool Options::isValid(const OString& option)
{
return (m_options.count(option) > 0);
}
-const OString Options::getOption(const OString& option)
+const OString& Options::getOption(const OString& option)
throw( IllegalArgument )
{
- if (m_options.count(option) > 0)
- {
- return m_options[option];
- } else
+ if (!isValid(option))
{
throw IllegalArgument("Option is not valid or currently not set.");
}
+ return m_options[option];
}
+/* vi:set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/idlc/source/preproc/eval.c b/idlc/source/preproc/eval.c
index cd3adc2204c7..bed61eb95f00 100644
--- a/idlc/source/preproc/eval.c
+++ b/idlc/source/preproc/eval.c
@@ -24,9 +24,11 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
+#include "cpp.h"
+
#include <stdlib.h>
#include <string.h>
-#include "cpp.h"
#define NSTAK 32
#define SGN 0
@@ -736,10 +738,10 @@ struct value
}
else
{
- static char cvcon[]
- = "b\bf\fn\nr\rt\tv\v''\"\"??\\\\";
+ static char cvcon[] = "b\bf\fn\nr\rt\tv\v''\"\"??\\\\";
+ static int cvlen = sizeof(cvcon) - 1;
- for (i = 0; i < (int)sizeof(cvcon); i += 2)
+ for (i = 0; i < cvlen; i += 2)
{
if (*p == cvcon[i])
{
@@ -748,9 +750,8 @@ struct value
}
}
p += 1;
- if (i >= (int)sizeof(cvcon))
- error(WARNING,
- "Undefined escape in character constant");
+ if (i >= cvlen)
+ error(WARNING,"Undefined escape in character constant");
}
}
else
diff --git a/idlc/source/preproc/lex.c b/idlc/source/preproc/lex.c
index fd6d00792984..856ee72bfc53 100644
--- a/idlc/source/preproc/lex.c
+++ b/idlc/source/preproc/lex.c
@@ -290,7 +290,7 @@ void
bigfsm[j][fp->state] = (short) nstate;
continue;
case C_ALPH:
- for (j = 0; j <= 256; j++)
+ for (j = 0; j < 256; j++)
if (('a' <= j && j <= 'z') || ('A' <= j && j <= 'Z')
|| j == '_')
bigfsm[j][fp->state] = (short) nstate;
@@ -687,9 +687,13 @@ void
if (s->fd >= 0)
{
- close(s->fd);
- dofree(s->inb);
+ (void) close(s->fd);
+ dofree(s->filename);
}
+
+ if (s->inb)
+ dofree(s->inb);
+
cursource = s->next;
dofree(s);
}
diff --git a/idlc/source/preproc/unix.c b/idlc/source/preproc/unix.c
index 4997e317e697..808b1d90dbd3 100644
--- a/idlc/source/preproc/unix.c
+++ b/idlc/source/preproc/unix.c
@@ -91,6 +91,7 @@ void
maketokenrow(3, &tr);
gettokens(&tr, 1);
doadefine(&tr, c);
+ dofree(tr.bp); tr.bp = 0;
unsetsource();
break;
diff --git a/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl b/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl
index c2e4eca935e1..c2e4eca935e1 100644..100755
--- a/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl
+++ b/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl
diff --git a/offapi/com/sun/star/util/PathSubstitution.idl b/offapi/com/sun/star/util/PathSubstitution.idl
index 455465ddf06a..dd55f74dccb4 100644
--- a/offapi/com/sun/star/util/PathSubstitution.idl
+++ b/offapi/com/sun/star/util/PathSubstitution.idl
@@ -48,57 +48,65 @@ module com { module sun { module star { module util {
/** A service to support the substitution and resubstitution of path variables.
- <p>
- A path variable must be specified with the following synatx: "$("&lt;variable-name&gt;")".
- Path variables are not case sensitive and are always provided as a UCB-complient URL's
- (for example: "file:///c:/temp" or "file:///usr/install"). This is mandatory to support an
- optional remote file system.<br>
- A user defined list of path variables is supported. This list is stored in the Office
- configuration file (org/openoffice/Office/Substitution.xml). Please have a look at the
- schema definition file which configuration structure this file uses.<br>
- There is also a set of variables that have pre-defined values:
- </p>
- <dl>
- <dt>$(inst)</dt>
- <dd>Installation path of the Office Basis layer.</dd>
- <dt>$(prog)</dt>
- <dd>Program path of the Office Basis layer.</dd>
+ <p>
+ A path variable must be specified with the following synatx: "$("&lt;variable-name&gt;")".
+ Path variables are not case sensitive and are always provided as a UCB-complient URL's
+ (for example: "file:///c:/temp" or "file:///usr/install"). This is mandatory to support an
+ optional remote file system.<br>
+ A user defined list of path variables is supported. This list is stored in the Office
+ configuration file (org/openoffice/Office/Substitution.xml). Please have a look at the
+ schema definition file which configuration structure this file uses.<br>
+ There is also a set of variables that have pre-defined values:
+ </p>
+ <dl>
+ <dt>$(inst)</dt>
+ <dd>Installation path of the Office Basis layer.</dd>
+ <dt>$(prog)</dt>
+ <dd>Program path of the Office Basis layer.</dd>
<dt>$(brandbaseurl)</dt>
<dd>Installation path of the the Office Brand layer.</dd>
- <dt>$(user)</dt>
- <dd>The user installation directory.</dd>
- <dt>$(work)</dt>
- <dd>The work directory of the user. Under Windows this would be the
- "MyDocuments" subdirectory. Under Unix this would be the home-directory</dd>
+ <dt>$(user)</dt>
+ <dd>The user installation directory.</dd>
+ <dt>$(work)</dt>
+ <dd>The work directory of the user. Under Windows this would be the
+ "MyDocuments" subdirectory. Under Unix this would be the home-directory</dd>
<dt>$(home)</dt>
- <dd>The home directory of the user. Under Unix this would be the home-
- directory. Under Windows this would be the "Documents and Settings\<username>"
- subdirectory.</dd>
+ <dd>The home directory of the user. Under Unix this would be the home-
+ directory. Under Windows this would be the "Documents and Settings\<username>"
+ subdirectory.</dd>
<dt>$(temp)</dt>
- <dd>The current temporary directory.</dd>
+ <dd>The current temporary directory.</dd>
<dt>$(path)</dt>
- <dd>The value of PATH environment variable.</dd>
+ <dd>The value of PATH environment variable.</dd>
<dt>$(lang)</dt>
- <dd>The country code used by the Office, like 01=english, 49=german.</dd>
- <dt>$(langid)</dt>
- <dd>The language code used by the Office, like 0x0009=english, 0x0409=english us.</dd>
+ <dd>The country code used by the Office, like 01=english, 49=german.</dd>
+ <dt>$(langid)</dt>
+ <dd>The language code used by the Office, like 0x0009=english, 0x0409=english us.</dd>
<dt>$(vlang)</dt>
- <dd>The language used by the Office as a string. Like "german" for a german Office.</dd>
- </dl>
+ <dd>The language used by the Office as a string. Like "german" for a german Office.</dd>
+ </dl>
+ <p>
+ Attention: Most predefined variables describe an absolute path.
+ The only exceptions are: $(lang), $(langid) and $(vlang).
+ Therefore the service implementation should only substitute variables which
+ are located at the start of a provided path string or are part of a multi-path.
+ This special service is not designed to be a text substiution but shall
+ provide (a) valid substituted path(s).
+ </p>
@since OOo 1.1.2
*/
published service PathSubstitution
{
- //-------------------------------------------------------------------------
- /** Interface to exchange path variables with defined paths and to resubstitute paths with path variables.
+ //-------------------------------------------------------------------------
+ /** Interface to exchange path variables with defined paths and to resubstitute paths with path variables.
- <p>
- To resubstitute path variables the caller must provide pathes as UCB-compliant URL's.
- </p>
- */
- interface com::sun::star::util::XStringSubstitution;
+ <p>
+ To resubstitute path variables the caller must provide pathes as UCB-compliant URL's.
+ </p>
+ */
+ interface com::sun::star::util::XStringSubstitution;
};
//=============================================================================
diff --git a/registry/tools/checksingleton.cxx b/registry/tools/checksingleton.cxx
index 75ea3ec7958a..903e059ac896 100644
--- a/registry/tools/checksingleton.cxx
+++ b/registry/tools/checksingleton.cxx
@@ -28,297 +28,150 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
-#include <stdio.h>
-#include <string.h>
-
#include "registry/registry.hxx"
#include "registry/reflread.hxx"
-#include <rtl/ustring.hxx>
-#include <rtl/alloc.h>
-#include <osl/process.h>
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-#include <osl/file.hxx>
-
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
+#include "fileurl.hxx"
+#include "options.hxx"
-using namespace ::rtl;
-using namespace ::osl;
+#include "rtl/ustring.hxx"
+#include "osl/diagnose.h"
-sal_Bool isFileUrl(const OString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
-
-OUString convertToFileUrl(const OString& fileName)
-{
- if ( isFileUrl(fileName) )
- {
- return OStringToOUString(fileName, osl_getThreadTextEncoding());
- }
+#include <stdio.h>
+#include <string.h>
- OUString uUrlFileName;
- OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
- {
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
- {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- }
+#include <vector>
+#include <string>
- return uUrlFileName;
-}
+using namespace rtl;
+using namespace registry::tools;
#define U2S( s ) \
OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr()
#define S2U( s ) \
OStringToOUString(s, RTL_TEXTENCODING_UTF8)
-struct LessString
-{
- sal_Bool operator()(const OUString& str1, const OUString& str2) const
- {
- return (str1 < str2);
- }
-};
-
-class Options
+class Options_Impl : public Options
{
public:
- Options()
- : m_bForceOutput(sal_False)
- {}
- ~Options()
+ explicit Options_Impl(char const * program)
+ : Options (program), m_bForceOutput(false)
{}
- sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False);
-
- OString prepareHelp();
- OString prepareVersion();
-
- const OString& getProgramName()
- { return m_program; }
- const OString& getIndexReg()
+ std::string const & getIndexReg() const
{ return m_indexRegName; }
- const OString& getTypeReg()
+ std::string const & getTypeReg() const
{ return m_typeRegName; }
- sal_Bool hasBase()
- { return m_base.getLength() > 0; }
- const OString& getBase()
+ bool hasBase() const
+ { return (m_base.getLength() > 0); }
+ const OString & getBase() const
{ return m_base; }
- sal_Bool forceOutput()
+ bool forceOutput() const
{ return m_bForceOutput; }
+
protected:
- OString m_program;
- OString m_indexRegName;
- OString m_typeRegName;
+ virtual void printUsage_Impl() const;
+ virtual bool initOptions_Impl (std::vector< std::string > & rArgs);
+
+ std::string m_indexRegName;
+ std::string m_typeRegName;
OString m_base;
- sal_Bool m_bForceOutput;
+ bool m_bForceOutput;
};
-sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+// virtual
+void Options_Impl::printUsage_Impl() const
{
- sal_Bool bRet = sal_True;
- sal_uInt16 i=0;
+ std::string const & rProgName = getProgramName();
+ fprintf(stderr,
+ "Usage: %s -r<filename> -o<filename> [-options] | @<filename>\n", rProgName.c_str()
+ );
+ fprintf(stderr,
+ " -o<filename> = filename specifies the name of the new singleton index registry.\n"
+ " -r<filename> = filename specifies the name of the type registry.\n"
+ " @<filename> = filename specifies a command file.\n"
+ "Options:\n"
+ " -b<name> = name specifies the name of a start key. The types will be searched\n"
+ " under this key in the type registry.\n"
+ " -f = force the output of all found singletons.\n"
+ " -h|-? = print this help message and exit.\n"
+ );
+ fprintf(stderr,
+ "\n%s Version 1.0\n\n", rProgName.c_str()
+ );
+}
- if (!bCmdFile)
+// virtual
+bool Options_Impl::initOptions_Impl(std::vector< std::string > & rArgs)
+{
+ std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
+ for (; first != last; ++first)
{
- bCmdFile = sal_True;
-
- m_program = av[0];
-
- if (ac < 2)
+ std::string option (*first);
+ if ((*first)[0] != '-')
{
- fprintf(stderr, "%s", prepareHelp().getStr());
- bRet = sal_False;
+ return badOption("invalid", option.c_str());
}
-
- i = 1;
- } else
- {
- i = 0;
- }
-
- char *s=NULL;
- for (; i < ac; i++)
- {
- if (av[i][0] == '-')
+ switch ((*first)[1])
{
- switch (av[i][1])
+ case 'r':
+ case 'R':
+ {
+ if (!((++first != last) && ((*first)[0] != '-')))
+ {
+ return badOption("invalid", option.c_str());
+ }
+ m_typeRegName = OString((*first).c_str(), (*first).size());
+ break;
+ }
+ case 'o':
+ case 'O':
{
- case 'r':
- case 'R':
- if (av[i][2] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
- m_typeRegName = OString(s);
- break;
- case 'o':
- case 'O':
- if (av[i][2] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
- m_indexRegName = OString(s);
- break;
- case 'b':
- case 'B':
- if (av[i][2] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
- m_base = OString(s);
- break;
- case 'f':
- case 'F':
- if (av[i][2] != '\0')
- {
- fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- }
- m_bForceOutput = sal_True;
- break;
- case 'h':
- case '?':
- if (av[i][2] != '\0')
- {
- fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- } else
- {
- fprintf(stdout, "%s", prepareHelp().getStr());
- exit(0);
- }
- break;
- default:
- fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
+ if (!((++first != last) && ((*first)[0] != '-')))
+ {
+ return badOption("invalid", option.c_str());
+ }
+ m_indexRegName = (*first);
+ break;
}
- } else
- {
- if (av[i][0] == '@')
+ case 'b':
+ case 'B':
{
- FILE* cmdFile = fopen(av[i]+1, "r");
- if( cmdFile == NULL )
- {
- fprintf(stderr, "%s", prepareHelp().getStr());
- bRet = sal_False;
- } else
+ if (!((++first != last) && ((*first)[0] != '-')))
{
- int rargc=0;
- char* rargv[512];
- char buffer[512];
-
- while ( fscanf(cmdFile, "%s", buffer) != EOF )
- {
- rargv[rargc]= strdup(buffer);
- rargc++;
- }
- fclose(cmdFile);
-
- bRet = initOptions(rargc, rargv, bCmdFile);
-
- for (long j=0; j < rargc; j++)
- {
- free(rargv[j]);
- }
+ return badOption("invalid", option.c_str());
+ }
+ m_base = OString((*first).c_str(), (*first).size());
+ break;
+ }
+ case 'f':
+ case 'F':
+ {
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", option.c_str());
}
- } else
+ m_bForceOutput = sal_True;
+ break;
+ }
+ case 'h':
+ case '?':
{
- fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", option.c_str());
+ }
+ return printUsage();
+ // break; // unreachable
}
+ default:
+ return badOption("unknown", option.c_str());
+ // break; // unreachable
}
}
-
- return bRet;
-}
-
-OString Options::prepareHelp()
-{
- OString help("\nusing: ");
- help += m_program + " -r<filename> -o<filename> [-options] | @<filename>\n";
- help += " -o<filename> = filename specifies the name of the new singleton index registry.\n";
- help += " -r<filename> = filename specifies the name of the type registry.\n";
- help += " @<filename> = filename specifies a command file.\n";
- help += "Options:\n";
- help += " -b<name> = name specifies the name of a start key. The types will be searched\n";
- help += " under this key in the type registry.\n";
- help += " -f = force the output of all found singletons.\n";
- help += " -h|-? = print this help message and exit.\n";
- help += prepareVersion();
-
- return help;
+ return true;
}
-OString Options::prepareVersion()
-{
- OString version(m_program);
- version += " Version 1.0\n\n";
- return version;
-}
-
-static Options options;
-
-static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey)
+static sal_Bool checkSingletons(Options_Impl const & options, RegistryKey& singletonKey, RegistryKey& typeKey)
{
RegValueType valueType = RG_VALUETYPE_NOT_DEFINED;
sal_uInt32 size = 0;
@@ -326,24 +179,22 @@ static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey)
sal_Bool bRet = sal_False;
RegError e = typeKey.getValueInfo(tmpName, &valueType, &size);
-
- if ( e != REG_VALUE_NOT_EXISTS && e != REG_INVALID_VALUE && valueType == RG_VALUETYPE_BINARY)
+ if ((e != REG_VALUE_NOT_EXISTS) && (e != REG_INVALID_VALUE) && (valueType == RG_VALUETYPE_BINARY))
{
- RegistryKey entryKey;
- RegValue value = rtl_allocateMemory(size);
-
- typeKey.getValue(tmpName, value);
-
- RegistryTypeReader reader((sal_uInt8*)value, size, sal_False);
+ std::vector< sal_uInt8 > value(size);
+ typeKey.getValue(tmpName, &value[0]); // @@@ broken api: write to buffer w/o buffer size.
+ RegistryTypeReader reader(&value[0], value.size(), sal_False);
if ( reader.isValid() && reader.getTypeClass() == RT_TYPE_SINGLETON )
{
- OUString singletonName = reader.getTypeName().replace('/', '.');
+ RegistryKey entryKey;
+ OUString singletonName = reader.getTypeName().replace('/', '.');
if ( singletonKey.createKey(singletonName, entryKey) )
{
fprintf(stderr, "%s: could not create SINGLETONS entry for \"%s\"\n",
- options.getProgramName().getStr(), U2S( singletonName ));
- } else
+ options.getProgramName().c_str(), U2S( singletonName ));
+ }
+ else
{
bRet = sal_True;
OUString value2 = reader.getSuperTypeName();
@@ -352,30 +203,26 @@ static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey)
(RegValue)value2.getStr(), sizeof(sal_Unicode)* (value2.getLength()+1)) )
{
fprintf(stderr, "%s: could not create data entry for singleton \"%s\"\n",
- options.getProgramName().getStr(), U2S( singletonName ));
+ options.getProgramName().c_str(), U2S( singletonName ));
}
if ( options.forceOutput() )
{
fprintf(stderr, "%s: create SINGLETON entry for \"%s\" -> \"%s\"\n",
- options.getProgramName().getStr(), U2S( singletonName ), U2S(value2));
+ options.getProgramName().c_str(), U2S( singletonName ), U2S(value2));
}
}
}
-
- rtl_freeMemory(value);
}
RegistryKeyArray subKeys;
-
typeKey.openSubKeys(tmpName, subKeys);
sal_uInt32 length = subKeys.getLength();
- RegistryKey elementKey;
for (sal_uInt32 i = 0; i < length; i++)
{
- elementKey = subKeys.getElement(i);
- if ( checkSingletons(singletonKey, elementKey) )
+ RegistryKey elementKey = subKeys.getElement(i);
+ if ( checkSingletons(options, singletonKey, elementKey) )
{
bRet = sal_True;
}
@@ -389,69 +236,85 @@ int main( int argc, char * argv[] )
int _cdecl main( int argc, char * argv[] )
#endif
{
- if ( !options.initOptions(argc, argv) )
+ std::vector< std::string > args;
+ for (int i = 1; i < argc; i++)
{
- exit(1);
+ int result = Options::checkArgument(args, argv[i], strlen(argv[i]));
+ if (result != 0)
+ {
+ // failure.
+ return (result);
+ }
}
- OUString indexRegName( convertToFileUrl(options.getIndexReg()) );
- OUString typeRegName( convertToFileUrl(options.getTypeReg()) );
+ Options_Impl options(argv[0]);
+ if (!options.initOptions(args))
+ {
+ options.printUsage();
+ return (1);
+ }
+ OUString indexRegName( convertToFileUrl(options.getIndexReg().c_str(), options.getIndexReg().size()) );
Registry indexReg;
- Registry typeReg;
-
if ( indexReg.open(indexRegName, REG_READWRITE) )
{
if ( indexReg.create(indexRegName) )
{
fprintf(stderr, "%s: open registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getIndexReg().getStr());
- exit(2);
+ options.getProgramName().c_str(), options.getIndexReg().c_str());
+ return (2);
}
}
+
+ OUString typeRegName( convertToFileUrl(options.getTypeReg().c_str(), options.getTypeReg().size()) );
+ Registry typeReg;
if ( typeReg.open(typeRegName, REG_READONLY) )
{
fprintf(stderr, "%s: open registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getTypeReg().getStr());
- exit(3);
+ options.getProgramName().c_str(), options.getTypeReg().c_str());
+ return (3);
}
- RegistryKey indexRoot, typeRoot;
+ RegistryKey indexRoot;
if ( indexReg.openRootKey(indexRoot) )
{
fprintf(stderr, "%s: open root key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getIndexReg().getStr());
- exit(4);
+ options.getProgramName().c_str(), options.getIndexReg().c_str());
+ return (4);
}
+
+ RegistryKey typeRoot;
if ( typeReg.openRootKey(typeRoot) )
{
fprintf(stderr, "%s: open root key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getTypeReg().getStr());
- exit(5);
+ options.getProgramName().c_str(), options.getTypeReg().c_str());
+ return (5);
}
- RegistryKey singletonKey, typeKey;
+ RegistryKey typeKey;
if ( options.hasBase() )
{
if ( typeRoot.openKey(S2U(options.getBase()), typeKey) )
{
fprintf(stderr, "%s: open base key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getTypeReg().getStr());
- exit(6);
+ options.getProgramName().c_str(), options.getTypeReg().c_str());
+ return (6);
}
- } else
+ }
+ else
{
typeKey = typeRoot;
}
+ RegistryKey singletonKey;
if ( indexRoot.createKey(OUString::createFromAscii("SINGLETONS"), singletonKey) )
{
fprintf(stderr, "%s: open/create SINGLETONS key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getIndexReg().getStr());
- exit(7);
+ options.getProgramName().c_str(), options.getIndexReg().c_str());
+ return (7);
}
- sal_Bool bSingletonsExist = checkSingletons(singletonKey, typeKey);
+ sal_Bool bSingletonsExist = checkSingletons(options, singletonKey, typeKey);
indexRoot.releaseKey();
typeRoot.releaseKey();
@@ -460,24 +323,22 @@ int _cdecl main( int argc, char * argv[] )
if ( indexReg.close() )
{
fprintf(stderr, "%s: closing registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getIndexReg().getStr());
- exit(9);
+ options.getProgramName().c_str(), options.getIndexReg().c_str());
+ return (9);
}
if ( !bSingletonsExist )
{
if ( indexReg.destroy(OUString()) )
{
fprintf(stderr, "%s: destroy registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getIndexReg().getStr());
- exit(10);
+ options.getProgramName().c_str(), options.getIndexReg().c_str());
+ return (10);
}
}
if ( typeReg.close() )
{
fprintf(stderr, "%s: closing registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getTypeReg().getStr());
- exit(11);
+ options.getProgramName().c_str(), options.getTypeReg().c_str());
+ return (11);
}
}
-
-
diff --git a/registry/tools/fileurl.cxx b/registry/tools/fileurl.cxx
new file mode 100644
index 000000000000..e3561888c674
--- /dev/null
+++ b/registry/tools/fileurl.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "fileurl.hxx"
+
+#include "rtl/ustring.hxx"
+#include "osl/diagnose.h"
+#include "osl/file.hxx"
+#include "osl/process.h"
+#include "osl/thread.h"
+
+#include <string.h>
+
+#ifdef SAL_UNX
+#define SEPARATOR '/'
+#else
+#define SEPARATOR '\\'
+#endif
+
+using rtl::OUString;
+using osl::FileBase;
+
+namespace registry
+{
+namespace tools
+{
+
+OUString convertToFileUrl(char const * filename, size_t length)
+{
+ OUString const uFileName(filename, length, osl_getThreadTextEncoding());
+ if (strncmp(filename, "file://", 7) == 0)
+ {
+ // already a FileUrl.
+ return uFileName;
+ }
+
+ OUString uFileUrl;
+ if (length > 0)
+ {
+ if ((filename[0] == '.') || (filename[0] != SEPARATOR))
+ {
+ // relative path name.
+ OUString uWorkingDir;
+ if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
+ {
+ OSL_ASSERT(false);
+ }
+ if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uFileUrl) != FileBase::E_None)
+ {
+ OSL_ASSERT(false);
+ }
+ }
+ else
+ {
+ // absolute path name.
+ if (FileBase::getFileURLFromSystemPath(uFileName, uFileUrl) != FileBase::E_None)
+ {
+ OSL_ASSERT(false);
+ }
+ }
+ }
+ return uFileUrl;
+}
+
+} // namespace tools
+} // namespace registry
diff --git a/registry/tools/fileurl.hxx b/registry/tools/fileurl.hxx
new file mode 100644
index 000000000000..bbaa218f32e6
--- /dev/null
+++ b/registry/tools/fileurl.hxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_REGISTRY_TOOLS_FILEURL_HXX
+#define INCLUDED_REGISTRY_TOOLS_FILEURL_HXX
+
+#include "rtl/ustring.hxx"
+
+namespace registry
+{
+namespace tools
+{
+
+rtl::OUString convertToFileUrl(char const * filename, size_t length);
+
+} // namespace tools
+} // namespace registry
+
+#endif /* INCLUDED_REGISTRY_TOOLS_FILEURL_HXX */
diff --git a/registry/tools/makefile.mk b/registry/tools/makefile.mk
index 1f0f75f0ecbc..06ca753ff044 100644
--- a/registry/tools/makefile.mk
+++ b/registry/tools/makefile.mk
@@ -43,7 +43,7 @@ ENABLE_EXCEPTIONS := TRUE
CDEFS += -DDLL_VERSION=$(EMQ)"$(DLLPOSTFIX)$(EMQ)"
APP1TARGET= $(TARGET)
-APP1OBJS= $(OBJ)$/regmerge.obj
+APP1OBJS= $(OBJ)$/regmerge.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj
APP1RPATH= UREBIN
APP1STDLIBS=\
@@ -51,7 +51,7 @@ APP1STDLIBS=\
$(REGLIB)
APP2TARGET= regview
-APP2OBJS= $(OBJ)$/regview.obj
+APP2OBJS= $(OBJ)$/regview.obj $(OBJ)/fileurl.obj
APP2RPATH= UREBIN
APP2STDLIBS=\
@@ -59,7 +59,7 @@ APP2STDLIBS=\
$(REGLIB)
APP3TARGET= regcompare
-APP3OBJS= $(OBJ)$/regcompare.obj
+APP3OBJS= $(OBJ)$/regcompare.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj
APP3RPATH= SDK
APP3STDLIBS=\
@@ -68,7 +68,7 @@ APP3STDLIBS=\
$(REGLIB)
APP4TARGET= checksingleton
-APP4OBJS= $(OBJ)$/checksingleton.obj
+APP4OBJS= $(OBJ)$/checksingleton.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj
APP4STDLIBS=\
$(SALLIB) \
diff --git a/registry/tools/options.cxx b/registry/tools/options.cxx
new file mode 100644
index 000000000000..d851825ebfb6
--- /dev/null
+++ b/registry/tools/options.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "options.hxx"
+
+#include "osl/diagnose.h"
+
+#include <stdio.h>
+#include <string.h>
+
+namespace registry
+{
+namespace tools
+{
+
+Options::Options (char const * program)
+ : m_program (program)
+{}
+
+Options::~Options()
+{}
+
+// static
+bool Options::checkArgument(std::vector< std::string> & rArgs, char const * arg, size_t len)
+{
+ bool result = ((arg != 0) && (len > 0));
+ OSL_PRECOND(result, "registry::tools::Options::checkArgument(): invalid arguments");
+ if (result)
+ {
+ OSL_TRACE("registry::tools:Options::checkArgument(): \"%s\"", arg);
+ switch (arg[0])
+ {
+ case '@':
+ if ((result = (len > 1)) == true)
+ {
+ // "@<cmdfile>"
+ result = Options::checkCommandFile(rArgs, &(arg[1]));
+ }
+ break;
+ case '-':
+ if ((result = (len > 1)) == true)
+ {
+ // "-<option>"
+ std::string option (&(arg[0]), 2);
+ rArgs.push_back(option);
+ if (len > 2)
+ {
+ // "-<option><param>"
+ std::string param(&(arg[2]), len - 2);
+ rArgs.push_back(param);
+ }
+ }
+ break;
+ default:
+ rArgs.push_back(std::string(arg, len));
+ break;
+ }
+ }
+ return (result);
+}
+
+// static
+bool Options::checkCommandFile(std::vector< std::string > & rArgs, char const * filename)
+{
+ FILE * fp = fopen(filename, "r");
+ if (fp == 0)
+ {
+ fprintf(stderr, "ERROR: Can't open command file \"%s\"\n", filename);
+ return (false);
+ }
+
+ std::string buffer;
+ buffer.reserve(256);
+
+ bool quoted = false;
+ int c = EOF;
+ while ((c = fgetc(fp)) != EOF)
+ {
+ switch(c)
+ {
+ case '\"':
+ quoted = !quoted;
+ break;
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ if (!quoted)
+ {
+ if (!buffer.empty())
+ {
+ if (!checkArgument(rArgs, buffer.c_str(), buffer.size()))
+ {
+ // failure.
+ (void) fclose(fp);
+ return false;
+ }
+ buffer.clear();
+ }
+ break;
+ }
+ default:
+ // quoted white-space fall through
+ buffer.push_back(sal::static_int_cast<char>(c));
+ break;
+ }
+ }
+ return (fclose(fp) == 0);
+}
+
+bool Options::initOptions (std::vector< std::string > & rArgs)
+{
+ return initOptions_Impl (rArgs);
+}
+
+bool Options::badOption (char const * reason, char const * option) const
+{
+ (void) fprintf(stderr, "%s: %s option '%s'\n", m_program.c_str(), reason, option);
+ return printUsage();
+}
+
+bool Options::printUsage() const
+{
+ printUsage_Impl();
+ return false;
+}
+
+} // namespace tools
+} // namespace registry
diff --git a/registry/tools/options.hxx b/registry/tools/options.hxx
new file mode 100644
index 000000000000..8e4c97877e3b
--- /dev/null
+++ b/registry/tools/options.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_REGISTRY_TOOLS_OPTIONS_HXX
+#define INCLUDED_REGISTRY_TOOLS_OPTIONS_HXX
+
+#include <string>
+#include <vector>
+
+namespace registry
+{
+namespace tools
+{
+class Options
+{
+ std::string m_program;
+
+ Options (Options const &);
+ Options & operator= (Options const &);
+
+public:
+ explicit Options (char const * program);
+ virtual ~Options();
+
+ static bool checkArgument (std::vector< std::string > & rArgs, char const * arg, size_t len);
+
+ bool initOptions (std::vector< std::string > & rArgs);
+ bool badOption (char const * reason, char const * option) const;
+
+ std::string const & getProgramName() const { return m_program; }
+ bool printUsage() const;
+
+protected:
+ static bool checkCommandFile(std::vector< std::string > & rArgs, char const * filename);
+
+ virtual bool initOptions_Impl(std::vector< std::string > & rArgs) = 0;
+ virtual void printUsage_Impl() const = 0;
+};
+
+} // namespace tools
+} // namespace registry
+
+#endif /* INCLUDED_REGISTRY_TOOLS_OPTIONS_HXX */
diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx
index ec8cdaa9e1a6..0eaa220ae2de 100644
--- a/registry/tools/regcompare.cxx
+++ b/registry/tools/regcompare.cxx
@@ -28,411 +28,266 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
-#include <stdio.h>
-#include <string.h>
-
-#include <set>
-#include <vector>
#include "registry/registry.hxx"
#include "registry/reader.hxx"
#include "registry/version.h"
+#include "fileurl.hxx"
+#include "options.hxx"
+
#include <rtl/ustring.hxx>
-#include <rtl/alloc.h>
-#include <osl/process.h>
#include <osl/diagnose.h>
-#include <osl/thread.h>
-#include <osl/file.hxx>
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
+#include <stdio.h>
+#include <string.h>
-using namespace ::rtl;
-using namespace ::osl;
+#include <set>
+#include <vector>
+#include <string>
-OUString shortName(const OUString& fullName)
-{
- return fullName.copy(fullName.lastIndexOf('/') + 1);
-}
+using namespace rtl;
+using namespace registry::tools;
-sal_Bool isFileUrl(const OString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
+typedef std::set< rtl::OUString > StringSet;
-OUString convertToFileUrl(const OString& fileName)
+class Options_Impl : public Options
{
- if ( isFileUrl(fileName) )
- {
- return OStringToOUString(fileName, osl_getThreadTextEncoding());
- }
-
- OUString uUrlFileName;
- OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
- {
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
- {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- }
+public:
+ explicit Options_Impl(char const * program)
+ : Options(program),
+ m_bFullCheck(false),
+ m_bForceOutput(false),
+ m_bUnoTypeCheck(false),
+ m_checkUnpublished(false)
+ {}
- return uUrlFileName;
-}
+ std::string const & getRegName1() const { return m_regName1; }
+ std::string const & getRegName2() const { return m_regName2; }
-#define U2S( s ) \
- OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr()
-#define S2U( s ) \
- OStringToOUString(s, RTL_TEXTENCODING_UTF8)
+ bool isStartKeyValid() const { return (m_startKey.getLength() > 0); }
+ OUString const & getStartKey() const { return m_startKey; }
+ bool matchedWithExcludeKey( const OUString& keyName) const;
-struct LessString
-{
- sal_Bool operator()(const OUString& str1, const OUString& str2) const
- {
- return (str1 < str2);
- }
-};
+ bool fullCheck() const { return m_bFullCheck; }
+ bool forceOutput() const { return m_bForceOutput; }
+ bool unoTypeCheck() const { return m_bUnoTypeCheck; }
+ bool checkUnpublished() const { return m_checkUnpublished; }
-typedef ::std::set< OUString > StringSet;
+protected:
+ bool setRegName_Impl(char c, std::string const & param);
-class Options
-{
-public:
- Options()
- : m_bFullCheck(sal_False)
- , m_bForceOutput(sal_False)
- , m_bUnoTypeCheck(sal_False)
- , m_checkUnpublished(false)
- {}
- ~Options()
- {}
+ virtual void printUsage_Impl() const;
+ virtual bool initOptions_Impl (std::vector< std::string > & rArgs);
- sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False);
-
- OString prepareHelp();
- OString prepareVersion();
-
- const OString& getProgramName()
- { return m_program; }
- const OString& getRegName1()
- { return m_regName1; }
- const OString& getRegName2()
- { return m_regName2; }
- sal_Bool isStartKeyValid()
- { return (m_startKey.getLength() > 0); };
- const OString& getStartKey()
- { return m_startKey; }
- sal_Bool existsExcludeKeys()
- { return !m_excludeKeys.empty(); };
- StringSet& getExcludeKeys()
- { return m_excludeKeys; }
- sal_Bool matchedWithExcludeKey( const OUString& keyName);
- sal_Bool fullCheck()
- { return m_bFullCheck; }
- sal_Bool forceOutput()
- { return m_bForceOutput; }
- sal_Bool unoTypeCheck()
- { return m_bUnoTypeCheck; }
- bool checkUnpublished() const { return m_checkUnpublished; }
-protected:
- OString m_program;
- OString m_regName1;
- OString m_regName2;
- OString m_startKey;
+ std::string m_regName1;
+ std::string m_regName2;
+ OUString m_startKey;
StringSet m_excludeKeys;
- sal_Bool m_bFullCheck;
- sal_Bool m_bForceOutput;
- sal_Bool m_bUnoTypeCheck;
+ bool m_bFullCheck;
+ bool m_bForceOutput;
+ bool m_bUnoTypeCheck;
bool m_checkUnpublished;
};
-sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile)
-{
- sal_Bool bRet = sal_True;
- sal_uInt16 i=0;
+#define U2S( s ) OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr()
- if (!bCmdFile)
- {
- bCmdFile = sal_True;
+inline rtl::OUString makeOUString (std::string const & s)
+{
+ return rtl::OUString(s.c_str(), s.size(), RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
+}
- OString name(av[0]);
- sal_Int32 index = name.lastIndexOf(SEPARATOR);
- m_program = name.copy((index > 0 ? index+1 : 0));
+inline rtl::OUString shortName(rtl::OUString const & fullName)
+{
+ return fullName.copy(fullName.lastIndexOf('/') + 1);
+}
- if (ac < 2)
- {
- fprintf(stdout, "%s", prepareHelp().getStr());
- bRet = sal_False;
- }
+bool Options_Impl::setRegName_Impl(char c, std::string const & param)
+{
+ bool one = (c == '1'), two = (c == '2');
+ if (one)
+ m_regName1 = param;
+ if (two)
+ m_regName2 = param;
+ return (one || two);
+}
- i = 1;
- } else
- {
- i = 0;
- }
+//virtual
+void Options_Impl::printUsage_Impl() const
+{
+ std::string const & rProgName = getProgramName();
+ fprintf(stderr,
+ "Usage: %s -r1<filename> -r2<filename> [-options] | @<filename>\n", rProgName.c_str()
+ );
+ fprintf(stderr,
+ " -r1<filename> = filename specifies the name of the first registry.\n"
+ " -r2<filename> = filename specifies the name of the second registry.\n"
+ " @<filename> = filename specifies a command file.\n"
+ "Options:\n"
+ " -s<name> = name specifies the name of a start key. If no start key\n"
+ " |S<name> is specified the comparison starts with the root key.\n"
+ " -x<name> = name specifies the name of a key which won't be compared. All\n"
+ " |X<name> subkeys won't be compared also. This option can be used more than once.\n"
+ " -f|F = force the detailed output of any diffenrences. Default\n"
+ " is that only the number of differences is returned.\n"
+ " -c|C = make a complete check, that means any differences will be\n"
+ " detected. Default is only a compatibility check that means\n"
+ " only UNO typelibrary entries will be checked.\n"
+ " -t|T = make an UNO type compatiblity check. This means that registry 2\n"
+ " will be checked against registry 1. If a interface in r2 contains\n"
+ " more methods or the methods are in a different order as in r1, r2 is\n"
+ " incompatible to r1. But if a service in r2 supports more properties as\n"
+ " in r1 and the new properties are 'optional' it is compatible.\n"
+ " -u|U = additionally check types that are unpublished in registry 1.\n"
+ " -h|-? = print this help message and exit.\n"
+ );
+ fprintf(stderr,
+ "\n%s Version 1.0\n\n", rProgName.c_str()
+ );
+}
- char *s=NULL;
- for (; i < ac; i++)
+// virtual
+bool Options_Impl::initOptions_Impl (std::vector< std::string > & rArgs)
+{
+ std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
+ for (; first != last; ++first)
{
- if (av[i][0] == '-')
+ if ((*first)[0] != '-')
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ switch ((*first)[1])
{
- switch (av[i][1])
+ case 'r':
+ case 'R':
{
- case 'r':
- case 'R':
+ if (!((++first != last) && ((*first)[0] != '-')))
{
- sal_Bool bFirst = sal_True;
- if (av[i][2] == '2')
- {
- bFirst = sal_False;
- } else if (av[i][2] != '1')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- }
- if (av[i][3] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
+ return badOption("invalid", (*first).c_str());
+ }
- if ( bFirst )
- {
- m_regName1 = OString(s);
- } else
+ std::string option(*first), param;
+ if (option.size() == 1)
+ {
+ // "-r<n><space><param>"
+ if (!((++first != last) && ((*first)[0] != '-')))
{
- m_regName2 = OString(s);
+ return badOption("invalid", (*first).c_str());
}
+ param = (*first);
}
- break;
- case 's':
- case 'S':
- if (av[i][2] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
- m_startKey = OString(s);
- break;
- case 'x':
- case 'X':
- if (av[i][2] == '\0')
- {
- if (i < ac - 1 && av[i+1][0] != '-')
- {
- i++;
- s = av[i];
- } else
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
- }
- } else
- {
- s = av[i] + 2;
- }
- m_excludeKeys.insert(S2U(s));
- break;
- case 'c':
- case 'C':
- if (av[i][2] != '\0')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- }
- m_bFullCheck = sal_True;
- break;
- case 'f':
- case 'F':
- if (av[i][2] != '\0')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- }
- m_bForceOutput = sal_True;
- break;
- case 't':
- case 'T':
- if (av[i][2] != '\0')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- }
- m_bUnoTypeCheck = sal_True;
- break;
- case 'u':
- case 'U':
- if (av[i][2] != '\0')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- }
- m_checkUnpublished = true;
- break;
- case 'h':
- case '?':
- if (av[i][2] != '\0')
- {
- fprintf(stdout, "%s: invalid option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- } else
- {
- fprintf(stdout, "%s", prepareHelp().getStr());
- exit(0);
- }
- break;
- default:
- fprintf(stdout, "%s: unknown option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
- break;
+ else
+ {
+ // "-r<n><param>"
+ param = std::string(&(option[1]), option.size() - 1);
+ }
+ if (!setRegName_Impl(option[0], param))
+ {
+ return badOption("invalid", option.c_str());
+ }
+ break;
}
- } else
- {
- if (av[i][0] == '@')
+ case 's':
+ case 'S':
{
- FILE* cmdFile = fopen(av[i]+1, "r");
- if( cmdFile == NULL )
- {
- fprintf(stdout, "%s", prepareHelp().getStr());
- bRet = sal_False;
- } else
+ if (!((++first != last) && ((*first)[0] != '-')))
{
- int rargc=0;
- char* rargv[512];
- char buffer[512];
-
- while ( fscanf(cmdFile, "%s", buffer) != EOF )
- {
- rargv[rargc]= strdup(buffer);
- rargc++;
- }
- fclose(cmdFile);
-
- bRet = initOptions(rargc, rargv, bCmdFile);
-
- for (long j=0; j < rargc; j++)
- {
- free(rargv[j]);
- }
+ return badOption("invalid", (*first).c_str());
+ }
+ m_startKey = makeOUString(*first);
+ break;
+ }
+ case 'x':
+ case 'X':
+ {
+ if (!((++first != last) && ((*first)[0] != '-')))
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ m_excludeKeys.insert(makeOUString(*first));
+ break;
+ }
+ case 'f':
+ case 'F':
+ {
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ m_bForceOutput = sal_True;
+ break;
+ }
+ case 'c':
+ case 'C':
+ {
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ m_bFullCheck = sal_True;
+ break;
+ }
+ case 't':
+ case 'T':
+ {
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ m_bUnoTypeCheck = sal_True;
+ break;
+ }
+ case 'u':
+ case 'U':
+ {
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", (*first).c_str());
}
- } else
+ m_checkUnpublished = true;
+ break;
+ }
+ case 'h':
+ case '?':
{
- fprintf(stdout, "%s: unknown option '%s'\n", m_program.getStr(), av[i]);
- bRet = sal_False;
+ if ((*first).size() > 2)
+ {
+ return badOption("invalid", (*first).c_str());
+ }
+ return printUsage();
+ // break; // Unreachable
+ }
+ default:
+ {
+ return badOption("unknown", (*first).c_str());
+ // break; // Unreachable
}
}
}
- if ( bRet )
+ if ( m_regName1.size() == 0 )
{
- if ( m_regName1.getLength() == 0 )
- {
- fprintf(stdout, "%s: missing option '-r1'\n", m_program.getStr());
- bRet = sal_False;
- }
- if ( m_regName2.getLength() == 0 )
- {
- fprintf(stdout, "%s: missing option '-r2'\n", m_program.getStr());
- bRet = sal_False;
- }
+ return badOption("missing", "-r1");
}
-
- return bRet;
-}
-
-OString Options::prepareHelp()
-{
- OString help("\nusing: ");
- help += m_program + " -r1<filename> -r2<filename> [-options] | @<filename>\n";
- help += " -r1<filename> = filename specifies the name of the first registry.\n";
- help += " -r2<filename> = filename specifies the name of the second registry.\n";
- help += " @<filename> = filename specifies a command file.\n";
- help += "Options:\n";
- help += " -s<name> = name specifies the name of a start key. If no start key\n";
- help += " |S<name> is specified the comparison starts with the root key.\n";
- help += " -x<name> = name specifies the name of a key which won't be compared. All\n";
- help += " |X<name> subkeys won't be compared also. This option can be used more than once.\n";
- help += " -f|F = force the detailed output of any diffenrences. Default\n";
- help += " is that only the number of differences is returned.\n";
- help += " -c|C = make a complete check, that means any differences will be\n";
- help += " detected. Default is only a compatibility check that means\n";
- help += " only UNO typelibrary entries will be checked.\n";
- help += " -t|T = make an UNO type compatiblity check. This means that registry 2\n";
- help += " will be checked against registry 1. If a interface in r2 contains\n";
- help += " more methods or the methods are in a different order as in r1, r2 is\n";
- help += " incompatible to r1. But if a service in r2 supports more properties as\n";
- help += " in r1 and the new properties are 'optonal' it is compatible.\n";
- help += " -u|U = additionally check types that are unpublished in registry 1.\n";
- help += " -h|-? = print this help message and exit.\n\n";
- help += prepareVersion();
-
- return help;
-}
-
-OString Options::prepareVersion()
-{
- OString version(m_program);
- version += " Version 1.0\n\n";
- return version;
+ if ( m_regName2.size() == 0 )
+ {
+ return badOption("missing", "-r2");
+ }
+ return true;
}
-sal_Bool Options::matchedWithExcludeKey( const OUString& keyName)
+bool Options_Impl::matchedWithExcludeKey( const OUString& keyName) const
{
- if ( m_excludeKeys.empty() )
- return sal_False;
-
- StringSet::const_iterator iter = m_excludeKeys.begin();
- StringSet::const_iterator end = m_excludeKeys.end();
-
- while ( iter != end )
+ if (!m_excludeKeys.empty())
{
- if ( keyName.indexOf(*iter) == 0)
- return sal_True;
-
- ++iter;
+ StringSet::const_iterator first = m_excludeKeys.begin(), last = m_excludeKeys.end();
+ for (; first != last; ++first)
+ {
+ if (keyName.indexOf(*first) == 0)
+ return true;
+ }
}
-
- return sal_False;
+ return false;
}
-static Options options;
-
static char const * getTypeClass(RTTypeClass typeClass)
{
switch (typeClass)
@@ -552,6 +407,7 @@ static char const * getConstValueType(RTConstValue& constValue)
return "NONE";
}
}
+
static void printConstValue(RTConstValue& constValue)
{
switch (constValue.m_type)
@@ -604,9 +460,17 @@ static void printConstValue(RTConstValue& constValue)
}
}
-static sal_uInt32 checkConstValue(const OUString& keyName,
+static void dumpTypeClass(sal_Bool & rbDump, RTTypeClass typeClass, OUString const & keyName)
+{
+ if (rbDump)
+ fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
+ rbDump = sal_False;
+}
+
+static sal_uInt32 checkConstValue(Options_Impl const & options,
+ const OUString& keyName,
RTTypeClass typeClass,
- sal_Bool& bDump,
+ sal_Bool & bDump,
RTConstValue& constValue1,
RTConstValue& constValue2,
sal_uInt16 index1)
@@ -620,11 +484,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %s != Value2 = %s\n", index1,
constValue1.m_value.aBool ? "TRUE" : "FALSE",
constValue2.m_value.aBool ? "TRUE" : "FALSE");
@@ -637,11 +497,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %d != Value2 = %d\n", index1,
constValue1.m_value.aByte, constValue2.m_value.aByte);
}
@@ -653,11 +509,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %d != Value2 = %d\n", index1,
constValue1.m_value.aShort, constValue2.m_value.aShort);
}
@@ -669,11 +521,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %d != Value2 = %d\n", index1,
constValue1.m_value.aUShort, constValue2.m_value.aUShort);
}
@@ -685,11 +533,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %ld != Value2 = %ld\n", index1,
sal::static_int_cast< long >(constValue1.m_value.aLong),
sal::static_int_cast< long >(constValue2.m_value.aLong));
@@ -702,11 +546,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %lu != Value2 = %lu\n", index1,
sal::static_int_cast< unsigned long >(constValue1.m_value.aULong),
sal::static_int_cast< unsigned long >(constValue2.m_value.aULong));
@@ -719,11 +559,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(
stdout, " Field %d: Value1 = %s != Value2 = %s\n",
index1,
@@ -742,11 +578,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(
stdout, " Field %d: Value1 = %s != Value2 = %s\n",
index1,
@@ -771,11 +603,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %f != Value2 = %f\n", index1,
constValue1.m_value.aFloat, constValue2.m_value.aFloat);
}
@@ -787,11 +615,7 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Value1 = %f != Value2 = %f\n", index1,
constValue1.m_value.aDouble, constValue2.m_value.aDouble);
}
@@ -805,45 +629,37 @@ static sal_uInt32 checkConstValue(const OUString& keyName,
return 0;
}
-static sal_uInt32 checkField(const OUString& keyName,
+static sal_uInt32 checkField(Options_Impl const & options,
+ const OUString& keyName,
RTTypeClass typeClass,
- sal_Bool& bDump,
+ sal_Bool & bDump,
typereg::Reader& reader1,
typereg::Reader& reader2,
sal_uInt16 index1,
sal_uInt16 index2)
{
sal_uInt32 nError = 0;
- if ( reader1.getFieldName(index1) !=
- reader2.getFieldName(index2) )
+ if ( reader1.getFieldName(index1) != reader2.getFieldName(index2) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Name1 = %s != Name2 = %s\n", index1,
U2S(reader1.getFieldName(index1)), U2S(reader2.getFieldName(index2)));
}
nError++;
}
- if ( reader1.getFieldTypeName(index1) !=
- reader2.getFieldTypeName(index2) )
+ if ( reader1.getFieldTypeName(index1) != reader2.getFieldTypeName(index2) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Type1 = %s != Type2 = %s\n", index1,
U2S(reader1.getFieldTypeName(index1)), U2S(reader2.getFieldTypeName(index2)));
}
nError++;
- } else
+ }
+ else
{
RTConstValue constValue1 = reader1.getFieldValue(index1);
RTConstValue constValue2 = reader2.getFieldValue(index2);
@@ -851,11 +667,7 @@ static sal_uInt32 checkField(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Access1 = %s != Access2 = %s\n", index1,
getConstValueType(constValue1), getConstValueType(constValue2));
fprintf(stdout, " Field %d: Value1 = ", index1);
@@ -865,9 +677,10 @@ static sal_uInt32 checkField(const OUString& keyName,
fprintf(stdout, "\n;");
}
nError++;
- } else
+ }
+ else
{
- nError += checkConstValue(keyName, typeClass, bDump, constValue1, constValue2, index1);
+ nError += checkConstValue(options, keyName, typeClass, bDump, constValue1, constValue2, index1);
}
}
@@ -875,11 +688,7 @@ static sal_uInt32 checkField(const OUString& keyName,
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Field %d: FieldAccess1 = %s != FieldAccess2 = %s\n", index1,
getFieldAccess(reader1.getFieldFlags(index1)).getStr(),
getFieldAccess(reader1.getFieldFlags(index2)).getStr());
@@ -887,16 +696,11 @@ static sal_uInt32 checkField(const OUString& keyName,
nError++;
}
- if ( options.fullCheck() &&
- (reader1.getFieldDocumentation(index1) != reader2.getFieldDocumentation(index2)) )
+ if ( options.fullCheck() && (reader1.getFieldDocumentation(index1) != reader2.getFieldDocumentation(index2)) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Field %d: Doku1 = %s\n Doku2 = %s\n", index1,
U2S(reader1.getFieldDocumentation(index1)), U2S(reader2.getFieldDocumentation(index2)));
}
@@ -937,24 +741,20 @@ static char const * getParamMode(RTParamMode paramMode)
}
}
-static sal_uInt32 checkMethod(const OUString& keyName,
+static sal_uInt32 checkMethod(Options_Impl const & options,
+ const OUString& keyName,
RTTypeClass typeClass,
- sal_Bool& bDump,
+ sal_Bool & bDump,
typereg::Reader& reader1,
typereg::Reader& reader2,
sal_uInt16 index)
{
sal_uInt32 nError = 0;
- if ( reader1.getMethodName(index) !=
- reader2.getMethodName(index) )
+ if ( reader1.getMethodName(index) != reader2.getMethodName(index) )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method1 %d: Name1 = %s != Name2 = %s\n", index,
U2S(reader1.getMethodName(index)),
U2S(reader2.getMethodName(index)));
@@ -962,16 +762,11 @@ static sal_uInt32 checkMethod(const OUString& keyName,
nError++;
}
- if ( reader1.getMethodReturnTypeName(index) !=
- reader2.getMethodReturnTypeName(index) )
+ if ( reader1.getMethodReturnTypeName(index) != reader2.getMethodReturnTypeName(index) )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method1 %d: ReturnType1 = %s != ReturnType2 = %s\n", index,
U2S(reader1.getMethodReturnTypeName(index)),
U2S(reader2.getMethodReturnTypeName(index)));
@@ -985,11 +780,7 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d : nParameters1 = %d != nParameters2 = %d\n", index, nParams1, nParams2);
}
nError++;
@@ -1001,27 +792,18 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d, Parameter %d: Type1 = %s != Type2 = %s\n", index, i,
U2S(reader1.getMethodParameterTypeName(index, i)),
U2S(reader2.getMethodParameterTypeName(index, i)));
}
nError++;
}
- if ( options.fullCheck() &&
- (reader1.getMethodParameterName(index, i) != reader2.getMethodParameterName(index, i)) )
+ if ( options.fullCheck() && (reader1.getMethodParameterName(index, i) != reader2.getMethodParameterName(index, i)) )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d, Parameter %d: Name1 = %s != Name2 = %s\n", index, i,
U2S(reader1.getMethodParameterName(index, i)),
U2S(reader2.getMethodParameterName(index, i)));
@@ -1032,11 +814,7 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d, Parameter %d: Mode1 = %s != Mode2 = %s\n", index, i,
getParamMode(reader1.getMethodParameterFlags(index, i)),
getParamMode(reader2.getMethodParameterFlags(index, i)));
@@ -1046,20 +824,12 @@ static sal_uInt32 checkMethod(const OUString& keyName,
}
if ( i < nParams1 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Registry1: Method %d contains %d more parameters\n", index, nParams1 - i);
}
if ( i < nParams2 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Registry2: Method %d contains %d more parameters\n", index, nParams2 - i);
}
@@ -1069,11 +839,7 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " nExceptions1 = %d != nExceptions2 = %d\n", nExcep1, nExcep2);
}
nError++;
@@ -1084,11 +850,7 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d, Exception %d: Name1 = %s != Name2 = %s\n", index, i,
U2S(reader1.getMethodExceptionTypeName(index, i)),
U2S(reader2.getMethodExceptionTypeName(index, i)));
@@ -1098,20 +860,12 @@ static sal_uInt32 checkMethod(const OUString& keyName,
}
if ( i < nExcep1 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Registry1: Method %d contains %d more exceptions\n", index, nExcep1 - i);
}
if ( i < nExcep2 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Registry2: Method %d contains %d more exceptions\n", index, nExcep2 - i);
}
@@ -1119,11 +873,7 @@ static sal_uInt32 checkMethod(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d: Mode1 = %s != Mode2 = %s\n", index,
getMethodMode(reader1.getMethodFlags(index)),
getMethodMode(reader2.getMethodFlags(index)));
@@ -1131,16 +881,11 @@ static sal_uInt32 checkMethod(const OUString& keyName,
nError++;
}
- if ( options.fullCheck() &&
- (reader1.getMethodDocumentation(index) != reader2.getMethodDocumentation(index)) )
+ if ( options.fullCheck() && (reader1.getMethodDocumentation(index) != reader2.getMethodDocumentation(index)) )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Method %d: Doku1 = %s\n Doku2 = %s\n", index,
U2S(reader1.getMethodDocumentation(index)),
U2S(reader2.getMethodDocumentation(index)));
@@ -1167,73 +912,54 @@ static char const * getReferenceType(RTReferenceType refType)
}
}
-static sal_uInt32 checkReference(const OUString& keyName,
+static sal_uInt32 checkReference(Options_Impl const & options,
+ const OUString& keyName,
RTTypeClass typeClass,
- sal_Bool& bDump,
+ sal_Bool & bDump,
typereg::Reader& reader1,
typereg::Reader& reader2,
sal_uInt16 index1,
sal_uInt16 index2)
{
sal_uInt32 nError = 0;
- if ( reader1.getReferenceTypeName(index1) !=
- reader2.getReferenceTypeName(index2) )
+ if ( reader1.getReferenceTypeName(index1) != reader2.getReferenceTypeName(index2) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Reference %d: Name1 = %s != Name2 = %s\n", index1,
U2S(reader1.getReferenceTypeName(index1)),
U2S(reader2.getReferenceTypeName(index2)));
}
nError++;
}
- if ( reader1.getReferenceTypeName(index1) !=
- reader2.getReferenceTypeName(index2) )
+ if ( reader1.getReferenceTypeName(index1) != reader2.getReferenceTypeName(index2) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Reference %d: Type1 = %s != Type2 = %s\n", index1,
getReferenceType(reader1.getReferenceSort(index1)),
getReferenceType(reader2.getReferenceSort(index2)));
}
nError++;
}
- if ( options.fullCheck() &&
- (reader1.getReferenceDocumentation(index1) != reader2.getReferenceDocumentation(index2)) )
+ if ( options.fullCheck() && (reader1.getReferenceDocumentation(index1) != reader2.getReferenceDocumentation(index2)) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Reference %d: Doku1 = %s\n Doku2 = %s\n", index1,
U2S(reader1.getReferenceDocumentation(index1)),
U2S(reader2.getReferenceDocumentation(index2)));
}
nError++;
}
- if ( reader1.getReferenceFlags(index1) !=
- reader2.getReferenceFlags(index2) )
+ if ( reader1.getReferenceFlags(index1) != reader2.getReferenceFlags(index2) )
{
if ( options.forceOutput() && !options.unoTypeCheck() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " Reference %d: Access1 = %s != Access2 = %s\n", index1,
getFieldAccess(reader1.getReferenceFlags(index1)).getStr(),
getFieldAccess(reader1.getReferenceFlags(index2)).getStr());
@@ -1243,9 +969,10 @@ static sal_uInt32 checkReference(const OUString& keyName,
return nError;
}
-static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
+static sal_uInt32 checkFieldsWithoutOrder(Options_Impl const & options,
+ const OUString& keyName,
RTTypeClass typeClass,
- sal_Bool& bDump,
+ sal_Bool & bDump,
typereg::Reader& reader1,
typereg::Reader& reader2)
{
@@ -1259,13 +986,9 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
- fprintf(stdout, " %s1 contains %d more properties as %s2\n",
- getTypeClass(typeClass), nFields1-nFields2, getTypeClass(typeClass));
+ dumpTypeClass (bDump, typeClass, keyName);
+ fprintf(stdout, " %s1 contains %d more properties as %s2\n",
+ getTypeClass(typeClass), nFields1-nFields2, getTypeClass(typeClass));
}
}
@@ -1276,7 +999,7 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
{
for (j=0; j < nFields2; j++)
{
- if (!checkField(keyName, typeClass, bDump, reader1, reader2, i, j))
+ if (!checkField(options, keyName, typeClass, bDump, reader1, reader2, i, j))
{
bFound = sal_True;
moreProps.insert(j);
@@ -1287,16 +1010,13 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
{
if (options.forceOutput())
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass (bDump, typeClass, keyName);
fprintf(stdout, " incompatible change: Field %d ('%s') of r1 is not longer a property of this %s in r2\n",
i, U2S(shortName(reader1.getFieldName(i))), getTypeClass(typeClass));
}
nError++;
- } else
+ }
+ else
{
bFound = sal_False;
}
@@ -1312,12 +1032,10 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
- fprintf(stdout, " incompatible change: Field %d ('%s') of r2 is a new property compared to this %s in r1 and is not 'optional'\n",
+ dumpTypeClass (bDump, typeClass, keyName);
+ fprintf(stdout,
+ " incompatible change: Field %d ('%s') of r2 is a new property"
+ " compared to this %s in r1 and is not 'optional'\n",
j, U2S(shortName(reader2.getFieldName(j))), getTypeClass(typeClass));
}
nError++;
@@ -1329,8 +1047,11 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName,
return nError;
}
-static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, sal_uInt32 size1,
- typereg::Reader& reader2, sal_uInt32 size2)
+static sal_uInt32 checkBlob(
+ Options_Impl const & options,
+ const OUString& keyName,
+ typereg::Reader& reader1, sal_uInt32 size1,
+ typereg::Reader& reader2, sal_uInt32 size2)
{
sal_uInt32 nError = 0;
sal_Bool bDump = sal_True;
@@ -1345,28 +1066,27 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
sal::static_int_cast< unsigned long >(size2));
}
}
- if (reader1.isPublished()) {
- if (!reader2.isPublished()) {
- if (options.forceOutput()) {
- if (bDump) {
- fprintf(stdout, "?: %s\n", U2S(keyName));
- bDump = false;
- }
+ if (reader1.isPublished())
+ {
+ if (!reader2.isPublished())
+ {
+ if (options.forceOutput())
+ {
+ dumpTypeClass(bDump, /*"?"*/ reader1.getTypeClass(), keyName);
fprintf(stdout, " published in 1 but unpublished in 2\n");
}
++nError;
}
- } else if (!options.checkUnpublished()) {
+ }
+ else if (!options.checkUnpublished())
+ {
return nError;
}
if ( reader1.getTypeClass() != reader2.getTypeClass() )
{
if ( options.forceOutput() )
{
- if (bDump) {
- fprintf(stdout, "?: %s\n", U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, /*"?"*/ reader1.getTypeClass(), keyName);
fprintf(stdout, " TypeClass1 = %s != TypeClass2 = %s\n",
getTypeClass(reader1.getTypeClass()),
getTypeClass(reader2.getTypeClass()));
@@ -1375,16 +1095,11 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
}
RTTypeClass typeClass = reader1.getTypeClass();
-
if ( reader1.getTypeName() != reader2.getTypeName() )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " TypeName1 = %s != TypeName2 = %s\n",
U2S(reader1.getTypeName()), U2S(reader2.getTypeName()));
}
@@ -1394,28 +1109,23 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
typeClass == RT_TYPE_STRUCT ||
typeClass == RT_TYPE_EXCEPTION) )
{
- if (reader1.getSuperTypeCount() != reader2.getSuperTypeCount()) {
- if (bDump) {
- fprintf(
- stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = false;
- }
+ if (reader1.getSuperTypeCount() != reader2.getSuperTypeCount())
+ {
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(
stdout, " SuperTypeCount1 = %d != SuperTypeCount2 = %d\n",
static_cast< int >(reader1.getSuperTypeCount()),
static_cast< int >(reader2.getSuperTypeCount()));
++nError;
- } else {
- for (sal_Int16 i = 0; i < reader1.getSuperTypeCount(); ++i) {
+ } else
+ {
+ for (sal_Int16 i = 0; i < reader1.getSuperTypeCount(); ++i)
+ {
if (reader1.getSuperTypeName(i) != reader2.getSuperTypeName(i))
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " SuperTypeName1 = %s != SuperTypeName2 = %s\n",
U2S(reader1.getSuperTypeName(i)), U2S(reader2.getSuperTypeName(i)));
}
@@ -1424,6 +1134,7 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
}
}
}
+
sal_uInt16 nFields1 = (sal_uInt16)reader1.getFieldCount();
sal_uInt16 nFields2 = (sal_uInt16)reader2.getFieldCount();
sal_Bool bCheckNormal = sal_True;
@@ -1441,41 +1152,31 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " nFields1 = %d != nFields2 = %d\n", nFields1, nFields2);
}
nError++;
}
+
sal_uInt16 i;
for (i=0; i < nFields1 && i < nFields2; i++)
{
- nError += checkField(keyName, typeClass, bDump, reader1, reader2, i, i);
+ nError += checkField(options, keyName, typeClass, bDump, reader1, reader2, i, i);
}
if ( i < nFields1 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Registry1 contains %d more fields\n", nFields1 - i);
}
if ( i < nFields2 && options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Registry2 contains %d more fields\n", nFields2 - i);
}
- } else
+ }
+ else
{
- nError += checkFieldsWithoutOrder(keyName, typeClass, bDump, reader1, reader2);
+ nError += checkFieldsWithoutOrder(options, keyName, typeClass, bDump, reader1, reader2);
}
if ( typeClass == RT_TYPE_INTERFACE )
@@ -1486,19 +1187,16 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " nMethods1 = %d != nMethods2 = %d\n", nMethods1, nMethods2);
}
nError++;
}
+
sal_uInt16 i;
for (i=0; i < nMethods1 && i < nMethods2; i++)
{
- nError += checkMethod(keyName, typeClass, bDump, reader1, reader2, i);
+ nError += checkMethod(options, keyName, typeClass, bDump, reader1, reader2, i);
}
if ( i < nMethods1 && options.forceOutput() )
{
@@ -1522,11 +1220,7 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " service1 contains %d more references as service2\n",
nReference1-nReference2);
}
@@ -1539,7 +1233,7 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
for (j=0; j < nReference2; j++)
{
- if (!checkReference(keyName, typeClass, bDump, reader1, reader2, i, j))
+ if (!checkReference(options, keyName, typeClass, bDump, reader1, reader2, i, j))
{
bFound = sal_True;
moreReferences.insert(j);
@@ -1550,16 +1244,15 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if (options.forceOutput())
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
- fprintf(stdout, " incompatible change: Reference %d ('%s') in 'r1' is not longer a reference of this service in 'r2'\n",
+ dumpTypeClass(bDump, typeClass, keyName);
+ fprintf(stdout,
+ " incompatible change: Reference %d ('%s') in 'r1' is not longer a reference"
+ " of this service in 'r2'\n",
i, U2S(shortName(reader1.getReferenceTypeName(i))));
}
nError++;
- } else
+ }
+ else
{
bFound = sal_False;
}
@@ -1575,12 +1268,10 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
- fprintf(stdout, " incompatible change: Reference %d ('%s') of r2 is a new reference compared to this service in r1 and is not 'optional'\n",
+ dumpTypeClass(bDump, typeClass, keyName);
+ fprintf(stdout,
+ " incompatible change: Reference %d ('%s') of r2 is a new reference"
+ " compared to this service in r1 and is not 'optional'\n",
j, U2S(shortName(reader2.getReferenceTypeName(j))));
}
nError++;
@@ -1588,25 +1279,23 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
}
}
}
- } else
+ }
+ else
{
if ( nReference1 != nReference2 )
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " nReferences1 = %d != nReferences2 = %d\n", nReference1, nReference2);
}
nError++;
}
+
sal_uInt16 i;
for (i=0; i < nReference1 && i < nReference2; i++)
{
- nError += checkReference(keyName, typeClass, bDump, reader1, reader2, i, i);
+ nError += checkReference(options, keyName, typeClass, bDump, reader1, reader2, i, i);
}
if ( i < nReference1 && options.forceOutput() )
{
@@ -1623,38 +1312,19 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s
{
if ( options.forceOutput() )
{
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
+ dumpTypeClass(bDump, typeClass, keyName);
fprintf(stdout, " Doku1 = %s\n Doku2 = %s\n",
U2S(reader1.getDocumentation()), U2S(reader2.getDocumentation()));
}
nError++;
}
-/*
- if ( nError &&
- (!keyName.compareTo(OUString::createFromAscii("/UCR/drafts"), 11) ||
- !keyName.compareTo(OUString::createFromAscii("/drafts"), 7)) )
- {
- if ( options.forceOutput() )
- {
- if ( bDump )
- {
- fprintf(stdout, "%s: %s\n", getTypeClass(typeClass), U2S(keyName));
- bDump = sal_False;
- }
- fprintf(stdout, " Note: \"drafts\" type changed incompatible, no effect to the final API\n");
- }
- return 0;
- }
-*/
return nError;
}
-static sal_uInt32 checkValueDifference(RegistryKey& key1, RegValueType valueType1, sal_uInt32 size1,
- RegistryKey& key2, RegValueType valueType2, sal_uInt32 size2)
+static sal_uInt32 checkValueDifference(
+ Options_Impl const & options,
+ RegistryKey& key1, RegValueType valueType1, sal_uInt32 size1,
+ RegistryKey& key2, RegValueType valueType2, sal_uInt32 size2)
{
OUString tmpName;
sal_uInt32 nError = 0;
@@ -1739,39 +1409,31 @@ static sal_uInt32 checkValueDifference(RegistryKey& key1, RegValueType valueType
if ( bEqual)
{
- RegValue value1 = rtl_allocateMemory(size1);
- RegValue value2 = rtl_allocateMemory(size2);
+ std::vector< sal_uInt8 > value1(size1);
+ key1.getValue(tmpName, &value1[0]);
- key1.getValue(tmpName, value1);
- key2.getValue(tmpName, value2);
-
- bEqual = (rtl_compareMemory(value1, value2, size1) == 0 );
+ std::vector< sal_uInt8 > value2(size2);
+ key2.getValue(tmpName, &value2[0]);
+ bEqual = (rtl_compareMemory(&value1[0], &value2[0], value1.size()) == 0 );
if ( !bEqual && valueType1 == RG_VALUETYPE_BINARY && valueType2 == RG_VALUETYPE_BINARY )
{
- typereg::Reader reader1(
- value1, size1, false, TYPEREG_VERSION_1);
- typereg::Reader reader2(
- value2, size2, false, TYPEREG_VERSION_1);
-
+ typereg::Reader reader1(&value1[0], value1.size(), false, TYPEREG_VERSION_1);
+ typereg::Reader reader2(&value2[0], value2.size(), false, TYPEREG_VERSION_1);
if ( reader1.isValid() && reader2.isValid() )
{
- return checkBlob(key1.getName(), reader1, size1, reader2, size2);
+ return checkBlob(options, key1.getName(), reader1, size1, reader2, size2);
}
}
-
- rtl_freeMemory(value1);
- rtl_freeMemory(value2);
-
if ( bEqual )
{
return 0;
- } else
+ }
+ else
{
if ( options.forceOutput() )
{
- fprintf(stdout, "Difference: key values of key \"%s\" are different\n",
- U2S(key1.getName()));
+ fprintf(stdout, "Difference: key values of key \"%s\" are different\n", U2S(key1.getName()));
}
nError++;
}
@@ -1786,102 +1448,98 @@ static sal_uInt32 checkValueDifference(RegistryKey& key1, RegValueType valueType
fprintf(stdout, " Registry 1: key has no value\n");
break;
case RG_VALUETYPE_LONG:
- case RG_VALUETYPE_STRING:
- case RG_VALUETYPE_UNICODE:
- {
- RegValue value1 = rtl_allocateMemory(size1);
- key1.getValue(tmpName, value1);
-
- switch (valueType1)
{
- case RG_VALUETYPE_LONG:
+ std::vector< sal_uInt8 > value1(size1);
+ key1.getValue(tmpName, &value1[0]);
+
fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_LONG\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size1));
- fprintf(stdout, " Data = %p\n", value1);
- break;
- case RG_VALUETYPE_STRING:
+ fprintf(stdout, " Data = %p\n", &value1[0]);
+ }
+ break;
+ case RG_VALUETYPE_STRING:
+ {
+ std::vector< sal_uInt8 > value1(size1);
+ key1.getValue(tmpName, &value1[0]);
+
fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_STRING\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size1));
- fprintf(stdout, " Data = \"%s\"\n", (sal_Char*)value1);
- break;
- case RG_VALUETYPE_UNICODE:
- {
- OUString uStrValue((sal_Unicode*)value1);
+ fprintf(stdout, " Data = \"%s\"\n", reinterpret_cast<char const*>(&value1[0]));
+ }
+ break;
+ case RG_VALUETYPE_UNICODE:
+ {
+ std::vector< sal_uInt8 > value1(size1);
+ key1.getValue(tmpName, &value1[0]);
+
+ OUString uStrValue(reinterpret_cast<sal_Unicode const*>(&value1[0]));
fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_UNICODE\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size1));
fprintf(stdout, " Data = \"%s\"\n", U2S(uStrValue));
- }
- break;
- default:
- OSL_ASSERT(false);
- break;
}
-
- rtl_freeMemory(value1);
- }
break;
case RG_VALUETYPE_BINARY:
fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_BINARY\n");
break;
case RG_VALUETYPE_LONGLIST:
{
- RegistryValueList<sal_Int32> valueList;
- key1.getLongListValue(tmpName, valueList);
- fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_LONGLIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size1));
- sal_uInt32 length = valueList.getLength();
- for (sal_uInt32 i=0; i<length; i++)
- {
+ RegistryValueList<sal_Int32> valueList;
+ key1.getLongListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_LONGLIST\n");
fprintf(
- stdout, " Data[%lu] = %ld\n",
- sal::static_int_cast< unsigned long >(i),
- sal::static_int_cast< long >(valueList.getElement(i)));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size1));
+ sal_uInt32 length = valueList.getLength();
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ fprintf(
+ stdout, " Data[%lu] = %ld\n",
+ sal::static_int_cast< unsigned long >(i),
+ sal::static_int_cast< long >(valueList.getElement(i)));
+ }
}
break;
case RG_VALUETYPE_STRINGLIST:
{
- RegistryValueList<sal_Char*> valueList;
- key1.getStringListValue(tmpName, valueList);
- fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_STRINGLIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size1));
- sal_uInt32 length = valueList.getLength();
- for (sal_uInt32 i=0; i<length; i++)
- {
+ RegistryValueList<sal_Char*> valueList;
+ key1.getStringListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_STRINGLIST\n");
fprintf(
- stdout, " Data[%lu] = \"%s\"\n",
- sal::static_int_cast< unsigned long >(i),
- valueList.getElement(i));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size1));
+ sal_uInt32 length = valueList.getLength();
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ fprintf(
+ stdout, " Data[%lu] = \"%s\"\n",
+ sal::static_int_cast< unsigned long >(i),
+ valueList.getElement(i));
+ }
}
break;
case RG_VALUETYPE_UNICODELIST:
{
- RegistryValueList<sal_Unicode*> valueList;
- key1.getUnicodeListValue(tmpName, valueList);
- fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_UNICODELIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size1));
- sal_uInt32 length = valueList.getLength();
- OUString uStrValue;
- for (sal_uInt32 i=0; i<length; i++)
- {
- uStrValue = OUString(valueList.getElement(i));
+ RegistryValueList<sal_Unicode*> valueList;
+ key1.getUnicodeListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 1: Value: Type = RG_VALUETYPE_UNICODELIST\n");
fprintf(
- stdout, " Data[%lu] = \"%s\"\n",
- sal::static_int_cast< unsigned long >(i), U2S(uStrValue));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size1));
+ sal_uInt32 length = valueList.getLength();
+ OUString uStrValue;
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ uStrValue = OUString(valueList.getElement(i));
+ fprintf(
+ stdout, " Data[%lu] = \"%s\"\n",
+ sal::static_int_cast< unsigned long >(i), U2S(uStrValue));
+ }
}
break;
}
@@ -1892,102 +1550,98 @@ static sal_uInt32 checkValueDifference(RegistryKey& key1, RegValueType valueType
fprintf(stdout, " Registry 2: key has no value\n");
break;
case RG_VALUETYPE_LONG:
- case RG_VALUETYPE_STRING:
- case RG_VALUETYPE_UNICODE:
- {
- RegValue value2 = rtl_allocateMemory(size2);
- key2.getValue(tmpName, value2);
-
- switch (valueType2)
{
- case RG_VALUETYPE_LONG:
+ std::vector< sal_uInt8 > value2(size2);
+ key2.getValue(tmpName, &value2[0]);
+
fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_LONG\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size2));
- fprintf(stdout, " Data = %p\n", value2);
- break;
- case RG_VALUETYPE_STRING:
+ fprintf(stdout, " Data = %p\n", &value2[0]);
+ }
+ break;
+ case RG_VALUETYPE_STRING:
+ {
+ std::vector< sal_uInt8 > value2(size2);
+ key2.getValue(tmpName, &value2[0]);
+
fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_STRING\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size2));
- fprintf(stdout, " Data = \"%s\"\n", (sal_Char*)value2);
- break;
- case RG_VALUETYPE_UNICODE:
- {
- OUString uStrValue((sal_Unicode*)value2);
+ fprintf(stdout, " Data = \"%s\"\n", reinterpret_cast<char const*>(&value2[0]));
+ }
+ break;
+ case RG_VALUETYPE_UNICODE:
+ {
+ std::vector< sal_uInt8 > value2(size2);
+ key2.getValue(tmpName, &value2[0]);
+
+ OUString uStrValue(reinterpret_cast<sal_Unicode const*>(&value2[0]));
fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_UNICODE\n");
fprintf(
stdout, " Size = %lu\n",
sal::static_int_cast< unsigned long >(size2));
fprintf(stdout, " Data = \"%s\"\n", U2S(uStrValue));
- }
- break;
- default:
- OSL_ASSERT(false);
- break;
}
-
- rtl_freeMemory(value2);
- }
break;
case RG_VALUETYPE_BINARY:
fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_BINARY\n");
break;
case RG_VALUETYPE_LONGLIST:
{
- RegistryValueList<sal_Int32> valueList;
- key2.getLongListValue(tmpName, valueList);
- fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_LONGLIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size2));
- sal_uInt32 length = valueList.getLength();
- for (sal_uInt32 i=0; i<length; i++)
- {
+ RegistryValueList<sal_Int32> valueList;
+ key2.getLongListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_LONGLIST\n");
fprintf(
- stdout, " Data[%lu] = %ld\n",
- sal::static_int_cast< unsigned long >(i),
- sal::static_int_cast< long >(valueList.getElement(i)));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size2));
+ sal_uInt32 length = valueList.getLength();
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ fprintf(
+ stdout, " Data[%lu] = %ld\n",
+ sal::static_int_cast< unsigned long >(i),
+ sal::static_int_cast< long >(valueList.getElement(i)));
+ }
}
break;
case RG_VALUETYPE_STRINGLIST:
{
- RegistryValueList<sal_Char*> valueList;
- key2.getStringListValue(tmpName, valueList);
- fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_STRINGLIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size2));
- sal_uInt32 length = valueList.getLength();
- for (sal_uInt32 i=0; i<length; i++)
- {
+ RegistryValueList<sal_Char*> valueList;
+ key2.getStringListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_STRINGLIST\n");
fprintf(
- stdout, " Data[%lu] = \"%s\"\n",
- sal::static_int_cast< unsigned long >(i),
- valueList.getElement(i));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size2));
+ sal_uInt32 length = valueList.getLength();
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ fprintf(
+ stdout, " Data[%lu] = \"%s\"\n",
+ sal::static_int_cast< unsigned long >(i),
+ valueList.getElement(i));
+ }
}
break;
case RG_VALUETYPE_UNICODELIST:
{
- RegistryValueList<sal_Unicode*> valueList;
- key2.getUnicodeListValue(tmpName, valueList);
- fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_UNICODELIST\n");
- fprintf(
- stdout, " Size = %lu\n",
- sal::static_int_cast< unsigned long >(size2));
- sal_uInt32 length = valueList.getLength();
- OUString uStrValue;
- for (sal_uInt32 i=0; i<length; i++)
- {
- uStrValue = OUString(valueList.getElement(i));
+ RegistryValueList<sal_Unicode*> valueList;
+ key2.getUnicodeListValue(tmpName, valueList);
+ fprintf(stdout, " Registry 2: Value: Type = RG_VALUETYPE_UNICODELIST\n");
fprintf(
- stdout, " Data[%lu] = \"%s\"\n",
- sal::static_int_cast< unsigned long >(i), U2S(uStrValue));
- }
+ stdout, " Size = %lu\n",
+ sal::static_int_cast< unsigned long >(size2));
+ sal_uInt32 length = valueList.getLength();
+ OUString uStrValue;
+ for (sal_uInt32 i=0; i<length; i++)
+ {
+ uStrValue = OUString(valueList.getElement(i));
+ fprintf(
+ stdout, " Data[%lu] = \"%s\"\n",
+ sal::static_int_cast< unsigned long >(i), U2S(uStrValue));
+ }
}
break;
}
@@ -1995,58 +1649,67 @@ static sal_uInt32 checkValueDifference(RegistryKey& key1, RegValueType valueType
return nError;
}
-static bool hasPublishedChildren(RegistryKey & key) {
+static bool hasPublishedChildren(Options_Impl const & options, RegistryKey & key)
+{
RegistryKeyNames subKeyNames;
key.getKeyNames(rtl::OUString(), subKeyNames);
- for (sal_uInt32 i = 0; i < subKeyNames.getLength(); ++i) {
+ for (sal_uInt32 i = 0; i < subKeyNames.getLength(); ++i)
+ {
rtl::OUString keyName(subKeyNames.getElement(i));
- if (!options.matchedWithExcludeKey(keyName)) {
+ if (!options.matchedWithExcludeKey(keyName))
+ {
keyName = keyName.copy(keyName.lastIndexOf('/') + 1);
RegistryKey subKey;
- if (!key.openKey(keyName, subKey)) {
- if (options.forceOutput()) {
+ if (!key.openKey(keyName, subKey))
+ {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("WARNING: could not open key \"%s\" in registry"
" \"%s\"\n"),
U2S(subKeyNames.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
}
- if (subKey.isValid()) {
+ if (subKey.isValid())
+ {
RegValueType type;
sal_uInt32 size;
- if (subKey.getValueInfo(rtl::OUString(), &type, &size)
- != REG_NO_ERROR)
+ if (subKey.getValueInfo(rtl::OUString(), &type, &size) != REG_NO_ERROR)
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("WARNING: could not read key \"%s\" in registry"
" \"%s\"\n"),
U2S(subKeyNames.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
- } else if (type == RG_VALUETYPE_BINARY) {
- char * value = new char[size];
+ }
+ else if (type == RG_VALUETYPE_BINARY)
+ {
bool published = false;
- if (subKey.getValue(rtl::OUString(), value) != REG_NO_ERROR)
+ std::vector< sal_uInt8 > value(size);
+ if (subKey.getValue(rtl::OUString(), &value[0]) != REG_NO_ERROR)
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("WARNING: could not read key \"%s\" in"
" registry \"%s\"\n"),
U2S(subKeyNames.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
- } else {
- published = typereg::Reader(
- value, size, false, TYPEREG_VERSION_1).
- isPublished();
}
- delete[] value;
- if (published) {
+ else
+ {
+ published = typereg::Reader(&value[0], value.size(), false, TYPEREG_VERSION_1).isPublished();
+ }
+ if (published)
+ {
return true;
}
}
@@ -2057,7 +1720,9 @@ static bool hasPublishedChildren(RegistryKey & key) {
}
static sal_uInt32 checkDifferences(
- RegistryKey& key, StringSet& keys, RegistryKeyNames& subKeyNames1,
+ Options_Impl const & options,
+ RegistryKey& key, StringSet& keys,
+ RegistryKeyNames& subKeyNames1,
RegistryKeyNames& subKeyNames2)
{
sal_uInt32 nError = 0;
@@ -2084,81 +1749,89 @@ static sal_uInt32 checkDifferences(
if ( options.forceOutput() )
{
fprintf(stdout, "EXISTENCE: key \"%s\" exists only in registry \"%s\"\n",
- U2S(subKeyNames1.getElement(i)), options.getRegName1().getStr());
+ U2S(subKeyNames1.getElement(i)), options.getRegName1().c_str());
}
nError++;
}
else
{
rtl::OUString keyName(subKeyNames1.getElement(i));
- if (!options.matchedWithExcludeKey(keyName)) {
+ if (!options.matchedWithExcludeKey(keyName))
+ {
keyName = keyName.copy(keyName.lastIndexOf('/') + 1);
RegistryKey subKey;
- if (key.openKey(keyName, subKey)) {
- if (options.forceOutput()) {
+ if (key.openKey(keyName, subKey))
+ {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("ERROR: could not open key \"%s\" in registry"
" \"%s\"\n"),
U2S(subKeyNames1.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
++nError;
}
- if (subKey.isValid()) {
+ if (subKey.isValid())
+ {
RegValueType type;
sal_uInt32 size;
- if (subKey.getValueInfo(rtl::OUString(), &type, &size)
- != REG_NO_ERROR)
+ if (subKey.getValueInfo(rtl::OUString(), &type, &size) != REG_NO_ERROR)
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("ERROR: could not read key \"%s\" in"
" registry \"%s\"\n"),
U2S(subKeyNames1.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
++nError;
- } else if (type == RG_VALUETYPE_BINARY) {
- char * value = new char[size];
- if (subKey.getValue(rtl::OUString(), value)
- != REG_NO_ERROR)
+ }
+ else if (type == RG_VALUETYPE_BINARY)
+ {
+ std::vector< sal_uInt8 > value(size);
+ if (subKey.getValue(rtl::OUString(), &value[0]) != REG_NO_ERROR)
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("ERROR: could not read key \"%s\" in"
" registry \"%s\"\n"),
U2S(subKeyNames1.getElement(i)),
- options.getRegName1().getStr());
+ options.getRegName1().c_str());
}
++nError;
- } else {
- typereg::Reader reader(
- value, size, false, TYPEREG_VERSION_1);
- if (reader.getTypeClass() == RT_TYPE_MODULE) {
- if (options.checkUnpublished()
- || hasPublishedChildren(subKey))
+ }
+ else
+ {
+ typereg::Reader reader(&value[0], value.size(), false, TYPEREG_VERSION_1);
+ if (reader.getTypeClass() == RT_TYPE_MODULE)
+ {
+ if (options.checkUnpublished() || hasPublishedChildren(options, subKey))
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("EXISTENCE: module \"%s\""
" %sexists only in registry"
" 1\n"),
- U2S(subKeyNames1.getElement(
- i)),
+ U2S(subKeyNames1.getElement(i)),
(options.checkUnpublished()
? ""
: "with published children "));
}
++nError;
}
- } else if (options.checkUnpublished()
- || reader.isPublished())
+ }
+ else if (options.checkUnpublished() || reader.isPublished())
{
- if (options.forceOutput()) {
+ if (options.forceOutput())
+ {
fprintf(
stdout,
("EXISTENCE: %spublished key \"%s\""
@@ -2169,7 +1842,6 @@ static sal_uInt32 checkDifferences(
++nError;
}
}
- delete[] value;
}
}
}
@@ -2194,7 +1866,7 @@ static sal_uInt32 checkDifferences(
if ( options.forceOutput() )
{
fprintf(stdout, "EXISTENCE: key \"%s\" exists only in registry \"%s\"\n",
- U2S(subKeyNames2.getElement(i)), options.getRegName2().getStr());
+ U2S(subKeyNames2.getElement(i)), options.getRegName2().c_str());
}
nError++;
}
@@ -2202,7 +1874,10 @@ static sal_uInt32 checkDifferences(
return nError;
}
-static sal_uInt32 compareKeys(RegistryKey& key1, RegistryKey& key2)
+static sal_uInt32 compareKeys(
+ Options_Impl const & options,
+ RegistryKey& key1,
+ RegistryKey& key2)
{
sal_uInt32 nError = 0;
@@ -2210,16 +1885,17 @@ static sal_uInt32 compareKeys(RegistryKey& key1, RegistryKey& key2)
RegValueType valueType2 = RG_VALUETYPE_NOT_DEFINED;
sal_uInt32 size1 = 0;
sal_uInt32 size2 = 0;
+
OUString tmpName;
RegError e1 = key1.getValueInfo(tmpName, &valueType1, &size1);
RegError e2 = key2.getValueInfo(tmpName, &valueType2, &size2);
-
- if ( e1 == e2 && e1 != REG_VALUE_NOT_EXISTS && e1 != REG_INVALID_VALUE )
+ if ( (e1 == e2) && (e1 != REG_VALUE_NOT_EXISTS) && (e1 != REG_INVALID_VALUE) )
{
- nError += checkValueDifference(key1, valueType1, size1, key2, valueType2, size2);
- } else
+ nError += checkValueDifference(options, key1, valueType1, size1, key2, valueType2, size2);
+ }
+ else
{
- if ( e1 != REG_INVALID_VALUE || e2 != REG_INVALID_VALUE )
+ if ( (e1 != REG_INVALID_VALUE) || (e2 != REG_INVALID_VALUE) )
{
if ( options.forceOutput() )
{
@@ -2236,16 +1912,14 @@ static sal_uInt32 compareKeys(RegistryKey& key1, RegistryKey& key2)
key2.getKeyNames(tmpName, subKeyNames2);
StringSet keys;
- nError += checkDifferences(key1, keys, subKeyNames1, subKeyNames2);
+ nError += checkDifferences(options, key1, keys, subKeyNames1, subKeyNames2);
StringSet::iterator iter = keys.begin();
StringSet::iterator end = keys.end();
- RegistryKey subKey1, subKey2;
- OUString keyName;
while ( iter != end )
{
- keyName = OUString(*iter);
+ OUString keyName(*iter);
if ( options.matchedWithExcludeKey(keyName) )
{
++iter;
@@ -2254,30 +1928,33 @@ static sal_uInt32 compareKeys(RegistryKey& key1, RegistryKey& key2)
sal_Int32 nPos = keyName.lastIndexOf( '/' );
keyName = keyName.copy( nPos != -1 ? nPos+1 : 0 );
+
+ RegistryKey subKey1;
if ( key1.openKey(keyName, subKey1) )
{
if ( options.forceOutput() )
{
fprintf(stdout, "ERROR: could not open key \"%s\" in registry \"%s\"\n",
- U2S(*iter), options.getRegName1().getStr());
+ U2S(*iter), options.getRegName1().c_str());
}
nError++;
}
+
+ RegistryKey subKey2;
if ( key2.openKey(keyName, subKey2) )
{
if ( options.forceOutput() )
{
fprintf(stdout, "ERROR: could not open key \"%s\" in registry \"%s\"\n",
- U2S(*iter), options.getRegName2().getStr());
+ U2S(*iter), options.getRegName2().c_str());
}
nError++;
}
+
if ( subKey1.isValid() && subKey2.isValid() )
{
- nError += compareKeys(subKey1, subKey2);
+ nError += compareKeys(options, subKey1, subKey2);
}
- subKey1.releaseKey();
- subKey2.releaseKey();
++iter;
}
@@ -2290,93 +1967,107 @@ int main( int argc, char * argv[] )
int _cdecl main( int argc, char * argv[] )
#endif
{
- if ( !options.initOptions(argc, argv) )
+ std::vector< std::string > args;
+
+ Options_Impl options(argv[0]);
+ for (int i = 1; i < argc; i++)
{
- exit(1);
+ if (!Options::checkArgument(args, argv[i], strlen(argv[i])))
+ {
+ // failure.
+ options.printUsage();
+ return (1);
+ }
+ }
+ if (!options.initOptions(args))
+ {
+ return (1);
}
- OUString regName1( convertToFileUrl(options.getRegName1()) );
- OUString regName2( convertToFileUrl(options.getRegName2()) );
-
- Registry reg1;
- Registry reg2;
+ OUString regName1( convertToFileUrl(options.getRegName1().c_str(), options.getRegName1().size()) );
+ OUString regName2( convertToFileUrl(options.getRegName2().c_str(), options.getRegName2().size()) );
+ Registry reg1, reg2;
if ( reg1.open(regName1, REG_READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName1().getStr());
- exit(2);
+ options.getProgramName().c_str(), options.getRegName1().c_str());
+ return (2);
}
if ( reg2.open(regName2, REG_READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName2().getStr());
- exit(3);
+ options.getProgramName().c_str(), options.getRegName2().c_str());
+ return (3);
}
RegistryKey key1, key2;
if ( reg1.openRootKey(key1) )
{
fprintf(stdout, "%s: open root key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName1().getStr());
- exit(4);
+ options.getProgramName().c_str(), options.getRegName1().c_str());
+ return (4);
}
if ( reg2.openRootKey(key2) )
{
fprintf(stdout, "%s: open root key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName2().getStr());
- exit(5);
+ options.getProgramName().c_str(), options.getRegName2().c_str());
+ return (5);
}
+
if ( options.isStartKeyValid() )
{
- if ( options.matchedWithExcludeKey( S2U(options.getStartKey()) ) )
+ if ( options.matchedWithExcludeKey( options.getStartKey() ) )
{
fprintf(stdout, "%s: start key is equal to one of the exclude keys\n",
- options.getProgramName().getStr());
- exit(6);
+ options.getProgramName().c_str());
+ return (6);
}
RegistryKey sk1, sk2;
- if ( key1.openKey(S2U(options.getStartKey()), sk1) )
+ if ( key1.openKey(options.getStartKey(), sk1) )
{
fprintf(stdout, "%s: open start key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName1().getStr());
- exit(7);
+ options.getProgramName().c_str(), options.getRegName1().c_str());
+ return (7);
}
- if ( key2.openKey(S2U(options.getStartKey()), sk2) )
+ if ( key2.openKey(options.getStartKey(), sk2) )
{
fprintf(stdout, "%s: open start key of registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName2().getStr());
- exit(8);
+ options.getProgramName().c_str(), options.getRegName2().c_str());
+ return (8);
}
key1 = sk1;
key2 = sk2;
}
- sal_uInt32 nError = compareKeys(key1, key2);
+ sal_uInt32 nError = compareKeys(options, key1, key2);
if ( nError )
{
if ( options.unoTypeCheck() )
{
fprintf(stdout, "%s: registries are incompatible: %lu differences!\n",
- options.getProgramName().getStr(),
+ options.getProgramName().c_str(),
sal::static_int_cast< unsigned long >(nError));
- } else
+ }
+ else
{
fprintf(stdout, "%s: registries contain %lu differences!\n",
- options.getProgramName().getStr(),
+ options.getProgramName().c_str(),
sal::static_int_cast< unsigned long >(nError));
}
- } else
+ }
+ else
{
if ( options.unoTypeCheck() )
{
fprintf(stdout, "%s: registries are compatible!\n",
- options.getProgramName().getStr());
- } else
+ options.getProgramName().c_str());
+ }
+ else
{
fprintf(stdout, "%s: registries are equal!\n",
- options.getProgramName().getStr());
+ options.getProgramName().c_str());
}
}
@@ -2385,17 +2076,15 @@ int _cdecl main( int argc, char * argv[] )
if ( reg1.close() )
{
fprintf(stdout, "%s: closing registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName1().getStr());
- exit(9);
+ options.getProgramName().c_str(), options.getRegName1().c_str());
+ return (9);
}
if ( reg2.close() )
{
fprintf(stdout, "%s: closing registry \"%s\" failed\n",
- options.getProgramName().getStr(), options.getRegName2().getStr());
- exit(10);
+ options.getProgramName().c_str(), options.getRegName2().c_str());
+ return (10);
}
- return nError > 0 ? 11 : 0;
+ return ((nError > 0) ? 11 : 0);
}
-
-
diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx
index 06786a9b993e..6ca47a18c795 100644
--- a/registry/tools/regmerge.cxx
+++ b/registry/tools/regmerge.cxx
@@ -28,70 +28,35 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
-#include <stdio.h>
-#include <string.h>
-
#include "registry/registry.hxx"
-#include <rtl/ustring.hxx>
-#include <rtl/alloc.h>
-#include <osl/process.h>
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-#include <osl/file.hxx>
+#include "fileurl.hxx"
+#include "options.hxx"
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
+#include "rtl/ustring.hxx"
+#include "osl/diagnose.h"
-using namespace ::rtl;
-using namespace ::osl;
+#include <stdio.h>
+#include <string.h>
-sal_Bool isFileUrl(const OString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
+using namespace rtl;
+using namespace registry::tools;
-OUString convertToFileUrl(const OString& fileName)
+class Options_Impl : public Options
{
- if ( isFileUrl(fileName) )
- {
- return OStringToOUString(fileName, osl_getThreadTextEncoding());
- }
-
- OUString uUrlFileName;
- OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
- {
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
- {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- }
+ bool m_bVerbose;
- return uUrlFileName;
-}
+public:
+ explicit Options_Impl (char const * program)
+ : Options(program), m_bVerbose(false)
+ {}
+ bool isVerbose() const { return m_bVerbose; }
-int realargc;
-char* realargv[2048];
+protected:
+ virtual void printUsage_Impl() const;
+ virtual bool initOptions_Impl(std::vector< std::string > & rArgs);
+};
-static void dumpHelp()
+void Options_Impl::printUsage_Impl() const
{
fprintf(stderr, "using: regmerge [-v|--verbose] mergefile mergeKeyName regfile_1 ... regfile_n\n");
fprintf(stderr, " regmerge @regcmds\nOptions:\n");
@@ -103,180 +68,112 @@ static void dumpHelp()
fprintf(stderr, " regfile_1..n : specifies one or more registry files which are merged.\n");
}
-static bool checkCommandFile(char* cmdfile)
+bool Options_Impl::initOptions_Impl (std::vector< std::string > & rArgs)
{
- FILE *commandfile;
- char option[256];
- bool bVerbose = false;
-
- commandfile = fopen(cmdfile+1, "r");
- if( commandfile == NULL )
- {
- fprintf(stderr, "ERROR: Can't open command file \"%s\"\n", cmdfile);
- } else
+ std::vector< std::string >::iterator first = rArgs.begin(), last = rArgs.end();
+ if ((first != last) && ((*first)[0] == '-'))
{
- while ( fscanf(commandfile, "%s", option) != EOF )
+ std::string option(*first);
+ if ((option.compare("-v") == 0) || (option.compare("--verbose") == 0))
{
- if (option[0]== '@')
- {
- bool bRet = checkCommandFile(option);
- // ensure that the option will not be overwritten
- if ( !bRet )
- bVerbose = bRet;
- } else {
- if (option[0]== '-') {
- if (strncmp(option, "-v", 2) == 0 ||
- strncmp(option, "--verbose", 9) == 0)
- {
- bVerbose = true;
- } else {
- fprintf(stderr, "ERROR: unknown option \"%s\"\n", option);
- dumpHelp();
- exit(-1);
- }
- }else
- {
- realargv[realargc]= strdup(option);
- realargc++;
- }
- }
- if (realargc == 2047)
- {
- fprintf(stderr, "ERROR: more than 2048 arguments.\n");
- break;
- }
+ m_bVerbose = true;
}
- fclose(commandfile);
- }
-
- return bVerbose;
-}
-
-static bool checkCommandArgs(int argc, char **argv)
-{
- bool bVerbose = false;
-
- realargc = 0;
-
- for (int i=0; i<argc; i++)
- {
- if (argv[i][0]== '@')
+ else if ((option.compare("-h") == 0) || (option.compare("-?") == 0))
{
- bool bRet = checkCommandFile(argv[i]);
- // ensure that the option will not be overwritten
- if ( !bRet )
- bVerbose = bRet;
- } else {
- if (argv[i][0]== '-') {
- if (strncmp(argv[i], "-v", 2) == 0 ||
- strncmp(argv[i], "--verbose", 9) == 0)
- {
- bVerbose = true;
- } else {
- fprintf(stderr, "ERROR: unknown option \"%s\"\n", argv[i]);
- dumpHelp();
- exit(-1);
- }
- } else
- {
- realargv[realargc]= strdup(argv[i]);
- realargc++;
- }
+ return printUsage();
}
+ else
+ {
+ return badOption("unknown", option.c_str());
+ }
+ (void) rArgs.erase(first);
}
-
- return bVerbose;
-}
-
-static void cleanCommandArgs()
-{
- for (int i=0; i<realargc; i++)
- {
- free(realargv[i]);
- }
+ return true;
}
-
-
#if (defined UNX) || (defined OS2)
int main( int argc, char * argv[] )
#else
int _cdecl main( int argc, char * argv[] )
#endif
{
- bool bVerbose = checkCommandArgs(argc, argv);
+ Options_Impl options(argv[0]);
- if (realargc < 4)
+ std::vector< std::string > args;
+ for (int i = 1; i < argc; i++)
{
- dumpHelp();
- cleanCommandArgs();
- exit(1);
+ if (!Options::checkArgument(args, argv[i], strlen(argv[i])))
+ {
+ options.printUsage();
+ return (1);
+ }
+ }
+ if (!options.initOptions(args))
+ {
+ return (1);
+ }
+ if (args.size() < 3)
+ {
+ options.printUsage();
+ return (1);
}
-
- ::rtl::OUString regName( convertToFileUrl(realargv[1]) );
Registry reg;
+ OUString regName( convertToFileUrl(args[0].c_str(), args[0].size()) );
if (reg.open(regName, REG_READWRITE) != REG_NO_ERROR)
{
if (reg.create(regName) != REG_NO_ERROR)
{
- if (bVerbose)
- fprintf(stderr, "open registry \"%s\" failed\n", realargv[1]);
- cleanCommandArgs();
- exit(-1);
+ if (options.isVerbose())
+ fprintf(stderr, "open registry \"%s\" failed\n", args[0].c_str());
+ return (-1);
}
}
RegistryKey rootKey;
- if (reg.openRootKey(rootKey) == REG_NO_ERROR)
+ if (reg.openRootKey(rootKey) != REG_NO_ERROR)
{
- ::rtl::OUString mergeKeyName( ::rtl::OUString::createFromAscii(realargv[2]) );
- ::rtl::OUString targetRegName;
- for (int i = 3; i < realargc; i++)
+ if (options.isVerbose())
+ fprintf(stderr, "open root key of registry \"%s\" failed\n", args[0].c_str());
+ return (-4);
+ }
+
+ OUString mergeKeyName( OUString::createFromAscii(args[1].c_str()) );
+ for (size_t i = 2; i < args.size(); i++)
+ {
+ OUString targetRegName( convertToFileUrl(args[i].c_str(), args[i].size()) );
+ RegError _ret = reg.mergeKey(rootKey, mergeKeyName, targetRegName, sal_False, options.isVerbose());
+ if (_ret != REG_NO_ERROR)
{
- targetRegName = convertToFileUrl(realargv[i]);
- RegError _ret = reg.mergeKey(rootKey, mergeKeyName, targetRegName, sal_False, bVerbose);
- if (_ret != REG_NO_ERROR)
- {
- if (_ret == REG_MERGE_CONFLICT)
- {
- if (bVerbose)
- fprintf(stderr, "merging registry \"%s\" under key \"%s\" in registry \"%s\".\n",
- realargv[i], realargv[2], realargv[1]);
- } else
- {
- if (bVerbose)
- fprintf(stderr, "ERROR: merging registry \"%s\" under key \"%s\" in registry \"%s\" failed.\n",
- realargv[i], realargv[2], realargv[1]);
- exit(-2);
- }
- } else
+ if (_ret == REG_MERGE_CONFLICT)
{
- if (bVerbose)
+ if (options.isVerbose())
fprintf(stderr, "merging registry \"%s\" under key \"%s\" in registry \"%s\".\n",
- realargv[i], realargv[2], realargv[1]);
+ args[i].c_str(), args[1].c_str(), args[0].c_str());
+ }
+ else
+ {
+ if (options.isVerbose())
+ fprintf(stderr, "ERROR: merging registry \"%s\" under key \"%s\" in registry \"%s\" failed.\n",
+ args[i].c_str(), args[1].c_str(), args[0].c_str());
+ return (-2);
}
}
-
- rootKey.releaseKey();
- } else
- {
- if (bVerbose)
- fprintf(stderr, "open root key of registry \"%s\" failed\n",
- realargv[1]);
- exit(-4);
+ else
+ {
+ if (options.isVerbose())
+ fprintf(stderr, "merging registry \"%s\" under key \"%s\" in registry \"%s\".\n",
+ args[i].c_str(), args[1].c_str(), args[0].c_str());
+ }
}
+ rootKey.releaseKey();
if (reg.close() != REG_NO_ERROR)
{
- if (bVerbose)
- fprintf(stderr, "closing registry \"%s\" failed\n", realargv[1]);
- cleanCommandArgs();
- exit(-5);
+ if (options.isVerbose())
+ fprintf(stderr, "closing registry \"%s\" failed\n", args[0].c_str());
+ return (-5);
}
- cleanCommandArgs();
return(0);
}
-
-
diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx
index 4e478e8985db..4c588449a1d8 100644
--- a/registry/tools/regview.cxx
+++ b/registry/tools/regview.cxx
@@ -28,65 +28,16 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
-#include <stdio.h>
-
#include "registry/registry.h"
-#include <rtl/ustring.hxx>
-#include <rtl/alloc.h>
-#include <osl/process.h>
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-#include <osl/file.hxx>
-
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
-
-using namespace ::rtl;
-using namespace ::osl;
-
-sal_Bool isFileUrl(const OString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
+#include "fileurl.hxx"
-OUString convertToFileUrl(const OString& fileName)
-{
- if ( isFileUrl(fileName) )
- {
- return OStringToOUString(fileName, osl_getThreadTextEncoding());
- }
+#include "rtl/ustring.hxx"
- OUString uUrlFileName;
- OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
- {
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
- {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- }
-
- return uUrlFileName;
-}
+#include <stdio.h>
+#include <string.h>
+using rtl::OUString;
+using namespace registry::tools;
#if (defined UNX) || (defined OS2)
int main( int argc, char * argv[] )
@@ -103,7 +54,7 @@ int _cdecl main( int argc, char * argv[] )
exit(1);
}
- OUString regName( convertToFileUrl(argv[1]) );
+ OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
{
fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
@@ -127,12 +78,14 @@ int _cdecl main( int argc, char * argv[] )
fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n",
argv[2], argv[1]);
}
- } else
+ }
+ else
{
fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n",
argv[2], argv[1]);
}
- } else
+ }
+ else
{
if (reg_dumpRegistry(hRootKey))
{
@@ -144,7 +97,8 @@ int _cdecl main( int argc, char * argv[] )
{
fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]);
}
- } else
+ }
+ else
{
fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]);
}
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index cc0c041bc328..67f1d05660a8 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -215,7 +215,8 @@ FileHandle_Impl::Allocator::~Allocator()
void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, size_t * pnSize)
{
OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
- *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz;
+ if ((0 != ppBuffer) && (0 != pnSize))
+ *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz;
}
void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
{
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 452d3eb2db70..2ed57b01a2c4 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -334,10 +334,8 @@ oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirecto
rtl_uString* ustrSystemPath = NULL;
oslFileError osl_error = osl_File_E_INVAL;
- OSL_ASSERT(ustrFileURL);
- OSL_ASSERT(pItem);
-
- if (0 == ustrFileURL->length || NULL == pItem)
+ OSL_ASSERT((0 != ustrFileURL) && (0 != pItem));
+ if ((0 == ustrFileURL) || (0 == ustrFileURL->length) || (0 == pItem))
return osl_File_E_INVAL;
osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False);
diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx
index 04fdd13e7c15..9dd3b08493b0 100644
--- a/sal/osl/unx/file_path_helper.cxx
+++ b/sal/osl/unx/file_path_helper.cxx
@@ -73,19 +73,21 @@
void SAL_CALL osl_systemPathRemoveSeparator(rtl_uString* pustrPath)
{
- OSL_PRECOND(pustrPath, "osl_systemPathRemoveSeparator: Invalid parameter");
-
- // maybe there are more than one separator at end
- // so we run in a loop
- while ((pustrPath->length > 1) && (FPH_CHAR_PATH_SEPARATOR == pustrPath->buffer[pustrPath->length - 1]))
+ OSL_PRECOND(0 != pustrPath, "osl_systemPathRemoveSeparator: Invalid parameter");
+ if (0 != pustrPath)
{
- pustrPath->length--;
- pustrPath->buffer[pustrPath->length] = (sal_Unicode)'\0';
- }
+ // maybe there are more than one separator at end
+ // so we run in a loop
+ while ((pustrPath->length > 1) && (FPH_CHAR_PATH_SEPARATOR == pustrPath->buffer[pustrPath->length - 1]))
+ {
+ pustrPath->length--;
+ pustrPath->buffer[pustrPath->length] = (sal_Unicode)'\0';
+ }
- OSL_POSTCOND((0 == pustrPath->length) || (1 == pustrPath->length) || \
- (pustrPath->length > 1 && pustrPath->buffer[pustrPath->length - 1] != FPH_CHAR_PATH_SEPARATOR), \
- "osl_systemPathRemoveSeparator: Post condition failed");
+ OSL_POSTCOND((0 == pustrPath->length) || (1 == pustrPath->length) || \
+ (pustrPath->length > 1 && pustrPath->buffer[pustrPath->length - 1] != FPH_CHAR_PATH_SEPARATOR), \
+ "osl_systemPathRemoveSeparator: Post condition failed");
+ }
}
/*******************************************
@@ -94,21 +96,22 @@
void SAL_CALL osl_systemPathEnsureSeparator(rtl_uString** ppustrPath)
{
- OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \
- "osl_systemPathEnsureSeparator: Invalid parameter");
-
- rtl::OUString path(*ppustrPath);
- sal_Int32 lp = path.getLength();
- sal_Int32 i = path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
-
- if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
- {
- path += FPH_PATH_SEPARATOR();
- rtl_uString_assign(ppustrPath, path.pData);
- }
-
- OSL_POSTCOND(path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR) == (path.getLength() - 1), \
- "osl_systemPathEnsureSeparator: Post condition failed");
+ OSL_PRECOND((0 != ppustrPath) && (0 != *ppustrPath), "osl_systemPathEnsureSeparator: Invalid parameter");
+ if ((0 != ppustrPath) && (0 != *ppustrPath))
+ {
+ rtl::OUString path(*ppustrPath);
+ sal_Int32 lp = path.getLength();
+ sal_Int32 i = path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
+
+ if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
+ {
+ path += FPH_PATH_SEPARATOR();
+ rtl_uString_assign(ppustrPath, path.pData);
+ }
+
+ OSL_POSTCOND(path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR) == (path.getLength() - 1), \
+ "osl_systemPathEnsureSeparator: Post condition failed");
+ }
}
/*******************************************
@@ -117,8 +120,8 @@
sal_Bool SAL_CALL osl_systemPathIsRelativePath(const rtl_uString* pustrPath)
{
- OSL_PRECOND(pustrPath, "osl_systemPathIsRelativePath: Invalid parameter");
- return ((0 == pustrPath->length) || (pustrPath->buffer[0] != FPH_CHAR_PATH_SEPARATOR));
+ OSL_PRECOND(0 != pustrPath, "osl_systemPathIsRelativePath: Invalid parameter");
+ return ((0 == pustrPath) || (0 == pustrPath->length) || (pustrPath->buffer[0] != FPH_CHAR_PATH_SEPARATOR));
}
/******************************************
@@ -177,21 +180,16 @@
sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry(
const rtl_uString* pustrPath)
{
- OSL_PRECOND(pustrPath, "osl_systemPathIsHiddenFileOrDirectoryEntry: Invalid parameter");
-
- sal_Bool is_hidden = sal_False;
+ OSL_PRECOND(0 != pustrPath, "osl_systemPathIsHiddenFileOrDirectoryEntry: Invalid parameter");
+ if ((0 == pustrPath) || (0 == pustrPath->length))
+ return sal_False;
- if (pustrPath->length > 0)
- {
- rtl::OUString fdp;
-
- osl_systemPathGetFileNameOrLastDirectoryPart(pustrPath, &fdp.pData);
-
- is_hidden = ((fdp.pData->length > 0) && (fdp.pData->buffer[0] == FPH_CHAR_DOT) &&
- !osl_systemPathIsLocalOrParentDirectoryEntry(fdp.pData));
- }
+ rtl::OUString fdp;
+ osl_systemPathGetFileNameOrLastDirectoryPart(pustrPath, &fdp.pData);
- return is_hidden;
+ return ((fdp.pData->length > 0) &&
+ (fdp.pData->buffer[0] == FPH_CHAR_DOT) &&
+ !osl_systemPathIsLocalOrParentDirectoryEntry(fdp.pData));
}
diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index 66c0d0f5c701..498778758ded 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -483,17 +483,20 @@ extern "C" int _imp_setProcessLocale( rtl_Locale * );
*********************************************/
oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale )
{
+ oslProcessError result = osl_Process_E_Unknown;
OSL_PRECOND(ppLocale, "osl_getProcessLocale(): Invalid parameter.");
+ if (ppLocale)
+ {
+ pthread_mutex_lock(&(g_process_locale.m_mutex));
- pthread_mutex_lock(&(g_process_locale.m_mutex));
-
- if (g_process_locale.m_pLocale == 0)
- _imp_getProcessLocale (&(g_process_locale.m_pLocale));
- *ppLocale = g_process_locale.m_pLocale;
-
- pthread_mutex_unlock (&(g_process_locale.m_mutex));
+ if (g_process_locale.m_pLocale == 0)
+ _imp_getProcessLocale (&(g_process_locale.m_pLocale));
+ *ppLocale = g_process_locale.m_pLocale;
+ result = osl_Process_E_None;
- return (osl_Process_E_None);
+ pthread_mutex_unlock (&(g_process_locale.m_mutex));
+ }
+ return (result);
}
/**********************************************
diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c
index c77a27543261..05d816c92755 100644
--- a/sal/osl/unx/profile.c
+++ b/sal/osl/unx/profile.c
@@ -514,7 +514,6 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
if ( pTmpProfile->m_bIsValid == sal_False )
{
- OSL_ASSERT(pProfile->m_bIsValid);
pthread_mutex_unlock(&(pTmpProfile->m_AccessLock));
#ifdef TRACE_OSL_PROFILE
OSL_TRACE("Out osl_readProfileString [not valid]\n");
diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index c8faf6c028f5..2f7b62a4bfa4 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -605,16 +605,16 @@ sal_Bool SAL_CALL osl_isEqualSocketAddr (
oslSocketAddr Addr1,
oslSocketAddr Addr2)
{
- struct sockaddr* pAddr1= &(Addr1->m_sockaddr);
- struct sockaddr* pAddr2= &(Addr2->m_sockaddr);
-
- OSL_ASSERT(pAddr1);
- OSL_ASSERT(pAddr2);
-
- if (pAddr1->sa_family == pAddr2->sa_family)
+ OSL_ASSERT((0 != Addr1) && (0 != Addr2));
+ if ((0 != Addr1) || (0 != Addr2))
{
- switch (pAddr1->sa_family)
- {
+ struct sockaddr* pAddr1= &(Addr1->m_sockaddr);
+ struct sockaddr* pAddr2= &(Addr2->m_sockaddr);
+
+ if (pAddr1->sa_family == pAddr2->sa_family)
+ {
+ switch (pAddr1->sa_family)
+ {
case AF_INET:
{
struct sockaddr_in* pInetAddr1= (struct sockaddr_in*)pAddr1;
@@ -623,16 +623,16 @@ sal_Bool SAL_CALL osl_isEqualSocketAddr (
if ((pInetAddr1->sin_family == pInetAddr2->sin_family) &&
(pInetAddr1->sin_addr.s_addr == pInetAddr2->sin_addr.s_addr) &&
(pInetAddr1->sin_port == pInetAddr2->sin_port))
- return (sal_True);
+ return (sal_True);
}
default:
{
- return (memcmp(pAddr1, Addr2, sizeof(struct sockaddr)) == 0);
+ return (memcmp(pAddr1, pAddr2, sizeof(struct sockaddr)) == 0);
}
- }
+ }
+ }
}
-
return (sal_False);
}
@@ -1173,7 +1173,6 @@ oslHostAddr SAL_CALL osl_createHostAddr (
rtl_string_release(strHostname);
}
-
return HostAddr;
}
@@ -1197,7 +1196,7 @@ oslHostAddr SAL_CALL osl_psz_createHostAddr (
pHostAddr= (oslHostAddr) malloc(sizeof(struct oslHostAddrImpl));
OSL_ASSERT(pHostAddr);
- if (pAddr == NULL)
+ if (pHostAddr == NULL)
{
free (cn);
return ((oslHostAddr)NULL);
@@ -2530,7 +2529,10 @@ sal_Bool __osl_socket_poll (
int timeout;
int result;
- OSL_ASSERT(pSocket);
+ OSL_ASSERT(0 != pSocket);
+ if (0 == pSocket)
+ return sal_False; /* EINVAL */
+
pSocket->m_nLastError = 0;
fds.fd = pSocket->m_Socket;
@@ -2573,7 +2575,10 @@ sal_Bool __osl_socket_poll (
struct timeval tv;
int result;
- OSL_ASSERT(pSocket);
+ OSL_ASSERT(0 != pSocket);
+ if (0 == pSocket)
+ return sal_False; /* EINVAL */
+
pSocket->m_nLastError = 0;
FD_ZERO(&fds);
diff --git a/sal/rtl/source/alloc.c b/sal/rtl/source/alloc.c
deleted file mode 100644
index 44b37c255004..000000000000
--- a/sal/rtl/source/alloc.c
+++ /dev/null
@@ -1,1541 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifdef PROFILE
-#undef OSL_DEBUG_LEVEL
-#define OSL_DEBUG_LEVEL 0
-#endif /* PROFILE */
-
-#include <sal/types.h>
-#include <osl/diagnose.h>
-#include <rtl/alloc.h>
-
-#ifndef INCLUDED_STDDEF_H
-#include <stddef.h>
-#define INCLUDED_STDDEF_H
-#endif
-
-#ifndef INCLUDED_STDLIB_H
-#include <stdlib.h>
-#define INCLUDED_STDLIB_H
-#endif
-
-#ifndef INCLUDED_STRING_H
-#include <string.h>
-#define INCLUDED_STRING_H
-#endif
-
-#ifndef FORCE_SYSALLOC
-
-/*===========================================================================
- *
- * rtl_memory (UNX) internals.
- *
- *=========================================================================*/
-#ifdef SAL_UNX
-
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-
-typedef pthread_mutex_t mutex_type;
-
-#define RTL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
-#define RTL_MUTEX_ACQUIRE(a) pthread_mutex_lock((a))
-#define RTL_MUTEX_RELEASE(a) pthread_mutex_unlock((a))
-
-#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
-static sal_Size __rtl_memory_vmpagesize (void)
-{
- /* xBSD */
- return (sal_Size)(getpagesize());
-}
-#elif defined(LINUX) || defined(SOLARIS)
-static sal_Size __rtl_memory_vmpagesize (void)
-{
- /* POSIX */
- return (sal_Size)(sysconf(_SC_PAGESIZE));
-}
-#else
-static sal_Size __rtl_memory_vmpagesize (void)
-{
- /* other */
- return (sal_Size)(0x2000);
-}
-#endif /* FREEBSD || NETBSD || MACOSX || LINUX || SOLARIS */
-
-#ifndef PROT_HEAP
-#define PROT_HEAP (PROT_READ | PROT_WRITE | PROT_EXEC)
-#endif
-
-/* #95880# building on Solaris 8 provides MAP_ANON, but it
- is not available on Solaris 7 */
-#if defined (SOLARIS)
-#ifdef MAP_ANON
-#undef MAP_ANON
-#endif
-#endif
-
-#ifndef MAP_ANON
-static void* __rtl_memory_vmalloc (sal_Size n)
-{
- /* SYSV */
- int fd = open("/dev/zero", O_RDWR);
- if (!(fd < 0))
- {
- void * p = mmap(NULL, n, PROT_HEAP, MAP_PRIVATE, fd, 0);
- close(fd);
- return ((p == MAP_FAILED) ? NULL : p);
- }
- return (NULL);
-}
-#else /* MAP_ANON */
-static void* __rtl_memory_vmalloc (sal_Size n)
-{
- /* xBSD */
- void * p = mmap(NULL, n, PROT_HEAP, MAP_PRIVATE | MAP_ANON, -1, 0);
- return ((p == MAP_FAILED) ? NULL : p);
-}
-#endif /* MAP_ANON */
-
-#define RTL_MEMORY_ALLOC(n) __rtl_memory_vmalloc((sal_Size)(n))
-#define RTL_MEMORY_FREE(p, n) munmap((void*)(p), (sal_Size)(n))
-
-#endif /* SAL_UNX */
-
-/*===========================================================================
- *
- * rtl_memory (W32) internals.
- *
- *=========================================================================*/
-#ifdef SAL_W32
-
-#define WIN32_LEAN_AND_MEAN
-#ifdef _MSC_VER
-#pragma warning(push,1) /* disable warnings within system headers */
-#endif
-#include <windows.h>
-#include <wchar.h>
-
-typedef CRITICAL_SECTION mutex_type;
-
-/* Static initializer (struct declared in WINNT.H). */
-#define RTL_MUTEX_INITIALIZER { NULL, -1, 0, NULL, NULL, 0 }
-
-/*
- * __rtl_mutex_init (dynamic initialization).
- *
- * Static initialization (with DebugInfo == NULL)
- * leads to Access Violation upon first contention.
- */
-static void __rtl_mutex_init (LPCRITICAL_SECTION lpCriticalSection)
-{
- static LONG g_spinlock = 0;
-
- while (InterlockedExchange (&g_spinlock, 1) == 1)
- {
- /* Already locked, spin */
- Sleep (0);
- }
- if (!(lpCriticalSection->DebugInfo))
- {
- /* Dynamic initialization */
- InitializeCriticalSection (lpCriticalSection);
- }
- InterlockedExchange (&g_spinlock, 0);
-}
-
-#define RTL_MUTEX_INIT(a) __rtl_mutex_init((LPCRITICAL_SECTION)(a))
-#define RTL_MUTEX_ACQUIRE(a) EnterCriticalSection((a))
-#define RTL_MUTEX_RELEASE(a) LeaveCriticalSection((a))
-
-static sal_Size __rtl_memory_vmpagesize (void)
-{
- SYSTEM_INFO info;
- GetSystemInfo (&info);
- return ((sal_Size)(info.dwPageSize));
-}
-
-#define RTL_MEMORY_ALLOC(n) \
-(void*)(VirtualAlloc (NULL, (SIZE_T)(n), MEM_COMMIT, PAGE_READWRITE))
-
-#define RTL_MEMORY_FREE(p, n) \
-(void)(VirtualFree ((LPVOID)(p), (SIZE_T)(0), MEM_RELEASE))
-
-#endif /* SAL_W32 */
-
-/*===========================================================================
- *
- * rtl_memory (OS2) internals.
- *
- *=========================================================================*/
-#ifdef SAL_OS2
-
-#define INCL_DOS
-#include <os2.h>
-
-typedef HMTX mutex_type;
-
-/* Static initializer */
-#define RTL_MUTEX_INITIALIZER -1
-
-/*
- * __rtl_mutex_init (dynamic initialization).
- *
- * Static initialization (with DebugInfo == NULL)
- * leads to Access Violation upon first contention.
- */
-static void __rtl_mutex_init (mutex_type* mutex)
-{
- APIRET rc = 0;
-
- rc = DosCreateMutexSem(NULL,mutex,0,0);
-
-}
-
-static int __rtl_mutex_destroy (mutex_type* mutex)
-{
- APIRET rc = 0;
-
-
- do {
- rc = DosCloseMutexSem(*mutex);
- if (rc == 301) DosReleaseMutexSem(*mutex);
- } while (rc == 301);
-
- *mutex = 0;
-
- /* Return the completion status: */
- return (0);
-}
-
-
-static int __rtl_mutex_acquire(mutex_type* mutex)
-{
- int ret = 0;
- int status = 0;
- APIRET rc = 0;
-
- // initialize static semaphores created with PTHREAD_MUTEX_INITIALIZER state.
- if (*mutex == -1)
- __rtl_mutex_init( mutex);
-
- rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
- if (rc)
- return(1);
-
- /* Return the completion status: */
- return (0);
-}
-
-static int __rtl_mutex_release(mutex_type* mutex)
-{
- int ret = 0;
- APIRET rc = 0;
- int status;
-
-
- // initialize static semaphores created with PTHREAD_MUTEX_INITIALIZER state.
- if (*mutex == -1)
- __rtl_mutex_init( mutex);
-
- rc = DosReleaseMutexSem(*mutex);
-
- /* Return the completion status: */
- return (0);
-}
-
-#define RTL_MUTEX_INIT(a) __rtl_mutex_init((mutex_type*)(a))
-#define RTL_MUTEX_ACQUIRE(a) __rtl_mutex_acquire((mutex_type*)(a))
-#define RTL_MUTEX_RELEASE(a) __rtl_mutex_release((mutex_type*)(a))
-
-static sal_Size __rtl_memory_vmpagesize (void)
-{
- return (sal_Size)(getpagesize());
-}
-
-#define RTL_MEMORY_ALLOC(n) (void*)(malloc(n))
-
-#define RTL_MEMORY_FREE(p, n) (void)(free(p))
-
-#endif /* SAL_OS2 */
-
-/*===========================================================================
- *
- * rtl_memory (global) internals.
- *
- *=========================================================================*/
-#define __L__ 32
-#define __P__ 24
-#define __N__ ((__L__) + (__P__))
-#define __M__ 0x10000
-
-static const sal_Size __T__ = (__M__) * 2 / 3;
-
-typedef struct __rtl_memory_desc_st memory_type;
-struct __rtl_memory_desc_st
-{
- sal_Size m_length;
- sal_Size m_offset;
- memory_type *m_flink;
- memory_type *m_blink;
-};
-
-static const int __C__ = 2 * sizeof(sal_Size);
-static const int __Q__ = 2 * sizeof(memory_type*);
-
-typedef struct __rtl_memory_stat_st memory_stat;
-struct __rtl_memory_stat_st
-{
- sal_uInt64 m_dequeue;
- sal_uInt64 m_enqueue;
- sal_Int32 m_delta_q;
-
- sal_uInt64 m_deqsize;
- sal_uInt64 m_enqsize;
- sal_Int32 m_delta_n;
-};
-
-#define RTL_MEMORY_ALIGN(n, m) (((n) + ((m) - 1)) & ~((m) - 1))
-#define RTL_MEMORY_SIZEOF(a) RTL_MEMORY_ALIGN(sizeof(a), sizeof(memory_type))
-
-struct __rtl_memory_global_st
-{
- sal_Size m_magic;
- sal_Size m_align;
-
- union {
- mutex_type m_lock;
- char m_data[RTL_MEMORY_SIZEOF(mutex_type)];
- } m_mutex;
-
- memory_type m_alloc_head;
- memory_type m_spare_head;
- memory_type m_queue_head[__N__];
-
-#if OSL_DEBUG_LEVEL > 0
- memory_stat m_queue_stat[__N__];
-#endif /* OSL_DEBUG_LEVEL */
-};
-
-static struct __rtl_memory_global_st g_memory =
-{
- 0, 0, { RTL_MUTEX_INITIALIZER },
- { 0, 0, NULL, NULL }, { 0, 0, NULL, NULL }, { { 0, 0, NULL, NULL } },
-#if OSL_DEBUG_LEVEL > 0
- { { 0, 0, 0, 0, 0, 0 } }
-#endif /* OSL_DEBUG_LEVEL */
-};
-
-void SAL_CALL ___rtl_memory_init (void);
-void SAL_CALL ___rtl_memory_fini (void);
-
-#define RTL_MEMORY_ENTER() \
-{ \
- if (!(g_memory.m_align)) ___rtl_memory_init(); \
- RTL_MUTEX_ACQUIRE(&(g_memory.m_mutex.m_lock)); \
-}
-
-#define RTL_MEMORY_LEAVE() \
-{ \
- RTL_MUTEX_RELEASE(&(g_memory.m_mutex.m_lock)); \
-}
-
-/*===========================================================================
- *
- * rtl_memory (queue) internals.
- *
- *=========================================================================*/
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static sal_Size queue (sal_Size n)
-{
- /* k = n div __C__ */
- register sal_Size k = n / __C__, m = __L__;
-
- OSL_PRECOND((__L__ == 32),
- "__rtl_memory_queue(): internal logic error");
- if (k > m)
- {
- /* k = k div __L__ = k div 32 */
- k >>= 5;
- while ((k >>= 1) > 0) m++;
- k = m;
- }
-
- OSL_POSTCOND((0 < k) && (k < __N__),
- "__rtl_memory_queue(): "
- "internal error: index out of bounds");
- return (k);
-}
-#else /* PRODUCT */
-#define queue(k, n) \
-{ \
- (k) = ((n) / __C__); \
- if ((k) > __L__) \
- { \
- register sal_Size m = __L__; \
- (k) >>= 5; \
- while (((k) >>= 1) > 0) m++; \
- (k) = m; \
- } \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-#define queue_start(entry) \
-{ \
- (entry)->m_flink = (entry); \
- (entry)->m_blink = (entry); \
-}
-
-#define queue_remove(entry) \
-{ \
- (entry)->m_blink->m_flink = (entry)->m_flink; \
- (entry)->m_flink->m_blink = (entry)->m_blink; \
- queue_start(entry); \
-}
-
-#define queue_insert_head(head, entry) \
-{ \
- (entry)->m_blink = (head); \
- (entry)->m_flink = (head)->m_flink; \
- (head)->m_flink = (entry); \
- (entry)->m_flink->m_blink = (entry); \
-}
-
-#define queue_insert_tail(head, entry) \
-{ \
- (entry)->m_flink = (head); \
- (entry)->m_blink = (head)->m_blink; \
- (head)->m_blink = (entry); \
- (entry)->m_blink->m_flink = (entry); \
-}
-
-/*===========================================================================
- *
- * rtl_memory (debug) internals.
- *
- *=========================================================================*/
-#if OSL_DEBUG_LEVEL > 0
-
-#define __dbg_memory_succ(entry, length) \
-(memory_type*)((char*)((entry)) + ((length) & ~0x1))
-
-#define __dbg_memory_pred(entry, offset) \
-(memory_type*)((char*)((entry)) - ((offset) & ~0x1))
-
-#define __dbg_memory_ensure(entry) (!((sal_Size)(entry) & 0x7))
-
-/*
- * __dbg_memory_dequeue.
- */
-static void __dbg_memory_dequeue (sal_Size n)
-{
- register sal_Size k = queue(n);
-
- g_memory.m_queue_stat[k].m_dequeue += 1;
- g_memory.m_queue_stat[k].m_delta_q += 1;
-
- g_memory.m_queue_stat[k].m_deqsize += n;
- g_memory.m_queue_stat[k].m_delta_n += n;
-}
-
-/*
- * __dbg_memory_enqueue.
- */
-static void __dbg_memory_enqueue (sal_Size n)
-{
- register sal_Size k = queue(n);
-
- g_memory.m_queue_stat[k].m_enqueue += 1;
- g_memory.m_queue_stat[k].m_delta_q -= 1;
-
- g_memory.m_queue_stat[k].m_enqsize += n;
- g_memory.m_queue_stat[k].m_delta_n -= n;
-}
-
-/*
- * __dbg_memory_insert.
- */
-static void __dbg_memory_insert (memory_type **ppMemory)
-{
- register memory_type * succ;
- succ = __dbg_memory_succ (*ppMemory, sizeof(memory_type));
-
- succ->m_length = (*ppMemory)->m_length - sizeof(memory_type);
- succ->m_offset = (*ppMemory)->m_offset;
-
- queue_insert_tail (&(g_memory.m_alloc_head), (*ppMemory));
- (*ppMemory) = succ;
-}
-
-/*
- * __dbg_memory_remove.
- */
-static void __dbg_memory_remove (memory_type **ppMemory)
-{
- (*ppMemory) = __dbg_memory_pred (*ppMemory, sizeof(memory_type));
- queue_remove (*ppMemory);
-}
-
-/*
- * __dbg_memory_verify_chain.
- */
-static int __dbg_memory_verify_chain (memory_type * x)
-{
- if (!__dbg_memory_ensure(x))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): invalid pointer alignment.");
- return (0);
- }
- if (!__dbg_memory_ensure(x->m_length & ~0x1))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): dynamic memory corruption");
- return (0);
- }
- if (!__dbg_memory_ensure(x->m_offset & ~0x1))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): dynamic memory corruption");
- return (0);
- }
- if (!(x->m_length & ~0x1))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): dynamic memory corruption");
- return (0);
- }
- return (1);
-}
-
-/*
- * __dbg_memory_verify_queue.
- */
-static int __dbg_memory_verify_queue (memory_type * x)
-{
- if (!__dbg_memory_ensure(x))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): invalid pointer alignment.");
- return (0);
- }
- if (!__dbg_memory_ensure(x->m_flink))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): free memory corruption");
- return (0);
- }
- if (!__dbg_memory_ensure(x->m_blink))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): free memory corruption");
- return (0);
- }
- if ((x == x->m_flink) || (x == x->m_blink))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): internal logic error");
- return (0);
- }
- return (1);
-}
-
-/*
- * __dbg_memory_verify_alloc.
- */
-static int __dbg_memory_verify_alloc (memory_type * x)
-{
- register memory_type *head, *entry;
- head = entry = &(g_memory.m_alloc_head);
-
- if (!__dbg_memory_ensure(x))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): invalid pointer alignment.");
- return (0);
- }
- while (!((entry = entry->m_flink) == head))
- {
- if ((entry < x) && (x < __dbg_memory_succ(entry, entry->m_length)))
- {
- head = entry = __dbg_memory_succ(entry, sizeof(memory_type));
- while (!((x == entry) || (entry->m_offset & 0x1)))
- {
- /* no match, not last */
- if (!__dbg_memory_verify_chain (entry))
- return (0);
- entry = __dbg_memory_succ(entry, entry->m_length);
- }
-
- /* match, or last */
- if (!__dbg_memory_verify_chain (entry))
- return (0);
- break;
- }
- }
- if (!(x == entry))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): memory not allocated.");
- return (0);
- }
- return (1);
-}
-
-/*
- * __dbg_memory_verify.
- */
-static int __dbg_memory_verify (memory_type * x, int debug)
-{
- /* dispatch upon 'debug' level */
- if (debug)
- {
- /* verify allocation */
- if (!__dbg_memory_verify_alloc (x))
- return (0);
- }
- else
- {
- /* verify 'chain' fields */
- if (!__dbg_memory_verify_chain (x))
- return (0);
- }
-
- /* verify 'used' bit */
- if (!(x->m_length & 0x1))
- {
- OSL_ENSURE(0, "__rtl_memory_verify(): memory not used.");
- return (0);
- }
- return (1);
-}
-
-#if OSL_DEBUG_LEVEL > 1
-/*
- * __dbg_memory_usage_update.
- */
-static sal_Size __dbg_memory_usage_update (memory_stat * stat, sal_Size length)
-{
- register sal_Size n = (length & ~0x1), k = queue(n);
-
- stat[k].m_dequeue += 1;
- stat[k].m_deqsize += n;
-
- if (!(length & 0x1))
- {
- /* not used */
- stat[k].m_enqueue += 1;
- stat[k].m_enqsize += n;
- return (n);
- }
- else
- {
- /* used */
- stat[k].m_delta_q += 1;
- stat[k].m_delta_n += n;
- return (0);
- }
-}
-
-/*
- * __dbg_memory_usage.
- */
-static void __dbg_memory_usage (memory_stat * total)
-{
- register memory_type *head, *entry, *memory;
- memory_stat stat[__N__];
-
- memset (stat, 0, __N__ * sizeof(memory_stat));
-
- head = entry = &(g_memory.m_alloc_head);
- while (!((entry = entry->m_flink) == head))
- {
- register sal_Size k = 0, n = entry->m_length - sizeof(memory_type);
-
- memory = __dbg_memory_succ(entry, sizeof(memory_type));
- while (!(memory->m_offset & 0x1))
- {
- /* not last */
- k += __dbg_memory_usage_update (stat, memory->m_length);
- memory = __dbg_memory_succ(memory, memory->m_length);
- }
-
- k += __dbg_memory_usage_update (stat, memory->m_length);
- OSL_TRACE("%x %10d %10d", (sal_Size)(entry), n, k);
- }
-
- if (total)
- {
- sal_Size i;
-
- memset (total, 0, sizeof(memory_stat));
- for (i = 0; i < __N__; i++)
- {
- total->m_dequeue += stat[i].m_dequeue;
- total->m_enqueue += stat[i].m_enqueue;
- total->m_delta_q += stat[i].m_delta_q;
-
- total->m_deqsize += stat[i].m_deqsize;
- total->m_enqsize += stat[i].m_enqsize;
- total->m_delta_n += stat[i].m_delta_n;
- }
- }
-}
-#endif /* OSL_DEBUG_LEVEL */
-
-#endif /* OSL_DEBUG_LEVEL */
-#if OSL_DEBUG_LEVEL > 0
-
-#define DBG_MEMORY_DEQUEUE(n) __dbg_memory_dequeue((sal_Size)(n) & ~0x1)
-#define DBG_MEMORY_ENQUEUE(n) __dbg_memory_enqueue((sal_Size)(n) & ~0x1)
-
-#define DBG_MEMORY_DEQFILL(entry, offset, length) \
- memset(((char*)(entry) + (offset)), 0x77777777, (length))
-#define DBG_MEMORY_ENQFILL(entry, offset, length) \
- memset(((char*)(entry) + (offset)), 0x33333333, (length))
-
-#define DBG_MEMORY_INSERT(entry) __dbg_memory_insert((entry))
-#define DBG_MEMORY_REMOVE(entry) __dbg_memory_remove((entry))
-
-#if OSL_DEBUG_LEVEL > 1
-#define DBG_MEMORY_VERIFY(entry) __dbg_memory_verify((entry), 1)
-#else /* OSL_DEBUG_LEVEL > 0 */
-#define DBG_MEMORY_VERIFY(entry) __dbg_memory_verify((entry), 0)
-#endif /* OSL_DEBUG_LEVEL */
-
-#define DBG_MEMORY_VERIFY_CHAIN(entry) __dbg_memory_verify_chain((entry))
-#define DBG_MEMORY_VERIFY_QUEUE(entry) __dbg_memory_verify_queue((entry))
-
-#else /* PRODUCT */
-
-#define DBG_MEMORY_DEQUEUE(n)
-#define DBG_MEMORY_ENQUEUE(n)
-
-#define DBG_MEMORY_DEQFILL(entry, offset, length)
-#define DBG_MEMORY_ENQFILL(entry, offset, length)
-
-#define DBG_MEMORY_INSERT(entry)
-#define DBG_MEMORY_REMOVE(entry)
-
-#define DBG_MEMORY_VERIFY(entry)
-#define DBG_MEMORY_VERIFY_CHAIN(entry)
-#define DBG_MEMORY_VERIFY_QUEUE(entry)
-
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*===========================================================================
- *
- * rtl_memory (manager) internals.
- *
- *=========================================================================*/
-#define queue_cast(entry, offset) \
-((memory_type*)((char*)(entry) + (ptrdiff_t)(offset)))
-
-#define __rtl_memory_used(entry) ((entry)->m_length & 0x1)
-#define __rtl_memory_last(entry) ((entry)->m_offset & 0x1)
-#define __rtl_memory_offset(entry) \
- ((ptrdiff_t)((entry)->m_offset & ~0x1))
-
-/*
- * ___rtl_memory_init.
- */
-void SAL_CALL ___rtl_memory_init (void)
-{
-#if defined(RTL_MUTEX_INIT)
- RTL_MUTEX_INIT (&(g_memory.m_mutex.m_lock));
-#endif /* RTL_MUTEX_INIT */
-
- RTL_MUTEX_ACQUIRE(&(g_memory.m_mutex.m_lock));
- if (!(g_memory.m_align))
- {
- sal_Size pagesize;
- int i;
-
- queue_start (&(g_memory.m_alloc_head));
- queue_start (&(g_memory.m_spare_head));
-
- for (i = 0; i < __N__; i++)
- queue_start (&(g_memory.m_queue_head[i]));
- for (i = 1; i <= __L__; i++)
- g_memory.m_queue_head[i].m_length = i * __C__;
- for (i = __L__ + 1; i < __N__; i++)
- g_memory.m_queue_head[i].m_length =
- 2 * g_memory.m_queue_head[i - 1].m_length;
-
- pagesize = __rtl_memory_vmpagesize();
- g_memory.m_align = RTL_MEMORY_ALIGN(__M__, pagesize);
- }
- RTL_MUTEX_RELEASE(&(g_memory.m_mutex.m_lock));
-}
-
-/*
- * ___rtl_memory_fini.
- */
-void SAL_CALL ___rtl_memory_fini (void)
-{
-#if OSL_DEBUG_LEVEL > 1
-
- memory_stat total;
-
- __dbg_memory_usage (&total);
- if (total.m_delta_n > 0)
- {
- OSL_TRACE("___rtl_memory_fini(): "
- "Leak: %10d (Alloc: %10d, Free: %10d)",
- total.m_delta_n,
- (sal_uInt32)(total.m_deqsize & 0xffffffff),
- (sal_uInt32)(total.m_enqsize & 0xffffffff));
- }
-
-#endif /* OSL_DEBUG_LEVEL */
-}
-
-/*
- * __rtl_memory_merge.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_merge (memory_type * prev, memory_type * next)
-{
- /* adjust length */
- prev->m_length += next->m_length;
- if (!__rtl_memory_last(next))
- {
- /* not last, adjust offset */
- register memory_type * succ = queue_cast(prev, prev->m_length);
- DBG_MEMORY_VERIFY_CHAIN (succ);
- succ->m_offset = prev->m_length | __rtl_memory_last(succ);
- }
-
- /* propagate 'last' bit */
- prev->m_offset |= __rtl_memory_last(next);
-}
-#else /* PRODUCT */
-#define __rtl_memory_merge(prev, next) \
-{ \
- (prev)->m_length += (next)->m_length; \
- if (!__rtl_memory_last((next))) \
- { \
- register memory_type * succ = queue_cast((prev), (prev)->m_length); \
- succ->m_offset = (prev)->m_length | __rtl_memory_last(succ); \
- } \
- (prev)->m_offset |= __rtl_memory_last((next)); \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*
- * __rtl_memory_split.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_split (memory_type * prev, memory_type * next)
-{
- /* adjust length */
- prev->m_length -= next->m_length;
- if (!__rtl_memory_last(prev))
- {
- /* not last, adjust offset */
- register memory_type * succ = queue_cast(next, next->m_length);
- DBG_MEMORY_VERIFY_CHAIN (succ);
- succ->m_offset = next->m_length | __rtl_memory_last(succ);
- }
-
- /* propagate 'last' bit */
- next->m_offset |= __rtl_memory_last(prev);
- prev->m_offset &= ~0x1;
-}
-#else /* PRODUCT */
-#define __rtl_memory_split(prev, next) \
-{ \
- (prev)->m_length -= (next)->m_length; \
- if (!__rtl_memory_last((prev))) \
- { \
- register memory_type * succ = queue_cast((next), (next)->m_length); \
- succ->m_offset = (next)->m_length | __rtl_memory_last(succ); \
- } \
-\
- (next)->m_offset |= __rtl_memory_last((prev)); \
- (prev)->m_offset &= ~0x1; \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*
- * __rtl_memory_insert.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_insert (memory_type * memory, sal_Size n)
-{
- /* obtain queue head */
- register memory_type *head;
-
- head = &(g_memory.m_queue_head[queue(n)]);
- DBG_MEMORY_VERIFY_CHAIN (head);
-
- /* insert at queue tail (first-in first-out) */
- queue_insert_tail (head, memory);
-}
-#else /* PRODUCT */
-#define __rtl_memory_insert(memory, n) \
-{ \
- register sal_Size h; \
-\
- queue(h, (n)); \
- queue_insert_tail (&(g_memory.m_queue_head[h]), (memory)); \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*
- * __rtl_memory_resize.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_resize (memory_type * memory, sal_Size n)
-{
- register sal_Size k = (memory->m_length - n);
-
- OSL_ENSURE(!(memory->m_length & 0x1),
- "__rtl_memory_resize(): "
- "internal logic error.");
-
- if ((k >= sizeof(memory_type)) && (n <= __T__))
- {
- /* split */
- register memory_type * remain = queue_cast(memory, n);
-
- remain->m_length = k; remain->m_offset = n;
- __rtl_memory_split (memory, remain);
-
- /* check postcond */
- if (!__rtl_memory_last(remain))
- {
- /* not last, verify used next entry */
- register memory_type *next;
-
- next = queue_cast(remain, remain->m_length);
- DBG_MEMORY_VERIFY_CHAIN (next);
-
- OSL_POSTCOND(__rtl_memory_used(next),
- "__rtl_memory_resize(): "
- "internal logic error.");
- }
-
- /* enqueue */
- __rtl_memory_insert (remain, k);
- DBG_MEMORY_VERIFY_QUEUE (remain);
- }
-
- DBG_MEMORY_DEQUEUE(memory->m_length);
-}
-#else /* PRODUCT */
-#define __rtl_memory_resize(memory, n) \
-{ \
- register sal_Size kn = ((memory)->m_length - (n)); \
- if ((kn >= sizeof(memory_type)) && (n <= __T__)) \
- { \
- register memory_type * remain = queue_cast((memory), (n)); \
-\
- remain->m_length = kn; remain->m_offset = (n); \
- __rtl_memory_split ((memory), remain); \
-\
- __rtl_memory_insert (remain, kn); \
- } \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*
- * __rtl_memory_dequeue.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_dequeue (memory_type **ppMemory, sal_Size n)
-{
- register memory_type *head, *entry;
- register sal_Size k, m = n;
-
- OSL_PRECOND(!*ppMemory, "__rtl_memory_dequeue(): internal logic error.");
- for (k = queue(m); k < __N__; k++)
- {
- /* first fit (equals best fit w/ ascending insert) */
- head = &(g_memory.m_queue_head[k]);
- for (entry = head->m_flink; entry != head; entry = entry->m_flink)
- {
- /* queue not empty */
- DBG_MEMORY_VERIFY_CHAIN (entry);
- if (entry->m_length >= m)
- {
- /* remove entry */
- DBG_MEMORY_VERIFY_QUEUE (entry);
- queue_remove (entry);
-
- /* assign result */
- *ppMemory = entry;
- goto dequeue_leave;
- }
- }
- }
-
- head = &(g_memory.m_spare_head);
- for (entry = head->m_flink; entry != head; entry = entry->m_flink)
- {
- /* queue not empty */
- DBG_MEMORY_VERIFY_CHAIN (entry);
- if (entry->m_length >= m)
- {
- /* remove entry */
- DBG_MEMORY_VERIFY_QUEUE (entry);
- queue_remove (entry);
-
- /* assign result */
- *ppMemory = entry;
- goto dequeue_leave;
- }
- }
-
-#if OSL_DEBUG_LEVEL > 0
- /* adjust for DBG_MEMORY_INSERT() overhead */
- m += sizeof(memory_type);
-#endif /* OSL_DEBUG_LEVEL */
-
- k = RTL_MEMORY_ALIGN((m > __M__) ? m : __M__, g_memory.m_align);
- if (!((entry = RTL_MEMORY_ALLOC(k)) == 0))
- {
- entry->m_length = k;
- entry->m_offset = 0x1; /* set 'last' bit */
-
- *ppMemory = entry;
- DBG_MEMORY_INSERT(ppMemory);
- }
-
-dequeue_leave:
- OSL_POSTCOND(*ppMemory, "__rtl_memory_dequeue(): out of memory.");
- if ((entry = *ppMemory) != 0)
- {
- /* adjust length */
- __rtl_memory_resize (entry, n);
-
- /* fill w/ 'uninitialized' pattern */
- DBG_MEMORY_DEQFILL (entry, __C__, entry->m_length - __C__);
- }
-#if OSL_DEBUG_LEVEL > 1
- if (!entry)
- {
- memory_stat total;
- __dbg_memory_usage (&total);
- }
-#endif /* OSL_DEBUG_LEVEL */
-}
-#else /* PRODUCT */
-#define __rtl_memory_dequeue(ppMemory, n, label) \
-{ \
- register memory_type *head, *entry; \
- register sal_Size h, m = (n); \
-\
- queue (h, m); \
- for (; h < __N__; h++) \
- { \
- head = &(g_memory.m_queue_head[h]); \
- for (entry = head->m_flink; entry != head; entry = entry->m_flink) \
- { \
- if (entry->m_length >= m) \
- { \
- queue_remove (entry); \
- goto label; \
- } \
- } \
- } \
-\
- head = &(g_memory.m_spare_head); \
- for (entry = head->m_flink; entry != head; entry = entry->m_flink) \
- { \
- if (entry->m_length >= m) \
- { \
- queue_remove (entry); \
- goto label; \
- } \
- } \
-\
- h = RTL_MEMORY_ALIGN((m > __M__) ? m : __M__, g_memory.m_align); \
- if (!((entry = RTL_MEMORY_ALLOC(h)) == 0)) \
- { \
- entry->m_length = h; \
- entry->m_offset = 0x1; \
- } \
-\
-label: \
- if (entry) \
- { \
- __rtl_memory_resize (entry, (n)); \
- *(ppMemory) = entry; \
- } \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-#define RTL_MEMORY_DEQUEUE(m, n, l) __rtl_memory_dequeue((m), (n))
-#else /* PRODUCT */
-#define RTL_MEMORY_DEQUEUE(m, n, l) __rtl_memory_dequeue(m, n, l)
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-/*
- * __rtl_memory_enqueue.
- */
-#if defined(PROFILE) || (OSL_DEBUG_LEVEL > 0)
-static void __rtl_memory_enqueue (memory_type **ppMemory)
-{
- register memory_type *head = *ppMemory;
-
- OSL_ENSURE(!__rtl_memory_used(head),
- "__rtl_memory_enqueue(): "
- "internal logic error.");
- DBG_MEMORY_ENQUEUE (head->m_length);
-
- /* fill w/ 'deinitialized' pattern */
- DBG_MEMORY_ENQFILL (head, __C__, head->m_length - __C__);
-
- /* try merge w/ next entry */
- if (!__rtl_memory_last(head))
- {
- /* not last, check next in chain */
- register memory_type * next;
-
- next = queue_cast(head, head->m_length);
- DBG_MEMORY_VERIFY_CHAIN (next);
-
- if (!__rtl_memory_used(next))
- {
- /* next not used */
- DBG_MEMORY_VERIFY_QUEUE (next);
- queue_remove (next);
-
- /* merge w/ next */
- __rtl_memory_merge (head, next);
- DBG_MEMORY_ENQFILL (next, 0, sizeof(memory_type));
- }
- }
-
- /* try merge w/ prev entry */
- if (__rtl_memory_offset(head) > 0)
- {
- /* not first, check prev in chain */
- register memory_type * prev;
-
- prev = queue_cast(head, -(__rtl_memory_offset(head)));
- DBG_MEMORY_VERIFY_CHAIN (prev);
-
- if (!__rtl_memory_used(prev))
- {
- /* prev not used */
- DBG_MEMORY_VERIFY_QUEUE (prev);
- queue_remove (prev);
-
- /* merge w/ prev */
- __rtl_memory_merge (prev, head);
- DBG_MEMORY_ENQFILL (head, 0, sizeof(memory_type));
- head = prev;
- }
- }
-
- if (!(head->m_offset == 0x1))
- {
- /* page still used, enqueue */
- __rtl_memory_insert (head, head->m_length);
- head = 0;
- }
- else if (head->m_length <= g_memory.m_align)
- {
- /* small page unused, check spare page */
- register memory_type * spare;
-
- spare = &(g_memory.m_spare_head);
- if (spare->m_flink == spare)
- {
- /* keep as spare page */
- queue_insert_tail (spare, head);
- head = 0;
- }
- }
- if ((*ppMemory = head) != 0)
- {
- /* page unused, remove */
- DBG_MEMORY_REMOVE(ppMemory);
- }
-}
-#else /* PRODUCT */
-#define __rtl_memory_enqueue(ppMemory) \
-{ \
- register memory_type *head = *(ppMemory); \
-\
- if (!__rtl_memory_last(head)) \
- { \
- register memory_type * next; \
- next = queue_cast(head, head->m_length); \
- if (!__rtl_memory_used(next)) \
- { \
- queue_remove (next); \
- __rtl_memory_merge (head, next); \
- } \
- } \
-\
- if (__rtl_memory_offset(head) > 0) \
- { \
- register memory_type * prev; \
- prev = queue_cast(head, -(__rtl_memory_offset(head))); \
- if (!__rtl_memory_used(prev)) \
- { \
- queue_remove (prev); \
- __rtl_memory_merge (prev, head); \
- head = prev; \
- } \
- } \
-\
- if (!(head->m_offset == 0x1)) \
- { \
- register memory_type * used = head; \
- __rtl_memory_insert (used, used->m_length); \
- head = 0; \
- } \
- else if (head->m_length <= g_memory.m_align) \
- { \
- register memory_type * spare; \
- spare = &(g_memory.m_spare_head); \
- if (spare->m_flink == spare) \
- { \
- queue_insert_tail (spare, head); \
- head = 0; \
- } \
- } \
-\
- *(ppMemory) = head; \
-}
-#endif /* OSL_DEBUG_LEVEL || PRODUCT */
-
-#define RTL_MEMORY_ENQUEUE(m) __rtl_memory_enqueue((m))
-
-#endif /* FORCE_SYSALLOC */
-
-/*===========================================================================
- *
- * rtl_memory (manager) implementation.
- *
- *=========================================================================*/
-/*
- * rtl_reallocateMemory.
- */
-#ifndef FORCE_SYSALLOC
-void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
-{
- memory_type * memory;
- if (!(!p || !n))
- {
- /* reallocate */
- register sal_Size datlen;
-
- memory = queue_cast(p, -(__C__)); p = 0;
- n = RTL_MEMORY_ALIGN(n, __Q__) + __C__;
-
- RTL_MEMORY_ENTER();
- DBG_MEMORY_VERIFY(memory);
-
- /* clear 'used' bit */
- DBG_MEMORY_ENQUEUE (memory->m_length);
- memory->m_length &= ~0x1;
-
- /* amount of data to be moved or copied */
- datlen = ((memory->m_length < n) ? memory->m_length : n);
-
- /* try merge w/ next entry */
- if (!__rtl_memory_last(memory))
- {
- /* not last, check next in chain */
- register memory_type * next;
-
- next = queue_cast(memory, memory->m_length);
- DBG_MEMORY_VERIFY_CHAIN(next);
-
- if (!__rtl_memory_used(next))
- {
- /* next not used */
- DBG_MEMORY_VERIFY_QUEUE(next);
- queue_remove (next);
-
- /* merge w/ next */
- __rtl_memory_merge (memory, next);
- }
- }
-
- /* try merge w/ prev entry */
- if (__rtl_memory_offset(memory) > 0)
- {
- /* not first, check prev in chain */
- register memory_type * prev;
-
- prev = queue_cast(memory, -(__rtl_memory_offset(memory)));
- DBG_MEMORY_VERIFY_CHAIN (prev);
-
- if (!__rtl_memory_used(prev))
- {
- /* prev not used, try merge, move */
- if ((memory->m_length + prev->m_length) >= n)
- {
- /* prev does fit */
- DBG_MEMORY_VERIFY_QUEUE (prev);
- queue_remove (prev);
-
- /* merge w/ prev */
- __rtl_memory_merge (prev, memory);
-
- /* move to prev */
- memmove (
- queue_cast(prev, __C__),
- queue_cast(memory, __C__),
- datlen - __C__);
- memory = prev;
- }
- }
- }
-
- if (memory->m_length >= n)
- {
- /* adjust, set 'used' bit */
- __rtl_memory_resize (memory, n);
- memory->m_length |= 0x1;
-
- /* assign result */
- p = queue_cast(memory, __C__);
- }
- else
- {
- /* allocate */
- memory_type * result = 0;
-
- /* restore 'used' bit */
- DBG_MEMORY_DEQUEUE (memory->m_length);
- memory->m_length |= 0x80000000;
-
- RTL_MEMORY_DEQUEUE (&result, n, realloc_label_1);
- if (result)
- {
- /* set 'used' bit */
- result->m_length |= 0x1;
-
- /* copy */
- memcpy (
- queue_cast(result, __C__),
- queue_cast(memory, __C__),
- datlen - __C__);
-
- /* clear 'used' bit, enqueue */
- memory->m_length &= 0x7fffffff;
- RTL_MEMORY_ENQUEUE (&memory);
- if (memory)
- {
- /* free memory page */
- RTL_MEMORY_FREE(memory, memory->m_length);
- }
-
- /* assign result */
- p = queue_cast(result, __C__);
- }
- }
- RTL_MEMORY_LEAVE();
- }
- else if (!p)
- {
- /* allocate */
- memory = 0;
- n = RTL_MEMORY_ALIGN(n, __Q__) + __C__;
-
- RTL_MEMORY_ENTER();
- RTL_MEMORY_DEQUEUE (&memory, n, realloc_label_2);
- if (memory)
- {
- /* set 'used' bit */
- memory->m_length |= 0x1;
-
- /* assign result */
- p = queue_cast(memory, __C__);
- }
- RTL_MEMORY_LEAVE();
- }
- else if (!n)
- {
- /* free */
- memory = queue_cast(p, -(__C__)); p = 0;
-
- RTL_MEMORY_ENTER();
- DBG_MEMORY_VERIFY(memory);
-
- /* clear 'used' bit, enqueue */
- memory->m_length &= ~0x1;
-
- RTL_MEMORY_ENQUEUE (&memory);
- if (memory)
- {
- /* free memory page */
- RTL_MEMORY_FREE(memory, memory->m_length);
- }
- RTL_MEMORY_LEAVE();
- }
- return (p);
-}
-#else /* FORCE_SYSALLOC */
-void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
-{
- return realloc(p, (sal_Size)(n));
-}
-#endif /* FORCE_SYSALLOC */
-
-/*
- * rtl_allocateMemory.
- */
-#ifndef FORCE_SYSALLOC
-void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C()
-{
- void * p = 0;
- if (n > 0)
- {
- memory_type * memory = 0;
- n = RTL_MEMORY_ALIGN(n, __Q__) + __C__;
-
- RTL_MEMORY_ENTER();
- RTL_MEMORY_DEQUEUE (&memory, n, alloc_label);
- if (memory)
- {
- /* set 'used' bit */
- memory->m_length |= 0x1;
-
- /* assign result */
- p = queue_cast(memory, __C__);
- }
- RTL_MEMORY_LEAVE();
- }
- return (p);
-}
-#else /* FORCE_SYSALLOC */
-void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C()
-{
- return malloc((sal_Size)(n));
-}
-#endif /* FORCE_SYSALLOC */
-
-/*
- * rtl_freeMemory.
- */
-#ifndef FORCE_SYSALLOC
-void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C()
-{
- if (p)
- {
- memory_type * memory = queue_cast(p, -(__C__));
-
- RTL_MEMORY_ENTER();
- DBG_MEMORY_VERIFY(memory);
-
- /* clear 'used' bit, enqueue */
- memory->m_length &= ~0x1;
-
- RTL_MEMORY_ENQUEUE (&memory);
- if (memory)
- {
- /* free memory page */
- RTL_MEMORY_FREE(memory, memory->m_length);
- }
- RTL_MEMORY_LEAVE();
- }
-}
-#else /* FORCE_SYSALLOC */
-void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C()
-{
- free(p);
-}
-#endif /* FORCE_SYSALLOC */
-
-/*
- * rtl_allocateZeroMemory.
- */
-#ifndef FORCE_SYSALLOC
-void* SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C()
-{
- void * p = 0;
- if (n > 0)
- {
- memory_type * memory = 0;
- n = RTL_MEMORY_ALIGN(n, __Q__) + __C__;
-
- RTL_MEMORY_ENTER();
- RTL_MEMORY_DEQUEUE (&memory, n, alloc_label); /* NYI: demand zero */
- if (memory)
- {
- /* zero, set 'used' bit */
- memset ((char*)memory + __C__, 0, memory->m_length - __C__);
- memory->m_length |= 0x1;
-
- /* assign result */
- p = queue_cast(memory, __C__);
- }
- RTL_MEMORY_LEAVE();
- }
- return (p);
-}
-#else /* FORCE_SYSALLOC */
-void* SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C()
-{
- return calloc((sal_Size)(n), 1);
-}
-#endif /* FORCE_SYSALLOC */
-
-/*
- * rtl_freeZeroMemory.
- */
-#ifndef FORCE_SYSALLOC
-void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
-{
- (void) n; /* unused */
- if (p)
- {
- memory_type * memory = queue_cast(p, -(__C__));
-
- RTL_MEMORY_ENTER();
- DBG_MEMORY_VERIFY(memory);
-
- /* clear 'used' bit, zero, enqueue */
- memory->m_length &= ~0x1;
- memset ((char*)memory + __C__, 0, memory->m_length - __C__);
-
- RTL_MEMORY_ENQUEUE (&memory); /* NYI: demand zero */
- if (memory)
- {
- /* free memory page */
- RTL_MEMORY_FREE(memory, memory->m_length);
- }
- RTL_MEMORY_LEAVE();
- }
-}
-#else /* FORCE_SYSALLOC */
-void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
-{
- if (p)
- {
- memset(p, 0, n);
- free(p);
- }
-}
-#endif /* FORCE_SYSALLOC */
-
-/*===========================================================================
- *
- * The End.
- *
- *=========================================================================*/
diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c
index 1a74c7e36cae..6b57df355cad 100644
--- a/sal/rtl/source/alloc_arena.c
+++ b/sal/rtl/source/alloc_arena.c
@@ -28,22 +28,13 @@
#define _BSD_SOURCE /* sys/mman.h: MAP_ANON */
#include "alloc_arena.h"
-#ifndef INCLUDED_RTL_ARENA_IMPL_H
#include "alloc_impl.h"
-#endif
#include "internal/once.h"
#include "sal/macros.h"
#include "osl/diagnose.h"
-#ifndef INCLUDED_STRING_H
#include <string.h>
-#endif
-
-#ifndef INCLUDED_STDIO_H
#include <stdio.h>
-#endif
-
-#include "sal/types.h"
#ifdef OS2
#undef OSL_TRACE
@@ -967,6 +958,7 @@ try_alloc:
if (result != 0)
{
rtl_arena_type * arena = result;
+ VALGRIND_CREATE_MEMPOOL(arena, 0, 0);
rtl_arena_constructor (arena);
if (!source_arena)
@@ -989,6 +981,7 @@ try_alloc:
{
rtl_arena_deactivate (arena);
rtl_arena_destructor (arena);
+ VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, size);
}
}
@@ -1014,6 +1007,7 @@ SAL_CALL rtl_arena_destroy (
{
rtl_arena_deactivate (arena);
rtl_arena_destructor (arena);
+ VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type));
}
}
@@ -1069,6 +1063,10 @@ SAL_CALL rtl_arena_alloc (
rtl_arena_hash_insert (arena, segment);
+ /* DEBUG ONLY: mark allocated, undefined */
+ OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size));
+ VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size);
+
(*pSize) = segment->m_size;
addr = (void*)(segment->m_addr);
}
@@ -1112,6 +1110,11 @@ SAL_CALL rtl_arena_free (
{
rtl_arena_segment_type *next, *prev;
+ /* DEBUG ONLY: mark unallocated, undefined */
+ VALGRIND_MEMPOOL_FREE(arena, segment->m_addr);
+ /* OSL_DEBUG_ONLY() */ VALGRIND_MAKE_MEM_UNDEFINED(segment->m_addr, segment->m_size);
+ OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size));
+
/* coalesce w/ adjacent free segment(s) */
rtl_arena_segment_coalesce (arena, segment);
@@ -1303,6 +1306,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_machdep_arena;
OSL_ASSERT(gp_machdep_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0);
rtl_arena_constructor (&g_machdep_arena);
gp_machdep_arena = rtl_arena_activate (
@@ -1319,6 +1323,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_default_arena;
OSL_ASSERT(gp_default_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0);
rtl_arena_constructor (&g_default_arena);
gp_default_arena = rtl_arena_activate (
@@ -1337,6 +1342,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_arena_arena;
OSL_ASSERT(gp_arena_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0);
rtl_arena_constructor (&g_arena_arena);
gp_arena_arena = rtl_arena_activate (
@@ -1362,7 +1368,18 @@ rtl_arena_init (void)
/* ================================================================= */
-#if defined(__GNUC__)
+/*
+ Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+
+ Mac OS X does not seem to support "__cxa__atexit", thus leading
+ to the situation that "__attribute__((destructor))__" functions
+ (in particular "rtl_{memory|cache|arena}_fini") become called
+ _before_ global C++ object d'tors.
+
+ Delegated the call to "rtl_arena_fini()" into a dummy C++ object,
+ see alloc_fini.cxx .
+*/
+#if defined(__GNUC__) && !defined(MACOSX)
static void rtl_arena_fini (void) __attribute__((destructor));
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#pragma fini(rtl_arena_fini)
diff --git a/sal/rtl/source/alloc_cache.c b/sal/rtl/source/alloc_cache.c
index 4e2c030fb3a6..f4d34bfdb437 100644
--- a/sal/rtl/source/alloc_cache.c
+++ b/sal/rtl/source/alloc_cache.c
@@ -507,6 +507,10 @@ rtl_cache_slab_alloc (
addr = (void*)rtl_cache_hash_insert (cache, bufctl);
else
addr = bufctl;
+
+ /* DEBUG ONLY: mark allocated, undefined */
+ OSL_DEBUG_ONLY(memset(addr, 0x77777777, cache->m_type_size));
+ VALGRIND_MEMPOOL_ALLOC(cache, addr, cache->m_type_size);
}
RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock));
@@ -529,6 +533,11 @@ rtl_cache_slab_free (
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock));
+ /* DEBUG ONLY: mark unallocated, undefined */
+ VALGRIND_MEMPOOL_FREE(cache, addr);
+ /* OSL_DEBUG_ONLY() */ VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size);
+ OSL_DEBUG_ONLY(memset(addr, 0x33333333, cache->m_type_size));
+
/* determine slab from addr */
if (cache->m_features & RTL_CACHE_FEATURE_HASH)
{
@@ -635,8 +644,13 @@ rtl_cache_magazine_clear (
void * obj = mag->m_objects[mag->m_mag_used - 1];
mag->m_objects[mag->m_mag_used - 1] = 0;
+ /* DEBUG ONLY: mark cached object allocated, undefined */
+ VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size);
if (cache->m_destructor != 0)
{
+ /* DEBUG ONLY: keep constructed object defined */
+ VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size);
+
/* destruct object */
(cache->m_destructor)(obj, cache->m_userarg);
}
@@ -965,11 +979,16 @@ rtl_cache_deactivate (
rtl_cache_type * cache
)
{
+ int active = 1;
+
/* remove from cache list */
RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock));
+ active = QUEUE_STARTED_NAMED(cache, cache_) == 0;
QUEUE_REMOVE_NAMED(cache, cache_);
RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
+ OSL_PRECOND(active, "rtl_cache_deactivate(): orphaned cache.");
+
/* cleanup magazine layer */
if (cache->m_magazine_cache != 0)
{
@@ -1121,6 +1140,7 @@ try_alloc:
if (result != 0)
{
rtl_cache_type * cache = result;
+ VALGRIND_CREATE_MEMPOOL(cache, 0, 0);
(void) rtl_cache_constructor (cache);
if (!source)
@@ -1148,6 +1168,7 @@ try_alloc:
/* activation failed */
rtl_cache_deactivate (cache);
rtl_cache_destructor (cache);
+ VALGRIND_DESTROY_MEMPOOL(cache);
rtl_arena_free (gp_cache_arena, cache, size);
}
}
@@ -1172,6 +1193,7 @@ void SAL_CALL rtl_cache_destroy (
{
rtl_cache_deactivate (cache);
rtl_cache_destructor (cache);
+ VALGRIND_DESTROY_MEMPOOL(cache);
rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type));
}
}
@@ -1201,6 +1223,14 @@ SAL_CALL rtl_cache_alloc (
if ((curr != 0) && (curr->m_mag_used > 0))
{
obj = curr->m_objects[--curr->m_mag_used];
+#if defined(HAVE_VALGRIND_MEMCHECK_H)
+ VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size);
+ if (cache->m_constructor != 0)
+ {
+ /* keep constructed object defined */
+ VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size);
+ }
+#endif /* HAVE_VALGRIND_MEMCHECK_H */
cache->m_cpu_stats.m_alloc += 1;
RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock));
@@ -1244,7 +1274,6 @@ SAL_CALL rtl_cache_alloc (
rtl_cache_slab_free (cache, obj), obj = 0;
}
}
-
return (obj);
}
@@ -1269,6 +1298,9 @@ SAL_CALL rtl_cache_free (
if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size))
{
curr->m_objects[curr->m_mag_used++] = obj;
+#if defined(HAVE_VALGRIND_MEMCHECK_H)
+ VALGRIND_MEMPOOL_FREE(cache, obj);
+#endif /* HAVE_VALGRIND_MEMCHECK_H */
cache->m_cpu_stats.m_free += 1;
RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock));
@@ -1582,6 +1614,7 @@ rtl_cache_once_init (void)
static rtl_cache_type g_cache_magazine_cache;
OSL_ASSERT(gp_cache_magazine_cache == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_cache_magazine_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_magazine_cache);
gp_cache_magazine_cache = rtl_cache_activate (
@@ -1606,6 +1639,7 @@ rtl_cache_once_init (void)
static rtl_cache_type g_cache_slab_cache;
OSL_ASSERT(gp_cache_slab_cache == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_cache_slab_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_slab_cache);
gp_cache_slab_cache = rtl_cache_activate (
@@ -1627,6 +1661,7 @@ rtl_cache_once_init (void)
static rtl_cache_type g_cache_bufctl_cache;
OSL_ASSERT(gp_cache_bufctl_cache == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_cache_bufctl_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_bufctl_cache);
gp_cache_bufctl_cache = rtl_cache_activate (
@@ -1657,7 +1692,18 @@ rtl_cache_init (void)
/* ================================================================= */
-#if defined(__GNUC__)
+/*
+ Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+
+ Mac OS X does not seem to support "__cxa__atexit", thus leading
+ to the situation that "__attribute__((destructor))__" functions
+ (in particular "rtl_{memory|cache|arena}_fini") become called
+ _before_ global C++ object d'tors.
+
+ Delegated the call to "rtl_cache_fini()" into a dummy C++ object,
+ see alloc_fini.cxx .
+*/
+#if defined(__GNUC__) && !defined(MACOSX)
static void rtl_cache_fini (void) __attribute__((destructor));
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#pragma fini(rtl_cache_fini)
@@ -1678,18 +1724,21 @@ rtl_cache_fini (void)
cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0;
rtl_cache_deactivate (cache);
rtl_cache_destructor (cache);
+ VALGRIND_DESTROY_MEMPOOL(cache);
}
if (gp_cache_slab_cache != 0)
{
cache = gp_cache_slab_cache, gp_cache_slab_cache = 0;
rtl_cache_deactivate (cache);
rtl_cache_destructor (cache);
+ VALGRIND_DESTROY_MEMPOOL(cache);
}
if (gp_cache_magazine_cache != 0)
{
cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0;
rtl_cache_deactivate (cache);
rtl_cache_destructor (cache);
+ VALGRIND_DESTROY_MEMPOOL(cache);
}
if (gp_cache_arena != 0)
{
diff --git a/sal/rtl/source/memory_fini.cxx b/sal/rtl/source/alloc_fini.cxx
index f88f09887595..cb04a525e75e 100755
--- a/sal/rtl/source/memory_fini.cxx
+++ b/sal/rtl/source/alloc_fini.cxx
@@ -25,30 +25,31 @@
*
************************************************************************/
-
/*
Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
Mac OS X does not seem to support "__cxa__atexit", thus leading
to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_memory_fini") become called _before_ global
- C++ object d'tors.
+ (in particular "rtl_{memory|cache|arena}_fini") become called
+ _before_ global C++ object d'tors.
Using a C++ dummy object instead.
*/
-#include <stdio.h>
-
extern "C" void rtl_memory_fini (void);
+extern "C" void rtl_cache_fini (void);
+extern "C" void rtl_arena_fini (void);
-
-struct RTL_Memory_Fini {
- ~RTL_Memory_Fini() ;
+struct RTL_Alloc_Fini
+{
+ ~RTL_Alloc_Fini() ;
};
-RTL_Memory_Fini::~RTL_Memory_Fini() {
+RTL_Alloc_Fini::~RTL_Alloc_Fini()
+{
rtl_memory_fini();
+ rtl_cache_fini();
+ rtl_arena_fini();
}
-
-static RTL_Memory_Fini rtl_Memory_Fini;
+static RTL_Alloc_Fini g_RTL_Alloc_Fini;
diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c
index 5137f868127d..5da66ca49d96 100644
--- a/sal/rtl/source/alloc_global.c
+++ b/sal/rtl/source/alloc_global.c
@@ -26,6 +26,7 @@
************************************************************************/
#include "rtl/alloc.h"
+#include "alloc_impl.h"
#ifndef INCLUDED_STRING_H
#include <string.h>
@@ -44,7 +45,6 @@
#include <stdio.h>
#define INCLUDED_STDIO_H
#endif
-#include "alloc_impl.h"
#include "internal/once.h"
#include "sal/macros.h"
#include "osl/diagnose.h"
@@ -151,11 +151,11 @@ rtl_memory_init (void)
Mac OS X does not seem to support "__cxa__atexit", thus leading
to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_memory_fini") become called _before_ global
- C++ object d'tors.
+ (in particular "rtl_{memory|cache|arena}_fini") become called
+ _before_ global C++ object d'tors.
- Delegated the call to "rtl_memory_fini" into a dummy C++ object,
- see memory_fini.cxx .
+ Delegated the call to "rtl_memory_fini()" into a dummy C++ object,
+ see alloc_fini.cxx .
*/
#if defined(__GNUC__) && !defined(MACOSX)
static void rtl_memory_fini (void) __attribute__((destructor));
diff --git a/sal/rtl/source/alloc_impl.h b/sal/rtl/source/alloc_impl.h
index d3d1924ddf91..a95b7c47465c 100644
--- a/sal/rtl/source/alloc_impl.h
+++ b/sal/rtl/source/alloc_impl.h
@@ -240,6 +240,30 @@ typedef CRITICAL_SECTION rtl_memory_lock_type;
#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */
+/** Valgrind support macros.
+ */
+#if !defined(HAVE_MEMCHECK_H) || (OSL_DEBUG_LEVEL == 0)
+#if !defined(NVALGRIND)
+#define NVALGRIND 1
+#endif /* ! NVALGRIND */
+#endif /* ! HAVE_MEMCHECK_H || (OSL_DEBUG_LEVEL == 0) */
+
+#if defined(NVALGRIND)
+#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
+#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
+#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)
+#define VALGRIND_FREELIKE_BLOCK(addr, rzB)
+#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)
+#define VALGRIND_DESTROY_MEMPOOL(pool)
+#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size)
+#define VALGRIND_MEMPOOL_FREE(pool, addr)
+#elif defined(HAVE_MEMCHECK_H)
+#include <memcheck.h>
+#if !defined(FORCE_SYSALLOC)
+#define FORCE_SYSALLOC 1
+#endif /* !FORCE_SYSALLOC */
+#endif /* NVALGRIND || HAVE_MEMCHECK_H */
+
#ifdef __cplusplus
}
#endif
diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk
index 9968d8992be4..145aa50b8be0 100644
--- a/sal/rtl/source/makefile.mk
+++ b/sal/rtl/source/makefile.mk
@@ -46,6 +46,11 @@ TARGETTYPE=CUI
.INCLUDE : settings.mk
+.IF "$(VALGRIND_CFLAGS)" != ""
+CFLAGS += $(VALGRIND_CFLAGS)
+CDEFS += -DHAVE_MEMCHECK_H=1
+.ENDIF # VALGRIND_CFLAGS
+
.IF "$(ALLOC)" == "SYS_ALLOC" || "$(ALLOC)" == "TCMALLOC" || "$(ALLOC)" == "JEMALLOC"
CDEFS+= -DFORCE_SYSALLOC
.ENDIF
@@ -96,7 +101,7 @@ SLOFILES= \
$(SLO)$/alloc_arena.obj
.IF "$(OS)"=="MACOSX"
-SLOFILES+=$(SLO)$/memory_fini.obj
+SLOFILES+=$(SLO)$/alloc_fini.obj
.ENDIF
@@ -129,7 +134,7 @@ OBJFILES= \
$(OBJ)$/alloc_arena.obj
.IF "$(OS)"=="MACOSX"
-OBJFILES+=$(OBJ)$/memory_fini.obj
+OBJFILES+=$(OBJ)$/alloc_fini.obj
.ENDIF
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index f1145a029c29..7e4ac7bcbb00 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -600,7 +600,8 @@ oslInterlockedCount SAL_CALL MappedLockBytes::release()
void MappedLockBytes::allocate_Impl (void ** ppPage, sal_uInt16 * pnSize)
{
OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation");
- *ppPage = 0, *pnSize = m_nPageSize;
+ if ((ppPage != 0) && (pnSize != 0))
+ *ppPage = 0, *pnSize = m_nPageSize;
}
void MappedLockBytes::deallocate_Impl (void * pPage)
diff --git a/store/source/lockbyte.hxx b/store/source/lockbyte.hxx
index ef34b8708f26..b2b6c905f9fd 100644
--- a/store/source/lockbyte.hxx
+++ b/store/source/lockbyte.hxx
@@ -26,7 +26,7 @@
************************************************************************/
#ifndef _STORE_LOCKBYTE_HXX_
-#define _STORE_LOCKBYTE_HXX_ "$Revision: 1.1.2.1 $"
+#define _STORE_LOCKBYTE_HXX_
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
diff --git a/store/source/object.hxx b/store/source/object.hxx
index 1061b9c568a9..a3b5ab1c6e63 100644
--- a/store/source/object.hxx
+++ b/store/source/object.hxx
@@ -26,7 +26,7 @@
************************************************************************/
#ifndef _STORE_OBJECT_HXX_
-#define _STORE_OBJECT_HXX_ "$Revision: 1.1.2.1 $"
+#define _STORE_OBJECT_HXX_
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
diff --git a/store/source/storbase.cxx b/store/source/storbase.cxx
index 6eb005e453d8..690bff8d258e 100644
--- a/store/source/storbase.cxx
+++ b/store/source/storbase.cxx
@@ -158,7 +158,8 @@ PageData::Allocator_Impl::~Allocator_Impl()
void PageData::Allocator_Impl::allocate_Impl (void ** ppPage, sal_uInt16 * pnSize)
{
OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation");
- *ppPage = rtl_cache_alloc(m_page_cache), *pnSize = m_page_size;
+ if ((ppPage != 0) && (pnSize != 0))
+ *ppPage = rtl_cache_alloc(m_page_cache), *pnSize = m_page_size;
}
void PageData::Allocator_Impl::deallocate_Impl (void * pPage)
diff --git a/store/source/stordir.hxx b/store/source/stordir.hxx
index 66dd14bd81a6..2e3d79e71319 100644
--- a/store/source/stordir.hxx
+++ b/store/source/stordir.hxx
@@ -26,7 +26,7 @@
************************************************************************/
#ifndef _STORE_STORDIR_HXX_
-#define _STORE_STORDIR_HXX_ "$Revision: 1.1.2.2 $"
+#define _STORE_STORDIR_HXX_
#ifndef _SAL_TYPES_H_
#include <sal/types.h>
diff --git a/unoil/climaker/version.txt b/unoil/climaker/version.txt
index 2678d1bc035b..f59c2f9482b4 100644..100755
--- a/unoil/climaker/version.txt
+++ b/unoil/climaker/version.txt
@@ -25,8 +25,8 @@
#
#*************************************************************************
-CLI_OOOTYPES_NEW_VERSION=1.0.7.0
-CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.6.0
-CLI_OOOTYPES_POLICY_VERSION=7.0.0.0
+CLI_OOOTYPES_NEW_VERSION=1.0.8.0
+CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.7.0
+CLI_OOOTYPES_POLICY_VERSION=8.0.0.0
CLI_OOOTYPES_POLICY_ASSEMBLY=policy.1.0.cli_oootypes