X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/62f19c197d32e8773a284616d575686d87903b7d..b2e4ca7d12b306cd15d4ec24ce7749db56729e2b:/src/doprnt.c diff --git a/src/doprnt.c b/src/doprnt.c index dae1dab04d..b8eb0f0719 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -1,7 +1,7 @@ /* Output like sprintf to a buffer of specified size. Also takes args differently: pass one pointer to the end of the format string in addition to the format string itself. - Copyright (C) 1985, 2001-2011 Free Software Foundation, Inc. + Copyright (C) 1985, 2001-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -26,7 +26,7 @@ along with GNU Emacs. If not, see . */ of the (`int') argument, suitable for display in an Emacs buffer. . For %s and %c, when field width is specified (e.g., %25s), it accounts for - the diplay width of each character, according to char-width-table. That + the display width of each character, according to char-width-table. That is, it does not assume that each character takes one column on display. . If the size of the buffer is not enough to produce the formatted string in @@ -347,7 +347,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, case 'e': case 'g': { - double d = va_arg(ap, double); + double d = va_arg (ap, double); sprintf (sprintf_buffer, fmtcpy, d); /* Now copy into final output, truncating as necessary. */ string = sprintf_buffer; @@ -427,7 +427,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, case 'c': { - int chr = va_arg(ap, int); + int chr = va_arg (ap, int); tem = CHAR_STRING (chr, (unsigned char *) charbuf); string = charbuf; string[tem] = 0; @@ -486,26 +486,7 @@ esprintf (char *buf, char const *format, ...) return nbytes; } -/* Format to a buffer BUF of positive size BUFSIZE. This is like - snprintf, except it is not limited to returning an 'int' so it - doesn't have a silly 2 GiB limit on typical 64-bit hosts. However, - it is limited to the Emacs-style formats that doprnt supports, and - BUFSIZE must be positive. - - Return the number of bytes put into BUF, excluding the terminating - '\0'. Unlike snprintf, always return a nonnegative value less than - BUFSIZE; if the output is truncated, return BUFSIZE - 1, which is - the length of the truncated output. */ -ptrdiff_t -esnprintf (char *buf, ptrdiff_t bufsize, char const *format, ...) -{ - ptrdiff_t nbytes; - va_list ap; - va_start (ap, format); - nbytes = doprnt (buf, bufsize, format, 0, ap); - va_end (ap); - return nbytes; -} +#if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT /* Format to buffer *BUF of positive size *BUFSIZE, reallocating *BUF and updating *BUFSIZE if the buffer is too small, and otherwise @@ -526,6 +507,8 @@ exprintf (char **buf, ptrdiff_t *bufsize, return nbytes; } +#endif + /* Act like exprintf, except take a va_list. */ ptrdiff_t evxprintf (char **buf, ptrdiff_t *bufsize,