logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

disable-unicode.patch (2703B)


  1. SPDX-FileCopyrightText: 2022 fosslinux <fosslinux@aussies.space>
  2. SPDX-License-Identifier: Python-2.0.1
  3. unicodetype_db.h is a file that needs to be regened, but it not
  4. particularly trivial to regen. For the first build of Python,
  5. strip out any kind of unicode support that requires
  6. unicodetype_db.h indiscriminately.
  7. We are effectively restricted to ASCII characters with this change,
  8. but it works.
  9. --- Python-2.0.1/Objects/unicodectype.c 2000-09-26 08:48:13.000000000 +1100
  10. +++ Python-2.0.1/Objects/unicodectype.c 2022-10-03 21:09:02.108869321 +1100
  11. @@ -29,30 +29,12 @@
  12. const unsigned char digit;
  13. } _PyUnicode_TypeRecord;
  14. -#include "unicodetype_db.h"
  15. -
  16. -static const _PyUnicode_TypeRecord *
  17. -gettyperecord(int code)
  18. -{
  19. - int index;
  20. -
  21. - if (code < 0 || code >= 65536)
  22. - index = 0;
  23. - else {
  24. - index = index1[(code>>SHIFT)];
  25. - index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))];
  26. - }
  27. - return &_PyUnicode_TypeRecords[index];
  28. -}
  29. -
  30. /* Returns 1 for Unicode characters having the category 'Zl' or type
  31. 'B', 0 otherwise. */
  32. int _PyUnicode_IsLinebreak(register const Py_UNICODE ch)
  33. {
  34. - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
  35. -
  36. - return (ctype->flags & LINEBREAK_MASK) != 0;
  37. + return 0;
  38. }
  39. /* Returns the titlecase Unicode characters corresponding to ch or just
  40. @@ -60,12 +44,7 @@
  41. Py_UNICODE _PyUnicode_ToTitlecase(register const Py_UNICODE ch)
  42. {
  43. - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
  44. -
  45. - if (ctype->title)
  46. - return ch + ctype->title;
  47. -
  48. - return ch + ctype->upper;
  49. + return ch;
  50. }
  51. /* Returns 1 for Unicode characters having the category 'Lt', 0
  52. @@ -73,9 +52,7 @@
  53. int _PyUnicode_IsTitlecase(register const Py_UNICODE ch)
  54. {
  55. - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
  56. -
  57. - return (ctype->flags & TITLE_MASK) != 0;
  58. + return 0;
  59. }
  60. /* Returns the integer decimal (0-9) for Unicode characters having
  61. @@ -83,15 +60,13 @@
  62. int _PyUnicode_ToDecimalDigit(register const Py_UNICODE ch)
  63. {
  64. - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
  65. -
  66. - return (ctype->flags & DECIMAL_MASK) ? ctype->decimal : -1;
  67. + return -1;
  68. }
  69. int _PyUnicode_IsDecimalDigit(register const Py_UNICODE ch)
  70. {
  71. if (_PyUnicode_ToDecimalDigit(ch) < 0)
  72. - return 0;
  73. + return 0;
  74. return 1;
  75. }
  76. @@ -100,15 +75,13 @@
  77. int _PyUnicode_ToDigit(register const Py_UNICODE ch)
  78. {
  79. - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
  80. -
  81. - return (ctype->flags & DIGIT_MASK) ? ctype->digit : -1;
  82. + return -1;
  83. }
  84. int _PyUnicode_IsDigit(register const Py_UNICODE ch)
  85. {
  86. if (_PyUnicode_ToDigit(ch) < 0)
  87. - return 0;
  88. + return 0;
  89. return 1;
  90. }