mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-35578 innodb_gis.rtree_debug fails on mac
strerror_s on Linux will, for unknown error codes, display 'Unknown error <codenum>' and our tests are written with this assumption. However, on macOS, sterror_s returns 'Unknown error: <codenum>' in the same case, which breaks tests. Make my_strerror consistent across the platforms by removing the ':' when present.
This commit is contained in:
parent
7b0f59da43
commit
a226f12675
1 changed files with 25 additions and 0 deletions
|
@ -860,6 +860,27 @@ int my_fprintf(FILE *stream, const char* format, ...)
|
|||
}
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* Delete the ':' character added by Apple's implementation of strerror_r */
|
||||
static void delete_colon_char(char *buf)
|
||||
{
|
||||
static const char *unknown_err= "Unknown error";
|
||||
static const size_t unknown_err_len= 13;
|
||||
char *ptr= strstr(buf, unknown_err);
|
||||
char *src= NULL;
|
||||
if (ptr) {
|
||||
ptr+= unknown_err_len;
|
||||
if (*ptr == ':') {
|
||||
// just overwrite the colon by shifting everything down by one,
|
||||
// e.g. "Unknown error: 1000" becomes "Unknown error 1000"
|
||||
src= ptr + 1;
|
||||
memmove(ptr, src, strlen(src) + 1); // include null
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Return system error text for given error number
|
||||
|
||||
|
@ -913,6 +934,10 @@ const char* my_strerror(char *buf, size_t len, int nr)
|
|||
#else
|
||||
strerror_r(nr, buf, len);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
delete_colon_char(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue