comparison src/doprnt.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents 5d09ddada9ae
children e22b0213b713
comparison
equal deleted inserted replaced
866:613552a02607 867:804517e16990
67 union printf_arg 67 union printf_arg
68 { 68 {
69 long l; 69 long l;
70 unsigned long ul; 70 unsigned long ul;
71 double d; 71 double d;
72 Intbyte *bp; 72 Ibyte *bp;
73 }; 73 };
74 74
75 /* We maintain a list of all the % specs in the specification, 75 /* We maintain a list of all the % specs in the specification,
76 along with the offset and length of the block of literal text 76 along with the offset and length of the block of literal text
77 before each spec. In addition, we have a "dummy" spec that 77 before each spec. In addition, we have a "dummy" spec that
97 right to that many characters. 97 right to that many characters.
98 98
99 Note that MINLEN and MAXLEN are Charcounts but LEN is a Bytecount. */ 99 Note that MINLEN and MAXLEN are Charcounts but LEN is a Bytecount. */
100 100
101 static void 101 static void
102 doprnt_2 (Lisp_Object stream, const Intbyte *string, Bytecount len, 102 doprnt_2 (Lisp_Object stream, const Ibyte *string, Bytecount len,
103 Charcount minlen, Charcount maxlen, int minus_flag, int zero_flag) 103 Charcount minlen, Charcount maxlen, int minus_flag, int zero_flag)
104 { 104 {
105 Lstream *lstr = XLSTREAM (stream); 105 Lstream *lstr = XLSTREAM (stream);
106 Charcount cclen = bytecount_to_charcount (string, len); 106 Charcount cclen = bytecount_to_charcount (string, len);
107 int to_add = minlen - cclen; 107 int to_add = minlen - cclen;
119 if (minus_flag) 119 if (minus_flag)
120 while (to_add-- > 0) 120 while (to_add-- > 0)
121 Lstream_putc (lstr, zero_flag ? '0' : ' '); 121 Lstream_putc (lstr, zero_flag ? '0' : ' ');
122 } 122 }
123 123
124 static const Intbyte * 124 static const Ibyte *
125 parse_off_posnum (const Intbyte *start, const Intbyte *end, int *returned_num) 125 parse_off_posnum (const Ibyte *start, const Ibyte *end, int *returned_num)
126 { 126 {
127 Intbyte arg_convert[100]; 127 Ibyte arg_convert[100];
128 REGISTER Intbyte *arg_ptr = arg_convert; 128 REGISTER Ibyte *arg_ptr = arg_convert;
129 129
130 *returned_num = -1; 130 *returned_num = -1;
131 while (start != end && isdigit (*start)) 131 while (start != end && isdigit (*start))
132 { 132 {
133 if (arg_ptr - arg_convert >= (int) sizeof (arg_convert) - 1) 133 if (arg_ptr - arg_convert >= (int) sizeof (arg_convert) - 1)
158 if (spec.zero_flag && spec.space_flag) \ 158 if (spec.zero_flag && spec.space_flag) \
159 spec.zero_flag = 0; \ 159 spec.zero_flag = 0; \
160 } while (0) 160 } while (0)
161 161
162 static printf_spec_dynarr * 162 static printf_spec_dynarr *
163 parse_doprnt_spec (const Intbyte *format, Bytecount format_length) 163 parse_doprnt_spec (const Ibyte *format, Bytecount format_length)
164 { 164 {
165 const Intbyte *fmt = format; 165 const Ibyte *fmt = format;
166 const Intbyte *fmt_end = format + format_length; 166 const Ibyte *fmt_end = format + format_length;
167 printf_spec_dynarr *specs = Dynarr_new (printf_spec); 167 printf_spec_dynarr *specs = Dynarr_new (printf_spec);
168 int prev_argnum = 0; 168 int prev_argnum = 0;
169 169
170 while (1) 170 while (1)
171 { 171 {
172 struct printf_spec spec; 172 struct printf_spec spec;
173 const Intbyte *text_end; 173 const Ibyte *text_end;
174 Intbyte ch; 174 Ibyte ch;
175 175
176 xzero (spec); 176 xzero (spec);
177 if (fmt == fmt_end) 177 if (fmt == fmt_end)
178 return specs; 178 return specs;
179 text_end = (Intbyte *) memchr (fmt, '%', fmt_end - fmt); 179 text_end = (Ibyte *) memchr (fmt, '%', fmt_end - fmt);
180 if (!text_end) 180 if (!text_end)
181 text_end = fmt_end; 181 text_end = fmt_end;
182 spec.text_before = fmt - format; 182 spec.text_before = fmt - format;
183 spec.text_before_len = text_end - fmt; 183 spec.text_before_len = text_end - fmt;
184 fmt = text_end; 184 fmt = text_end;
196 continue; 196 continue;
197 } 197 }
198 198
199 /* Is there a field number specifier? */ 199 /* Is there a field number specifier? */
200 { 200 {
201 const Intbyte *ptr; 201 const Ibyte *ptr;
202 int fieldspec; 202 int fieldspec;
203 203
204 ptr = parse_off_posnum (fmt, fmt_end, &fieldspec); 204 ptr = parse_off_posnum (fmt, fmt_end, &fieldspec);
205 if (fieldspec > 0 && ptr != fmt_end && *ptr == '$') 205 if (fieldspec > 0 && ptr != fmt_end && *ptr == '$')
206 { 206 {
382 arg.ul = (unsigned long) va_arg (vargs, unsigned int); 382 arg.ul = (unsigned long) va_arg (vargs, unsigned int);
383 } 383 }
384 else if (strchr (double_converters, ch)) 384 else if (strchr (double_converters, ch))
385 arg.d = va_arg (vargs, double); 385 arg.d = va_arg (vargs, double);
386 else if (strchr (string_converters, ch)) 386 else if (strchr (string_converters, ch))
387 arg.bp = va_arg (vargs, Intbyte *); 387 arg.bp = va_arg (vargs, Ibyte *);
388 else abort (); 388 else abort ();
389 389
390 Dynarr_add (args, arg); 390 Dynarr_add (args, arg);
391 } 391 }
392 392
403 va_list VARGS, or an array of Lisp objects in LARGS of size 403 va_list VARGS, or an array of Lisp objects in LARGS of size
404 NARGS. (Behavior is different in the two cases -- you either get 404 NARGS. (Behavior is different in the two cases -- you either get
405 standard sprintf() behavior or `format' behavior.) */ 405 standard sprintf() behavior or `format' behavior.) */
406 406
407 static Bytecount 407 static Bytecount
408 emacs_doprnt_1 (Lisp_Object stream, const Intbyte *format_nonreloc, 408 emacs_doprnt_1 (Lisp_Object stream, const Ibyte *format_nonreloc,
409 Bytecount format_length, Lisp_Object format_reloc, 409 Bytecount format_length, Lisp_Object format_reloc,
410 int nargs, const Lisp_Object *largs, va_list vargs) 410 int nargs, const Lisp_Object *largs, va_list vargs)
411 { 411 {
412 printf_spec_dynarr *specs = 0; 412 printf_spec_dynarr *specs = 0;
413 printf_arg_dynarr *args = 0; 413 printf_arg_dynarr *args = 0;
459 if (!ch) 459 if (!ch)
460 continue; 460 continue;
461 461
462 if (ch == '%') 462 if (ch == '%')
463 { 463 {
464 doprnt_2 (stream, (Intbyte *) &ch, 1, 0, -1, 0, 0); 464 doprnt_2 (stream, (Ibyte *) &ch, 1, 0, -1, 0, 0);
465 continue; 465 continue;
466 } 466 }
467 467
468 /* The char '*' as converter means the field width, precision 468 /* The char '*' as converter means the field width, precision
469 was specified as an argument. Extract the data and forward 469 was specified as an argument. Extract the data and forward
502 syntax_error ("Invalid repositioning argument", 502 syntax_error ("Invalid repositioning argument",
503 make_int (spec->argnum)); 503 make_int (spec->argnum));
504 504
505 else if (ch == 'S' || ch == 's') 505 else if (ch == 'S' || ch == 's')
506 { 506 {
507 Intbyte *string; 507 Ibyte *string;
508 Bytecount string_len; 508 Bytecount string_len;
509 509
510 if (!largs) 510 if (!largs)
511 { 511 {
512 string = Dynarr_at (args, spec->argnum - 1).bp; 512 string = Dynarr_at (args, spec->argnum - 1).bp;
518 to signal an error instead? Or should we just use the 518 to signal an error instead? Or should we just use the
519 empty string? -dkindred@cs.cmu.edu 8/1997 ]] 519 empty string? -dkindred@cs.cmu.edu 8/1997 ]]
520 Do not hide bugs. --ben 520 Do not hide bugs. --ben
521 */ 521 */
522 if (!string) 522 if (!string)
523 string = (Intbyte *) "(null)"; 523 string = (Ibyte *) "(null)";
524 #else 524 #else
525 assert (string); 525 assert (string);
526 #endif 526 #endif
527 string_len = strlen ((char *) string); 527 string_len = strlen ((char *) string);
528 } 528 }
589 } 589 }
590 590
591 591
592 if (ch == 'c') 592 if (ch == 'c')
593 { 593 {
594 Emchar a; 594 Ichar a;
595 Bytecount charlen; 595 Bytecount charlen;
596 Intbyte charbuf[MAX_EMCHAR_LEN]; 596 Ibyte charbuf[MAX_ICHAR_LEN];
597 597
598 a = (Emchar) arg.l; 598 a = (Ichar) arg.l;
599 599
600 if (!valid_emchar_p (a)) 600 if (!valid_ichar_p (a))
601 syntax_error ("invalid character value %d to %%c spec", 601 syntax_error ("invalid character value %d to %%c spec",
602 make_int (a)); 602 make_int (a));
603 603
604 charlen = set_charptr_emchar (charbuf, a); 604 charlen = set_itext_ichar (charbuf, a);
605 doprnt_2 (stream, charbuf, charlen, spec->minwidth, 605 doprnt_2 (stream, charbuf, charlen, spec->minwidth,
606 -1, spec->minus_flag, spec->zero_flag); 606 -1, spec->minus_flag, spec->zero_flag);
607 } 607 }
608 else 608 else
609 { 609 {
656 sprintf (text_to_print, constructed_spec, arg.ul); 656 sprintf (text_to_print, constructed_spec, arg.ul);
657 else 657 else
658 sprintf (text_to_print, constructed_spec, arg.l); 658 sprintf (text_to_print, constructed_spec, arg.l);
659 } 659 }
660 660
661 doprnt_2 (stream, (Intbyte *) text_to_print, 661 doprnt_2 (stream, (Ibyte *) text_to_print,
662 strlen (text_to_print), 0, -1, 0, 0); 662 strlen (text_to_print), 0, -1, 0, 0);
663 } 663 }
664 } 664 }
665 } 665 }
666 666
671 /* Basic external entry point into string formatting. See 671 /* Basic external entry point into string formatting. See
672 emacs_doprnt_1(). 672 emacs_doprnt_1().
673 */ 673 */
674 674
675 Bytecount 675 Bytecount
676 emacs_doprnt_va (Lisp_Object stream, const Intbyte *format_nonreloc, 676 emacs_doprnt_va (Lisp_Object stream, const Ibyte *format_nonreloc,
677 Bytecount format_length, Lisp_Object format_reloc, 677 Bytecount format_length, Lisp_Object format_reloc,
678 va_list vargs) 678 va_list vargs)
679 { 679 {
680 return emacs_doprnt_1 (stream, format_nonreloc, format_length, 680 return emacs_doprnt_1 (stream, format_nonreloc, format_length,
681 format_reloc, 0, 0, vargs); 681 format_reloc, 0, 0, vargs);
684 /* Basic external entry point into string formatting. See 684 /* Basic external entry point into string formatting. See
685 emacs_doprnt_1(). 685 emacs_doprnt_1().
686 */ 686 */
687 687
688 Bytecount 688 Bytecount
689 emacs_doprnt (Lisp_Object stream, const Intbyte *format_nonreloc, 689 emacs_doprnt (Lisp_Object stream, const Ibyte *format_nonreloc,
690 Bytecount format_length, Lisp_Object format_reloc, 690 Bytecount format_length, Lisp_Object format_reloc,
691 int nargs, const Lisp_Object *largs, ...) 691 int nargs, const Lisp_Object *largs, ...)
692 { 692 {
693 va_list vargs; 693 va_list vargs;
694 Bytecount val; 694 Bytecount val;
712 #### It shouldn't be necessary to specify the number of arguments. 712 #### It shouldn't be necessary to specify the number of arguments.
713 This would require some rewriting of the doprnt() functions, though. 713 This would require some rewriting of the doprnt() functions, though.
714 */ 714 */
715 715
716 Lisp_Object 716 Lisp_Object
717 emacs_vsprintf_string_lisp (const CIntbyte *format_nonreloc, 717 emacs_vsprintf_string_lisp (const CIbyte *format_nonreloc,
718 Lisp_Object format_reloc, int nargs, 718 Lisp_Object format_reloc, int nargs,
719 const Lisp_Object *largs) 719 const Lisp_Object *largs)
720 { 720 {
721 Lisp_Object stream; 721 Lisp_Object stream;
722 Lisp_Object obj; 722 Lisp_Object obj;
723 struct gcpro gcpro1, gcpro2; 723 struct gcpro gcpro1, gcpro2;
724 GCPRO2 (largs[0], format_reloc); 724 GCPRO2 (largs[0], format_reloc);
725 gcpro1.nvars = nargs; 725 gcpro1.nvars = nargs;
726 726
727 stream = make_resizing_buffer_output_stream (); 727 stream = make_resizing_buffer_output_stream ();
728 emacs_doprnt (stream, (Intbyte *) format_nonreloc, format_nonreloc ? 728 emacs_doprnt (stream, (Ibyte *) format_nonreloc, format_nonreloc ?
729 strlen (format_nonreloc) : 0, 729 strlen (format_nonreloc) : 0,
730 format_reloc, nargs, largs); 730 format_reloc, nargs, largs);
731 Lstream_flush (XLSTREAM (stream)); 731 Lstream_flush (XLSTREAM (stream));
732 obj = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)), 732 obj = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
733 Lstream_byte_count (XLSTREAM (stream))); 733 Lstream_byte_count (XLSTREAM (stream)));
738 738
739 /* Like emacs_vsprintf_string_lisp() but accepts its extra args directly 739 /* Like emacs_vsprintf_string_lisp() but accepts its extra args directly
740 (using variable arguments), rather than as an array. */ 740 (using variable arguments), rather than as an array. */
741 741
742 Lisp_Object 742 Lisp_Object
743 emacs_sprintf_string_lisp (const CIntbyte *format_nonreloc, 743 emacs_sprintf_string_lisp (const CIbyte *format_nonreloc,
744 Lisp_Object format_reloc, int nargs, ...) 744 Lisp_Object format_reloc, int nargs, ...)
745 { 745 {
746 Lisp_Object *args = alloca_array (Lisp_Object, nargs); 746 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
747 va_list va; 747 va_list va;
748 int i; 748 int i;
758 } 758 }
759 759
760 /* Like emacs_vsprintf_string_lisp() but returns a malloc()ed memory block. 760 /* Like emacs_vsprintf_string_lisp() but returns a malloc()ed memory block.
761 Return length out through LEN_OUT, if not null. */ 761 Return length out through LEN_OUT, if not null. */
762 762
763 Intbyte * 763 Ibyte *
764 emacs_vsprintf_malloc_lisp (const CIntbyte *format_nonreloc, 764 emacs_vsprintf_malloc_lisp (const CIbyte *format_nonreloc,
765 Lisp_Object format_reloc, int nargs, 765 Lisp_Object format_reloc, int nargs,
766 const Lisp_Object *largs, Bytecount *len_out) 766 const Lisp_Object *largs, Bytecount *len_out)
767 { 767 {
768 Lisp_Object stream; 768 Lisp_Object stream;
769 Intbyte *retval; 769 Ibyte *retval;
770 Bytecount len; 770 Bytecount len;
771 struct gcpro gcpro1, gcpro2; 771 struct gcpro gcpro1, gcpro2;
772 772
773 GCPRO2 (largs[0], format_reloc); 773 GCPRO2 (largs[0], format_reloc);
774 gcpro1.nvars = nargs; 774 gcpro1.nvars = nargs;
775 775
776 stream = make_resizing_buffer_output_stream (); 776 stream = make_resizing_buffer_output_stream ();
777 emacs_doprnt (stream, (Intbyte *) format_nonreloc, format_nonreloc ? 777 emacs_doprnt (stream, (Ibyte *) format_nonreloc, format_nonreloc ?
778 strlen (format_nonreloc) : 0, 778 strlen (format_nonreloc) : 0,
779 format_reloc, nargs, largs); 779 format_reloc, nargs, largs);
780 Lstream_flush (XLSTREAM (stream)); 780 Lstream_flush (XLSTREAM (stream));
781 len = Lstream_byte_count (XLSTREAM (stream)); 781 len = Lstream_byte_count (XLSTREAM (stream));
782 retval = (Intbyte *) xmalloc (len + 1); 782 retval = (Ibyte *) xmalloc (len + 1);
783 memcpy (retval, resizing_buffer_stream_ptr (XLSTREAM (stream)), len); 783 memcpy (retval, resizing_buffer_stream_ptr (XLSTREAM (stream)), len);
784 retval[len] = '\0'; 784 retval[len] = '\0';
785 Lstream_delete (XLSTREAM (stream)); 785 Lstream_delete (XLSTREAM (stream));
786 786
787 if (len_out) 787 if (len_out)
791 } 791 }
792 792
793 /* Like emacs_sprintf_string_lisp() but returns a malloc()ed memory block. 793 /* Like emacs_sprintf_string_lisp() but returns a malloc()ed memory block.
794 Return length out through LEN_OUT, if not null. */ 794 Return length out through LEN_OUT, if not null. */
795 795
796 Intbyte * 796 Ibyte *
797 emacs_sprintf_malloc_lisp (Bytecount *len_out, const CIntbyte *format_nonreloc, 797 emacs_sprintf_malloc_lisp (Bytecount *len_out, const CIbyte *format_nonreloc,
798 Lisp_Object format_reloc, int nargs, ...) 798 Lisp_Object format_reloc, int nargs, ...)
799 { 799 {
800 Lisp_Object *args = alloca_array (Lisp_Object, nargs); 800 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
801 va_list va; 801 va_list va;
802 int i; 802 int i;
803 Intbyte *retval; 803 Ibyte *retval;
804 804
805 va_start (va, nargs); 805 va_start (va, nargs);
806 for (i = 0; i < nargs; i++) 806 for (i = 0; i < nargs; i++)
807 args[i] = va_arg (va, Lisp_Object); 807 args[i] = va_arg (va, Lisp_Object);
808 va_end (va); 808 va_end (va);
813 813
814 /* vsprintf()-like replacement. Returns a Lisp string. Data 814 /* vsprintf()-like replacement. Returns a Lisp string. Data
815 from Lisp strings is OK because we explicitly inhibit GC. */ 815 from Lisp strings is OK because we explicitly inhibit GC. */
816 816
817 Lisp_Object 817 Lisp_Object
818 emacs_vsprintf_string (const CIntbyte *format, va_list vargs) 818 emacs_vsprintf_string (const CIbyte *format, va_list vargs)
819 { 819 {
820 Lisp_Object stream = make_resizing_buffer_output_stream (); 820 Lisp_Object stream = make_resizing_buffer_output_stream ();
821 Lisp_Object obj; 821 Lisp_Object obj;
822 int count = begin_gc_forbidden (); 822 int count = begin_gc_forbidden ();
823 823
824 emacs_doprnt_va (stream, (Intbyte *) format, strlen (format), Qnil, 824 emacs_doprnt_va (stream, (Ibyte *) format, strlen (format), Qnil,
825 vargs); 825 vargs);
826 Lstream_flush (XLSTREAM (stream)); 826 Lstream_flush (XLSTREAM (stream));
827 obj = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)), 827 obj = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
828 Lstream_byte_count (XLSTREAM (stream))); 828 Lstream_byte_count (XLSTREAM (stream)));
829 Lstream_delete (XLSTREAM (stream)); 829 Lstream_delete (XLSTREAM (stream));
833 833
834 /* sprintf()-like replacement. Returns a Lisp string. Data 834 /* sprintf()-like replacement. Returns a Lisp string. Data
835 from Lisp strings is OK because we explicitly inhibit GC. */ 835 from Lisp strings is OK because we explicitly inhibit GC. */
836 836
837 Lisp_Object 837 Lisp_Object
838 emacs_sprintf_string (const CIntbyte *format, ...) 838 emacs_sprintf_string (const CIbyte *format, ...)
839 { 839 {
840 va_list vargs; 840 va_list vargs;
841 Lisp_Object retval; 841 Lisp_Object retval;
842 842
843 va_start (vargs, format); 843 va_start (vargs, format);
848 848
849 /* vsprintf()-like replacement. Returns a malloc()ed memory block. Data 849 /* vsprintf()-like replacement. Returns a malloc()ed memory block. Data
850 from Lisp strings is OK because we explicitly inhibit GC. Return 850 from Lisp strings is OK because we explicitly inhibit GC. Return
851 length out through LEN_OUT, if not null. */ 851 length out through LEN_OUT, if not null. */
852 852
853 Intbyte * 853 Ibyte *
854 emacs_vsprintf_malloc (const CIntbyte *format, va_list vargs, 854 emacs_vsprintf_malloc (const CIbyte *format, va_list vargs,
855 Bytecount *len_out) 855 Bytecount *len_out)
856 { 856 {
857 int count = begin_gc_forbidden (); 857 int count = begin_gc_forbidden ();
858 Lisp_Object stream = make_resizing_buffer_output_stream (); 858 Lisp_Object stream = make_resizing_buffer_output_stream ();
859 Intbyte *retval; 859 Ibyte *retval;
860 Bytecount len; 860 Bytecount len;
861 861
862 emacs_doprnt_va (stream, (Intbyte *) format, strlen (format), Qnil, 862 emacs_doprnt_va (stream, (Ibyte *) format, strlen (format), Qnil,
863 vargs); 863 vargs);
864 Lstream_flush (XLSTREAM (stream)); 864 Lstream_flush (XLSTREAM (stream));
865 len = Lstream_byte_count (XLSTREAM (stream)); 865 len = Lstream_byte_count (XLSTREAM (stream));
866 retval = (Intbyte *) xmalloc (len + 1); 866 retval = (Ibyte *) xmalloc (len + 1);
867 memcpy (retval, resizing_buffer_stream_ptr (XLSTREAM (stream)), len); 867 memcpy (retval, resizing_buffer_stream_ptr (XLSTREAM (stream)), len);
868 retval[len] = '\0'; 868 retval[len] = '\0';
869 end_gc_forbidden (count); 869 end_gc_forbidden (count);
870 Lstream_delete (XLSTREAM (stream)); 870 Lstream_delete (XLSTREAM (stream));
871 871
876 876
877 /* sprintf()-like replacement. Returns a malloc()ed memory block. Data 877 /* sprintf()-like replacement. Returns a malloc()ed memory block. Data
878 from Lisp strings is OK because we explicitly inhibit GC. Return length 878 from Lisp strings is OK because we explicitly inhibit GC. Return length
879 out through LEN_OUT, if not null. */ 879 out through LEN_OUT, if not null. */
880 880
881 Intbyte * 881 Ibyte *
882 emacs_sprintf_malloc (Bytecount *len_out, const CIntbyte *format, ...) 882 emacs_sprintf_malloc (Bytecount *len_out, const CIbyte *format, ...)
883 { 883 {
884 va_list vargs; 884 va_list vargs;
885 Intbyte *retval; 885 Ibyte *retval;
886 886
887 va_start (vargs, format); 887 va_start (vargs, format);
888 retval = emacs_vsprintf_malloc (format, vargs, len_out); 888 retval = emacs_vsprintf_malloc (format, vargs, len_out);
889 va_end (vargs); 889 va_end (vargs);
890 return retval; 890 return retval;
893 /* vsprintf() replacement. Writes output into OUTPUT, which better 893 /* vsprintf() replacement. Writes output into OUTPUT, which better
894 have enough space for the output. Data from Lisp strings is OK 894 have enough space for the output. Data from Lisp strings is OK
895 because we explicitly inhibit GC. */ 895 because we explicitly inhibit GC. */
896 896
897 Bytecount 897 Bytecount
898 emacs_vsprintf (Intbyte *output, const CIntbyte *format, va_list vargs) 898 emacs_vsprintf (Ibyte *output, const CIbyte *format, va_list vargs)
899 { 899 {
900 Bytecount retval; 900 Bytecount retval;
901 int count = begin_gc_forbidden (); 901 int count = begin_gc_forbidden ();
902 Lisp_Object stream = make_resizing_buffer_output_stream (); 902 Lisp_Object stream = make_resizing_buffer_output_stream ();
903 Bytecount len; 903 Bytecount len;
904 904
905 retval = emacs_doprnt_va (stream, (Intbyte *) format, strlen (format), Qnil, 905 retval = emacs_doprnt_va (stream, (Ibyte *) format, strlen (format), Qnil,
906 vargs); 906 vargs);
907 Lstream_flush (XLSTREAM (stream)); 907 Lstream_flush (XLSTREAM (stream));
908 len = Lstream_byte_count (XLSTREAM (stream)); 908 len = Lstream_byte_count (XLSTREAM (stream));
909 memcpy (output, resizing_buffer_stream_ptr (XLSTREAM (stream)), len); 909 memcpy (output, resizing_buffer_stream_ptr (XLSTREAM (stream)), len);
910 output[len] = '\0'; 910 output[len] = '\0';
917 /* sprintf() replacement. Writes output into OUTPUT, which better 917 /* sprintf() replacement. Writes output into OUTPUT, which better
918 have enough space for the output. Data from Lisp strings is OK 918 have enough space for the output. Data from Lisp strings is OK
919 because we explicitly inhibit GC. */ 919 because we explicitly inhibit GC. */
920 920
921 Bytecount 921 Bytecount
922 emacs_sprintf (Intbyte *output, const CIntbyte *format, ...) 922 emacs_sprintf (Ibyte *output, const CIbyte *format, ...)
923 { 923 {
924 va_list vargs; 924 va_list vargs;
925 Bytecount retval; 925 Bytecount retval;
926 926
927 va_start (vargs, format); 927 va_start (vargs, format);