Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
13KB

  1. diff -Naur Python-3.8.0-orig/Include/iscygpty.h Python-3.8.0/Include/iscygpty.h
  2. --- Python-3.8.0-orig/Include/iscygpty.h 1970-01-01 03:00:00.000000000 +0300
  3. +++ Python-3.8.0/Include/iscygpty.h 2019-10-22 10:04:39.461927600 +0300
  4. @@ -0,0 +1,41 @@
  5. +/*
  6. + * iscygpty.h -- part of ptycheck
  7. + * https://github.com/k-takata/ptycheck
  8. + *
  9. + * Copyright (c) 2015-2017 K.Takata
  10. + *
  11. + * You can redistribute it and/or modify it under the terms of either
  12. + * the MIT license (as described below) or the Vim license.
  13. + *
  14. + * Permission is hereby granted, free of charge, to any person obtaining
  15. + * a copy of this software and associated documentation files (the
  16. + * "Software"), to deal in the Software without restriction, including
  17. + * without limitation the rights to use, copy, modify, merge, publish,
  18. + * distribute, sublicense, and/or sell copies of the Software, and to
  19. + * permit persons to whom the Software is furnished to do so, subject to
  20. + * the following conditions:
  21. + *
  22. + * The above copyright notice and this permission notice shall be
  23. + * included in all copies or substantial portions of the Software.
  24. + *
  25. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  28. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  29. + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  30. + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  31. + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. + */
  33. +
  34. +#ifndef _ISCYGPTY_H
  35. +#define _ISCYGPTY_H
  36. +
  37. +#ifdef _WIN32
  38. +int is_cygpty(int fd);
  39. +int is_cygpty_used(void);
  40. +#else
  41. +#define is_cygpty(fd) 0
  42. +#define is_cygpty_used() 0
  43. +#endif
  44. +
  45. +#endif /* _ISCYGPTY_H */
  46. diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in
  47. --- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:04:25.063102300 +0300
  48. +++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:04:39.867528300 +0300
  49. @@ -346,6 +346,7 @@
  50. Python/import.o \
  51. Python/importdl.o \
  52. Python/initconfig.o \
  53. + Python/iscygpty.o \
  54. Python/marshal.o \
  55. Python/modsupport.o \
  56. Python/mysnprintf.o \
  57. @@ -1011,6 +1012,7 @@
  58. $(srcdir)/Include/import.h \
  59. $(srcdir)/Include/interpreteridobject.h \
  60. $(srcdir)/Include/intrcheck.h \
  61. + $(srcdir)/Include/iscygpty.h \
  62. $(srcdir)/Include/iterobject.h \
  63. $(srcdir)/Include/listobject.h \
  64. $(srcdir)/Include/longintrepr.h \
  65. diff -Naur Python-3.8.0-orig/Modules/_io/fileio.c Python-3.8.0/Modules/_io/fileio.c
  66. --- Python-3.8.0-orig/Modules/_io/fileio.c 2019-10-14 16:34:47.000000000 +0300
  67. +++ Python-3.8.0/Modules/_io/fileio.c 2019-10-22 10:04:40.273129000 +0300
  68. @@ -18,6 +18,7 @@
  69. #endif
  70. #include <stddef.h> /* For offsetof */
  71. #include "_iomodule.h"
  72. +#include "iscygpty.h"
  73. /*
  74. * Known likely problems:
  75. @@ -1119,7 +1120,7 @@
  76. return err_closed();
  77. Py_BEGIN_ALLOW_THREADS
  78. _Py_BEGIN_SUPPRESS_IPH
  79. - res = isatty(self->fd);
  80. + res = isatty(self->fd) || is_cygpty(self->fd);
  81. _Py_END_SUPPRESS_IPH
  82. Py_END_ALLOW_THREADS
  83. return PyBool_FromLong(res);
  84. diff -Naur Python-3.8.0-orig/Modules/main.c Python-3.8.0/Modules/main.c
  85. --- Python-3.8.0-orig/Modules/main.c 2019-10-14 16:34:47.000000000 +0300
  86. +++ Python-3.8.0/Modules/main.c 2019-10-22 10:04:41.068730400 +0300
  87. @@ -5,6 +5,7 @@
  88. #include "pycore_pylifecycle.h"
  89. #include "pycore_pymem.h"
  90. #include "pycore_pystate.h"
  91. +#include "iscygpty.h"
  92. #ifdef __FreeBSD__
  93. # include <fenv.h> /* fedisableexcept() */
  94. @@ -103,7 +104,7 @@
  95. static int
  96. stdin_is_interactive(const PyConfig *config)
  97. {
  98. - return (isatty(fileno(stdin)) || config->interactive);
  99. + return (isatty(fileno(stdin)) || config->interactive || is_cygpty(fileno(stdin)));
  100. }
  101. diff -Naur Python-3.8.0-orig/Modules/posixmodule.c Python-3.8.0/Modules/posixmodule.c
  102. --- Python-3.8.0-orig/Modules/posixmodule.c 2019-10-22 10:02:48.171332100 +0300
  103. +++ Python-3.8.0/Modules/posixmodule.c 2019-10-22 10:04:41.489931200 +0300
  104. @@ -34,6 +34,7 @@
  105. FSCTL_GET_REPARSE_POINT is not exported with WIN32_LEAN_AND_MEAN. */
  106. # include <windows.h>
  107. #endif
  108. +#include "iscygpty.h"
  109. #include "pycore_ceval.h" /* _PyEval_ReInitThreads() */
  110. #include "pycore_pystate.h" /* _PyRuntime */
  111. @@ -9258,7 +9259,7 @@
  112. {
  113. int return_value;
  114. _Py_BEGIN_SUPPRESS_IPH
  115. - return_value = isatty(fd);
  116. + return_value = isatty(fd) || is_cygpty(fd);
  117. _Py_END_SUPPRESS_IPH
  118. return return_value;
  119. }
  120. diff -Naur Python-3.8.0-orig/Python/frozenmain.c Python-3.8.0/Python/frozenmain.c
  121. --- Python-3.8.0-orig/Python/frozenmain.c 2019-10-14 16:34:47.000000000 +0300
  122. +++ Python-3.8.0/Python/frozenmain.c 2019-10-22 10:04:41.895531900 +0300
  123. @@ -4,6 +4,7 @@
  124. #include "Python.h"
  125. #include "pycore_pystate.h"
  126. #include <locale.h>
  127. +#include "iscygpty.h"
  128. #ifdef MS_WINDOWS
  129. extern void PyWinFreeze_ExeInit(void);
  130. @@ -107,7 +108,7 @@
  131. else
  132. sts = 0;
  133. - if (inspect && isatty((int)fileno(stdin)))
  134. + if (inspect && (isatty((int)fileno(stdin)) || is_cygpty((int)fileno(stdin))))
  135. sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
  136. #ifdef MS_WINDOWS
  137. diff -Naur Python-3.8.0-orig/Python/iscygpty.c Python-3.8.0/Python/iscygpty.c
  138. --- Python-3.8.0-orig/Python/iscygpty.c 1970-01-01 03:00:00.000000000 +0300
  139. +++ Python-3.8.0/Python/iscygpty.c 2019-10-22 10:04:42.301132600 +0300
  140. @@ -0,0 +1,185 @@
  141. +/*
  142. + * iscygpty.c -- part of ptycheck
  143. + * https://github.com/k-takata/ptycheck
  144. + *
  145. + * Copyright (c) 2015-2017 K.Takata
  146. + *
  147. + * You can redistribute it and/or modify it under the terms of either
  148. + * the MIT license (as described below) or the Vim license.
  149. + *
  150. + * Permission is hereby granted, free of charge, to any person obtaining
  151. + * a copy of this software and associated documentation files (the
  152. + * "Software"), to deal in the Software without restriction, including
  153. + * without limitation the rights to use, copy, modify, merge, publish,
  154. + * distribute, sublicense, and/or sell copies of the Software, and to
  155. + * permit persons to whom the Software is furnished to do so, subject to
  156. + * the following conditions:
  157. + *
  158. + * The above copyright notice and this permission notice shall be
  159. + * included in all copies or substantial portions of the Software.
  160. + *
  161. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  162. + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  163. + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  164. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  165. + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  166. + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  167. + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  168. + */
  169. +
  170. +#ifdef _WIN32
  171. +
  172. +#include <ctype.h>
  173. +#include <io.h>
  174. +#include <wchar.h>
  175. +#include <windows.h>
  176. +
  177. +#ifdef USE_FILEEXTD
  178. +/* VC 7.1 or earlier doesn't support SAL. */
  179. +# if !defined(_MSC_VER) || (_MSC_VER < 1400)
  180. +# define __out
  181. +# define __in
  182. +# define __in_opt
  183. +# endif
  184. +/* Win32 FileID API Library:
  185. + * http://www.microsoft.com/en-us/download/details.aspx?id=22599
  186. + * Needed for WinXP. */
  187. +# include <fileextd.h>
  188. +#else /* USE_FILEEXTD */
  189. +/* VC 8 or earlier. */
  190. +# if defined(_MSC_VER) && (_MSC_VER < 1500)
  191. +# ifdef ENABLE_STUB_IMPL
  192. +# define STUB_IMPL
  193. +# else
  194. +# error "Win32 FileID API Library is required for VC2005 or earlier."
  195. +# endif
  196. +# endif
  197. +#endif /* USE_FILEEXTD */
  198. +
  199. +
  200. +#include "iscygpty.h"
  201. +
  202. +//#define USE_DYNFILEID
  203. +#ifdef USE_DYNFILEID
  204. +typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)(
  205. + HANDLE hFile,
  206. + FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
  207. + LPVOID lpFileInformation,
  208. + DWORD dwBufferSize
  209. +);
  210. +static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL;
  211. +
  212. +# ifndef USE_FILEEXTD
  213. +static BOOL WINAPI stub_GetFileInformationByHandleEx(
  214. + HANDLE hFile,
  215. + FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
  216. + LPVOID lpFileInformation,
  217. + DWORD dwBufferSize
  218. + )
  219. +{
  220. + return FALSE;
  221. +}
  222. +# endif
  223. +
  224. +static void setup_fileid_api(void)
  225. +{
  226. + if (pGetFileInformationByHandleEx != NULL) {
  227. + return;
  228. + }
  229. + pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx)
  230. + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
  231. + "GetFileInformationByHandleEx");
  232. + if (pGetFileInformationByHandleEx == NULL) {
  233. +# ifdef USE_FILEEXTD
  234. + pGetFileInformationByHandleEx = GetFileInformationByHandleEx;
  235. +# else
  236. + pGetFileInformationByHandleEx = stub_GetFileInformationByHandleEx;
  237. +# endif
  238. + }
  239. +}
  240. +#else
  241. +# define pGetFileInformationByHandleEx GetFileInformationByHandleEx
  242. +# define setup_fileid_api()
  243. +#endif
  244. +
  245. +
  246. +#define is_wprefix(s, prefix) \
  247. + (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0)
  248. +
  249. +/* Check if the fd is a cygwin/msys's pty. */
  250. +int is_cygpty(int fd)
  251. +{
  252. +#ifdef STUB_IMPL
  253. + return 0;
  254. +#else
  255. + HANDLE h;
  256. + int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1);
  257. + FILE_NAME_INFO *nameinfo;
  258. + WCHAR *p = NULL;
  259. +
  260. + setup_fileid_api();
  261. +
  262. + h = (HANDLE) _get_osfhandle(fd);
  263. + if (h == INVALID_HANDLE_VALUE) {
  264. + return 0;
  265. + }
  266. + /* Cygwin/msys's pty is a pipe. */
  267. + if (GetFileType(h) != FILE_TYPE_PIPE) {
  268. + return 0;
  269. + }
  270. + nameinfo = malloc(size + sizeof(WCHAR));
  271. + if (nameinfo == NULL) {
  272. + return 0;
  273. + }
  274. + /* Check the name of the pipe:
  275. + * '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */
  276. + if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) {
  277. + nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0';
  278. + p = nameinfo->FileName;
  279. + if (is_wprefix(p, L"\\cygwin-")) { /* Cygwin */
  280. + p += 8;
  281. + } else if (is_wprefix(p, L"\\msys-")) { /* MSYS and MSYS2 */
  282. + p += 6;
  283. + } else {
  284. + p = NULL;
  285. + }
  286. + if (p != NULL) {
  287. + while (*p && isxdigit(*p)) /* Skip 16-digit hexadecimal. */
  288. + ++p;
  289. + if (is_wprefix(p, L"-pty")) {
  290. + p += 4;
  291. + } else {
  292. + p = NULL;
  293. + }
  294. + }
  295. + if (p != NULL) {
  296. + while (*p && isdigit(*p)) /* Skip pty number. */
  297. + ++p;
  298. + if (is_wprefix(p, L"-from-master")) {
  299. + //p += 12;
  300. + } else if (is_wprefix(p, L"-to-master")) {
  301. + //p += 10;
  302. + } else {
  303. + p = NULL;
  304. + }
  305. + }
  306. + }
  307. + free(nameinfo);
  308. + return (p != NULL);
  309. +#endif /* STUB_IMPL */
  310. +}
  311. +
  312. +/* Check if at least one cygwin/msys pty is used. */
  313. +int is_cygpty_used(void)
  314. +{
  315. + int fd, ret = 0;
  316. +
  317. + for (fd = 0; fd < 3; fd++) {
  318. + ret |= is_cygpty(fd);
  319. + }
  320. + return ret;
  321. +}
  322. +
  323. +#endif /* _WIN32 */
  324. +
  325. +/* vim: set ts=4 sw=4: */
  326. diff -Naur Python-3.8.0-orig/Python/pylifecycle.c Python-3.8.0/Python/pylifecycle.c
  327. --- Python-3.8.0-orig/Python/pylifecycle.c 2019-10-14 16:34:47.000000000 +0300
  328. +++ Python-3.8.0/Python/pylifecycle.c 2019-10-22 10:04:42.691133300 +0300
  329. @@ -24,6 +24,7 @@
  330. #include "ast.h"
  331. #include "marshal.h"
  332. #include "osdefs.h"
  333. +#include "iscygpty.h"
  334. #include <locale.h>
  335. #ifdef HAVE_SIGNAL_H
  336. @@ -2349,7 +2350,7 @@
  337. int
  338. Py_FdIsInteractive(FILE *fp, const char *filename)
  339. {
  340. - if (isatty((int)fileno(fp)))
  341. + if (isatty((int)fileno(fp)) || is_cygpty((int)fileno(fp)))
  342. return 1;
  343. if (!Py_InteractiveFlag)
  344. return 0;
  345. --- Python-3.8.7/Python/bltinmodule.c.orig 2020-12-21 17:25:24.000000000 +0100
  346. +++ Python-3.8.7/Python/bltinmodule.c 2021-01-06 16:50:48.899457200 +0100
  347. @@ -1,6 +1,7 @@
  348. /* Built-in functions */
  349. #include "Python.h"
  350. +#include "iscygpty.h"
  351. #include <ctype.h>
  352. #include "ast.h"
  353. #undef Yield /* undefine macro conflicting with <winbase.h> */
  354. @@ -1980,7 +1981,7 @@
  355. Py_DECREF(tmp);
  356. if (fd < 0 && PyErr_Occurred())
  357. return NULL;
  358. - tty = fd == fileno(stdin) && isatty(fd);
  359. + tty = fd == fileno(stdin) && (isatty(fd) || is_cygpty(fd));
  360. }
  361. if (tty) {
  362. tmp = _PyObject_CallMethodId(fout, &PyId_fileno, NULL);
  363. @@ -1993,7 +1994,7 @@
  364. Py_DECREF(tmp);
  365. if (fd < 0 && PyErr_Occurred())
  366. return NULL;
  367. - tty = fd == fileno(stdout) && isatty(fd);
  368. + tty = fd == fileno(stdout) && (isatty(fd) || is_cygpty(fd));
  369. }
  370. }
  371. --- Python-3.8.7/Objects/fileobject.c.orig 2020-12-21 17:25:24.000000000 +0100
  372. +++ Python-3.8.7/Objects/fileobject.c 2021-01-06 16:51:19.605061600 +0100
  373. @@ -2,6 +2,7 @@
  374. #define PY_SSIZE_T_CLEAN
  375. #include "Python.h"
  376. +#include "iscygpty.h"
  377. #include "pycore_pystate.h"
  378. #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)
  379. @@ -434,7 +435,7 @@
  380. }
  381. Py_BEGIN_ALLOW_THREADS
  382. - res = isatty(self->fd);
  383. + res = isatty(self->fd) || is_cygpty(self->fd);
  384. Py_END_ALLOW_THREADS
  385. return PyBool_FromLong(res);
  386. --- Python-3.8.7/Python/fileutils.c.orig 2020-12-21 17:25:24.000000000 +0100
  387. +++ Python-3.8.7/Python/fileutils.c 2021-01-06 16:50:56.153853200 +0100
  388. @@ -1,4 +1,5 @@
  389. #include "Python.h"
  390. +#include "iscygpty.h"
  391. #include "pycore_fileutils.h"
  392. #include "osdefs.h"
  393. #include <locale.h>
  394. @@ -59,7 +60,7 @@
  395. #endif
  396. int valid;
  397. _Py_BEGIN_SUPPRESS_IPH
  398. - valid = isatty(fd);
  399. + valid = isatty(fd) || is_cygpty(fd);
  400. _Py_END_SUPPRESS_IPH
  401. if (!valid)
  402. Py_RETURN_NONE;