Add g_strsignal() to string_calls module
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user