diff options
17 files changed, 41 insertions, 32 deletions
diff --git a/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp b/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp index 9b2b40e82..23f932d26 100644 --- a/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp +++ b/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp @@ -20,6 +20,8 @@ #include <QtCore/QRegularExpression> #include <QtCore/QStack> +#include <cstring> + // Helpers for qAddPostRoutine namespace PySide { @@ -142,7 +144,7 @@ QString qObjectTr(PyTypeObject *type, const char *sourceText, const char *disamb if (type == sbkObjectType) continue; const char *context = type->tp_name; - const char *dotpos = strrchr(context, '.'); + const char *dotpos = std::strrchr(context, '.'); if (dotpos != nullptr) context = dotpos + 1; result = QCoreApplication::translate(context, sourceText, disambiguation, n); diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index 61327cc1b..1c78394f9 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -116,11 +116,11 @@ MetaObjectBuilder::MetaObjectBuilder(PyTypeObject *type, const QMetaObject *meta { m_d->m_baseObject = metaObject; const char *className = type->tp_name; - if (const char *lastDot = strrchr(type->tp_name, '.')) + if (const char *lastDot = std::strrchr(type->tp_name, '.')) className = lastDot + 1; // Different names indicate a Python class inheriting a Qt class. // Parse the type. - if (strcmp(className, metaObject->className()) != 0) { + if (std::strcmp(className, metaObject->className()) != 0) { m_d->m_builder = new QMetaObjectBuilder(); m_d->m_builder->setClassName(className); m_d->m_builder->setSuperClass(metaObject); diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index 2af02beca..f1dd0972b 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -14,6 +14,8 @@ #include <QtCore/qstringlist.h> +#include <cstring> + ////////////////////////////////////////////////////////////////////////////// // // PYSIDE-1019: Support switchable extensions @@ -446,9 +448,9 @@ static PyObject *methodWithNewName(PyTypeObject *type, * Create a method with a lower case name. */ auto *obtype = reinterpret_cast<PyObject *>(type); - const auto len = strlen(new_name); + const auto len = std::strlen(new_name); auto *name = new char[len + 1]; - strcpy(name, new_name); + std::strcpy(name, new_name); auto *new_meth = new PyMethodDef; new_meth->ml_name = name; new_meth->ml_meth = meth->ml_meth; diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index 1ef492eaf..ca09fef1c 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -677,7 +677,7 @@ PyObject *getHiddenDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *n bool inherits(PyTypeObject *objType, const char *class_name) { - if (strcmp(objType->tp_name, class_name) == 0) + if (std::strcmp(objType->tp_name, class_name) == 0) return true; PyTypeObject *base = objType->tp_base; diff --git a/sources/pyside6/libpyside/pysideqenum.cpp b/sources/pyside6/libpyside/pysideqenum.cpp index f15074d59..9576ec715 100644 --- a/sources/pyside6/libpyside/pysideqenum.cpp +++ b/sources/pyside6/libpyside/pysideqenum.cpp @@ -9,12 +9,13 @@ #include <sbkstaticstrings.h> #include <sbkstring.h> -#include <map> - #include <QtCore/qmetatype.h> #include <QtCore/qdebug.h> #include <QtCore/qlist.h> +#include <map> +#include <cstring> + /////////////////////////////////////////////////////////////// // // PYSIDE-957: Create QEnum dynamically from Python Enum @@ -99,7 +100,7 @@ static bool is_module_code() if (ob_name.isNull()) return false; const char *codename = Shiboken::String::toCString(ob_name); - return strcmp(codename, "<module>") == 0; + return std::strcmp(codename, "<module>") == 0; } } // extern "C" diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index a4d1b66b5..5949e7ff3 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -450,7 +450,7 @@ static FunctionArgumentsResult extractFunctionArgumentsFromSlot(PyObject *slot) // it being actually being that. if (ret.objCode == nullptr) ret.function = nullptr; - } else if (strcmp(Py_TYPE(slot)->tp_name, "compiled_function") == 0) { + } else if (std::strcmp(Py_TYPE(slot)->tp_name, "compiled_function") == 0) { ret.isMethod = false; ret.function = slot; @@ -1259,7 +1259,7 @@ QByteArray getCallbackSignature(QMetaMethod signal, QObject *receiver, prefix += '('; for (int i = 0; i < mo->methodCount(); i++) { QMetaMethod me = mo->method(i); - if ((strncmp(me.methodSignature(), prefix, prefix.size()) == 0) && + if ((std::strncmp(me.methodSignature(), prefix, prefix.size()) == 0) && QMetaObject::checkConnectArgs(signal, me.methodSignature())) { numArgs = me.parameterTypes().size() + useSelf; break; @@ -1279,7 +1279,7 @@ QByteArray getCallbackSignature(QMetaMethod signal, QObject *receiver, prefix += '('; for (int i = 0, count = mo->methodCount(); i < count; ++i) { QMetaMethod me = mo->method(i); - if ((strncmp(me.methodSignature(), prefix, prefix.size()) == 0) && + if ((std::strncmp(me.methodSignature(), prefix, prefix.size()) == 0) && QMetaObject::checkConnectArgs(signal, me)) { numArgs = me.parameterTypes().size() + useSelf; break; diff --git a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp index 941e38c6e..8e888ed47 100644 --- a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp +++ b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp @@ -25,6 +25,9 @@ #include <QtRemoteObjects/qremoteobjectpendingcall.h> #include <QtRemoteObjects/qremoteobjectreplica.h> +#include <cstring> +#include <cctype> + using namespace Shiboken; class FriendlyReplica : public QRemoteObjectReplica @@ -167,7 +170,7 @@ struct SourceDefs auto name = callData->name.sliced(4); auto index = metaObject->indexOfProperty(name.constData()); if (index < 0) { - name[0] = tolower(name[0]); // Try lower case + name[0] = std::tolower(name[0]); // Try lower case index = metaObject->indexOfProperty(name.constData()); } // It is possible a .rep names a Slot "push" or "pushSomething" that @@ -478,9 +481,9 @@ PyTypeObject *createDynamicClassImpl(QMetaObject *meta) PyTypeObject *createDynamicClass(QMetaObject *meta, PyObject *properties_capsule) { bool isSource; - if (strncmp(meta->superClass()->className(), "QObject", 7) == 0) { + if (std::strncmp(meta->superClass()->className(), "QObject", 7) == 0) { isSource = true; - } else if (strncmp(meta->superClass()->className(), "QRemoteObjectReplica", 20) == 0) { + } else if (std::strncmp(meta->superClass()->className(), "QRemoteObjectReplica", 20) == 0) { isSource = false; } else { PyErr_SetString(PyExc_RuntimeError, diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index e23b48862..a482c3a60 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -22,6 +22,7 @@ #include <clang-c/Index.h> #include <algorithm> +#include <cstring> #include <iterator> #include <string_view> @@ -706,7 +707,7 @@ const char *languageLevelOption(LanguageLevel l) LanguageLevel languageLevelFromOption(const char *o) { for (const LanguageLevelMapping &m : languageLevelMapping) { - if (!strcmp(m.option, o)) + if (!std::strcmp(m.option, o)) return m.level; } return LanguageLevel::Default; diff --git a/sources/shiboken6/ApiExtractor/tests/testutil.h b/sources/shiboken6/ApiExtractor/tests/testutil.h index 8f79b4a7d..40501c350 100644 --- a/sources/shiboken6/ApiExtractor/tests/testutil.h +++ b/sources/shiboken6/ApiExtractor/tests/testutil.h @@ -49,7 +49,7 @@ namespace TestUtil } QByteArrayList arguments; arguments.append(QFile::encodeName(tempSource.fileName())); - tempSource.write(cppCode, qint64(strlen(cppCode))); + tempSource.write(cppCode, qint64(qstrlen(cppCode))); tempSource.close(); auto builder = std::make_unique<AbstractMetaBuilder>(); diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 7136fc59d..64b089c7f 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -120,7 +120,7 @@ check_PyTypeObject_valid() Shiboken::AutoDecRef tpDict(PepType_GetDict(check)); auto *checkDict = tpDict.object(); if (false - || strcmp(probe_tp_name, check->tp_name) != 0 + || std::strcmp(probe_tp_name, check->tp_name) != 0 || probe_tp_basicsize != check->tp_basicsize || probe_tp_dealloc != check->tp_dealloc || probe_tp_repr != check->tp_repr diff --git a/sources/shiboken6/libshiboken/sbkconverter.cpp b/sources/shiboken6/libshiboken/sbkconverter.cpp index f97ad5f3c..f6c9c36b4 100644 --- a/sources/shiboken6/libshiboken/sbkconverter.cpp +++ b/sources/shiboken6/libshiboken/sbkconverter.cpp @@ -904,7 +904,7 @@ SpecificConverter::SpecificConverter(const char *typeName) m_converter = getConverter(typeName); if (!m_converter) return; - const auto len = strlen(typeName); + const auto len = std::strlen(typeName); char lastChar = typeName[len -1]; if (lastChar == '&') { m_type = ReferenceConversion; diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp index 212fcec86..a1f35ff34 100644 --- a/sources/shiboken6/libshiboken/sbkenum.cpp +++ b/sources/shiboken6/libshiboken/sbkenum.cpp @@ -282,14 +282,14 @@ void setTypeConverter(PyTypeObject *type, SbkConverter *converter, static void setModuleAndQualnameOnType(PyObject *type, const char *fullName) { - const char *colon = strchr(fullName, ':'); + const char *colon = std::strchr(fullName, ':'); assert(colon); int package_level = atoi(fullName); const char *mod = colon + 1; const char *qual = mod; for (int idx = package_level; idx > 0; --idx) { - const char *dot = strchr(qual, '.'); + const char *dot = std::strchr(qual, '.'); if (!dot) break; qual = dot + 1; @@ -306,7 +306,7 @@ static PyTypeObject *createEnumForPython(PyObject *scopeOrModule, const char *fullName, PyObject *pyEnumItems) { - const char *dot = strrchr(fullName, '.'); + const char *dot = std::strrchr(fullName, '.'); AutoDecRef name(Shiboken::String::fromCString(dot ? dot + 1 : fullName)); static PyObject *enumName = String::createStaticString("IntEnum"); @@ -473,7 +473,7 @@ PyTypeObject *createPythonEnum(const char *fullName, PyObject *pyEnumItems, return nullptr; } - const char *dot = strrchr(fullName, '.'); + const char *dot = std::strrchr(fullName, '.'); AutoDecRef name(Shiboken::String::fromCString(dot ? dot + 1 : fullName)); AutoDecRef callArgs(Py_BuildValue("(OO)", name.object(), pyEnumItems)); auto *newType = PyObject_Call(PyEnumType, callArgs, callDict); diff --git a/sources/shiboken6/libshiboken/sbkstring.cpp b/sources/shiboken6/libshiboken/sbkstring.cpp index 2c22a220c..9f55abcf0 100644 --- a/sources/shiboken6/libshiboken/sbkstring.cpp +++ b/sources/shiboken6/libshiboken/sbkstring.cpp @@ -221,7 +221,7 @@ PyObject *getSnakeCaseName(const char *name, bool lower) char *q = new_name; for (; *p && q - new_name < 200; ++p, ++q) { if (std::isupper(*p)) { - if (p != name && isupper(*(p - 1))) + if (p != name && std::isupper(*(p - 1))) return createStaticString(name); *q = '_'; ++q; diff --git a/sources/shiboken6/libshiboken/sbktypefactory.cpp b/sources/shiboken6/libshiboken/sbktypefactory.cpp index 94dd47cf3..f86bab9d8 100644 --- a/sources/shiboken6/libshiboken/sbktypefactory.cpp +++ b/sources/shiboken6/libshiboken/sbktypefactory.cpp @@ -131,7 +131,7 @@ PyTypeObject *SbkType_FromSpec_BMDWB(PyType_Spec *spec, const char *qual = mod; for (int idx = package_level; idx > 0; --idx) { - const char *dot = strchr(qual, '.'); + const char *dot = std::strchr(qual, '.'); if (!dot) break; qual = dot + 1; @@ -305,7 +305,7 @@ _PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) } /* Set the type name and qualname */ - s = strrchr(const_cast<char *>(spec->name), '.'); + s = std::strrchr(const_cast<char *>(spec->name), '.'); if (s == nullptr) s = (char*)spec->name; else @@ -373,7 +373,7 @@ _PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) if (slot->slot == Py_tp_doc) { const char *old_doc = reinterpret_cast<char *>(slot->pfunc); //_PyType_DocWithoutSignature(type->tp_name, slot->pfunc); - size_t len = strlen(old_doc)+1; + size_t len = std::strlen(old_doc)+1; char *tp_doc = reinterpret_cast<char *>(PyObject_MALLOC(len)); if (tp_doc == nullptr) { type->tp_doc = nullptr; diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp index 3c60a7cb2..fc0663ba8 100644 --- a/sources/shiboken6/libshiboken/signature/signature.cpp +++ b/sources/shiboken6/libshiboken/signature/signature.cpp @@ -536,7 +536,7 @@ static int _finishSignaturesCommon(PyObject *module) // the shiboken module (or a test module). [[maybe_unused]] const char *name = PyModule_GetName(module); if (pyside_globals->finish_import_func == nullptr) { - assert(strncmp(name, "PySide6.", 8) != 0); + assert(std::strncmp(name, "PySide6.", 8) != 0); return 0; } // Call a Python function which has to finish something as well. diff --git a/sources/shiboken6/libshiboken/signature/signature_helper.cpp b/sources/shiboken6/libshiboken/signature/signature_helper.cpp index 3ecddbf01..cb6e131d2 100644 --- a/sources/shiboken6/libshiboken/signature/signature_helper.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_helper.cpp @@ -32,7 +32,7 @@ static int _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_ PyGetSetDef *gsp = type->tp_getset; if (gsp != nullptr) { for (; gsp->name != nullptr; gsp++) { - if (strcmp(gsp->name, name) == 0) { + if (std::strcmp(gsp->name, name) == 0) { new_gsp->set = gsp->set; new_gsp->doc = gsp->doc; new_gsp->closure = gsp->closure; @@ -43,7 +43,7 @@ static int _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_ PyMemberDef *md = type->tp_members; if (md != nullptr) for (; md->name != nullptr; md++) - if (strcmp(md->name, name) == 0) + if (std::strcmp(md->name, name) == 0) return 1; return 0; } @@ -64,7 +64,7 @@ int add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **doc_descr) PyObject *have_descr = PyDict_GetItemString(dict, gsp->name); if (have_descr != nullptr) { Py_INCREF(have_descr); - if (strcmp(gsp->name, "__doc__") == 0) + if (std::strcmp(gsp->name, "__doc__") == 0) *doc_descr = have_descr; else assert(false); diff --git a/sources/shiboken6/tests/libsample/bytearray.cpp b/sources/shiboken6/tests/libsample/bytearray.cpp index 78d5162b0..a70950c6d 100644 --- a/sources/shiboken6/tests/libsample/bytearray.cpp +++ b/sources/shiboken6/tests/libsample/bytearray.cpp @@ -59,7 +59,7 @@ ByteArray &ByteArray::append(char c) ByteArray &ByteArray::append(const char *data) { m_data.pop_back(); - std::copy(data, data + strlen(data), std::back_inserter(m_data)); + std::copy(data, data + std::strlen(data), std::back_inserter(m_data)); m_data.push_back('\0'); return *this; } |
