From a97e36d21ea94b4aeb0539d711396ea653a60e41 Mon Sep 17 00:00:00 2001 From: Rick Bird Date: Sun, 17 Apr 2011 15:12:59 -0400 Subject: [PATCH] Changed all RESTRICT keywords to C99 restrict Issue refs #238 --- hdrs/attrib.h | 12 ++++++------ hdrs/externs.h | 18 +++++++++--------- hdrs/mushtype.h | 1 + src/attrib.c | 6 +++--- src/funmath.c | 4 ++-- src/ident.c | 2 +- src/strutil.c | 10 +++++----- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/hdrs/attrib.h b/hdrs/attrib.h index 26b90d5..3e4c30f 100644 --- a/hdrs/attrib.h +++ b/hdrs/attrib.h @@ -63,12 +63,12 @@ typedef enum { extern int good_atr_name(char const *s); extern ATTR *atr_match(char const *string); extern ATTR *atr_sub_branch(ATTR *branch); -extern void atr_new_add(dbref thing, char const *RESTRICT atr, - char const *RESTRICT s, dbref player, unsigned int flags, +extern void atr_new_add(dbref thing, char const *restrict atr, + char const *restrict s, dbref player, unsigned int flags, unsigned char derefs, boolexp wlock, boolexp rlock, time_t modtime); -extern atr_err atr_add(dbref thing, char const *RESTRICT atr, - char const *RESTRICT s, dbref player, unsigned int flags); +extern atr_err atr_add(dbref thing, char const *restrict atr, + char const *restrict s, dbref player, unsigned int flags); extern atr_err atr_clr(dbref thing, char const *atr, dbref player); extern atr_err wipe_atr(dbref thing, char const *atr, dbref player); extern ATTR *atr_get(dbref thing, char const *atr); @@ -88,8 +88,8 @@ extern int atr_comm_divmatch(dbref thing, dbref player, int type, int end, char **abp, dbref *errobj); extern int one_comm_match(dbref thing, dbref player, const char *atr, const char *str); -extern int do_set_atr(dbref thing, char const *RESTRICT atr, - char const *RESTRICT s, dbref player, unsigned int flags); +extern int do_set_atr(dbref thing, char const *restrict atr, + char const *restrict s, dbref player, unsigned int flags); extern void do_atrlock(dbref player, char const *arg1, char const *arg2, char write_lock); extern void do_atrchown(dbref player, char const *arg1, char const *arg2); extern int string_to_atrflag(dbref player, char const *p, privbits *bits); diff --git a/hdrs/externs.h b/hdrs/externs.h index 99bd8da..eac9013 100644 --- a/hdrs/externs.h +++ b/hdrs/externs.h @@ -476,8 +476,8 @@ extern void s_Pennies(dbref thing, int amount); /* From strutil.c */ extern char *split_token(char **sp, char sep); extern char *chopstr(const char *str, size_t lim); -extern int string_prefix(const char *RESTRICT string, - const char *RESTRICT prefix); +extern int string_prefix(const char *restrict string, + const char *restrict prefix); extern const char *string_match(const char *src, const char *sub); extern char *strupper(const char *s); extern char *strlower(const char *s); @@ -521,7 +521,7 @@ strdup(const char *s) __attribute_malloc__; ((*(bp) - (buf) >= BUFFER_LEN - 1) ? \ 1 : (*(*(bp))++ = (x), 0)) /* Like sprintf */ - extern int safe_format(char *buff, char **bp, const char *RESTRICT fmt, ...) + 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(intmax_t i, char *buff, char **bp); @@ -546,17 +546,17 @@ strdup(const char *s) __attribute_malloc__; /* Append N copies of the character X to the end of a string */ extern int safe_fill(char x, size_t n, char *buff, char **bp); /* Append an accented string */ - extern int safe_accent(const char *RESTRICT base, - const char *RESTRICT tmplate, size_t len, char *buff, + extern int safe_accent(const char *restrict base, + const char *restrict tmplate, size_t len, char *buff, char **bp); - extern char *str_escaped_chr(const char *RESTRICT string, char escape_chr); + extern char *str_escaped_chr(const char *restrict string, char escape_chr); extern char *mush_strncpy(char *restrict, const char *, size_t); extern char *replace_string - (const char *RESTRICT old, const char *RESTRICT newbit, - const char *RESTRICT string) __attribute_malloc__; + (const char *restrict old, const char *restrict newbit, + const char *restrict string) __attribute_malloc__; extern char *replace_string2(const char *old[2], const char *newbits[2], - const char *RESTRICT string) + const char *restrict string) __attribute_malloc__; extern const char *standard_tokens[2]; /* ## and #@ */ extern char *trim_space_sep(char *str, char sep); diff --git a/hdrs/mushtype.h b/hdrs/mushtype.h index 8b6df5a..ef92e16 100644 --- a/hdrs/mushtype.h +++ b/hdrs/mushtype.h @@ -5,6 +5,7 @@ #include #endif #include +#include /* Connect Flags */ /** Default connection, nothing special */ diff --git a/src/attrib.c b/src/attrib.c index d2109c1..24f59cb 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -517,7 +517,7 @@ create_atr(dbref thing, char const *atr_name, const ATTR *hint) * \param derefs the initial deref count to use for the attribute value. */ void -atr_new_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, +atr_new_add(dbref thing, const char *restrict atr, const char *restrict s, dbref player, uint32_t flags, uint8_t derefs, boolexp wlock, boolexp rlock, time_t modtime) { @@ -614,7 +614,7 @@ atr_new_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, */ atr_err -atr_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, +atr_add(dbref thing, const char *restrict atr, const char *restrict s, dbref player, uint32_t flags) { ATTR *ptr, *root = NULL; @@ -1829,7 +1829,7 @@ one_comm_match(dbref thing, dbref player, const char *atr, const char *str) * \retval 1 success. */ int -do_set_atr(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, +do_set_atr(dbref thing, const char *restrict atr, const char *restrict s, dbref player, uint32_t flags) { ATTR *old; diff --git a/src/funmath.c b/src/funmath.c index a54fd18..4635fe3 100644 --- a/src/funmath.c +++ b/src/funmath.c @@ -37,7 +37,7 @@ static NVAL find_median(NVAL *, int); static NVAL angle_to_rad(NVAL angle, const char *from); static NVAL rad_to_angle(NVAL angle, const char *to); -static double frac(double v, double *RESTRICT n, double *RESTRICT d, +static double frac(double v, double *restrict n, double *RESTRICT d, double error); int format_long(intmax_t n, char *buff, char **bp, int maxlen, int base); @@ -1264,7 +1264,7 @@ FUNCTION(fun_root) * \return -1.0 if (v < MIN || v > MAX || error < 0.0) | (v - n/d) / v | otherwise. */ static double -frac(double v, double *RESTRICT n, double *RESTRICT d, double error) +frac(double v, double *restrict n, double *RESTRICT d, double error) { /* Based on a routine found in netlib (http://www.netlib.org) by diff --git a/src/ident.c b/src/ident.c index cdab44a..daa6011 100644 --- a/src/ident.c +++ b/src/ident.c @@ -345,7 +345,7 @@ id_query(ident_t *id, struct sockaddr *laddr, socklen_t llen, ** Fiddling: Pär Emanuelsson */ static char * -xstrtok(char *RESTRICT cp, const char *RESTRICT cs, char *RESTRICT dc) +xstrtok(char *restrict cp, const char *restrict cs, char *restrict dc) { static char *bp = 0; diff --git a/src/strutil.c b/src/strutil.c index 6b262e0..84d03ed 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -157,7 +157,7 @@ strncasecmp(const char *s1, const char *s2, size_t n) * \retval 0 string does not begin with prefix. */ int -string_prefix(const char *RESTRICT string, const char *RESTRICT prefix) +string_prefix(const char *restrict string, const char *restrict prefix) { if (!string || !prefix) return 0; @@ -275,7 +275,7 @@ upcasestr(char *s) * \retval 0 success. */ int -safe_accent(const char *RESTRICT base, const char *RESTRICT tmplate, size_t len, +safe_accent(const char *restrict base, const char *restrict tmplate, size_t len, char *buff, char **bp) { /* base and tmplate must be the same length */ @@ -627,7 +627,7 @@ safe_accent(const char *RESTRICT base, const char *RESTRICT tmplate, size_t len, * \return number of characters left over, or 0 for success. */ int -safe_format(char *buff, char **bp, const char *RESTRICT fmt, ...) +safe_format(char *buff, char **bp, const char *restrict fmt, ...) { APPEND_ARGS; #ifdef HAS_VSNPRINTF @@ -1008,7 +1008,7 @@ replace_string2(const char *old[2], const char *newbits[2], * \return pointer to the start of the string */ char * -copy_up_to(char *RESTRICT dest, const char *RESTRICT src, char c) +copy_up_to(char *restrict dest, const char *restrict src, char c) { char *d; d = dest; @@ -1574,7 +1574,7 @@ show_tm(struct tm *when) } char * -str_escaped_chr(const char *RESTRICT string, char escape_chr) +str_escaped_chr(const char *restrict string, char escape_chr) { const char *p; char *result, *r; -- 2.30.2