| 1 |
688 |
jeremybenn |
typedef __SIZE_TYPE__ size_t;
|
| 2 |
|
|
typedef unsigned char Bufbyte;
|
| 3 |
|
|
typedef int Bytecount;
|
| 4 |
|
|
typedef int Charcount;
|
| 5 |
|
|
typedef struct lstream Lstream;
|
| 6 |
|
|
typedef int Lisp_Object;
|
| 7 |
|
|
extern Lisp_Object Qnil;
|
| 8 |
|
|
extern inline int
|
| 9 |
|
|
TRUE_LIST_P (Lisp_Object object)
|
| 10 |
|
|
{
|
| 11 |
|
|
return (( object ) == ( Qnil )) ;
|
| 12 |
|
|
}
|
| 13 |
|
|
struct Lisp_String
|
| 14 |
|
|
{
|
| 15 |
|
|
Bytecount _size;
|
| 16 |
|
|
Bufbyte *_data;
|
| 17 |
|
|
};
|
| 18 |
|
|
typedef enum lstream_buffering
|
| 19 |
|
|
{
|
| 20 |
|
|
LSTREAM_LINE_BUFFERED,
|
| 21 |
|
|
} Lstream_buffering;
|
| 22 |
|
|
struct lstream
|
| 23 |
|
|
{
|
| 24 |
|
|
Lstream_buffering buffering;
|
| 25 |
|
|
unsigned char *out_buffer;
|
| 26 |
|
|
size_t out_buffer_size;
|
| 27 |
|
|
size_t out_buffer_ind;
|
| 28 |
|
|
size_t byte_count;
|
| 29 |
|
|
long flags;
|
| 30 |
|
|
char data[1];
|
| 31 |
|
|
};
|
| 32 |
|
|
typedef struct printf_spec printf_spec;
|
| 33 |
|
|
struct printf_spec
|
| 34 |
|
|
{
|
| 35 |
|
|
};
|
| 36 |
|
|
typedef union printf_arg printf_arg;
|
| 37 |
|
|
union printf_arg
|
| 38 |
|
|
{
|
| 39 |
|
|
};
|
| 40 |
|
|
typedef struct
|
| 41 |
|
|
{
|
| 42 |
|
|
int cur;
|
| 43 |
|
|
} printf_spec_dynarr;
|
| 44 |
|
|
typedef struct
|
| 45 |
|
|
{
|
| 46 |
|
|
} printf_arg_dynarr;
|
| 47 |
|
|
static void
|
| 48 |
|
|
doprnt_1 (Lisp_Object stream, const Bufbyte *string, Bytecount len,
|
| 49 |
|
|
Charcount minlen, Charcount maxlen, int minus_flag, int zero_flag)
|
| 50 |
|
|
{
|
| 51 |
|
|
Charcount cclen;
|
| 52 |
|
|
Bufbyte pad;
|
| 53 |
|
|
Lstream *lstr = (( struct lstream *) ((void *)(((( stream ) & ((1UL << ((4 * 8 ) - 4 ) ) - 1UL) ) ) | 0x40000000 )) ) ;
|
| 54 |
|
|
cclen = ( len ) ;
|
| 55 |
|
|
if (zero_flag)
|
| 56 |
|
|
pad = '0';
|
| 57 |
|
|
pad = ' ';
|
| 58 |
|
|
#if 0
|
| 59 |
|
|
if (minlen > cclen && !minus_flag)
|
| 60 |
|
|
#endif
|
| 61 |
|
|
{
|
| 62 |
|
|
int to_add = minlen - cclen;
|
| 63 |
|
|
while (to_add > 0)
|
| 64 |
|
|
{
|
| 65 |
|
|
(( lstr )->out_buffer_ind >= ( lstr )->out_buffer_size ? Lstream_fputc ( lstr , pad ) : (( lstr )->out_buffer[( lstr )->out_buffer_ind++] = (unsigned char) ( pad ), ( lstr )->byte_count++, ( lstr )->buffering == LSTREAM_LINE_BUFFERED && ( lstr )->out_buffer[( lstr )->out_buffer_ind - 1] == '\n' ? Lstream_flush_out ( lstr ) : 0)) ;
|
| 66 |
|
|
to_add--;
|
| 67 |
|
|
}
|
| 68 |
|
|
}
|
| 69 |
|
|
if (maxlen >= 0)
|
| 70 |
|
|
len = ( ((( maxlen ) <= ( cclen )) ? ( maxlen ) : ( cclen )) ) ;
|
| 71 |
|
|
Lstream_write (lstr, string, len);
|
| 72 |
|
|
if (minlen > cclen && minus_flag)
|
| 73 |
|
|
{
|
| 74 |
|
|
int to_add = minlen - cclen;
|
| 75 |
|
|
while (to_add > 0)
|
| 76 |
|
|
{
|
| 77 |
|
|
(( lstr )->out_buffer_ind >= ( lstr )->out_buffer_size ? Lstream_fputc ( lstr , pad ) : (( lstr )->out_buffer[( lstr )->out_buffer_ind++] = (unsigned char) ( pad ), ( lstr )->byte_count++, ( lstr )->buffering == LSTREAM_LINE_BUFFERED && ( lstr )->out_buffer[( lstr )->out_buffer_ind - 1] == '\n' ? Lstream_flush_out ( lstr ) : 0)) ;
|
| 78 |
|
|
to_add--;
|
| 79 |
|
|
}
|
| 80 |
|
|
}
|
| 81 |
|
|
}
|
| 82 |
|
|
static Bytecount
|
| 83 |
|
|
emacs_doprnt_1 (Lisp_Object stream, const Bufbyte *format_nonreloc,
|
| 84 |
|
|
Lisp_Object format_reloc, Bytecount format_length,
|
| 85 |
|
|
int nargs,
|
| 86 |
|
|
const Lisp_Object *largs)
|
| 87 |
|
|
{
|
| 88 |
|
|
int i;
|
| 89 |
|
|
printf_spec_dynarr *specs = 0;
|
| 90 |
|
|
format_nonreloc = (( (( struct Lisp_String *) ((void *)(((( format_reloc ) & ((1UL << ((4 * 8 ) - 4 ) ) - 1UL) ) ) | 0x40000000 )) ) )->_data + 0) ;
|
| 91 |
|
|
format_length = (( (( struct Lisp_String *) ((void *)(((( format_reloc ) & ((1UL << ((4 * 8 ) - 4 ) ) - 1UL) ) ) | 0x40000000 )) ) )->_size) ;
|
| 92 |
|
|
specs = parse_doprnt_spec (format_nonreloc, format_length);
|
| 93 |
|
|
for (i = 0; i < (( specs )->cur) ; i++)
|
| 94 |
|
|
{
|
| 95 |
|
|
char ch;
|
| 96 |
|
|
doprnt_1 (stream, (Bufbyte *) &ch, 1, 0, -1, 0, 0);
|
| 97 |
|
|
}
|
| 98 |
|
|
}
|