re PR libfortran/32858 (printf-capabilities for runtime_error())
2007-07-29 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/32858 PR libfortran/30814 * configure.ac: Added checks for presence of stdio.h and stdarg.h. Test presence of vsnprintf(). * configure: Regenerated. * config.h.in: Regenerated. * libgfortran.h: Include <stdio.h>. Add printf attribute to prototype of runtime_error. Remove prototype for st_sprintf. Add prototype for st_vprintf. * runtime/main.c (store_exec_path): Replace st_sprintf by sprintf. * runtime/error.c (st_sprintf): Remove. (runtime_error): Rewrite as a variadic function. Call st_vprintf(). * intrinsics/pack_generic.c: Output extents of LHS and RHS for bounds error. * io/open.c (new_unit): Replace st_sprintf by sprintf. * io/list_read.c (convert_integer): Likewise. (parse_repeat): Likewise. (read_logical): Likewise. (read_character): Likewise. (parse_real): Likewise. (read_real): Likewise. (check_type): Likewise. (nml_parse_qualifyer): Likewise. (nml_read_obj): Likewise. (nml_get_ojb_data): Likewise. * io/unix.c (init_error_stream): Remove. (tempfile): Replace st_sprintf by sprintf. (st_vprintf): New function. (st_printf): Rewrite to call st_vprintf. * io/transfer.c (require_type): Replace st_sprintf by sprintf. * io/format.c (format_error): Likewise. * io/write.c (nml_write_obj): Likewise. 2007-07-29 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/32858 PR libfortran/30814 * gfortran.dg/pack_bounds_1.f90: Adjust to new error message. From-SVN: r127049
This commit is contained in:
parent
6a56381bf7
commit
d8163f5cc0
16 changed files with 193 additions and 259 deletions
|
@ -185,63 +185,6 @@ xtoa (GFC_UINTEGER_LARGEST n, char *buffer, size_t len)
|
|||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* st_sprintf()-- Simple sprintf() for formatting memory buffers. */
|
||||
|
||||
void
|
||||
st_sprintf (char *buffer, const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char c;
|
||||
const char *p;
|
||||
int count;
|
||||
char itoa_buf[GFC_ITOA_BUF_SIZE];
|
||||
|
||||
va_start (arg, format);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c = *format++;
|
||||
if (c != '%')
|
||||
{
|
||||
*buffer++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
c = *format++;
|
||||
switch (c)
|
||||
{
|
||||
case 'c':
|
||||
*buffer++ = (char) va_arg (arg, int);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
p = gfc_itoa (va_arg (arg, int), itoa_buf, sizeof (itoa_buf));
|
||||
count = strlen (p);
|
||||
|
||||
memcpy (buffer, p, count);
|
||||
buffer += count;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
p = va_arg (arg, char *);
|
||||
count = strlen (p);
|
||||
|
||||
memcpy (buffer, p, count);
|
||||
buffer += count;
|
||||
break;
|
||||
|
||||
default:
|
||||
*buffer++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
va_end (arg);
|
||||
}
|
||||
|
||||
|
||||
/* show_locus()-- Print a line number and filename describing where
|
||||
* something went wrong */
|
||||
|
||||
|
@ -306,10 +249,16 @@ iexport(os_error);
|
|||
* invalid fortran program. */
|
||||
|
||||
void
|
||||
runtime_error (const char *message)
|
||||
runtime_error (const char *message, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
recursion_check ();
|
||||
st_printf ("Fortran runtime error: %s\n", message);
|
||||
st_printf ("Fortran runtime error: ");
|
||||
va_start (ap, message);
|
||||
st_vprintf (message, ap);
|
||||
va_end (ap);
|
||||
st_printf ("\n");
|
||||
sys_exit (2);
|
||||
}
|
||||
iexport(runtime_error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue