annotate src/doprnt.c @ 1785:19755499df90

* window.c (window_internal_width): New function, which accounts for scrollbars if present. * lisp.h (window_internal_height, window_internal_width): Add extern declarations for these. * dispnew.c (direct_output_for_insert, direct_output_forward_char, buffer_posn_from_coords): Use window_internal_width instead of writing out its definition. * indent.c (compute_motion): Doc fix; mention scrollbars and window_internal_width. (pos_tab_offset, Fvertical_motion): Use window_internal_width instead of writing it out. * window.c (Fpos_visible_in_window_p, Fwindow_width, Fscroll_left, Fscroll_right): Same. * xdisp.c (redisplay, try_window, try_window_id, display_text_line): Same. * xdisp.c (display_string): Add new variable `f', to be W's frame. Use it to set desired_glyphs, and to get the frame's width to decide whether or not to draw vertical bars. * xdisp.c (display_text_line): If we're using vertical scrollbars, don't draw the vertical bars separating side-by-side windows. (display_string): Same thing. Draw spaces to fill in the part of the mode line that is under the scrollbar in partial-width windows. * xdisp.c (display_text_line): Use the usable internal width of the window, as calculated above, as the limit on the length of the overlay arrow's image, rather than using the window's width field, less one. * xdisp.c (redisplay): Call condemn_scrollbars_hook and judge_scrollbars_hook whenever they are set, not just when the frame has vertical scrollbars. * termhooks.h (mouse_position_hook): Doc fix. (set_vertical_scrollbar_hook): This doesn't return anything any more, and doesn't take a struct scrollbar * argument any more. (condemn_scrollbars_hook, redeem_scrollbar_hook, judge_scrollbars_hook): Doc fixes. * term.c (mouse_position_hook): Doc fix. (set_vertical_scrollbar_hook): This doesn't return anything any more. Doc fixes. * keyboard.c (kbd_buffer_get_event): Receive the scrollbar's window from *mouse_position_hook and pass it to make_lispy_movement, instead of working with a pointer to a struct scrollbar. (make_lispy_event): We don't need a window_from_scrollbar function anymore; we are given the window directly in *EVENT. Unify the code which generates text-area mouse clicks and scrollbar clicks; use the same code to distinguish clicks from drags on the scrollbar as in the text area. Distinguish clicks from drags by storing a copy of the lispy position list returned as part of the event. (button_down_location): Make this a lisp vector, rather than an array of random structures. (struct mouse_position): Remove this; it's been replaced by a lisp list. (make_lispy_movement): Accept the scrollbar's window as a parameter, rather than the scrollbar itself. If FRAME is zero, assume that the other arguments are garbage. (syms_of_keyboard): No need to staticpro each window of button_down_location now; just initialize and staticpro it. * window.c (window_from_scrollbar): Function deleted; no longer needed. * xdisp.c (redisplay_window): Just pass the window to set_vertical_scrollbar hook; don't pass the scrollbar object too. * xterm.c (XTmouse_position): Don't return a pointer to the scrollbar for scrollbar motion; instead, return the scrollbar's window. * xdisp.c (echo_area_display): Move the assignment of f and the check for visibility out of the "#ifdef MULTI_FRAME" clause; they should work under any circumstances. * xdisp.c (redisplay_window): If we're not going to redisplay this window because it's a minibuffer whose contents have already been updated, go ahead and jump to the scrollbar refreshing code anyway; they still need to be updated. Initialize opoint, so it's known to be valid when we jump. Calculate the scrollbar settings properly for minibuffers, no matter what they are displaying at the time. * xdisp.c (redisplay_windows): Don't restore the current buffer and its point before refreshing the scrollbars; we need the buffer accurate.
author Jim Blandy <jimb@redhat.com>
date Thu, 14 Jan 1993 15:18:53 +0000
parents 3165b2697c78
children b6c62e4abf59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1 /* Output like sprintf to a buffer of specified size.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
2 Also takes args differently: pass one pointer to an array of strings
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
3 in addition to the format string which is separate.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
4 Copyright (C) 1985 Free Software Foundation, Inc.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
5
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
6 This file is part of GNU Emacs.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
7
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
8 GNU Emacs is free software; you can redistribute it and/or modify
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10 the Free Software Foundation; either version 1, or (at your option)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
11 any later version.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
12
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
13 GNU Emacs is distributed in the hope that it will be useful,
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
16 GNU General Public License for more details.
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
17
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19 along with GNU Emacs; see the file COPYING. If not, write to
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
23 #include <stdio.h>
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
24 #include <ctype.h>
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
26 /* Generate output from a format-spec FORMAT,
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
27 terminated at position FORMAT_END.
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
28 Output goes in BUFFER, which has room for BUFSIZE chars.
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
29 If the output does not fit, truncate it to fit.
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
30 Returns the number of characters stored into BUFFER.
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
31 ARGS points to the vector of arguments, and NARGS says how many.
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
32 A double counts as two arguments. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
33
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34 doprnt (buffer, bufsize, format, format_end, nargs, args)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
35 char *buffer;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 register int bufsize;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 char *format;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 char *format_end;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 int nargs;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40 char **args;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42 int cnt = 0; /* Number of arg to gobble next */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 register char *fmt = format; /* Pointer into format string */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 register char *bufptr = buffer; /* Pointer into output buffer.. */
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
45 /* Use this for sprintf unless we need something really big. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
46 char tembuf[100];
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
47 /* Size of sprintf_buffer. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
48 int size_allocated = 100;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
49 /* Buffer to use for sprintf. Either tembuf or same as BIG_BUFFER. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
50 char *sprintf_buffer = tembuf;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
51 /* Buffer we have got with malloc. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
52 char *big_buffer = 0;
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53 register int tem;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 char *string;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55 char fmtcpy[20];
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
56 int minlen;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 int size; /* Field width factor; e.g., %90d */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59 if (format_end == 0)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 format_end = format + strlen (format);
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 bufsize--;
116
6b517878550a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 49
diff changeset
63 while (fmt != format_end && bufsize > 0) /* Loop until end of format
6b517878550a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 49
diff changeset
64 string or buffer full */
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66 if (*fmt == '%') /* Check for a '%' character */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 {
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
68 int size_bound;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
69
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
70 fmt++;
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 147
diff changeset
71 /* Copy this one %-spec into fmtcpy. */
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 string = fmtcpy;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 *string++ = '%';
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 147
diff changeset
74 while (string < fmtcpy + sizeof fmtcpy - 1)
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 *string++ = *fmt;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77 if (! (*fmt >= '0' && *fmt <= '9') && *fmt != '-' && *fmt != ' ')
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 break;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 fmt++;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 *string = 0;
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
82 /* Get an idea of how much space we might need. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
83 size_bound = atoi (&fmtcpy[1]) + 50;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
84 /* Make sure we have that much. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
85 if (size_bound > size_allocated)
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
86 {
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
87 if (big_buffer)
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
88 big_buffer = (char *) xrealloc (big_buffer, size_bound);
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
89 else
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
90 big_buffer = (char *) xmalloc (size_bound);
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
91 sprintf_buffer = big_buffer;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
92 size_allocated = size_bound;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
93 }
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 minlen = 0;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 switch (*fmt++)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 default:
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 error ("Invalid format operation %%%c", fmt[-1]);
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 /* case 'b': */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
101 case 'd':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 case 'o':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 case 'x':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 if (cnt == nargs)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 error ("Format string wants too many arguments");
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
106 sprintf (sprintf_buffer, fmtcpy, args[cnt++]);
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
107 /* Now copy into final output, truncating as nec. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
108 string = sprintf_buffer;
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109 goto doit;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
111 case 'f':
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
112 case 'e':
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
113 case 'g':
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
114 {
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
115 union { double d; char *half[2]; } u;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
116 if (cnt + 1 == nargs)
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
117 error ("Format string wants too many arguments");
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
118 u.half[0] = args[cnt++];
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
119 u.half[1] = args[cnt++];
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
120 sprintf (sprintf_buffer, fmtcpy, u.d);
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
121 /* Now copy into final output, truncating as nec. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
122 string = sprintf_buffer;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
123 goto doit;
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
124 }
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
125
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 case 'S':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 string[-1] = 's';
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128 case 's':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
129 if (cnt == nargs)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
130 error ("Format string wants too many arguments");
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
131 string = args[cnt++];
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
132 if (fmtcpy[1] != 's')
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
133 minlen = atoi (&fmtcpy[1]);
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 /* Copy string into final output, truncating if no room. */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135 doit:
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 tem = strlen (string);
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 if (minlen > 0)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
139 while (minlen > tem && bufsize > 0)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141 *bufptr++ = ' ';
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
142 bufsize--;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
143 minlen--;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
144 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
145 minlen = 0;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
146 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 if (tem > bufsize)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
148 tem = bufsize;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
149 strncpy (bufptr, string, tem);
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
150 bufptr += tem;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
151 bufsize -= tem;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
152 if (minlen < 0)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
154 while (minlen < - tem && bufsize > 0)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
155 {
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
156 *bufptr++ = ' ';
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
157 bufsize--;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
158 minlen++;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
159 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
160 minlen = 0;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
161 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
162 continue;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
163
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
164 case 'c':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
165 if (cnt == nargs)
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
166 error ("Format string wants too many arguments");
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
167 *bufptr++ = (int) args[cnt++];
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
168 bufsize--;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
169 continue;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
170
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
171 case '%':
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
172 fmt--; /* Drop thru and this % will be treated as normal */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
173 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
174 }
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
175 *bufptr++ = *fmt++; /* Just some characters; Copy 'em */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
176 bufsize--;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
177 };
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
178
147
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
179 /* If we had to malloc something, free it. */
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
180 if (big_buffer)
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
181 free (big_buffer);
0f50f1badd75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 116
diff changeset
182
49
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
183 *bufptr = 0; /* Make sure our string end with a '\0' */
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
184 return bufptr - buffer;
94e408cdb3ce Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
185 }