Also takes args differently: pass one pointer to an array of strings
in addition to the format string which is separate.
Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
#include <ctype.h>
+#include <setjmp.h>
#ifdef STDC_HEADERS
#include <float.h>
char *format_end;
int nargs;
char **args;
-{
- return doprnt1 (0, buffer, bufsize, format, format_end, nargs, args);
-}
-
-/* Like doprnt except that strings in ARGS are passed
- as Lisp_Object. */
-
-int
-doprnt_lisp (buffer, bufsize, format, format_end, nargs, args)
- char *buffer;
- register int bufsize;
- char *format;
- char *format_end;
- int nargs;
- char **args;
-{
- return doprnt1 (1, buffer, bufsize, format, format_end, nargs, args);
-}
-
-static int
-doprnt1 (lispstrings, buffer, bufsize, format, format_end, nargs, args)
- int lispstrings;
- char *buffer;
- register int bufsize;
- char *format;
- char *format_end;
- int nargs;
- char **args;
{
int cnt = 0; /* Number of arg to gobble next */
register char *fmt = format; /* Pointer into format string */
char fixed_buffer[20]; /* Default buffer for small formatting. */
char *fmtcpy;
int minlen;
- unsigned char charbuf[5]; /* Used for %c. */
+ unsigned char charbuf[MAX_MULTIBYTE_LENGTH + 1]; /* Used for %c. */
if (format_end == 0)
format_end = format + strlen (format);
unsigned n = *fmt - '0';
while ('0' <= fmt[1] && fmt[1] <= '9')
{
- if (n * 10 / 10 != n
- || (n = n * 10 + (fmt[1] - '0')) < n)
+ if (n * 10 + fmt[1] - '0' < n)
error ("Format width or precision too large");
+ n = n * 10 + fmt[1] - '0';
*string++ = *++fmt;
}
error ("Not enough arguments for format string");
if (fmtcpy[1] != 's')
minlen = atoi (&fmtcpy[1]);
- if (lispstrings)
- {
- string = ((struct Lisp_String *) args[cnt])->data;
- tem = STRING_BYTES ((struct Lisp_String *) args[cnt]);
- cnt++;
- }
- else
- {
- string = (unsigned char *) args[cnt++];
- tem = strlen (string);
- }
+ string = (unsigned char *) args[cnt++];
+ tem = strlen (string);
width = strwidth (string, tem);
goto doit1;
};
/* If we had to malloc something, free it. */
- if (big_buffer)
- xfree (big_buffer);
+ xfree (big_buffer);
*bufptr = 0; /* Make sure our string end with a '\0' */
return bufptr - buffer;