Kaydet (Commit) 941049c9 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

clang-cl loplugin: pyuno

Change-Id: Ic093b58be1f2b78d904d6d036b52532f97c3b336
Reviewed-on: https://gerrit.libreoffice.org/29857Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 4cfb22aa
......@@ -40,7 +40,7 @@ PyRef ustring2PyUnicode( const OUString & str )
PyRef ret;
#if Py_UNICODE_SIZE == 2
// YD force conversion since python/2 uses wchar_t
ret = PyRef( PyUnicode_FromUnicode( (const Py_UNICODE*)str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
ret = PyRef( PyUnicode_FromUnicode( str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
#else
OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), nullptr) , SAL_NO_ACQUIRE );
......@@ -60,7 +60,7 @@ OUString pyString2ustring( PyObject *pystr )
if( PyUnicode_Check( pystr ) )
{
#if Py_UNICODE_SIZE == 2
ret = OUString( (sal_Unicode * ) PyUnicode_AS_UNICODE( pystr ) );
ret = OUString( PyUnicode_AS_UNICODE( pystr ) );
#else
#if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0);
......
......@@ -75,13 +75,13 @@ int main(int argc, char ** argv, char **) {
int wmain(int argc, wchar_t ** argv, wchar_t **) {
#endif
wchar_t path[MAX_PATH];
DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH);
DWORD n = GetModuleFileNameW(nullptr, path, MAX_PATH);
if (n == 0 || n >= MAX_PATH) {
exit(EXIT_FAILURE);
}
wchar_t * pathEnd = tools::filename(path);
*pathEnd = L'\0';
n = GetEnvironmentVariableW(L"UNO_PATH", NULL, 0);
n = GetEnvironmentVariableW(L"UNO_PATH", nullptr, 0);
if (n == 0) {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND ||
!SetEnvironmentVariableW(L"UNO_PATH", path))
......@@ -94,21 +94,21 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
wchar_t * bootstrapEnd = tools::buildPath(
bootstrap + MY_LENGTH(L"vnd.sun.star.pathname:"), path, pathEnd,
MY_STRING(L"fundamental.ini"));
if (bootstrapEnd == NULL) {
if (bootstrapEnd == nullptr) {
exit(EXIT_FAILURE);
}
wchar_t pythonpath2[MAX_PATH];
wchar_t * pythonpath2End = tools::buildPath(
pythonpath2, path, pathEnd,
MY_STRING(L"\\python-core-" PYTHON_VERSION_STRING L"\\lib"));
if (pythonpath2End == NULL) {
if (pythonpath2End == nullptr) {
exit(EXIT_FAILURE);
}
wchar_t pythonpath3[MAX_PATH];
wchar_t * pythonpath3End = tools::buildPath(
pythonpath3, path, pathEnd,
MY_STRING(L"\\python-core-" PYTHON_VERSION_STRING L"\\lib\\site-packages"));
if (pythonpath3End == NULL) {
if (pythonpath3End == nullptr) {
exit(EXIT_FAILURE);
}
#ifdef __MINGW32__
......@@ -123,14 +123,14 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
wchar_t pythonhome[MAX_PATH];
wchar_t * pythonhomeEnd = tools::buildPath(
pythonhome, path, pathEnd, MY_STRING(L"\\python-core-" PYTHON_VERSION_STRING));
if (pythonhomeEnd == NULL) {
if (pythonhomeEnd == nullptr) {
exit(EXIT_FAILURE);
}
wchar_t pythonexe[MAX_PATH];
wchar_t * pythonexeEnd = tools::buildPath(
pythonexe, path, pathEnd,
MY_STRING(L"\\python-core-" PYTHON_VERSION_STRING L"\\bin\\python.exe"));
if (pythonexeEnd == NULL) {
if (pythonexeEnd == nullptr) {
exit(EXIT_FAILURE);
}
std::size_t clSize = MY_LENGTH(L"\"") + 4 * (pythonexeEnd - pythonexe) +
......@@ -161,13 +161,13 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
#endif
}
*cp = L'\0';
n = GetEnvironmentVariableW(L"PATH", NULL, 0);
n = GetEnvironmentVariableW(L"PATH", nullptr, 0);
wchar_t * orig;
if (n == 0) {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
exit(EXIT_FAILURE);
}
orig = (wchar_t *)L"";
orig = const_cast<wchar_t *>(L"");
} else {
orig = new wchar_t[n];
if (GetEnvironmentVariableW(L"PATH", orig, n) != n - 1)
......@@ -188,12 +188,12 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
delete [] orig;
}
delete [] value;
n = GetEnvironmentVariableW(L"PYTHONPATH", NULL, 0);
n = GetEnvironmentVariableW(L"PYTHONPATH", nullptr, 0);
if (n == 0) {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
exit(EXIT_FAILURE);
}
orig = (wchar_t *)L"";
orig = const_cast<wchar_t *>(L"");
} else {
orig = new wchar_t[n];
if (GetEnvironmentVariableW(L"PYTHONPATH", orig, n) != n - 1)
......@@ -229,7 +229,7 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
if (!SetEnvironmentVariableW(L"PYTHONHOME", pythonhome)) {
exit(EXIT_FAILURE);
}
n = GetEnvironmentVariableW(L"URE_BOOTSTRAP", NULL, 0);
n = GetEnvironmentVariableW(L"URE_BOOTSTRAP", nullptr, 0);
if (n == 0) {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND ||
!SetEnvironmentVariableW(L"URE_BOOTSTRAP", bootstrap))
......@@ -242,8 +242,8 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
startinfo.cb = sizeof (STARTUPINFOW);
PROCESS_INFORMATION procinfo;
if (!CreateProcessW(
pythonexe, cl, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, NULL,
NULL, &startinfo, &procinfo)) {
pythonexe, cl, nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr,
nullptr, &startinfo, &procinfo)) {
exit(EXIT_FAILURE);
}
WaitForSingleObject(procinfo.hProcess,INFINITE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment