python.cxx (67c7d1c1) | python.cxx (9813d809) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 79 unchanged lines hidden (view full) --- 88 n = GetEnvironmentVariableW(L"UNO_PATH", NULL, 0); 89 if (n == 0) { 90 if (GetLastError() != ERROR_ENVVAR_NOT_FOUND || 91 !SetEnvironmentVariableW(L"UNO_PATH", path)) 92 { 93 exit(EXIT_FAILURE); 94 } 95 } | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 79 unchanged lines hidden (view full) --- 88 n = GetEnvironmentVariableW(L"UNO_PATH", NULL, 0); 89 if (n == 0) { 90 if (GetLastError() != ERROR_ENVVAR_NOT_FOUND || 91 !SetEnvironmentVariableW(L"UNO_PATH", path)) 92 { 93 exit(EXIT_FAILURE); 94 } 95 } |
96 |
|
96 wchar_t bootstrap[MY_LENGTH(L"vnd.sun.star.pathname:") + MAX_PATH] = 97 L"vnd.sun.star.pathname:"; //TODO: overflow 98 wchar_t * bootstrapEnd = tools::buildPath( 99 bootstrap + MY_LENGTH(L"vnd.sun.star.pathname:"), path, pathEnd, 100 MY_STRING(L"fundamental.ini")); | 97 wchar_t bootstrap[MY_LENGTH(L"vnd.sun.star.pathname:") + MAX_PATH] = 98 L"vnd.sun.star.pathname:"; //TODO: overflow 99 wchar_t * bootstrapEnd = tools::buildPath( 100 bootstrap + MY_LENGTH(L"vnd.sun.star.pathname:"), path, pathEnd, 101 MY_STRING(L"fundamental.ini")); |
101 if (bootstrapEnd == NULL || 102 (tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\basis-link")) 103 == NULL)) | 102 if (bootstrapEnd == NULL) |
104 { 105 exit(EXIT_FAILURE); 106 } | 103 { 104 exit(EXIT_FAILURE); 105 } |
107 pathEnd = tools::resolveLink(path); 108 wchar_t path1[MAX_PATH]; 109 wchar_t * path1End = tools::buildPath( 110 path1, path, pathEnd, MY_STRING(L"\\program")); 111 if (path1End == NULL) { 112 exit(EXIT_FAILURE); 113 } | 106 |
114 wchar_t pythonpath2[MAX_PATH]; 115 wchar_t * pythonpath2End = tools::buildPath( 116 pythonpath2, path, pathEnd, | 107 wchar_t pythonpath2[MAX_PATH]; 108 wchar_t * pythonpath2End = tools::buildPath( 109 pythonpath2, path, pathEnd, |
117 MY_STRING(L"\\program\\python-core-" MY_PYVERSION L"\\lib")); | 110 MY_STRING(L"python-core-" MY_PYVERSION L"\\lib")); |
118 if (pythonpath2End == NULL) { 119 exit(EXIT_FAILURE); 120 } | 111 if (pythonpath2End == NULL) { 112 exit(EXIT_FAILURE); 113 } |
114 |
|
121 wchar_t pythonpath3[MAX_PATH]; 122 wchar_t * pythonpath3End = tools::buildPath( 123 pythonpath3, path, pathEnd, 124 MY_STRING( | 115 wchar_t pythonpath3[MAX_PATH]; 116 wchar_t * pythonpath3End = tools::buildPath( 117 pythonpath3, path, pathEnd, 118 MY_STRING( |
125 L"\\program\\python-core-" MY_PYVERSION L"\\lib\\site-packages")); | 119 L"python-core-" MY_PYVERSION L"\\lib\\site-packages")); |
126 if (pythonpath3End == NULL) { 127 exit(EXIT_FAILURE); 128 } | 120 if (pythonpath3End == NULL) { 121 exit(EXIT_FAILURE); 122 } |
123 |
|
129#ifdef __MINGW32__ 130 wchar_t pythonpath4[MAX_PATH]; 131 wchar_t * pythonpath4End = tools::buildPath( 132 pythonpath4, path, pathEnd, | 124#ifdef __MINGW32__ 125 wchar_t pythonpath4[MAX_PATH]; 126 wchar_t * pythonpath4End = tools::buildPath( 127 pythonpath4, path, pathEnd, |
133 MY_STRING(L"\\program\\python-core-" MY_PYVERSION L"\\lib\\lib-dynload")); | 128 MY_STRING(L"python-core-" MY_PYVERSION L"\\lib\\lib-dynload")); |
134 if (pythonpath4End == NULL) { 135 exit(EXIT_FAILURE); 136 } 137 wchar_t pythonpath5[MAX_PATH]; 138 wchar_t * pythonpath5End = tools::buildPath( 139 pythonpath5, path, pathEnd, | 129 if (pythonpath4End == NULL) { 130 exit(EXIT_FAILURE); 131 } 132 wchar_t pythonpath5[MAX_PATH]; 133 wchar_t * pythonpath5End = tools::buildPath( 134 pythonpath5, path, pathEnd, |
140 MY_STRING(L"\\program\\python-core-" MY_PYVERSION L"\\lib\\lib-dynload")); | 135 MY_STRING(L"python-core-" MY_PYVERSION L"\\lib\\lib-dynload")); |
141 if (pythonpath5End == NULL) { 142 exit(EXIT_FAILURE); 143 } 144#endif 145 wchar_t pythonhome[MAX_PATH]; 146 wchar_t * pythonhomeEnd = tools::buildPath( 147 pythonhome, path, pathEnd, | 136 if (pythonpath5End == NULL) { 137 exit(EXIT_FAILURE); 138 } 139#endif 140 wchar_t pythonhome[MAX_PATH]; 141 wchar_t * pythonhomeEnd = tools::buildPath( 142 pythonhome, path, pathEnd, |
148 MY_STRING(L"\\program\\python-core-" MY_PYVERSION)); | 143 MY_STRING(L"python-core-" MY_PYVERSION)); |
149 if (pythonhomeEnd == NULL) { 150 exit(EXIT_FAILURE); 151 } 152 wchar_t pythonexe[MAX_PATH]; 153 wchar_t * pythonexeEnd = tools::buildPath( 154 pythonexe, path, pathEnd, 155#ifdef __MINGW32__ 156 MY_STRING( | 144 if (pythonhomeEnd == NULL) { 145 exit(EXIT_FAILURE); 146 } 147 wchar_t pythonexe[MAX_PATH]; 148 wchar_t * pythonexeEnd = tools::buildPath( 149 pythonexe, path, pathEnd, 150#ifdef __MINGW32__ 151 MY_STRING( |
157 L"\\program\\python-core-" MY_PYVERSION L"\\bin\\python.bin")); | 152 L"python-core-" MY_PYVERSION L"\\bin\\python.bin")); |
158#else 159 MY_STRING( | 153#else 154 MY_STRING( |
160 L"\\program\\python-core-" MY_PYVERSION L"\\bin\\python.exe")); | 155 L"python-core-" MY_PYVERSION L"\\bin\\python.exe")); |
161#endif 162 if (pythonexeEnd == NULL) { 163 exit(EXIT_FAILURE); 164 } | 156#endif 157 if (pythonexeEnd == NULL) { 158 exit(EXIT_FAILURE); 159 } |
165 if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\ure-link")) == NULL) 166 { 167 exit(EXIT_FAILURE); 168 } 169 pathEnd = tools::resolveLink(path); 170 if (pathEnd == NULL) { 171 exit(EXIT_FAILURE); 172 } 173 pathEnd = tools::buildPath(path, path, pathEnd, MY_STRING(L"\\bin")); 174 if (pathEnd == NULL) { 175 exit(EXIT_FAILURE); 176 } | 160 |
177 std::size_t clSize = MY_LENGTH(L"\"") + 4 * (pythonexeEnd - pythonexe) + 178 MY_LENGTH(L"\"\0"); //TODO: overflow 179 // 4 * len: each char preceded by backslash, each trailing backslash 180 // doubled 181 for (int i = 1; i < argc; ++i) { 182#ifdef __MINGW32__ 183 clSize += MY_LENGTH(L" \"") + 4 * strlen(argv[i]) + 184#else --- 31 unchanged lines hidden (view full) --- 216 orig = new wchar_t[n]; 217 if (orig == NULL || 218 GetEnvironmentVariableW(L"PATH", orig, n) != n - 1) 219 { 220 exit(EXIT_FAILURE); 221 } 222 } 223 wchar_t * value = new wchar_t[ | 161 std::size_t clSize = MY_LENGTH(L"\"") + 4 * (pythonexeEnd - pythonexe) + 162 MY_LENGTH(L"\"\0"); //TODO: overflow 163 // 4 * len: each char preceded by backslash, each trailing backslash 164 // doubled 165 for (int i = 1; i < argc; ++i) { 166#ifdef __MINGW32__ 167 clSize += MY_LENGTH(L" \"") + 4 * strlen(argv[i]) + 168#else --- 31 unchanged lines hidden (view full) --- 200 orig = new wchar_t[n]; 201 if (orig == NULL || 202 GetEnvironmentVariableW(L"PATH", orig, n) != n - 1) 203 { 204 exit(EXIT_FAILURE); 205 } 206 } 207 wchar_t * value = new wchar_t[ |
224 (pathEnd - path) + MY_LENGTH(L";") + (path1End - path1) + 225 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 226 wsprintfW(value, L"%s;%s%s%s", path, path1, n == 0 ? L"" : L";", orig); | 208 (pathEnd - path) + MY_LENGTH(L";") + 209 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 210 211 wsprintfW(value, L"%s%s%s", path, n == 0 ? L"" : L";", orig); 212 |
227 if (!SetEnvironmentVariableW(L"PATH", value)) { 228 exit(EXIT_FAILURE); 229 } 230 if (n != 0) { 231 delete [] orig; 232 } 233 delete [] value; 234 n = GetEnvironmentVariableW(L"PYTHONPATH", NULL, 0); --- 18 unchanged lines hidden (view full) --- 253 MY_LENGTH(L";") + (pythonpath3End - pythonpath3) + 254 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 255 wsprintfW( 256 value, L"%s;%s;%s;%s;%s%s%s", path1, pythonpath2, pythonpath4, 257 pythonpath5, pythonpath3, 258 n == 0 ? L"" : L";", orig); 259#else 260 value = new wchar_t[ | 213 if (!SetEnvironmentVariableW(L"PATH", value)) { 214 exit(EXIT_FAILURE); 215 } 216 if (n != 0) { 217 delete [] orig; 218 } 219 delete [] value; 220 n = GetEnvironmentVariableW(L"PYTHONPATH", NULL, 0); --- 18 unchanged lines hidden (view full) --- 239 MY_LENGTH(L";") + (pythonpath3End - pythonpath3) + 240 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 241 wsprintfW( 242 value, L"%s;%s;%s;%s;%s%s%s", path1, pythonpath2, pythonpath4, 243 pythonpath5, pythonpath3, 244 n == 0 ? L"" : L";", orig); 245#else 246 value = new wchar_t[ |
261 (path1End - path1) + MY_LENGTH(L";") + (pythonpath2End - pythonpath2) + | 247 (pythonpath2End - pythonpath2) + |
262 MY_LENGTH(L";") + (pythonpath3End - pythonpath3) + 263 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 264 wsprintfW( | 248 MY_LENGTH(L";") + (pythonpath3End - pythonpath3) + 249 (n == 0 ? 0 : MY_LENGTH(L";") + (n - 1)) + 1]; //TODO: overflow 250 wsprintfW( |
265 value, L"%s;%s;%s%s%s", path1, pythonpath2, pythonpath3, | 251 value, L"%s;%s%s%s", pythonpath2, pythonpath3, |
266 n == 0 ? L"" : L";", orig); 267#endif 268 if (!SetEnvironmentVariableW(L"PYTHONPATH", value)) { 269 exit(EXIT_FAILURE); 270 } 271 if (n != 0) { 272 delete [] orig; 273 } --- 26 unchanged lines hidden --- | 252 n == 0 ? L"" : L";", orig); 253#endif 254 if (!SetEnvironmentVariableW(L"PYTHONPATH", value)) { 255 exit(EXIT_FAILURE); 256 } 257 if (n != 0) { 258 delete [] orig; 259 } --- 26 unchanged lines hidden --- |