re PR libfortran/27107 (Make dependency on io/io.h broken)
PR libfortran/27107 * runtime/environ.c: Don't include io/io.h. * runtime/string.c: Don't include io/io.h. (compare0): Add cast to avoid warning. * runtime/error.c: Don't include io/io.h. (st_printf): Move to io/unix.c. * intrinsics/flush.c: Delete, contents moved to io/intrinsics.c. * intrinsics/fget.c: Likewise. * intrinsics/ftell.c: Likewise. * intrinsics/tty.c: Likewise. * libgfortran.h (DEFAULT_RECL, notification_std, get_unformatted_convert, IOPARM_*, st_parameter_common, unit_convert, DEFAULT_TEMPDIR): New declarations. * io/io.h (DEFAULT_RECL, notification_std, get_unformatted_convert, IOPARM_*, st_parameter_common, unit_convert, DEFAULT_TEMPDIR): Move to libgfortran.h. * io/unix.c: Add io/unix.h content. (st_printf): New function. * io/intrinsics.c: New file. * io/unix.h: Remove, contents moved into unix.c. * libtool-version: Update library version to 3.0.0. * configure.ac: Update library version to 0.3. * Makefile.am (intrinsics/fget.c, intrinsics/flush.c, intrinsics/ftell.c, intrinsics/tty.c, libgfortran.h): Remove targets. * Makefile.in: Regenerate. * configure: Regenerate. From-SVN: r120869
This commit is contained in:
parent
e7fd0be47b
commit
0dce3ca161
17 changed files with 462 additions and 580 deletions
|
@ -37,8 +37,6 @@ Boston, MA 02110-1301, USA. */
|
|||
#include <errno.h>
|
||||
|
||||
#include "libgfortran.h"
|
||||
#include "../io/io.h"
|
||||
#include "../io/unix.h"
|
||||
|
||||
/* Error conditions. The tricky part here is printing a message when
|
||||
* it is the I/O subsystem that is severely wounded. Our goal is to
|
||||
|
@ -122,104 +120,6 @@ xtoa (GFC_UINTEGER_LARGEST n, char *buffer, size_t len)
|
|||
}
|
||||
|
||||
|
||||
/* st_printf()-- simple printf() function for streams that handles the
|
||||
* formats %d, %s and %c. This function handles printing of error
|
||||
* messages that originate within the library itself, not from a user
|
||||
* program. */
|
||||
|
||||
int
|
||||
st_printf (const char *format, ...)
|
||||
{
|
||||
int count, total;
|
||||
va_list arg;
|
||||
char *p;
|
||||
const char *q;
|
||||
stream *s;
|
||||
char itoa_buf[GFC_ITOA_BUF_SIZE];
|
||||
unix_stream err_stream;
|
||||
|
||||
total = 0;
|
||||
s = init_error_stream (&err_stream);
|
||||
va_start (arg, format);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
count = 0;
|
||||
|
||||
while (format[count] != '%' && format[count] != '\0')
|
||||
count++;
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
p = salloc_w (s, &count);
|
||||
memmove (p, format, count);
|
||||
sfree (s);
|
||||
}
|
||||
|
||||
total += count;
|
||||
format += count;
|
||||
if (*format++ == '\0')
|
||||
break;
|
||||
|
||||
switch (*format)
|
||||
{
|
||||
case 'c':
|
||||
count = 1;
|
||||
|
||||
p = salloc_w (s, &count);
|
||||
*p = (char) va_arg (arg, int);
|
||||
|
||||
sfree (s);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
q = gfc_itoa (va_arg (arg, int), itoa_buf, sizeof (itoa_buf));
|
||||
count = strlen (q);
|
||||
|
||||
p = salloc_w (s, &count);
|
||||
memmove (p, q, count);
|
||||
sfree (s);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
q = xtoa (va_arg (arg, unsigned), itoa_buf, sizeof (itoa_buf));
|
||||
count = strlen (q);
|
||||
|
||||
p = salloc_w (s, &count);
|
||||
memmove (p, q, count);
|
||||
sfree (s);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
q = va_arg (arg, char *);
|
||||
count = strlen (q);
|
||||
|
||||
p = salloc_w (s, &count);
|
||||
memmove (p, q, count);
|
||||
sfree (s);
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
return total;
|
||||
|
||||
default:
|
||||
count = 2;
|
||||
p = salloc_w (s, &count);
|
||||
p[0] = format[-1];
|
||||
p[1] = format[0];
|
||||
sfree (s);
|
||||
break;
|
||||
}
|
||||
|
||||
total += count;
|
||||
format++;
|
||||
}
|
||||
|
||||
va_end (arg);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
/* st_sprintf()-- Simple sprintf() for formatting memory buffers. */
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue