summaryrefslogtreecommitdiff
path: root/vsnprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'vsnprintf.c')
-rw-r--r--vsnprintf.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/vsnprintf.c b/vsnprintf.c
index bb77e3d1be..ecd5573dd5 100644
--- a/vsnprintf.c
+++ b/vsnprintf.c
@@ -101,23 +101,12 @@
# endif
#endif
-#if defined(__hpux) && !defined(__GNUC__) && !defined(__STDC__)
-#define const
-#endif
-
#if defined(sgi)
#undef __const
#define __const
#endif /* People who don't like const sys_error */
#include <stddef.h>
-#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC)
-#include <string.h>
-#endif
-
-#if !defined(__CYGWIN32__) && defined(__hpux) && !defined(__GNUC__)
-#include <stdlib.h>
-#endif
#ifndef NULL
#define NULL 0
@@ -161,11 +150,13 @@ struct __sbuf {
* _ub, _up, and _ur are used when ungetc() pushes back more characters
* than fit in the current _bf, or when ungetc() pushes back a character
* that does not match the previous one in _bf. When this happens,
- * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
+ * _ub._base becomes non-nil (i.e., a stream has ungetc() data if and only if
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
*
* NB: see WARNING above before changing the layout of this structure!
*/
+struct __suio;
+
typedef struct __sFILE {
unsigned char *_p; /* current position in (some) buffer */
#if 0
@@ -178,8 +169,8 @@ typedef struct __sFILE {
#if 0
size_t _lbfsize; /* 0 or -_bf._size, for inline putc */
#endif
- int (*vwrite)(/* struct __sFILE*, struct __suio * */);
- const char *(*vextra)(/* struct __sFILE*, size_t, void*, long*, int */);
+ int (*vwrite)(struct __sFILE*, struct __suio *);
+ const char *(*vextra)(struct __sFILE*, size_t, void*, long*, int);
} FILE;
@@ -196,7 +187,7 @@ typedef struct __sFILE {
#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
#define __SOPT 0x0400 /* do fseek() optimisation */
#define __SNPT 0x0800 /* do not do fseek() optimisation */
-#define __SOFF 0x1000 /* set iff _offset is in fact correct */
+#define __SOFF 0x1000 /* set if and only if _offset is in fact correct */
#define __SMOD 0x2000 /* true => fgetln modified _p text */
@@ -249,9 +240,7 @@ BSD__sfvwrite(register FILE *fp, register struct __suio *uio)
if ((len = uio->uio_resid) == 0)
return (0);
-#ifndef __hpux
#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
iov = uio->uio_iov;
@@ -561,9 +550,9 @@ BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
int fprec = 0; /* floating point precision */
char expstr[7]; /* buffer for exponent string */
#endif
- u_long MAYBE_UNUSED(ulval); /* integer arguments %[diouxX] */
+ u_long MAYBE_UNUSED(ulval) = 0; /* integer arguments %[diouxX] */
#ifdef _HAVE_SANE_QUAD_
- u_quad_t MAYBE_UNUSED(uqval); /* %q integers */
+ u_quad_t MAYBE_UNUSED(uqval) = 0; /* %q integers */
#endif /* _HAVE_SANE_QUAD_ */
int base; /* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
@@ -823,7 +812,7 @@ reswitch: switch (ch) {
(PRI_EXTRA_MARK_LEN < 1 || \
(*(s) == PRI_EXTRA_MARK[0] && \
(PRI_EXTRA_MARK_LEN == 1 || \
- strncmp((s)+1, PRI_EXTRA_MARK+1, \
+ strncmp((s)+1, &PRI_EXTRA_MARK[1], \
PRI_EXTRA_MARK_LEN-1) == 0)))
#else
# define PRI_EXTRA_MARK_LEN 0
@@ -1266,8 +1255,8 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt, int ch, int *l
}
buf[0] = 0; /* rve - digits may be 0 */
memcpy(buf, digits, rve - digits);
- xfree(digits);
rve = buf + (rve - digits);
+ free(digits);
digits = buf;
if (flags & ALT) { /* Print trailing zeros */
bp = digits + ndigits;