flexablelib-speedups 3.7.0__tar.gz → 3.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-speedups
3
- Version: 3.7.0
3
+ Version: 3.7.2
4
4
  Summary: Optional C acceleration of terminal frame drawing for flexablelib (cut, pad, borders, frame diffs, images).
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -6,7 +6,7 @@ directly: :mod:`flexablelib._frames` picks it up when it is installed and
6
6
  falls back to identical pure-Python code when it is not.
7
7
  """
8
8
 
9
- __version__ = '3.7.0'
9
+ __version__ = '3.7.2'
10
10
 
11
11
  from . import _frames # noqa: F401,E402
12
12
 
@@ -42,12 +42,18 @@ static const struct ascii_fold_entry ascii_fold_table[] = {
42
42
  {0x2193, 'v'},
43
43
  {0x2194, '-'},
44
44
  {0x2195, '|'},
45
+ {0x2196, '\\'},
46
+ {0x2197, '/'},
47
+ {0x2198, '\\'},
48
+ {0x2199, '/'},
45
49
  {0x219E, '<'},
46
50
  {0x21A0, '>'},
47
51
  {0x21A4, '<'},
48
52
  {0x21A6, '>'},
49
53
  {0x21A9, '<'},
50
54
  {0x21B5, '<'},
55
+ {0x21BA, 'o'},
56
+ {0x21BB, 'o'},
51
57
  {0x21D0, '<'},
52
58
  {0x21D1, '^'},
53
59
  {0x21D2, '>'},
@@ -65,8 +71,16 @@ static const struct ascii_fold_entry ascii_fold_table[] = {
65
71
  {0x2264, '<'},
66
72
  {0x2265, '>'},
67
73
  {0x22EF, '.'},
74
+ {0x2326, '>'},
75
+ {0x232B, '<'},
68
76
  {0x23CE, '<'},
77
+ {0x23F1, 'o'},
78
+ {0x23F2, 'o'},
79
+ {0x23F8, '='},
80
+ {0x23F9, '#'},
81
+ {0x23FA, 'o'},
69
82
  {0x2423, '_'},
83
+ {0x24D8, 'i'},
70
84
  {0x2500, '-'},
71
85
  {0x2501, '-'},
72
86
  {0x2502, '|'},
@@ -332,11 +346,14 @@ static const struct ascii_fold_entry ascii_fold_table[] = {
332
346
  {0x2716, 'x'},
333
347
  {0x2717, 'x'},
334
348
  {0x2718, 'x'},
349
+ {0x271A, '+'},
335
350
  {0x2726, '*'},
336
351
  {0x2727, '*'},
352
+ {0x27F2, 'o'},
353
+ {0x27F3, 'o'},
337
354
  {0x27F5, '<'},
338
355
  {0x27F6, '>'},
339
356
  {0x2B51, '*'},
340
357
  };
341
358
 
342
- #define ASCII_FOLD_COUNT 333
359
+ #define ASCII_FOLD_COUNT 350
@@ -62,6 +62,20 @@ static int buf_int(Buf *b, long v)
62
62
  /* ------------------------------------------------------------------ */
63
63
  /* unfilter */
64
64
 
65
+ /* Raise flexablelib._images.ImageError (a ValueError) with a message, the
66
+ same exception the Python implementation raises. */
67
+ static void
68
+ set_image_error(const char *message)
69
+ {
70
+ PyObject *mod = PyImport_ImportModule("flexablelib._images");
71
+ PyObject *cls = mod ? PyObject_GetAttrString(mod, "ImageError") : NULL;
72
+ Py_XDECREF(mod);
73
+ if (cls) {
74
+ PyErr_SetString(cls, message);
75
+ Py_DECREF(cls);
76
+ }
77
+ }
78
+
65
79
  static PyObject *
66
80
  img_unfilter(PyObject *self, PyObject *args)
67
81
  {
@@ -81,6 +95,14 @@ img_unfilter(PyObject *self, PyObject *args)
81
95
  for (Py_ssize_t r = 0; r < rows; r++) {
82
96
  if (pos + 1 + stride > in.len) goto truncated;
83
97
  int ft = src[pos];
98
+ if (ft > 4) {
99
+ char message[48];
100
+ Py_DECREF(res); PyBuffer_Release(&in);
101
+ PyOS_snprintf(message, sizeof message,
102
+ "PNG con filtro desconocido %d", ft);
103
+ set_image_error(message);
104
+ return NULL;
105
+ }
84
106
  const unsigned char *line = src + pos + 1;
85
107
  unsigned char *o = out + r * stride;
86
108
  const unsigned char *prev = r ? out + (r - 1) * stride : NULL;
@@ -100,10 +122,7 @@ img_unfilter(PyObject *self, PyObject *args)
100
122
  int pa = abs(p - a), pb = abs(p - b), pc = abs(p - c);
101
123
  pred = (pa <= pb && pa <= pc) ? a : (pb <= pc ? b : c);
102
124
  break; }
103
- default:
104
- Py_DECREF(res); PyBuffer_Release(&in);
105
- PyErr_Format(PyExc_ValueError, "PNG con filtro desconocido %d", ft);
106
- return NULL;
125
+ default: pred = 0; break; /* unreachable: checked above */
107
126
  }
108
127
  o[i] = (unsigned char)((line[i] + pred) & 255);
109
128
  }
@@ -113,12 +132,7 @@ img_unfilter(PyObject *self, PyObject *args)
113
132
  truncated:
114
133
  Py_DECREF(res);
115
134
  PyBuffer_Release(&in);
116
- {
117
- PyObject *mod = PyImport_ImportModule("flexablelib._images");
118
- PyObject *cls = mod ? PyObject_GetAttrString(mod, "ImageError") : NULL;
119
- Py_XDECREF(mod);
120
- if (cls) { PyErr_SetString(cls, "PNG truncado"); Py_DECREF(cls); }
121
- }
135
+ set_image_error("PNG truncado");
122
136
  return NULL;
123
137
  }
124
138
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-speedups
3
- Version: 3.7.0
3
+ Version: 3.7.2
4
4
  Summary: Optional C acceleration of terminal frame drawing for flexablelib (cut, pad, borders, frame diffs, images).
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez