Add g_strsignal() to string_calls module

This commit is contained in:
matt335672
2023-06-08 15:57:17 +01:00
parent a2798fe9e9
commit 0f32661056
4 changed files with 33 additions and 3 deletions
+24
View File
@@ -422,6 +422,30 @@ g_atoi(const char *str)
return atoi(str);
}
/*****************************************************************************/
char *
g_strsignal(int signum)
{
char *result = strsignal(signum);
if (result == NULL)
{
// Using a static buffer offers the same guarantees as the
// strsignal() call
static char buff[32];
unsigned int len;
len = g_snprintf(buff, sizeof(buff), "SIG#%d", signum);
if (len >= sizeof(buff))
{
// Buffer overflow
g_snprintf(buff, sizeof(buff), "SIG???");
}
result = buff;
}
return result;
}
/*****************************************************************************/
/* As g_atoi() but allows for hexadecimal too */
int