From 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:50 -0500 Subject: Second Life viewer sources 1.14.0.0 --- linden/indra/llxml/llcontrol.cpp | 75 +++++----- linden/indra/llxml/llcontrol.h | 6 +- linden/indra/llxml/llxml_vc8.vcproj | 276 ++++++++++++++++++++++++++++++++++++ linden/indra/llxml/llxmlnode.cpp | 34 ++--- linden/indra/llxml/llxmlnode.h | 1 + linden/indra/llxml/llxmlparser.cpp | 12 +- linden/indra/llxml/llxmlparser.h | 2 +- 7 files changed, 344 insertions(+), 62 deletions(-) create mode 100644 linden/indra/llxml/llxml_vc8.vcproj (limited to 'linden/indra/llxml') diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp index 79fd522..c365aed 100644 --- a/linden/indra/llxml/llcontrol.cpp +++ b/linden/indra/llxml/llcontrol.cpp @@ -132,7 +132,8 @@ void LLControlGroup::cleanup() LLControlBase* LLControlGroup::getControl(const LLString& name) { - return mNameTable[name]; + ctrl_name_table_t::iterator iter = mNameTable.find(name); + return iter == mNameTable.end() ? NULL : (LLControlBase*)iter->second; } BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, const LLSD initial_val, const LLString& comment, BOOL persist) @@ -143,9 +144,11 @@ BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, con LLControl* control = new LLControl(name, type, initial_val, comment, persist); mNameTable[name] = control; return TRUE; - } else + } + else { llwarns << "LLControlGroup::declareControl: Control named " << name << " already exists." << llendl; + mNameTable.erase(name); return FALSE; } } @@ -207,7 +210,7 @@ BOOL LLControlGroup::declareColor3(const LLString& name, const LLColor3 &initial LLSD LLControlGroup::registerListener(const LLString& name, LLSimpleListenerObservable *listener) { - LLControlBase *control = mNameTable[name]; + LLControlBase *control = getControl(name); if (control) { return control->registerListener(listener); @@ -217,7 +220,7 @@ LLSD LLControlGroup::registerListener(const LLString& name, LLSimpleListenerObse BOOL LLControlGroup::getBOOL(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_BOOLEAN)) return control->get().asBoolean(); @@ -230,7 +233,7 @@ BOOL LLControlGroup::getBOOL(const LLString& name) S32 LLControlGroup::getS32(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_S32)) return control->get().asInteger(); @@ -243,7 +246,7 @@ S32 LLControlGroup::getS32(const LLString& name) U32 LLControlGroup::getU32(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_U32)) return control->get().asInteger(); @@ -256,7 +259,7 @@ U32 LLControlGroup::getU32(const LLString& name) F32 LLControlGroup::getF32(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_F32)) return (F32) control->get().asReal(); @@ -269,7 +272,7 @@ F32 LLControlGroup::getF32(const LLString& name) LLString LLControlGroup::findString(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_STRING)) return control->get().asString(); @@ -278,7 +281,7 @@ LLString LLControlGroup::findString(const LLString& name) LLString LLControlGroup::getString(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_STRING)) return control->get().asString(); @@ -304,7 +307,7 @@ LLString LLControlGroup::getText(const LLString& name) LLVector3 LLControlGroup::getVector3(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_VEC3)) return control->get(); @@ -317,7 +320,7 @@ LLVector3 LLControlGroup::getVector3(const LLString& name) LLVector3d LLControlGroup::getVector3d(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_VEC3D)) return control->get(); @@ -330,7 +333,7 @@ LLVector3d LLControlGroup::getVector3d(const LLString& name) LLRect LLControlGroup::getRect(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_RECT)) return control->get(); @@ -376,7 +379,7 @@ LLColor4 LLControlGroup::getColor(const LLString& name) LLColor4U LLControlGroup::getColor4U(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL4U)) return control->get(); @@ -389,7 +392,7 @@ LLColor4U LLControlGroup::getColor4U(const LLString& name) LLColor4 LLControlGroup::getColor4(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL4)) return control->get(); @@ -402,7 +405,7 @@ LLColor4 LLControlGroup::getColor4(const LLString& name) LLColor3 LLControlGroup::getColor3(const LLString& name) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL3)) return control->get(); @@ -415,9 +418,8 @@ LLColor3 LLControlGroup::getColor3(const LLString& name) BOOL LLControlGroup::controlExists(const LLString& name) { - void *control = mNameTable[name]; - - return (control != 0); + ctrl_name_table_t::iterator iter = mNameTable.find(name); + return iter != mNameTable.end(); } //------------------------------------------------------------------- @@ -426,7 +428,7 @@ BOOL LLControlGroup::controlExists(const LLString& name) void LLControlGroup::setBOOL(const LLString& name, BOOL val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_BOOLEAN)) { @@ -441,7 +443,7 @@ void LLControlGroup::setBOOL(const LLString& name, BOOL val) void LLControlGroup::setS32(const LLString& name, S32 val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_S32)) { @@ -456,7 +458,7 @@ void LLControlGroup::setS32(const LLString& name, S32 val) void LLControlGroup::setF32(const LLString& name, F32 val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_F32)) { @@ -471,7 +473,7 @@ void LLControlGroup::setF32(const LLString& name, F32 val) void LLControlGroup::setU32(const LLString& name, U32 val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_U32)) { @@ -486,7 +488,7 @@ void LLControlGroup::setU32(const LLString& name, U32 val) void LLControlGroup::setString(const LLString& name, const LLString &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_STRING)) { @@ -501,7 +503,7 @@ void LLControlGroup::setString(const LLString& name, const LLString &val) void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_VEC3)) { @@ -515,7 +517,7 @@ void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_VEC3D)) { @@ -529,7 +531,7 @@ void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) void LLControlGroup::setRect(const LLString& name, const LLRect &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_RECT)) { @@ -543,7 +545,7 @@ void LLControlGroup::setRect(const LLString& name, const LLRect &val) void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL4U)) { @@ -557,7 +559,7 @@ void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) { - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL4)) { @@ -576,7 +578,7 @@ void LLControlGroup::setValue(const LLString& name, const LLSD& val) return; } - LLControlBase* control = mNameTable[name]; + LLControlBase* control = getControl(name); if (control) { @@ -599,7 +601,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de llifstream file; S32 version; - file.open(filename.c_str()); + file.open(filename.c_str()); /*Flawfinder: ignore*/ if (!file) { @@ -629,7 +631,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de if (name.substr(0,2) == "//") { // This is a comment. - char buffer[MAX_STRING]; + char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); continue; } @@ -643,7 +645,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de if (!name.empty()) { //read in to end of line - char buffer[MAX_STRING]; + char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } @@ -709,7 +711,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de break; case TYPE_BOOLEAN: { - char boolstring[256]; + char boolstring[256]; /*Flawfinder: ignore*/ BOOL valid = FALSE; BOOL initial = FALSE; @@ -858,7 +860,7 @@ U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declarat { name = child_nodep->getName(); - BOOL declared = (mNameTable[name].notNull()); + BOOL declared = controlExists(name); if (require_declaration && !declared) { @@ -1045,8 +1047,7 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) break; } - LLControlBase* control = (LLControlBase *)mNameTable[name]; - + LLControlBase* control = (LLControlBase *)iter->second; if (!control) { llwarns << "Tried to save invalid control: " << name << llendl; @@ -1067,7 +1068,7 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) } llofstream file; - file.open(filename.c_str()); + file.open(filename.c_str()); /*Flawfinder: ignore*/ if (!file.is_open()) { diff --git a/linden/indra/llxml/llcontrol.h b/linden/indra/llxml/llcontrol.h index 846a3b5..ca5f711 100644 --- a/linden/indra/llxml/llcontrol.h +++ b/linden/indra/llxml/llcontrol.h @@ -67,6 +67,7 @@ protected: BOOL mHasRange; BOOL mPersist; BOOL mIsDefault; + static std::set mChangedControls; static std::list mFreeIDs;//These lists are used to store the ID's of registered event listeners. static std::list mUsedIDs; @@ -171,7 +172,10 @@ public: } } - /*virtual*/ void resetToDefault() { mCurrent = mDefault; mIsDefault = TRUE;} + /*virtual*/ void resetToDefault() + { + setValue(mDefault); + } virtual ~LLControl() { diff --git a/linden/indra/llxml/llxml_vc8.vcproj b/linden/indra/llxml/llxml_vc8.vcproj new file mode 100644 index 0000000..0b2a2b1 --- /dev/null +++ b/linden/indra/llxml/llxml_vc8.vcproj @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp index 6366519..50a08be 100644 --- a/linden/indra/llxml/llxmlnode.cpp +++ b/linden/indra/llxml/llxmlnode.cpp @@ -561,7 +561,7 @@ bool LLXMLNode::parseFile( LLXMLNode* defaults_tree) { // Read file - FILE* fp = LLFile::fopen(filename.c_str(), "rb"); + FILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ if (fp == NULL) { node = new LLXMLNode(); @@ -1865,12 +1865,12 @@ U32 LLXMLNode::getUUIDValue(U32 expected_length, LLUUID *array) LLUUID uuid_value; value_string = skipWhitespace(value_string); - if (strlen(value_string) < (UUID_STR_LENGTH-1)) + if (strlen(value_string) < (UUID_STR_LENGTH-1)) /* Flawfinder: ignore */ { break; } - char uuid_string[UUID_STR_LENGTH]; - memcpy(uuid_string, value_string, (UUID_STR_LENGTH-1)); + char uuid_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + memcpy(uuid_string, value_string, (UUID_STR_LENGTH-1)); /* Flawfinder: ignore */ uuid_string[(UUID_STR_LENGTH-1)] = 0; if (!LLUUID::parseUUID(uuid_string, &uuid_value)) @@ -2155,18 +2155,18 @@ void LLXMLNode::setFloatValue(U32 length, const F32 *array, Encoding encoding, U LLString new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { - char format_string[10]; + char format_string[10]; /* Flawfinder: ignore */ if (precision > 0) { if (precision > 25) { precision = 25; } - sprintf(format_string, "%%.%dg", precision); + snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ } else { - sprintf(format_string, "%%g"); + snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ } for (U32 pos=0; pos 0) { if (precision > 25) { precision = 25; } - sprintf(format_string, "%%.%dg", precision); + snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ } else { - sprintf(format_string, "%%g"); + snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ } for (U32 pos=0; posmName->mString; - for (U32 pos=0; posmLength; ++pos) { const char *node_name = node_array[pos]->mName->mString; - for (U32 pos2=0; pos2mString, node_uuid_checksum.getString().c_str(), uuid_checksum.getString().c_str())); + error_buffer.append(llformat("ERROR Node %s: UUID checksum mismatch: read %s / calc %s.\n", mName->mString, node_uuid_checksum.asString().c_str(), uuid_checksum.asString().c_str())); return FALSE; } } diff --git a/linden/indra/llxml/llxmlnode.h b/linden/indra/llxml/llxmlnode.h index 6ecd9ce..bfe0fbe 100644 --- a/linden/indra/llxml/llxmlnode.h +++ b/linden/indra/llxml/llxmlnode.h @@ -34,6 +34,7 @@ #include "indra_constants.h" #include "llmemory.h" +#include "llthread.h" #include "llstring.h" #include "llstringtable.h" diff --git a/linden/indra/llxml/llxmlparser.cpp b/linden/indra/llxml/llxmlparser.cpp index 57e6a30..056d850 100644 --- a/linden/indra/llxml/llxmlparser.cpp +++ b/linden/indra/llxml/llxmlparser.cpp @@ -41,7 +41,7 @@ LLXmlParser::LLXmlParser() mParser( NULL ), mDepth( 0 ) { - strcpy( mAuxErrorString, "no error" ); + strcpy( mAuxErrorString, "no error" ); /* Flawfinder: ignore */ // Override the document's declared encoding. mParser = XML_ParserCreate(NULL); @@ -73,10 +73,10 @@ BOOL LLXmlParser::parseFile(const std::string &path) BOOL success = TRUE; - FILE *file = LLFile::fopen(path.c_str(), "rb"); + FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ if( !file ) { - sprintf( mAuxErrorString, "Couldn't open file %s", path.c_str()); + snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Couldn't open file %s", path.c_str()); /* Flawfinder: ignore */ success = FALSE; } else @@ -90,7 +90,7 @@ BOOL LLXmlParser::parseFile(const std::string &path) void* buffer = XML_GetBuffer(mParser, buffer_size); if( !buffer ) { - sprintf( mAuxErrorString, "Unable to allocate XML buffer while reading file %s", path.c_str() ); + snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Unable to allocate XML buffer while reading file %s", path.c_str() ); /* Flawfinder: ignore */ success = FALSE; goto exit_label; } @@ -98,14 +98,14 @@ BOOL LLXmlParser::parseFile(const std::string &path) bytes_read = (S32)fread(buffer, 1, buffer_size, file); if( bytes_read <= 0 ) { - sprintf( mAuxErrorString, "Error while reading file %s", path.c_str() ); + snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Error while reading file %s", path.c_str() ); /* Flawfinder: ignore */ success = FALSE; goto exit_label; } if( !XML_ParseBuffer(mParser, bytes_read, TRUE ) ) { - sprintf( mAuxErrorString, "Error while parsing file %s", path.c_str() ); + snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Error while parsing file %s", path.c_str() ); /* Flawfinder: ignore */ success = FALSE; } diff --git a/linden/indra/llxml/llxmlparser.h b/linden/indra/llxml/llxmlparser.h index 27c137a..e1bd2e2 100644 --- a/linden/indra/llxml/llxmlparser.h +++ b/linden/indra/llxml/llxmlparser.h @@ -122,7 +122,7 @@ public: protected: XML_Parser mParser; int mDepth; - char mAuxErrorString[1024]; + char mAuxErrorString[1024]; /*Flawfinder: ignore*/ }; #endif // LL_LLXMLPARSER_H -- cgit v1.1