summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/info/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/texinfo/info/window.c')
-rw-r--r--contrib/texinfo/info/window.c656
1 files changed, 327 insertions, 329 deletions
diff --git a/contrib/texinfo/info/window.c b/contrib/texinfo/info/window.c
index 304e89c..dbe706e 100644
--- a/contrib/texinfo/info/window.c
+++ b/contrib/texinfo/info/window.c
@@ -1,9 +1,10 @@
-/* window.c -- Windows in Info. */
+/* window.c -- Windows in Info.
+ $Id: window.c,v 1.5 1998/02/23 22:43:38 karl Exp $
-/* This file is part of GNU Info, a program for reading online documentation
+ This file is part of GNU Info, a program for reading online documentation
stored in Info format.
- Copyright (C) 1993 Free Software Foundation, Inc.
+ Copyright (C) 1993, 97 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,10 +22,7 @@
Written by Brian Fox (bfox@ai.mit.edu). */
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include "info.h"
#include "nodes.h"
#include "window.h"
#include "display.h"
@@ -136,36 +134,36 @@ window_new_screen_size (width, height)
while ((height - echo_area_required) / numwins <= WINDOW_MIN_SIZE)
{
/* If only one window, make the size of it be zero, and return
- immediately. */
+ immediately. */
if (!windows->next)
- {
- windows->height = 0;
- maybe_free (windows->line_starts);
- windows->line_starts = (char **)NULL;
- windows->line_count = 0;
- break;
- }
+ {
+ windows->height = 0;
+ maybe_free (windows->line_starts);
+ windows->line_starts = (char **)NULL;
+ windows->line_count = 0;
+ break;
+ }
/* If we have some temporary windows, delete one of them. */
for (win = windows; win; win = win->next)
- if (win->flags & W_TempWindow)
- break;
+ if (win->flags & W_TempWindow)
+ break;
/* Otherwise, delete the first window, and try again. */
if (!win)
- win = windows;
+ win = windows;
if (window_deletion_notifier)
- (*window_deletion_notifier) (win);
+ (*window_deletion_notifier) (win);
window_delete_window (win);
numwins--;
}
/* The screen has changed height and width. */
- delta_height = height - the_screen->height; /* This is how much. */
- the_screen->height = height; /* This is the new height. */
- the_screen->width = width; /* This is the new width. */
+ delta_height = height - the_screen->height; /* This is how much. */
+ the_screen->height = height; /* This is the new height. */
+ the_screen->width = width; /* This is the new width. */
/* Set the start of the echo area. */
the_echo_area->first_row = height - the_echo_area->height;
@@ -186,34 +184,34 @@ window_new_screen_size (width, height)
for (win = windows; win; win = win->next)
{
if ((win->width != width) && ((win->flags & W_InhibitMode) == 0))
- {
- win->width = width;
- maybe_free (win->modeline);
- win->modeline = (char *)xmalloc (1 + width);
- }
+ {
+ win->width = width;
+ maybe_free (win->modeline);
+ win->modeline = (char *)xmalloc (1 + width);
+ }
win->height += delta_each;
/* If the previous height of this window was zero, it was the only
- window, and it was not visible. Thus we need to compensate for
- the echo_area. */
+ window, and it was not visible. Thus we need to compensate for
+ the echo_area. */
if (win->height == delta_each)
- win->height -= (1 + the_echo_area->height);
+ win->height -= (1 + the_echo_area->height);
/* If this is not the first window in the chain, then change the
- first row of it. We cannot just add delta_each to the first row,
- since this window's first row is the sum of the collective increases
- that have gone before it. So we just add one to the location of the
- previous window's modeline. */
+ first row of it. We cannot just add delta_each to the first row,
+ since this window's first row is the sum of the collective increases
+ that have gone before it. So we just add one to the location of the
+ previous window's modeline. */
if (win->prev)
- win->first_row = (win->prev->first_row + win->prev->height) + 1;
+ win->first_row = (win->prev->first_row + win->prev->height) + 1;
/* The last window in the chain gets the extra space (or shrinkage). */
if (!win->next)
- win->height += delta_leftover;
+ win->height += delta_leftover;
if (win->node)
- recalculate_line_starts (win);
+ recalculate_line_starts (win);
win->flags |= W_UpdateWindow;
}
@@ -232,32 +230,32 @@ window_new_screen_size (width, height)
win = windows;
while (win)
- {
- if ((win->height < WINDOW_MIN_HEIGHT) ||
- (win->height > avail))
- {
- WINDOW *lastwin;
-
- /* Split the space among the available windows. */
- delta_each = avail / numwins;
- delta_leftover = avail - (delta_each * numwins);
-
- for (win = windows; win; win = win->next)
- {
- lastwin = win;
- if (win->prev)
- win->first_row =
- (win->prev->first_row + win->prev->height) + 1;
- win->height = delta_each;
- }
-
- /* Give the leftover space (if any) to the last window. */
- lastwin->height += delta_leftover;
- break;
- }
- else
- win= win->next;
- }
+ {
+ if ((win->height < WINDOW_MIN_HEIGHT) ||
+ (win->height > avail))
+ {
+ WINDOW *lastwin;
+
+ /* Split the space among the available windows. */
+ delta_each = avail / numwins;
+ delta_leftover = avail - (delta_each * numwins);
+
+ for (win = windows; win; win = win->next)
+ {
+ lastwin = win;
+ if (win->prev)
+ win->first_row =
+ (win->prev->first_row + win->prev->height) + 1;
+ win->height = delta_each;
+ }
+
+ /* Give the leftover space (if any) to the last window. */
+ lastwin->height += delta_leftover;
+ break;
+ }
+ else
+ win= win->next;
+ }
}
}
@@ -412,25 +410,25 @@ window_change_window_height (window, amount)
/* WINDOW decreasing in size? */
if (amount < 0)
{
- int abs_amount = -amount; /* It is easier to deal with this way. */
+ int abs_amount = -amount; /* It is easier to deal with this way. */
/* If the resultant window would be too small, stop here. */
if ((window->height - abs_amount) < WINDOW_MIN_HEIGHT)
- return;
+ return;
/* If we have two neighboring windows, choose the smaller one to get
- larger. */
+ larger. */
if (next && prev)
- {
- if (prev->height < next->height)
- shrink_me_growing_prev (window, prev, abs_amount);
- else
- shrink_me_growing_next (window, next, abs_amount);
- }
+ {
+ if (prev->height < next->height)
+ shrink_me_growing_prev (window, prev, abs_amount);
+ else
+ shrink_me_growing_next (window, next, abs_amount);
+ }
else if (next)
- shrink_me_growing_next (window, next, abs_amount);
+ shrink_me_growing_next (window, next, abs_amount);
else
- shrink_me_growing_prev (window, prev, abs_amount);
+ shrink_me_growing_prev (window, prev, abs_amount);
}
/* WINDOW increasing in size? */
@@ -439,65 +437,65 @@ window_change_window_height (window, amount)
int total_avail, next_avail = 0, prev_avail = 0;
if (next)
- next_avail = next->height - WINDOW_MIN_SIZE;
+ next_avail = next->height - WINDOW_MIN_SIZE;
if (prev)
- prev_avail = prev->height - WINDOW_MIN_SIZE;
+ prev_avail = prev->height - WINDOW_MIN_SIZE;
total_avail = next_avail + prev_avail;
/* If there isn't enough space available to grow this window, give up. */
if (amount > total_avail)
- return;
+ return;
/* If there aren't two neighboring windows, or if one of the neighbors
- is larger than the other one by at least AMOUNT, grow that one. */
+ is larger than the other one by at least AMOUNT, grow that one. */
if ((next && !prev) || ((next_avail - amount) >= prev_avail))
- grow_me_shrinking_next (window, next, amount);
+ grow_me_shrinking_next (window, next, amount);
else if ((prev && !next) || ((prev_avail - amount) >= next_avail))
- grow_me_shrinking_prev (window, prev, amount);
+ grow_me_shrinking_prev (window, prev, amount);
else
- {
- int change;
-
- /* This window has two neighbors. They both must be shrunk in to
- make enough space for WINDOW to grow. Make them both the same
- size. */
- if (prev_avail > next_avail)
- {
- change = prev_avail - next_avail;
- grow_me_shrinking_prev (window, prev, change);
- amount -= change;
- }
- else
- {
- change = next_avail - prev_avail;
- grow_me_shrinking_next (window, next, change);
- amount -= change;
- }
-
- /* Both neighbors are the same size. Split the difference in
- AMOUNT between them. */
- while (amount)
- {
- window->height++;
- amount--;
-
- /* Odd numbers grow next, even grow prev. */
- if (amount & 1)
- {
- prev->height--;
- window->first_row--;
- }
- else
- {
- next->height--;
- next->first_row++;
- }
- }
- window_adjust_pagetop (prev);
- window_adjust_pagetop (next);
- }
+ {
+ int change;
+
+ /* This window has two neighbors. They both must be shrunk in to
+ make enough space for WINDOW to grow. Make them both the same
+ size. */
+ if (prev_avail > next_avail)
+ {
+ change = prev_avail - next_avail;
+ grow_me_shrinking_prev (window, prev, change);
+ amount -= change;
+ }
+ else
+ {
+ change = next_avail - prev_avail;
+ grow_me_shrinking_next (window, next, change);
+ amount -= change;
+ }
+
+ /* Both neighbors are the same size. Split the difference in
+ AMOUNT between them. */
+ while (amount)
+ {
+ window->height++;
+ amount--;
+
+ /* Odd numbers grow next, even grow prev. */
+ if (amount & 1)
+ {
+ prev->height--;
+ window->first_row--;
+ }
+ else
+ {
+ next->height--;
+ next->first_row++;
+ }
+ }
+ window_adjust_pagetop (prev);
+ window_adjust_pagetop (next);
+ }
}
if (prev)
prev->flags |= W_UpdateWindow;
@@ -526,10 +524,10 @@ window_tile_windows (style)
for (win = windows; win; win = win->next)
if (do_internals || !win->node ||
- (win->node->flags & N_IsInternal) == 0)
+ (win->node->flags & N_IsInternal) == 0)
{
- avail += win->height;
- numwins++;
+ avail += win->height;
+ numwins++;
}
if (numwins <= 1 || !the_screen->height)
@@ -544,11 +542,11 @@ window_tile_windows (style)
for (win = windows; win; win = win->next)
{
if (do_internals || !win->node ||
- (win->node->flags & N_IsInternal) == 0)
- {
- last_adjusted = win;
- win->height = per_win_height;
- }
+ (win->node->flags & N_IsInternal) == 0)
+ {
+ last_adjusted = win;
+ win->height = per_win_height;
+ }
}
if (last_adjusted)
@@ -558,7 +556,7 @@ window_tile_windows (style)
for (win = windows; win; win = win->next)
{
if (win->prev)
- win->first_row = win->prev->first_row + win->prev->height + 1;
+ win->first_row = win->prev->first_row + win->prev->height + 1;
window_adjust_pagetop (win);
win->flags |= W_UpdateWindow;
@@ -591,11 +589,11 @@ window_toggle_wrap (window)
window_adjust_pagetop (window);
/* If the pagetop hasn't changed maybe we can do some scrolling now
- to speed up the display. Many of the line starts will be the same,
- so scrolling here is a very good optimization.*/
+ to speed up the display. Many of the line starts will be the same,
+ so scrolling here is a very good optimization.*/
if (old_pagetop == window->pagetop)
- display_scroll_line_starts
- (window, old_pagetop, old_starts, old_lines);
+ display_scroll_line_starts
+ (window, old_pagetop, old_starts, old_lines);
maybe_free (old_starts);
}
window->flags |= W_UpdateWindow;
@@ -650,12 +648,12 @@ window_delete_window (window)
if (window == active_window)
{
/* If there isn't a next window, then there must be a previous one,
- since we cannot delete the last window. If there is a next window,
- prefer to use that as the active window. */
+ since we cannot delete the last window. If there is a next window,
+ prefer to use that as the active window. */
if (next)
- active_window = next;
+ active_window = next;
else
- active_window = prev;
+ active_window = prev;
}
if (next && active_window == next)
@@ -674,13 +672,13 @@ window_delete_window (window)
int diff;
/* Try to adjust the visible part of the node so that as little
- text as possible has to move. */
+ text as possible has to move. */
diff = window_to_fix->first_row - window->first_row;
window_to_fix->first_row = window->first_row;
window_to_fix->pagetop -= diff;
if (window_to_fix->pagetop < 0)
- window_to_fix->pagetop = 0;
+ window_to_fix->pagetop = 0;
}
/* The `+ 1' is to offset the difference between the first_row locations.
@@ -725,24 +723,24 @@ character_width (character, hpos)
int width = 1;
if (ISO_Latin_p)
- printable_limit = 160;
+ printable_limit = 255;
if (character > printable_limit)
width = 3;
else if (iscntrl (character))
{
switch (character)
- {
- case '\r':
- case '\n':
- width = the_screen->width - hpos;
- break;
- case '\t':
- width = ((hpos + 8) & 0xf8) - hpos;
- break;
- default:
- width = 2;
- }
+ {
+ case '\r':
+ case '\n':
+ width = the_screen->width - hpos;
+ break;
+ case '\t':
+ width = ((hpos + 8) & 0xf8) - hpos;
+ break;
+ default:
+ width = 2;
+ }
}
else if (character == DEL)
width = 2;
@@ -820,61 +818,61 @@ calculate_line_starts (window)
unsigned int cwidth, c;
add_pointer_to_array (line, line_starts_index, line_starts,
- line_starts_slots, 100, char *);
+ line_starts_slots, 100, char *);
if (bump_index)
- {
- i++;
- bump_index = 0;
- }
+ {
+ i++;
+ bump_index = 0;
+ }
while (1)
- {
- c = node->contents[i];
- cwidth = character_width (c, hpos);
-
- /* If this character fits within this line, just do the next one. */
- if ((hpos + cwidth) < window->width)
- {
- i++;
- hpos += cwidth;
- continue;
- }
- else
- {
- /* If this character would position the cursor at the start of
- the next printed screen line, then do the next line. */
- if (c == '\n' || c == '\r' || c == '\t')
- {
- i++;
- hpos = 0;
- break;
- }
- else
- {
- /* This character passes the window width border. Postion
- the cursor after the printed character, but remember this
- line start as where this character is. A bit tricky. */
-
- /* If this window doesn't wrap lines, proceed to the next
- physical line here. */
- if (window->flags & W_NoWrap)
- {
- hpos = 0;
- while (i < node->nodelen && node->contents[i] != '\n')
- i++;
-
- if (node->contents[i] == '\n')
- i++;
- }
- else
- {
- hpos = the_screen->width - hpos;
- bump_index++;
- }
- break;
- }
- }
- }
+ {
+ c = node->contents[i];
+ cwidth = character_width (c, hpos);
+
+ /* If this character fits within this line, just do the next one. */
+ if ((hpos + cwidth) < window->width)
+ {
+ i++;
+ hpos += cwidth;
+ continue;
+ }
+ else
+ {
+ /* If this character would position the cursor at the start of
+ the next printed screen line, then do the next line. */
+ if (c == '\n' || c == '\r' || c == '\t')
+ {
+ i++;
+ hpos = 0;
+ break;
+ }
+ else
+ {
+ /* This character passes the window width border. Postion
+ the cursor after the printed character, but remember this
+ line start as where this character is. A bit tricky. */
+
+ /* If this window doesn't wrap lines, proceed to the next
+ physical line here. */
+ if (window->flags & W_NoWrap)
+ {
+ hpos = 0;
+ while (i < node->nodelen && node->contents[i] != '\n')
+ i++;
+
+ if (node->contents[i] == '\n')
+ i++;
+ }
+ else
+ {
+ hpos = the_screen->width - hpos;
+ bump_index++;
+ }
+ break;
+ }
+ }
+ }
}
window->line_starts = line_starts;
window->line_count = line_starts_index;
@@ -916,7 +914,7 @@ window_adjust_pagetop (window)
line_start = window->line_starts[line];
if ((line_start - contents) > window->point)
- break;
+ break;
}
/* The line index preceding the line start which is past point is the
@@ -929,26 +927,26 @@ window_adjust_pagetop (window)
(line - window->pagetop > (window->height - 1)))
{
/* The user-settable variable "scroll-step" is used to attempt
- to make point visible, iff it is non-zero. If that variable
- is zero, then the line containing point is centered within
- the window. */
+ to make point visible, iff it is non-zero. If that variable
+ is zero, then the line containing point is centered within
+ the window. */
if (window_scroll_step < window->height)
- {
- if ((line < window->pagetop) &&
- ((window->pagetop - window_scroll_step) <= line))
- window->pagetop -= window_scroll_step;
- else if ((line - window->pagetop > (window->height - 1)) &&
- ((line - (window->pagetop + window_scroll_step)
- < window->height)))
- window->pagetop += window_scroll_step;
- else
- window->pagetop = line - ((window->height - 1) / 2);
- }
+ {
+ if ((line < window->pagetop) &&
+ ((window->pagetop - window_scroll_step) <= line))
+ window->pagetop -= window_scroll_step;
+ else if ((line - window->pagetop > (window->height - 1)) &&
+ ((line - (window->pagetop + window_scroll_step)
+ < window->height)))
+ window->pagetop += window_scroll_step;
+ else
+ window->pagetop = line - ((window->height - 1) / 2);
+ }
else
- window->pagetop = line - ((window->height - 1) / 2);
+ window->pagetop = line - ((window->height - 1) / 2);
if (window->pagetop < 0)
- window->pagetop = 0;
+ window->pagetop = 0;
window->flags |= W_UpdateWindow;
}
}
@@ -970,7 +968,7 @@ window_line_of_point (window)
for (i = start; i < window->line_count; i++)
{
if ((window->line_starts[i] - window->node->contents) > window->point)
- break;
+ break;
}
return (i - 1);
@@ -1029,7 +1027,7 @@ window_chars_to_goal (line, goal)
check = hpos + character_width (line[i], hpos);
if (check > goal)
- break;
+ break;
hpos = check;
}
@@ -1056,26 +1054,26 @@ window_make_modeline (window)
if (window->pagetop == 0)
{
if (lines_remaining <= window->height)
- strcpy (location_indicator, "All");
+ strcpy (location_indicator, "All");
else
- strcpy (location_indicator, "Top");
+ strcpy (location_indicator, "Top");
}
else
{
if (lines_remaining <= window->height)
- strcpy (location_indicator, "Bot");
+ strcpy (location_indicator, "Bot");
else
- {
- float pt, lc;
- int percentage;
+ {
+ float pt, lc;
+ int percentage;
- pt = (float)window->pagetop;
- lc = (float)window->line_count;
+ pt = (float)window->pagetop;
+ lc = (float)window->line_count;
- percentage = 100 * (pt / lc);
+ percentage = 100 * (pt / lc);
- sprintf (location_indicator, "%2d%%", percentage);
- }
+ sprintf (location_indicator, "%2d%%", percentage);
+ }
}
/* Calculate the maximum size of the information to stick in MODELINE. */
@@ -1088,49 +1086,49 @@ window_make_modeline (window)
if (node)
{
- if (node->nodename)
- nodename = node->nodename;
+ if (node->nodename)
+ nodename = node->nodename;
- if (node->parent)
- {
- parent = filename_non_directory (node->parent);
- modeline_len += strlen ("Subfile: ") + strlen (node->filename);
- }
+ if (node->parent)
+ {
+ parent = filename_non_directory (node->parent);
+ modeline_len += strlen ("Subfile: ") + strlen (node->filename);
+ }
- if (node->filename)
- filename = filename_non_directory (node->filename);
+ if (node->filename)
+ filename = filename_non_directory (node->filename);
- if (node->flags & N_UpdateTags)
- update_message = "--*** Tags out of Date ***";
+ if (node->flags & N_UpdateTags)
+ update_message = _("--*** Tags out of Date ***");
}
if (update_message)
modeline_len += strlen (update_message);
modeline_len += strlen (filename);
modeline_len += strlen (nodename);
- modeline_len += 4; /* strlen (location_indicator). */
+ modeline_len += 4; /* strlen (location_indicator). */
/* 10 for the decimal representation of the number of lines in this
node, and the remainder of the text that can appear in the line. */
- modeline_len += 10 + strlen ("-----Info: (), lines ----, ");
+ modeline_len += 10 + strlen (_("-----Info: (), lines ----, "));
modeline_len += window->width;
modeline = (char *)xmalloc (1 + modeline_len);
/* Special internal windows have no filename. */
if (!parent && !*filename)
- sprintf (modeline, "-%s---Info: %s, %d lines --%s--",
- (window->flags & W_NoWrap) ? "$" : "-",
- nodename, window->line_count, location_indicator);
+ sprintf (modeline, _("-%s---Info: %s, %d lines --%s--"),
+ (window->flags & W_NoWrap) ? "$" : "-",
+ nodename, window->line_count, location_indicator);
else
- sprintf (modeline, "-%s%s-Info: (%s)%s, %d lines --%s--",
- (window->flags & W_NoWrap) ? "$" : "-",
- (node && (node->flags & N_IsCompressed)) ? "zz" : "--",
- parent ? parent : filename,
- nodename, window->line_count, location_indicator);
+ sprintf (modeline, _("-%s%s-Info: (%s)%s, %d lines --%s--"),
+ (window->flags & W_NoWrap) ? "$" : "-",
+ (node && (node->flags & N_IsCompressed)) ? "zz" : "--",
+ parent ? parent : filename,
+ nodename, window->line_count, location_indicator);
if (parent)
- sprintf (modeline + strlen (modeline), " Subfile: %s", filename);
+ sprintf (modeline + strlen (modeline), _(" Subfile: %s"), filename);
if (update_message)
sprintf (modeline + strlen (modeline), "%s", update_message);
@@ -1141,9 +1139,9 @@ window_make_modeline (window)
modeline[window->width] = '\0';
else
{
- while (i < window->width)
- modeline[i++] = '-';
- modeline[i] = '\0';
+ while (i < window->width)
+ modeline[i++] = '-';
+ modeline[i] = '\0';
}
strcpy (window->modeline, modeline);
@@ -1197,9 +1195,9 @@ window_set_state (window, state)
/* **************************************************************** */
-/* */
-/* Manipulating Home-Made Nodes */
-/* */
+/* */
+/* Manipulating Home-Made Nodes */
+/* */
/* **************************************************************** */
/* A place to buffer echo area messages. */
@@ -1259,8 +1257,8 @@ message_in_echo_area (format, arg1, arg2)
if (echo_area_node)
{
add_pointer_to_array (echo_area_node, old_echo_area_nodes_index,
- old_echo_area_nodes, old_echo_area_nodes_slots,
- 4, NODE *);
+ old_echo_area_nodes, old_echo_area_nodes_slots,
+ 4, NODE *);
}
echo_area_node = (NODE *)NULL;
window_message_in_echo_area (format, arg1, arg2);
@@ -1299,7 +1297,7 @@ message_buffer_resize (length)
while (message_buffer_size <= message_buffer_index + length)
message_buffer = (char *)
xrealloc (message_buffer,
- message_buffer_size += 100 + (2 * length));
+ message_buffer_size += 100 + (2 * length));
}
/* Format MESSAGE_BUFFER with the results of printing FORMAT with ARG1 and
@@ -1323,70 +1321,70 @@ build_message_buffer (format, arg1, arg2)
for (i = 0; format[i]; i++)
{
if (format[i] != '%')
- {
- message_buffer[message_buffer_index++] = format[i];
- len--;
- }
+ {
+ message_buffer[message_buffer_index++] = format[i];
+ len--;
+ }
else
- {
- char c;
-
- c = format[++i];
-
- switch (c)
- {
- case '%': /* Insert a percent sign. */
- message_buffer_resize (len + 1);
- message_buffer[message_buffer_index++] = '%';
- break;
-
- case 's': /* Insert the current arg as a string. */
- {
- char *string;
- int string_len;
-
- string = (char *)args[arg_index++];
- string_len = strlen (string);
-
- message_buffer_resize (len + string_len);
- sprintf
- (message_buffer + message_buffer_index, "%s", string);
- message_buffer_index += string_len;
- }
- break;
-
- case 'd': /* Insert the current arg as an integer. */
- {
- long long_val;
- int integer;
-
- long_val = (long)args[arg_index++];
- integer = (int)long_val;
-
- message_buffer_resize (len + 32);
- sprintf
- (message_buffer + message_buffer_index, "%d", integer);
- message_buffer_index = strlen (message_buffer);
- }
- break;
-
- case 'c': /* Insert the current arg as a character. */
- {
- long long_val;
- int character;
-
- long_val = (long)args[arg_index++];
- character = (int)long_val;
-
- message_buffer_resize (len + 1);
- message_buffer[message_buffer_index++] = character;
- }
- break;
-
- default:
- abort ();
- }
- }
+ {
+ char c;
+
+ c = format[++i];
+
+ switch (c)
+ {
+ case '%': /* Insert a percent sign. */
+ message_buffer_resize (len + 1);
+ message_buffer[message_buffer_index++] = '%';
+ break;
+
+ case 's': /* Insert the current arg as a string. */
+ {
+ char *string;
+ int string_len;
+
+ string = (char *)args[arg_index++];
+ string_len = strlen (string);
+
+ message_buffer_resize (len + string_len);
+ sprintf
+ (message_buffer + message_buffer_index, "%s", string);
+ message_buffer_index += string_len;
+ }
+ break;
+
+ case 'd': /* Insert the current arg as an integer. */
+ {
+ long long_val;
+ int integer;
+
+ long_val = (long)args[arg_index++];
+ integer = (int)long_val;
+
+ message_buffer_resize (len + 32);
+ sprintf
+ (message_buffer + message_buffer_index, "%d", integer);
+ message_buffer_index = strlen (message_buffer);
+ }
+ break;
+
+ case 'c': /* Insert the current arg as a character. */
+ {
+ long long_val;
+ int character;
+
+ long_val = (long)args[arg_index++];
+ character = (int)long_val;
+
+ message_buffer_resize (len + 1);
+ message_buffer[message_buffer_index++] = character;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
}
message_buffer[message_buffer_index] = '\0';
}
@@ -1474,7 +1472,7 @@ pad_to (count, string)
else
{
while (i < count)
- string[i++] = ' ';
+ string[i++] = ' ';
}
string[i] = '\0';
OpenPOWER on IntegriCloud