diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-08-08 22:39:54 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-08-08 23:21:35 -0700 |
commit | 1ed63b5d0630a4b5b4a8d31174d9f3e95a970913 (patch) | |
tree | 47373d65dd7495380858f848fda5368d1dcb180c /missing | |
parent | dfcccf43766e22aec8793b0a3f963d5ec5a52b80 (diff) | |
download | tcpdump-1ed63b5d0630a4b5b4a8d31174d9f3e95a970913.tar.gz |
Remove more old-compiler compensation.
We require an environment with a C99-compatible snprintf(), so we don't
need to work around older implementations. Make the configuration
process fail if we don't have snprintf() and vsnprintf().
We require at least VS 2015, so we don't have to check for _MSC_VER >=
1400. Make the build fail if we don't have at least VS 2015.
We apparently do, however, have to use __inline, as the VS 2015
documentation doesn't meaning plain old "inline". Update a comment.
Diffstat (limited to 'missing')
-rw-r--r-- | missing/getservent.c | 4 | ||||
-rw-r--r-- | missing/snprintf.c | 115 | ||||
-rw-r--r-- | missing/win_ether_ntohost.c | 4 |
3 files changed, 4 insertions, 119 deletions
diff --git a/missing/getservent.c b/missing/getservent.c index 198644f2..39cee068 100644 --- a/missing/getservent.c +++ b/missing/getservent.c @@ -65,9 +65,9 @@ const char *etc_path(const char *file) return (file); else #ifdef _WIN32 - nd_snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file); + snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file); #else - nd_snprintf(path, sizeof(path), "%s%s", env, file); + snprintf(path, sizeof(path), "%s%s", env, file); #endif return (path); } diff --git a/missing/snprintf.c b/missing/snprintf.c index 3b21f31f..2f12cf16 100644 --- a/missing/snprintf.c +++ b/missing/snprintf.c @@ -67,25 +67,6 @@ struct state { /* XXX - methods */ }; -#ifndef HAVE_VSNPRINTF -static int -sn_reserve (struct state *state, size_t n) -{ - return state->s + n > state->theend; -} - -static int -sn_append_char (struct state *state, unsigned char c) -{ - if (sn_reserve (state, 1)) { - return 1; - } else { - *state->s++ = c; - return 0; - } -} -#endif - #if 0 static int as_reserve (struct state *state, size_t n) @@ -454,37 +435,6 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) return 0; } -#ifndef HAVE_SNPRINTF -int -nd_snprintf (char *str, size_t sz, const char *format, ...) -{ - va_list args; - int ret; - - va_start(args, format); - ret = nd_vsnprintf (str, sz, format, args); - -#ifdef PARANOIA - { - int ret2; - char *tmp; - - tmp = malloc (sz); - if (tmp == NULL) - abort (); - - ret2 = vsprintf (tmp, format, args); - if (ret != ret2 || strcmp(str, tmp)) - abort (); - free (tmp); - } -#endif - - va_end(args); - return ret; -} -#endif - #if 0 #ifndef HAVE_ASPRINTF int @@ -516,45 +466,6 @@ asprintf (char **ret, const char *format, ...) } #endif -#ifndef HAVE_ASNPRINTF -int -nd_asnprintf (char **ret, size_t max_sz, const char *format, ...) -{ - va_list args; - int val; - - va_start(args, format); - val = nd_vasnprintf (ret, max_sz, format, args); - -#ifdef PARANOIA - { - int ret2; - char *tmp; - tmp = malloc (val + 1); - if (tmp == NULL) - abort (); - - ret2 = vsprintf (tmp, format, args); - if (val != ret2 || strcmp(*ret, tmp)) - abort (); - free (tmp); - } -#endif - - va_end(args); - return val; -} -#endif - -#ifndef HAVE_VASPRINTF -int -vasprintf (char **ret, const char *format, va_list args) -{ - return nd_vasnprintf (ret, 0, format, args); -} -#endif - - #ifndef HAVE_VASNPRINTF int nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) @@ -597,29 +508,3 @@ nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) } #endif #endif - -#ifndef HAVE_VSNPRINTF -int -nd_vsnprintf (char *str, size_t sz, const char *format, va_list args) -{ - struct state state; - int ret; - unsigned char *ustr = (unsigned char *)str; - - state.max_sz = 0; - state.sz = sz; - state.str = ustr; - state.s = ustr; - state.theend = ustr + sz - 1; - state.append_char = sn_append_char; - state.reserve = sn_reserve; - - ret = xyzprintf (&state, format, args); - *state.s = '\0'; - if (ret) - return sz; - else - return state.s - state.str; -} -#endif - diff --git a/missing/win_ether_ntohost.c b/missing/win_ether_ntohost.c index 6ac26b7c..05930923 100644 --- a/missing/win_ether_ntohost.c +++ b/missing/win_ether_ntohost.c @@ -85,9 +85,9 @@ const char *etc_path (const char *file) return (file); if (win9x) - nd_snprintf (path, sizeof(path), "%s\\etc\\%s", env, file); + snprintf (path, sizeof(path), "%s\\etc\\%s", env, file); else - nd_snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file); + snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file); return (path); } |