From a947a68256949120cc3cdf2601b82fdc5efc390e Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 2 Apr 2016 13:09:24 +0300 Subject: [PATCH] Fixed excpetion throwing in INI document to that generated corrupted messages because snprintf was used instead of vsnprintf. Revised most of the INI plugin and cleaned code. --- modules/ini/Common.cpp | 34 +++++++++++++++---- modules/ini/Common.hpp | 22 +++++++++++-- modules/ini/Document.cpp | 67 ++++++++++++++++++++------------------ modules/ini/Document.hpp | 27 +++++++--------- modules/ini/Entries.cpp | 34 ++++++++++++++++--- modules/ini/Entries.hpp | 18 ++++++++--- modules/ini/Module.cpp | 70 +++++++++++++++++++++++----------------- modules/irc/Common.cpp | 2 +- modules/irc/Module.cpp | 2 +- 9 files changed, 180 insertions(+), 96 deletions(-) diff --git a/modules/ini/Common.cpp b/modules/ini/Common.cpp index 43d5c857..9e8cb3cf 100644 --- a/modules/ini/Common.cpp +++ b/modules/ini/Common.cpp @@ -3,7 +3,8 @@ #include "Module.hpp" // ------------------------------------------------------------------------------------------------ -#include +#include +#include // ------------------------------------------------------------------------------------------------ #include @@ -33,8 +34,10 @@ void SqThrowF(CSStr str, ...) va_list args; va_start (args, str); // Write the requested contents - if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0) - strcpy(g_Buffer, "Unknown error has occurred"); + if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0) + { + std::strcpy(g_Buffer, "Unknown error has occurred"); + } // Release the argument list va_end(args); // Throw the exception with the resulted message @@ -48,17 +51,26 @@ CSStr FmtStr(CSStr str, ...) va_list args; va_start (args, str); // Write the requested contents - if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0) - g_Buffer[0] = 0; /* make sure the string is terminated */ + if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0) + { + g_Buffer[0] = 0; // Make sure the string is terminated + } // Release the argument list va_end(args); // Return the data from the buffer return g_Buffer; } +// ------------------------------------------------------------------------------------------------ +StackGuard::StackGuard() + : m_VM(_SqVM), m_Top(sq_gettop(m_VM)) +{ + /* ... */ +} + // ------------------------------------------------------------------------------------------------ StackGuard::StackGuard(HSQUIRRELVM vm) - : m_Top(sq_gettop(vm)), m_VM(vm) + : m_VM(vm), m_Top(sq_gettop(vm)) { /* ... */ } @@ -69,6 +81,16 @@ StackGuard::~StackGuard() sq_pop(m_VM, sq_gettop(m_VM) - m_Top); } +// ------------------------------------------------------------------------------------------------ +void DocumentRef::Validate() const +{ + // Is the document handle valid? + if (!m_Ptr) + { + STHROWF("Invalid INI document reference"); + } +} + // ------------------------------------------------------------------------------------------------ SQInteger IniResult::Typename(HSQUIRRELVM vm) { diff --git a/modules/ini/Common.hpp b/modules/ini/Common.hpp index fb6cedba..11178efa 100644 --- a/modules/ini/Common.hpp +++ b/modules/ini/Common.hpp @@ -57,6 +57,11 @@ CSStr FmtStr(CSStr str, ...); */ struct StackGuard { + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + StackGuard(); + /* -------------------------------------------------------------------------------------------- * Base constructor. */ @@ -92,8 +97,8 @@ private: private: // -------------------------------------------------------------------------------------------- - Int32 m_Top; /* The top of the stack when this instance was created. */ - HSQUIRRELVM m_VM; /* The VM where the stack should be restored. */ + HSQUIRRELVM m_VM; // The VM where the stack should be restored. + Int32 m_Top; // The top of the stack when this instance was created. }; /* ------------------------------------------------------------------------------------------------ @@ -120,6 +125,11 @@ public: // -------------------------------------------------------------------------------------------- typedef unsigned int Counter; // Reference counter type. + /* -------------------------------------------------------------------------------------------- + * Validate the document reference and throw an error if invalid. + */ + void Validate() const; + private: // -------------------------------------------------------------------------------------------- @@ -132,7 +142,9 @@ private: void Grab() { if (m_Ptr) + { ++(*m_Ref); + } } /* -------------------------------------------------------------------------------------------- @@ -420,11 +432,17 @@ public: Int32 Cmp(const IniResult & o) const { if (m_Result == o.m_Result) + { return 0; + } else if (m_Result > o.m_Result) + { return 1; + } else + { return -1; + } } /* -------------------------------------------------------------------------------------------- diff --git a/modules/ini/Document.cpp b/modules/ini/Document.cpp index 8c76eeef..dd4b0055 100644 --- a/modules/ini/Document.cpp +++ b/modules/ini/Document.cpp @@ -20,30 +20,28 @@ SQInteger Document::Typename(HSQUIRRELVM vm) return 1; } -// ------------------------------------------------------------------------------------------------ -void Document::Validate() const -{ - // Is the document handle valid? - if (!m_Doc) - STHROWF("Invalid INI document reference"); -} - // ------------------------------------------------------------------------------------------------ Int32 Document::Cmp(const Document & o) const { if (m_Doc == o.m_Doc) + { return 0; + } else if (m_Doc.m_Ptr > o.m_Doc.m_Ptr) + { return 1; + } else + { return -1; + } } // ------------------------------------------------------------------------------------------------ IniResult Document::LoadFile(CSStr filepath) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to load the file from disk and return the result return IniResult("load INI file", m_Doc->LoadFile(filepath)); } @@ -52,7 +50,7 @@ IniResult Document::LoadFile(CSStr filepath) IniResult Document::LoadData(CSStr source, Int32 size) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to load the file from memory and return the result return IniResult("load INI file", m_Doc->LoadData(source, size < 0 ? strlen(source) : size)); } @@ -61,7 +59,7 @@ IniResult Document::LoadData(CSStr source, Int32 size) IniResult Document::SaveFile(CSStr filepath, bool signature) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to save the file to disk and return the result return IniResult("save INI file", m_Doc->SaveFile(filepath, signature)); } @@ -70,12 +68,14 @@ IniResult Document::SaveFile(CSStr filepath, bool signature) Object Document::SaveData(bool signature) { // Validate the handle - Validate(); + m_Doc.Validate(); // The string where the content will be saved String source; // Attempt to save the data to string if (m_Doc->Save(source, signature) < 0) + { STHROWF("Unable to save INI document"); + } // Obtain the initial stack size const StackGuard sg(_SqVM); // Transform it into a script object @@ -88,7 +88,7 @@ Object Document::SaveData(bool signature) Entries Document::GetAllSections() const { // Validate the handle - Validate(); + m_Doc.Validate(); // Prepare a container to receive the entries static Container entries; // Obtain all sections from the INI document @@ -101,7 +101,7 @@ Entries Document::GetAllSections() const Entries Document::GetAllKeys(CSStr section) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Prepare a container to receive the entries static Container entries; // Obtain all sections from the INI document @@ -114,7 +114,7 @@ Entries Document::GetAllKeys(CSStr section) const Entries Document::GetAllValues(CSStr section, CSStr key) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Prepare a container to receive the entries static Container entries; // Obtain all sections from the INI document @@ -127,7 +127,7 @@ Entries Document::GetAllValues(CSStr section, CSStr key) const Int32 Document::GetSectionSize(CSStr section) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Return the requested information return m_Doc->GetSectionSize(section); } @@ -136,12 +136,15 @@ Int32 Document::GetSectionSize(CSStr section) const bool Document::HasMultipleKeys(CSStr section, CSStr key) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Where to retrive whether the key has multiple instances bool multiple = false; // Attempt to query the information - if (m_Doc->GetValue(section, key, NULL, &multiple) == NULL) - return true; /* Doesn't exist */ + if (m_Doc->GetValue(section, key, nullptr, &multiple) == nullptr) + { + return true; // Doesn't exist + } + // Return the result return multiple; } @@ -149,43 +152,43 @@ bool Document::HasMultipleKeys(CSStr section, CSStr key) const CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to query the information and return it - return m_Doc->GetValue(section, key, def, NULL); + return m_Doc->GetValue(section, key, def, nullptr); } // ------------------------------------------------------------------------------------------------ SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to query the information and return it - return (SQInteger)m_Doc->GetLongValue(section, key, def, NULL); + return static_cast< SQInteger >(m_Doc->GetLongValue(section, key, def, nullptr)); } // ------------------------------------------------------------------------------------------------ SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to query the information and return it - return (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL); + return static_cast< SQFloat >(m_Doc->GetDoubleValue(section, key, def, nullptr)); } // ------------------------------------------------------------------------------------------------ bool Document::GetBoolean(CSStr section, CSStr key, bool def) const { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to query the information and return it - return m_Doc->GetBoolValue(section, key, def, NULL); + return m_Doc->GetBoolValue(section, key, def, nullptr); } // ------------------------------------------------------------------------------------------------ IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to apply the specified information and return the result return IniResult("set INI value", m_Doc->SetValue(section, key, value, comment, force)); } @@ -194,7 +197,7 @@ IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to apply the specified information and return the result return IniResult("set INI integer", m_Doc->SetLongValue(section, key, value, comment, hex, force)); } @@ -203,7 +206,7 @@ IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool h IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to apply the specified information and return the result return IniResult("set INI float", m_Doc->SetDoubleValue(section, key, value, comment, force)); } @@ -212,7 +215,7 @@ IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to apply the specified information return IniResult("set INI boolean", m_Doc->SetBoolValue(section, key, value, comment, force)); } @@ -221,7 +224,7 @@ IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty) { // Validate the handle - Validate(); + m_Doc.Validate(); // Attempt to remove the specified value and return the result return m_Doc->DeleteValue(section, key, value, empty); } diff --git a/modules/ini/Document.hpp b/modules/ini/Document.hpp index b49e40ab..19b5d30a 100644 --- a/modules/ini/Document.hpp +++ b/modules/ini/Document.hpp @@ -27,11 +27,6 @@ protected: */ Document & operator = (const Document & o); - /* -------------------------------------------------------------------------------------------- - * Validate the document reference and throw an error if invalid. - */ - void Validate() const; - private: // --------------------------------------------------------------------------------------------- @@ -283,7 +278,7 @@ public: */ IniResult SetValue(CSStr section, CSStr key, CSStr value) { - return SetValue(section, key, value, false, NULL); + return SetValue(section, key, value, false, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -291,7 +286,7 @@ public: */ IniResult SetValue(CSStr section, CSStr key, CSStr value, bool force) { - return SetValue(section, key, value, force, NULL); + return SetValue(section, key, value, force, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -304,7 +299,7 @@ public: */ IniResult SetInteger(CSStr section, CSStr key, SQInteger value) { - return SetInteger(section, key, value, false, false, NULL); + return SetInteger(section, key, value, false, false, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -312,7 +307,7 @@ public: */ IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex) { - return SetInteger(section, key, value, hex, false, NULL); + return SetInteger(section, key, value, hex, false, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -320,7 +315,7 @@ public: */ IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force) { - return SetInteger(section, key, value, hex, force, NULL); + return SetInteger(section, key, value, hex, force, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -333,7 +328,7 @@ public: */ IniResult SetFloat(CSStr section, CSStr key, SQFloat value) { - return SetFloat(section, key, value, false, NULL); + return SetFloat(section, key, value, false, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -341,7 +336,7 @@ public: */ IniResult SetFloat(CSStr section, CSStr key, SQFloat value, bool force) { - return SetFloat(section, key, value, force, NULL); + return SetFloat(section, key, value, force, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -354,7 +349,7 @@ public: */ IniResult SetBoolean(CSStr section, CSStr key, bool value) { - return SetBoolean(section, key, value, false, NULL); + return SetBoolean(section, key, value, false, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -362,7 +357,7 @@ public: */ IniResult SetBoolean(CSStr section, CSStr key, bool value, bool force) { - return SetBoolean(section, key, value, force, NULL); + return SetBoolean(section, key, value, force, nullptr); } /* -------------------------------------------------------------------------------------------- @@ -375,7 +370,7 @@ public: */ bool DeleteValue(CSStr section) { - return DeleteValue(section, NULL, NULL, false); + return DeleteValue(section, nullptr, nullptr, false); } /* -------------------------------------------------------------------------------------------- @@ -383,7 +378,7 @@ public: */ bool DeleteValue(CSStr section, CSStr key) { - return DeleteValue(section, key, NULL, false); + return DeleteValue(section, key, nullptr, false); } /* -------------------------------------------------------------------------------------------- diff --git a/modules/ini/Entries.cpp b/modules/ini/Entries.cpp index ec5ecf55..815a7b10 100644 --- a/modules/ini/Entries.cpp +++ b/modules/ini/Entries.cpp @@ -17,11 +17,17 @@ SQInteger Entries::Typename(HSQUIRRELVM vm) Int32 Entries::Cmp(const Entries & o) const { if (m_Elem == o.m_Elem) + { return 0; + } else if (m_List.size() > o.m_List.size()) + { return 1; + } else + { return -1; + } } // ------------------------------------------------------------------------------------------------ @@ -29,7 +35,9 @@ void Entries::Next() { // Are there any other elements ahead? if (!m_List.empty() && m_Elem != m_List.end()) - ++m_Elem; /* Go ahead one element */ + { + ++m_Elem; // Go ahead one element + } } // ------------------------------------------------------------------------------------------------ @@ -37,7 +45,9 @@ void Entries::Prev() { // Are there any other elements behind? if (!m_List.empty() && m_Elem != m_List.begin()) - --m_Elem; /* Go back one element */ + { + --m_Elem; // Go back one element + } } // ------------------------------------------------------------------------------------------------ @@ -45,9 +55,14 @@ void Entries::Advance(Int32 n) { // Are there any other elements ahead? if (m_List.empty() || m_Elem == m_List.end()) + { return; + } // Jump as many elements as possible within the specified distance - while ((--n >= 0) && m_Elem != m_List.end()) ++m_Elem; + while ((--n >= 0) && m_Elem != m_List.end()) + { + ++m_Elem; + } } // ------------------------------------------------------------------------------------------------ @@ -55,9 +70,14 @@ void Entries::Retreat(Int32 n) { // Are there any other elements behind? if (m_List.empty() || m_Elem == m_List.begin()) + { return; + } // Jump as many elements as possible within the specified distance - while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem; + while ((--n >= 0) && m_Elem != m_List.begin()) + { + --m_Elem; + } } // ------------------------------------------------------------------------------------------------ @@ -65,7 +85,9 @@ CSStr Entries::GetItem() const { // is the current element valid? if (m_List.empty() || m_Elem == m_List.end()) + { STHROWF("Invalid INI entry [item]"); + } // Return the requested information return m_Elem->pItem; } @@ -75,7 +97,9 @@ CSStr Entries::GetComment() const { // is the current element valid? if (m_List.empty() || m_Elem == m_List.end()) + { STHROWF("Invalid INI entry [comment]"); + } // Return the requested information return m_Elem->pComment; } @@ -85,7 +109,9 @@ Int32 Entries::GetOrder() const { // is the current element valid? if (m_List.empty() || m_Elem == m_List.end()) + { STHROWF("Invalid INI entry [order]"); + } // Return the requested information return m_Elem->nOrder; } diff --git a/modules/ini/Entries.hpp b/modules/ini/Entries.hpp index 28387c3e..133f030e 100644 --- a/modules/ini/Entries.hpp +++ b/modules/ini/Entries.hpp @@ -36,9 +36,9 @@ protected: private: // --------------------------------------------------------------------------------------------- - DocumentRef m_Doc; /* The document that contains the elements. */ - Container m_List; /* The list of elements to iterate. */ - Iterator m_Elem; /* The currently processed element. */ + DocumentRef m_Doc; // The document that contains the elements. + Container m_List; // The list of elements to iterate. + Iterator m_Elem; // The currently processed element. public: @@ -126,7 +126,7 @@ public: */ Int32 GetSize() const { - return (Int32)m_List.size(); + return static_cast< Int32 >(m_List.size()); } /* -------------------------------------------------------------------------------------------- @@ -135,9 +135,13 @@ public: void Reset() { if (m_List.empty()) + { m_Elem = m_List.end(); + } else + { m_Elem = m_List.begin(); + } } /* -------------------------------------------------------------------------------------------- @@ -166,7 +170,9 @@ public: void Sort() { if (!m_List.empty()) + { m_List.sort(DocumentRef::Type::Entry::KeyOrder()); + } } /* -------------------------------------------------------------------------------------------- @@ -175,7 +181,9 @@ public: void SortByKeyOrder() { if (!m_List.empty()) + { m_List.sort(DocumentRef::Type::Entry::KeyOrder()); + } } /* -------------------------------------------------------------------------------------------- @@ -184,7 +192,9 @@ public: void SortByLoadOrder() { if (!m_List.empty()) + { m_List.sort(DocumentRef::Type::Entry::LoadOrder()); + } } /* -------------------------------------------------------------------------------------------- diff --git a/modules/ini/Module.cpp b/modules/ini/Module.cpp index bbecb42f..b9a52610 100644 --- a/modules/ini/Module.cpp +++ b/modules/ini/Module.cpp @@ -5,12 +5,12 @@ #include "Document.hpp" // -------------------------------------------------------------------------------------------- -#include +#include +#include +#include // -------------------------------------------------------------------------------------------- -#include -#include -#include +#include // -------------------------------------------------------------------------------------------- #if defined(WIN32) || defined(_WIN32) @@ -20,14 +20,14 @@ namespace SqMod { // -------------------------------------------------------------------------------------------- -PluginFuncs* _Func = NULL; -PluginCallbacks* _Clbk = NULL; -PluginInfo* _Info = NULL; +PluginFuncs* _Func = nullptr; +PluginCallbacks* _Clbk = nullptr; +PluginInfo* _Info = nullptr; // -------------------------------------------------------------------------------------------- -HSQAPI _SqAPI = NULL; -HSQEXPORTS _SqMod = NULL; -HSQUIRRELVM _SqVM = NULL; +HSQAPI _SqAPI = nullptr; +HSQEXPORTS _SqMod = nullptr; +HSQUIRRELVM _SqVM = nullptr; /* ------------------------------------------------------------------------------------------------ * Bind speciffic functions to certain server events. @@ -53,7 +53,9 @@ void OnSquirrelInitialize() _SqMod = sq_api_import(_Func); // Did we failed to obtain the plugin exports? if(!_SqMod) + { OutputError("Failed to attach [%s] on host plugin.", SQINI_NAME); + } else { // Obtain the Squirrel API @@ -70,12 +72,16 @@ void OnSquirrelLoad() { // Make sure that we have a valid plugin API if (!_SqMod) - return; /* Unable to proceed. */ + { + return; // Unable to proceed! + } // Obtain the Squirrel API and VM _SqVM = _SqMod->GetSquirrelVM(); // Make sure that a valid virtual machine exists if (!_SqVM) - return; /* Unable to proceed. */ + { + return; // Unable to proceed! + } // Set this as the default database DefaultVM::Set(_SqVM); // Register the module API @@ -91,7 +97,7 @@ void OnSquirrelTerminate() { OutputMessage("Terminating: %s", SQINI_NAME); // Release the current database (if any) - DefaultVM::Set(NULL); + DefaultVM::Set(nullptr); } /* -------------------------------------------------------------------------------------------- @@ -100,10 +106,12 @@ void OnSquirrelTerminate() bool CheckAPIVer(CCStr ver) { // Obtain the numeric representation of the API version - long vernum = strtol(ver, NULL, 10); + long vernum = std::strtol(ver, nullptr, 10); // Check against version mismatch if (vernum == SQMOD_API_VER) + { return true; + } // Log the incident OutputError("API version mismatch on %s", SQINI_NAME); OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER); @@ -120,7 +128,9 @@ static int OnInternalCommand(unsigned int type, const char * text) { case SQMOD_INITIALIZE_CMD: if (CheckAPIVer(text)) + { OnSquirrelInitialize(); + } break; case SQMOD_LOAD_CMD: OnSquirrelLoad(); @@ -158,9 +168,9 @@ void BindCallbacks() // ------------------------------------------------------------------------------------------------ void UnbindCallbacks() { - _Clbk->OnInitServer = NULL; - _Clbk->OnInternalCommand = NULL; - _Clbk->OnShutdownServer = NULL; + _Clbk->OnInitServer = nullptr; + _Clbk->OnInternalCommand = nullptr; + _Clbk->OnShutdownServer = nullptr; } // -------------------------------------------------------------------------------------------- @@ -169,31 +179,31 @@ void RegisterAPI(HSQUIRRELVM vm) Table inins(vm); inins.Bind(_SC("Result"), Class< IniResult >(vm, _SC("SqIniResult")) - /* Constructors */ + // Constructors .Ctor() .Ctor< CSStr, SQInteger >() .Ctor< const IniResult & >() - /* Core Metamethods */ + // Core Metamethods .Func(_SC("_cmp"), &IniResult::Cmp) .SquirrelFunc(_SC("_typename"), &IniResult::Typename) .Func(_SC("_tostring"), &IniResult::ToString) - /* Properties */ + // Properties .Prop(_SC("Valid"), &IniResult::IsValid) .Prop(_SC("Action"), &IniResult::GetAction) .Prop(_SC("Result"), &IniResult::GetResult) - /* Functions */ + // Member Methods .Func(_SC("Check"), &IniResult::Check) ); inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries")) - /* Constructors */ + // Constructors .Ctor() .Ctor< const Entries & >() - /* Core Metamethods */ + // Core Metamethods .Func(_SC("_cmp"), &Entries::Cmp) .SquirrelFunc(_SC("_typename"), &Entries::Typename) .Func(_SC("_tostring"), &Entries::ToString) - /* Properties */ + // Properties .Prop(_SC("Valid"), &Entries::IsValid) .Prop(_SC("Empty"), &Entries::IsEmpty) .Prop(_SC("References"), &Entries::GetRefCount) @@ -201,7 +211,7 @@ void RegisterAPI(HSQUIRRELVM vm) .Prop(_SC("Item"), &Entries::GetItem) .Prop(_SC("Comment"), &Entries::GetComment) .Prop(_SC("Order"), &Entries::GetOrder) - /* Functions */ + // Member Methods .Func(_SC("Reset"), &Entries::Reset) .Func(_SC("Next"), &Entries::Next) .Func(_SC("Prev"), &Entries::Prev) @@ -213,16 +223,16 @@ void RegisterAPI(HSQUIRRELVM vm) ); inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument")) - /* Constructors */ + // Constructors .Ctor() .Ctor< bool >() .Ctor< bool, bool >() .Ctor< bool, bool, bool >() - /* Core Metamethods */ + // Core Metamethods .Func(_SC("_cmp"), &Document::Cmp) .SquirrelFunc(_SC("_typename"), &Document::Typename) .Func(_SC("_tostring"), &Document::ToString) - /* Properties */ + // Properties .Prop(_SC("Valid"), &Document::IsValid) .Prop(_SC("Empty"), &Document::IsEmpty) .Prop(_SC("References"), &Document::GetRefCount) @@ -230,7 +240,7 @@ void RegisterAPI(HSQUIRRELVM vm) .Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey) .Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine) .Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces) - /* Functions */ + // Member Methods .Func(_SC("Reset"), &Document::Reset) .Func(_SC("LoadFile"), &Document::LoadFile) .Overload< IniResult (Document::*)(CSStr) >(_SC("LoadString"), &Document::LoadData) @@ -400,7 +410,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb _Info = info; // Assign plugin information _Info->uPluginVer = SQINI_VERSION; - strcpy(_Info->szName, SQINI_HOST_NAME); + std::strcpy(_Info->szName, SQINI_HOST_NAME); // Bind callbacks BindCallbacks(); // Notify that the plugin was successfully loaded diff --git a/modules/irc/Common.cpp b/modules/irc/Common.cpp index 4b7540e8..a1858de2 100644 --- a/modules/irc/Common.cpp +++ b/modules/irc/Common.cpp @@ -57,7 +57,7 @@ CSStr FmtStr(CSStr str, ...) // Write the requested contents if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0) { - g_Buffer[0] = 0; // make sure the string is terminated + g_Buffer[0] = 0; // Make sure the string is terminated } // Release the argument list va_end(args); diff --git a/modules/irc/Module.cpp b/modules/irc/Module.cpp index 7433fdad..445ea1c6 100644 --- a/modules/irc/Module.cpp +++ b/modules/irc/Module.cpp @@ -619,7 +619,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb _Info = info; // Assign plugin information _Info->uPluginVer = SQIRC_VERSION; - strcpy(_Info->szName, SQIRC_HOST_NAME); + std::strcpy(_Info->szName, SQIRC_HOST_NAME); // Bind callbacks BindCallbacks(); // Notify that the plugin was successfully loaded