From: Ari Johnson Date: Fri, 7 Nov 2008 21:01:32 +0000 (+0000) Subject: Use long integer types in several places, such as unparse_integer() X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=721bd96c170791fabc570fbbcdd424c3adb776ea;p=cobramush.git Use long integer types in several places, such as unparse_integer() --- diff --git a/hdrs/externs.h b/hdrs/externs.h index bdb2a6b..2932d32 100644 --- a/hdrs/externs.h +++ b/hdrs/externs.h @@ -494,11 +494,11 @@ strdup(const char *s) extern int safe_format(char *buff, char **bp, const char *RESTRICT fmt, ...) __attribute__ ((__format__(__printf__, 3, 4))); /* Append an int to the end of a buffer */ - extern int safe_integer(int i, char *buff, char **bp); - extern int safe_uinteger(unsigned int, char *buff, char **bp); + extern int safe_integer(long i, char *buff, char **bp); + extern int safe_uinteger(unsigned long, char *buff, char **bp); /* Same, but for a SBUF_LEN buffer, not BUFFER_LEN */ #define SBUF_LEN 64 /**< A short buffer */ - extern int safe_integer_sbuf(int i, char *buff, char **bp); + extern int safe_integer_sbuf(long i, char *buff, char **bp); /* Append a NVAL to a string */ extern int safe_number(NVAL n, char *buff, char **bp); /* Append a dbref to a buffer */ diff --git a/hdrs/parse.h b/hdrs/parse.h index 6f425a0..dd84c81 100644 --- a/hdrs/parse.h +++ b/hdrs/parse.h @@ -61,8 +61,8 @@ extern dbref parse_objid(char const *str); #define unparse_boolean(x) ((x) ? "1" : "0") char *unparse_dbref(dbref num); -char *unparse_integer(int num); -char *unparse_uinteger(unsigned int num); +char *unparse_integer(long num); +char *unparse_uinteger(unsigned long num); char *unparse_number(NVAL num); char *unparse_types(int type); diff --git a/src/strutil.c b/src/strutil.c index cdb0713..c177da5 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -641,7 +641,7 @@ safe_format(char *buff, char **bp, const char *RESTRICT fmt, ...) * \return 0 on success, non-zero on failure. */ int -safe_integer(int i, char *buff, char **bp) +safe_integer(long i, char *buff, char **bp) { return format_long(i, buff, bp, BUFFER_LEN, 10); } @@ -653,7 +653,7 @@ safe_integer(int i, char *buff, char **bp) * \return 0 on success, non-zero on failure. */ int -safe_uinteger(unsigned int i, char *buff, char **bp) +safe_uinteger(unsigned long i, char *buff, char **bp) { return safe_str(unparse_uinteger(i), buff, bp); } @@ -665,7 +665,7 @@ safe_uinteger(unsigned int i, char *buff, char **bp) * \return 0 on success, non-zero on failure. */ int -safe_integer_sbuf(int i, char *buff, char **bp) +safe_integer_sbuf(long i, char *buff, char **bp) { return format_long(i, buff, bp, SBUF_LEN, 10); } diff --git a/src/unparse.c b/src/unparse.c index cd35e8e..02f14cc 100644 --- a/src/unparse.c +++ b/src/unparse.c @@ -257,7 +257,7 @@ unparse_dbref(dbref num) * \return address of static buffer containing stringified value. */ char * -unparse_integer(int num) +unparse_integer(long num) { static char str[SBUF_LEN]; char *strp; @@ -273,11 +273,11 @@ unparse_integer(int num) * \return address of static buffer containing stringified value. */ char * -unparse_uinteger(unsigned int num) +unparse_uinteger(unsigned long num) { static char str[16]; - sprintf(str, "%u", num); + sprintf(str, "%lu", num); return str; }