|
42 | 42 | #undef CLAMP |
43 | 43 | #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) |
44 | 44 |
|
| 45 | +/* expat 2.9.0 deprecates the line and column functions in favor of 64-bit |
| 46 | + versions, but a system expat (ASTROPY_USE_SYSTEM_EXPAT) may be older. */ |
| 47 | +#if XML_MAJOR_VERSION > 2 || (XML_MAJOR_VERSION == 2 && XML_MINOR_VERSION >= 9) |
| 48 | +#define GET_LINE_NUMBER XML_GetCurrentLineNumber64 |
| 49 | +#define GET_COLUMN_NUMBER XML_GetCurrentColumnNumber64 |
| 50 | +#else |
| 51 | +#define GET_LINE_NUMBER XML_GetCurrentLineNumber |
| 52 | +#define GET_COLUMN_NUMBER XML_GetCurrentColumnNumber |
| 53 | +#endif |
| 54 | + |
45 | 55 | static Py_ssize_t next_power_of_2(Py_ssize_t n) |
46 | 56 | { |
47 | 57 | /* Calculate the next-higher power of two that is >= 'n' */ |
@@ -445,8 +455,8 @@ static void startElement(IterParser *self, const XML_Char *name, const XML_Char |
445 | 455 | PyTuple_SetItem(tuple, 2, pyatts); |
446 | 456 | pyatts = NULL; |
447 | 457 |
|
448 | | - self->last_line = (unsigned long)XML_GetCurrentLineNumber(self->parser); |
449 | | - self->last_col = (unsigned long)XML_GetCurrentColumnNumber(self->parser); |
| 458 | + self->last_line = (unsigned long)GET_LINE_NUMBER(self->parser); |
| 459 | + self->last_col = (unsigned long)GET_COLUMN_NUMBER(self->parser); |
450 | 460 |
|
451 | 461 | pos = make_pos(self); |
452 | 462 | if (pos == NULL) { |
@@ -584,8 +594,8 @@ static void characterData(IterParser *self, const XML_Char *text, int len) |
584 | 594 | } |
585 | 595 |
|
586 | 596 | if (self->text_size == 0) { |
587 | | - self->last_line = (unsigned long)XML_GetCurrentLineNumber(self->parser); |
588 | | - self->last_col = (unsigned long)XML_GetCurrentColumnNumber(self->parser); |
| 597 | + self->last_line = (unsigned long)GET_LINE_NUMBER(self->parser); |
| 598 | + self->last_col = (unsigned long)GET_COLUMN_NUMBER(self->parser); |
589 | 599 | } |
590 | 600 |
|
591 | 601 | if (self->keep_text) { |
@@ -663,8 +673,8 @@ static void xmlDecl( |
663 | 673 | PyTuple_SetItem(tuple, 2, attrs); |
664 | 674 | attrs = NULL; |
665 | 675 |
|
666 | | - self->last_line = (unsigned long)XML_GetCurrentLineNumber(self->parser); |
667 | | - self->last_col = (unsigned long)XML_GetCurrentColumnNumber(self->parser); |
| 676 | + self->last_line = (unsigned long)GET_LINE_NUMBER(self->parser); |
| 677 | + self->last_col = (unsigned long)GET_COLUMN_NUMBER(self->parser); |
668 | 678 |
|
669 | 679 | pos = make_pos(self); |
670 | 680 | if (pos == NULL) { |
@@ -797,8 +807,8 @@ static PyObject *IterParser_next(PyObject *selfO) |
797 | 807 | PyErr_Format( |
798 | 808 | PyExc_ValueError, |
799 | 809 | "%lu:%lu: %s", |
800 | | - XML_GetCurrentLineNumber(self->parser), |
801 | | - XML_GetCurrentColumnNumber(self->parser), |
| 810 | + (unsigned long)GET_LINE_NUMBER(self->parser), |
| 811 | + (unsigned long)GET_COLUMN_NUMBER(self->parser), |
802 | 812 | XML_ErrorString(XML_GetErrorCode(self->parser)) |
803 | 813 | ); |
804 | 814 | goto fail; |
|
0 commit comments