X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/5dd6771b28c257af405d7248639ed0e3bcdce38b..4974d09cc659e2859fcf916ad020628c9695e2f8:/sbr/m_name.c diff --git a/sbr/m_name.c b/sbr/m_name.c index 18ee081c..a4b49af8 100644 --- a/sbr/m_name.c +++ b/sbr/m_name.c @@ -1,23 +1,25 @@ - -/* - * m_name.c -- return a message number as a string +/* m_name.c -- return a message number as a string * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ +#include #include -static char name[BUFSIZ]; - +#define STR(s) #s +#define SIZE(n) (sizeof STR(n)) /* Includes NUL. */ char * m_name (int num) { + static char name[SIZE(INT_MAX)]; + if (num <= 0) return "?"; - snprintf (name, sizeof(name), "%d", num); + snprintf(name, sizeof name, "%d", num); + return name; }