summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapp.cpp72
-rw-r--r--indra/llcommon/llapp.h16
-rw-r--r--indra/llcommon/llevents.cpp7
-rw-r--r--indra/llcommon/llinitparam.cpp7
-rw-r--r--indra/llcommon/llmetricperformancetester.cpp14
-rw-r--r--indra/llcommon/llmetricperformancetester.h10
-rw-r--r--indra/llcommon/llsdserialize.cpp42
-rw-r--r--indra/llcommon/llstring.h4
-rw-r--r--indra/llcommon/llsys.h5
9 files changed, 149 insertions, 28 deletions
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index 2c76f29020..6cc9e804d4 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -256,6 +256,70 @@ bool LLApp::parseCommandOptions(int argc, char** argv)
return true;
}
+bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
+{
+ LLSD commands;
+ std::string name;
+ std::string value;
+ for(int ii = 1; ii < argc; ++ii)
+ {
+ if(wargv[ii][0] != '-')
+ {
+ LL_INFOS() << "Did not find option identifier while parsing token: "
+ << wargv[ii] << LL_ENDL;
+ return false;
+ }
+ int offset = 1;
+ if(wargv[ii][1] == '-') ++offset;
+
+#if LL_WINDOWS
+ name.assign(utf16str_to_utf8str(&wargv[ii][offset]));
+#else
+ name.assign(wstring_to_utf8str(&wargv[ii][offset]));
+#endif
+ if(((ii+1) >= argc) || (wargv[ii+1][0] == '-'))
+ {
+ // we found another option after this one or we have
+ // reached the end. simply record that this option was
+ // found and continue.
+ int flag = name.compare("logfile");
+ if (0 == flag)
+ {
+ commands[name] = "log";
+ }
+ else
+ {
+ commands[name] = true;
+ }
+
+ continue;
+ }
+ ++ii;
+
+#if LL_WINDOWS
+ value.assign(utf16str_to_utf8str((wargv[ii])));
+#else
+ value.assign(wstring_to_utf8str((wargv[ii])));
+#endif
+
+#if LL_WINDOWS
+ //Windows changed command line parsing. Deal with it.
+ S32 slen = value.length() - 1;
+ S32 start = 0;
+ S32 end = slen;
+ if (wargv[ii][start]=='"')start++;
+ if (wargv[ii][end]=='"')end--;
+ if (start!=0 || end!=slen)
+ {
+ value = value.substr (start,end);
+ }
+#endif
+
+ commands[name] = value;
+ }
+ setOptionData(PRIORITY_COMMAND_LINE, commands);
+ return true;
+}
void LLApp::manageLiveFile(LLLiveFile* livefile)
{
@@ -354,7 +418,7 @@ void LLApp::setupErrorHandling(bool second_instance)
std::wstring wpipe_name;
wpipe_name = mCrashReportPipeStr + wstringize(getPid());
- const std::wstring wdump_path(wstringize(mDumpPath));
+ const std::wstring wdump_path(utf8str_to_utf16str(mDumpPath));
int retries = 30;
for (; retries > 0; --retries)
@@ -515,9 +579,9 @@ void LLApp::setMiniDumpDir(const std::string &path)
if(mExceptionHandler == 0) return;
#ifdef LL_WINDOWS
- wchar_t buffer[MAX_MINDUMP_PATH_LENGTH];
- mbstowcs(buffer, mDumpPath.c_str(), MAX_MINDUMP_PATH_LENGTH);
- mExceptionHandler->set_dump_path(std::wstring(buffer));
+ std::wstring buffer(utf8str_to_utf16str(mDumpPath));
+ if (buffer.size() > MAX_MINDUMP_PATH_LENGTH) buffer.resize(MAX_MINDUMP_PATH_LENGTH);
+ mExceptionHandler->set_dump_path(buffer);
#elif LL_LINUX
//google_breakpad::MinidumpDescriptor desc("/tmp"); //path works in debug fails in production inside breakpad lib so linux gets a little less stack reporting until it is patched.
google_breakpad::MinidumpDescriptor desc(mDumpPath); //path works in debug fails in production inside breakpad lib so linux gets a little less stack reporting until it is patched.
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index ff9a92b45f..acd829d864 100644
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -106,7 +106,7 @@ public:
LLSD getOption(const std::string& name) const;
/**
- * @brief Parse command line options and insert them into
+ * @brief Parse ASCII command line options and insert them into
* application command line options.
*
* The name inserted into the option will have leading option
@@ -119,6 +119,20 @@ public:
*/
bool parseCommandOptions(int argc, char** argv);
+ /**
+ * @brief Parse Unicode command line options and insert them into
+ * application command line options.
+ *
+ * The name inserted into the option will have leading option
+ * identifiers (a minus or double minus) stripped. All options
+ * with values will be stored as a string, while all options
+ * without values will be stored as true.
+ * @param argc The argc passed into main().
+ * @param wargv The wargv passed into main().
+ * @return Returns true if the parse succeeded.
+ */
+ bool parseCommandOptions(int argc, wchar_t** wargv);
+
/**
* @brief Keep track of live files automatically.
*
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp
index 97270e4931..93db6c0d17 100644
--- a/indra/llcommon/llevents.cpp
+++ b/indra/llcommon/llevents.cpp
@@ -316,6 +316,13 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
const NameList& after,
const NameList& before)
{
+ if (!mSignal)
+ {
+ LL_WARNS() << "Can't connect listener" << LL_ENDL;
+ // connect will fail, return dummy
+ return LLBoundListener();
+ }
+
float nodePosition = 1.0;
// if the supplied name is empty we are not interested in the ordering mechanism
diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp
index 1d104cf55d..aa2f4eb289 100644
--- a/indra/llcommon/llinitparam.cpp
+++ b/indra/llcommon/llinitparam.cpp
@@ -193,12 +193,7 @@ namespace LLInitParam
{
if (!silent)
{
- std::string file_name = p.getCurrentFileName();
- if(!file_name.empty())
- {
- file_name = "in file: " + file_name;
- }
- p.parserWarning(llformat("Failed to parse parameter \"%s\" %s", p.getCurrentElementName().c_str(), file_name.c_str()));
+ p.parserWarning(llformat("Failed to parse parameter \"%s\"", p.getCurrentElementName().c_str()));
}
return false;
}
diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp
index 16fc365da1..f8a93baf45 100644
--- a/indra/llcommon/llmetricperformancetester.cpp
+++ b/indra/llcommon/llmetricperformancetester.cpp
@@ -132,8 +132,8 @@ void LLMetricPerformanceTesterBasic::doAnalysisMetrics(std::string baseline, std
}
// Open baseline and current target, exit if one is inexistent
- std::ifstream base_is(baseline.c_str());
- std::ifstream target_is(target.c_str());
+ llifstream base_is(baseline.c_str());
+ llifstream target_is(target.c_str());
if (!base_is.is_open() || !target_is.is_open())
{
LL_WARNS() << "'-analyzeperformance' error : baseline or current target file inexistent" << LL_ENDL;
@@ -151,7 +151,7 @@ void LLMetricPerformanceTesterBasic::doAnalysisMetrics(std::string baseline, std
target_is.close();
//output comparision
- std::ofstream os(output.c_str());
+ llofstream os(output.c_str());
os << "Label, Metric, Base(B), Target(T), Diff(T-B), Percentage(100*T/B)\n";
for(LLMetricPerformanceTesterBasic::name_tester_map_t::iterator iter = LLMetricPerformanceTesterBasic::sTesterMap.begin() ;
@@ -212,7 +212,7 @@ void LLMetricPerformanceTesterBasic::addMetric(std::string str)
}
/*virtual*/
-void LLMetricPerformanceTesterBasic::analyzePerformance(std::ofstream* os, LLSD* base, LLSD* current)
+void LLMetricPerformanceTesterBasic::analyzePerformance(llofstream* os, LLSD* base, LLSD* current)
{
resetCurrentCount() ;
@@ -254,14 +254,14 @@ void LLMetricPerformanceTesterBasic::analyzePerformance(std::ofstream* os, LLSD*
}
/*virtual*/
-void LLMetricPerformanceTesterBasic::compareTestResults(std::ofstream* os, std::string metric_string, S32 v_base, S32 v_current)
+void LLMetricPerformanceTesterBasic::compareTestResults(llofstream* os, std::string metric_string, S32 v_base, S32 v_current)
{
*os << llformat(" ,%s, %d, %d, %d, %.4f\n", metric_string.c_str(), v_base, v_current,
v_current - v_base, (v_base != 0) ? 100.f * v_current / v_base : 0) ;
}
/*virtual*/
-void LLMetricPerformanceTesterBasic::compareTestResults(std::ofstream* os, std::string metric_string, F32 v_base, F32 v_current)
+void LLMetricPerformanceTesterBasic::compareTestResults(llofstream* os, std::string metric_string, F32 v_base, F32 v_current)
{
*os << llformat(" ,%s, %.4f, %.4f, %.4f, %.4f\n", metric_string.c_str(), v_base, v_current,
v_current - v_base, (fabs(v_base) > 0.0001f) ? 100.f * v_current / v_base : 0.f ) ;
@@ -293,7 +293,7 @@ LLMetricPerformanceTesterWithSession::~LLMetricPerformanceTesterWithSession()
}
/*virtual*/
-void LLMetricPerformanceTesterWithSession::analyzePerformance(std::ofstream* os, LLSD* base, LLSD* current)
+void LLMetricPerformanceTesterWithSession::analyzePerformance(llofstream* os, LLSD* base, LLSD* current)
{
// Load the base session
resetCurrentCount() ;
diff --git a/indra/llcommon/llmetricperformancetester.h b/indra/llcommon/llmetricperformancetester.h
index e6b46be1cf..2e99ed979d 100644
--- a/indra/llcommon/llmetricperformancetester.h
+++ b/indra/llcommon/llmetricperformancetester.h
@@ -60,7 +60,7 @@ public:
* By default, compares the test results against the baseline one by one, item by item,
* in the increasing order of the LLSD record counter, starting from the first one.
*/
- virtual void analyzePerformance(std::ofstream* os, LLSD* base, LLSD* current) ;
+ virtual void analyzePerformance(llofstream* os, LLSD* base, LLSD* current) ;
static void doAnalysisMetrics(std::string baseline, std::string target, std::string output) ;
@@ -93,8 +93,8 @@ protected:
* @param[in] v_base - Base value of the metric.
* @param[in] v_current - Current value of the metric.
*/
- virtual void compareTestResults(std::ofstream* os, std::string metric_string, S32 v_base, S32 v_current) ;
- virtual void compareTestResults(std::ofstream* os, std::string metric_string, F32 v_base, F32 v_current) ;
+ virtual void compareTestResults(llofstream* os, std::string metric_string, S32 v_base, S32 v_current) ;
+ virtual void compareTestResults(llofstream* os, std::string metric_string, F32 v_base, F32 v_current) ;
/**
* @brief Reset internal record count. Count starts with 1.
@@ -181,7 +181,7 @@ public:
* This will be loading the base and current sessions and compare them using the virtual
* abstract methods loadTestSession() and compareTestSessions()
*/
- virtual void analyzePerformance(std::ofstream* os, LLSD* base, LLSD* current) ;
+ virtual void analyzePerformance(llofstream* os, LLSD* base, LLSD* current) ;
protected:
/**
@@ -205,7 +205,7 @@ protected:
* @brief Compare the base session and the target session. Assumes base and current sessions have been loaded.
* @param[out] os - The comparison result as a standard stream
*/
- virtual void compareTestSessions(std::ofstream* os) = 0;
+ virtual void compareTestSessions(llofstream* os) = 0;
LLTestSession* mBaseSessionp;
LLTestSession* mCurrentSessionp;
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 81ba8631c6..3a219eb998 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -2091,7 +2091,18 @@ std::string zip_llsd(LLSD& data)
}
have = CHUNK-strm.avail_out;
- output = (U8*) realloc(output, cur_size+have);
+ U8* new_output = (U8*) realloc(output, cur_size+have);
+ if (new_output == NULL)
+ {
+ LL_WARNS() << "Failed to compress LLSD block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL;
+ deflateEnd(&strm);
+ if (output)
+ {
+ free(output);
+ }
+ return std::string();
+ }
+ output = new_output;
memcpy(output+cur_size, out, have);
cur_size += have;
}
@@ -2174,7 +2185,19 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
U32 have = CHUNK-strm.avail_out;
- result = (U8*) realloc(result, cur_size + have);
+ U8* new_result = (U8*)realloc(result, cur_size + have);
+ if (new_result == NULL)
+ {
+ LL_WARNS() << "Failed to unzip LLSD block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL;
+ inflateEnd(&strm);
+ if (result)
+ {
+ free(result);
+ }
+ delete[] in;
+ return false;
+ }
+ result = new_result;
memcpy(result+cur_size, out, have);
cur_size += have;
@@ -2266,7 +2289,20 @@ U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize, std::istream& is, S32
U32 have = CHUNK-strm.avail_out;
- result = (U8*) realloc(result, cur_size + have);
+ U8* new_result = (U8*) realloc(result, cur_size + have);
+ if (new_result == NULL)
+ {
+ LL_WARNS() << "Failed to unzip LLSD NavMesh block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL;
+ inflateEnd(&strm);
+ if (result)
+ {
+ free(result);
+ }
+ delete[] in;
+ valid = false;
+ return NULL;
+ }
+ result = new_result;
memcpy(result+cur_size, out, have);
cur_size += have;
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 2255e638c2..abe5fda603 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -1325,6 +1325,10 @@ void LLStringUtilBase<T>::removeCRLF(string_type& string)
template<class T>
void LLStringUtilBase<T>::removeWindowsCR(string_type& string)
{
+ if (string.empty())
+ {
+ return;
+ }
const T LF = 10;
const T CR = 13;
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 962367f69f..294d0066ca 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -37,13 +37,14 @@
//
#include "llsd.h"
+#include "llsingleton.h"
#include <iosfwd>
#include <string>
-class LL_COMMON_API LLOSInfo
+class LL_COMMON_API LLOSInfo : public LLSingleton<LLOSInfo>
{
+ LLSINGLETON(LLOSInfo);
public:
- LLOSInfo();
void stream(std::ostream& s) const;
const std::string& getOSString() const;