[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5596] use text_buffer instead of message_buffer
From: |
Gavin D. Smith |
Subject: |
[5596] use text_buffer instead of message_buffer |
Date: |
Thu, 22 May 2014 22:03:11 +0000 |
Revision: 5596
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5596
Author: gavin
Date: 2014-05-22 22:03:09 +0000 (Thu, 22 May 2014)
Log Message:
-----------
use text_buffer instead of message_buffer
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/indices.c
trunk/info/infodoc.c
trunk/info/nodemenu.c
trunk/info/window.c
trunk/info/window.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/ChangeLog 2014-05-22 22:03:09 UTC (rev 5596)
@@ -1,3 +1,19 @@
+2014-05-21 Gavin Smith <address@hidden>
+
+ * info/indices.c (info_index_apropos): Use text_buffer_* functions
+ directly. Don't create apropos window if nothing found.
+ * info/infodoc.c (dump_map_to_message_buffer)
+ (dump_map_to_text_buffer): Renamed. Take struct text_buffer *
+ argument.
+ (create_internal_info_help_node): Don't use *_message_buffer
+ functions.
+ * info/nodemenu.c (get_visited_nodes): Don't use *_message_buffer
+ functions.
+ * info/window.c (build_message_node): Don't use *_message_buffer
+ functions.
+ (message_buffer, build_message_buffer, message_buffer_to_node)
+ (initialize_message_buffer, printf_to_message_buffer): Removed.
+
2014-05-21 Karl Berry <address@hidden>
* doc/texinfo.tex (\documentlanguage): \let_ inside \tex,
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/info/indices.c 2014-05-22 22:03:09 UTC (rev 5596)
@@ -611,39 +611,42 @@
{
REFERENCE **apropos_list;
NODE *apropos_node;
+ struct text_buffer message;
apropos_list = apropos_in_all_indices (line, 1);
if (!apropos_list)
- info_error (_(APROPOS_NONE), line);
+ {
+ info_error (_(APROPOS_NONE), line);
+ free (line);
+ return;
+ }
else
{
register int i;
- char *line_buffer;
- initialize_message_buffer ();
- printf_to_message_buffer
- (_("\n* Menu: Nodes whose indices contain `%s':\n"),
+ text_buffer_init (&message);
+ text_buffer_printf (&message,
+ _("\n* Menu: Nodes whose indices contain `%s':\n"),
line);
- line_buffer = xmalloc (500);
for (i = 0; apropos_list[i]; i++)
{
- int len;
+ int line_start = text_buffer_off (&message);
+
/* The label might be identical to that of another index
entry in another Info file. Therefore, we make the file
name part of the menu entry, to make them all distinct. */
- sprintf (line_buffer, "* %s [%s]: ",
+ text_buffer_printf (&message, "* %s [%s]: ",
apropos_list[i]->label, apropos_list[i]->filename);
- len = pad_to (40, line_buffer);
- sprintf (line_buffer + len, "(%s)%s.",
+ while (text_buffer_off (&message) - line_start < 40)
+ text_buffer_add_char (&message, ' ');
+ text_buffer_printf (&message, "(%s)%s.\n",
apropos_list[i]->filename, apropos_list[i]->nodename);
- printf_to_message_buffer ("%s\n", line_buffer);
}
- free (line_buffer);
}
- apropos_node = message_buffer_to_node ();
+ apropos_node = text_buffer_to_node (&message);
scan_node_contents (0, &apropos_node);
add_gcable_pointer (apropos_node->contents);
Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/info/infodoc.c 2014-05-22 22:03:09 UTC (rev 5596)
@@ -190,10 +190,8 @@
static char *where_is_internal (Keymap map, InfoCommand *cmd);
-struct text_buffer message_buffer;
-
void
-dump_map_to_message_buffer (char *prefix, Keymap map)
+dump_map_to_text_buffer (struct text_buffer *tb, char *prefix, Keymap map)
{
register int i;
unsigned prefix_len = strlen (prefix);
@@ -207,11 +205,11 @@
new_prefix[prefix_len] = i;
if (map[i].type == ISKMAP)
{
- dump_map_to_message_buffer (new_prefix, (Keymap)map[i].function);
+ dump_map_to_text_buffer (tb, new_prefix, (Keymap)map[i].function);
}
else if (map[i].function)
{
- long start_of_line = message_buffer.off;
+ long start_of_line = tb->off;
register int last;
char *doc, *name;
@@ -236,16 +234,16 @@
if (last - 1 != i)
{
- printf_to_message_buffer ("%s .. ", pretty_keyseq (new_prefix));
+ text_buffer_printf (tb, "%s .. ", pretty_keyseq (new_prefix));
new_prefix[prefix_len] = last - 1;
- printf_to_message_buffer ("%s", pretty_keyseq (new_prefix));
+ text_buffer_printf (tb, "%s", pretty_keyseq (new_prefix));
i = last - 1;
}
else
- printf_to_message_buffer ("%s", pretty_keyseq (new_prefix));
+ text_buffer_printf (tb, "%s", pretty_keyseq (new_prefix));
- while (message_buffer.off - start_of_line < 8)
- printf_to_message_buffer (" ");
+ while (tb->off - start_of_line < 8)
+ text_buffer_printf (tb, " ");
#if defined (NAMED_FUNCTIONS)
/* Print the name of the function, and some padding before the
@@ -254,23 +252,23 @@
int length_so_far;
int desired_doc_start = 40;
- printf_to_message_buffer ("(%s)", name);
- length_so_far = message_buffer.off - start_of_line;
+ text_buffer_printf (tb, "(%s)", name);
+ length_so_far = tb->off - start_of_line;
if ((desired_doc_start + strlen (doc))
>= (unsigned int) the_screen->width)
- printf_to_message_buffer ("\n ");
+ text_buffer_printf (tb, "\n ");
else
{
while (length_so_far < desired_doc_start)
{
- printf_to_message_buffer (" ");
+ text_buffer_printf (tb, " ");
length_so_far++;
}
}
}
#endif /* NAMED_FUNCTIONS */
- printf_to_message_buffer ("%s\n", doc);
+ text_buffer_printf (tb, "%s\n", doc);
}
}
free (new_prefix);
@@ -298,19 +296,20 @@
if (!contents)
{
int printed_one_mx = 0;
+ struct text_buffer msg;
- initialize_message_buffer ();
+ text_buffer_init (&msg);
for (i = 0; info_internal_help_text[i]; i++)
{
#ifdef INFOKEY
- printf_to_message_buffer (replace_in_documentation
+ text_buffer_printf (&msg, replace_in_documentation
(_(info_internal_help_text[i]), help_is_only_window_p),
NULL, NULL, NULL);
#else
/* Don't translate blank lines, gettext outputs the po file
header in that case. We want a blank line. */
- char *msg = *(info_internal_help_text[i])
+ char *mesg = *(info_internal_help_text[i])
? _(info_internal_help_text[i])
: info_internal_help_text[i];
char *key = info_help_keys_text[i][vi_keys_p];
@@ -320,19 +319,19 @@
if (STREQ (key, "CTRL-x 0") && help_is_only_window_p)
key = "l";
- printf_to_message_buffer (msg, key, NULL, NULL);
+ text_buffer_printf (&msg, mesg, key, NULL, NULL);
#endif /* !INFOKEY */
}
- printf_to_message_buffer ("---------------------\n");
- printf_to_message_buffer (_("The current search path is:\n"));
- printf_to_message_buffer ("%s\n", infopath ());
- printf_to_message_buffer ("---------------------\n\n");
- printf_to_message_buffer (_("Commands available in Info windows:\n\n"));
- dump_map_to_message_buffer ("", info_keymap);
- printf_to_message_buffer ("---------------------\n\n");
- printf_to_message_buffer (_("Commands available in the echo area:\n\n"));
- dump_map_to_message_buffer ("", echo_area_keymap);
+ text_buffer_printf (&msg, "---------------------\n");
+ text_buffer_printf (&msg, _("The current search path is:\n"));
+ text_buffer_printf (&msg, "%s\n", infopath ());
+ text_buffer_printf (&msg, "---------------------\n\n");
+ text_buffer_printf (&msg, _("Commands available in Info windows:\n\n"));
+ dump_map_to_text_buffer (&msg, "", info_keymap);
+ text_buffer_printf (&msg, "---------------------\n\n");
+ text_buffer_printf (&msg, _("Commands available in the echo area:\n\n"));
+ dump_map_to_text_buffer (&msg, "", echo_area_keymap);
#if defined (NAMED_FUNCTIONS)
/* Get a list of commands which have no keystroke equivs. */
@@ -349,19 +348,19 @@
{
if (!printed_one_mx)
{
- printf_to_message_buffer ("---------------------\n\n");
+ text_buffer_printf (&msg, "---------------------\n\n");
if (exec_keys && exec_keys[0])
- printf_to_message_buffer
- (_("The following commands can only be invoked via
%s:\n\n"),
+ text_buffer_printf (&msg,
+ _("The following commands can only be invoked via
%s:\n\n"),
exec_keys);
else
- printf_to_message_buffer
- (_("The following commands cannot be invoked at
all:\n\n"));
+ text_buffer_printf (&msg,
+ _("The following commands cannot be invoked at
all:\n\n"));
printed_one_mx = 1;
}
- printf_to_message_buffer
- ("%s %s\n %s\n",
+ text_buffer_printf (&msg,
+ "%s %s\n %s\n",
exec_keys,
function_doc_array[i].func_name,
replace_in_documentation (strlen (function_doc_array[i].doc)
@@ -374,7 +373,7 @@
free (exec_keys);
#endif /* NAMED_FUNCTIONS */
- node = message_buffer_to_node ();
+ node = text_buffer_to_node (&msg);
internal_info_help_node_contents = node->contents;
}
else
Modified: trunk/info/nodemenu.c
===================================================================
--- trunk/info/nodemenu.c 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/info/nodemenu.c 2014-05-22 22:03:09 UTC (rev 5596)
@@ -136,6 +136,7 @@
NODE *node;
char **lines = NULL;
size_t lines_index = 0, lines_slots = 0;
+ struct text_buffer message;
if (!info_windows)
return NULL;
@@ -196,26 +197,26 @@
lines_index = newlen;
}
- initialize_message_buffer ();
+ text_buffer_init (&message);
- printf_to_message_buffer ("\n");
- printf_to_message_buffer
- ("%s", replace_in_documentation
+ text_buffer_printf (&message, "\n");
+ text_buffer_printf (&message,
+ "%s", replace_in_documentation
(_("Here is the menu of nodes you have recently visited.\n\
Select one from this menu, or use `\\[history-node]' in another window.\n"),
0));
- printf_to_message_buffer ("%s\n", nodemenu_format_info ());
+ text_buffer_printf (&message, "%s\n", nodemenu_format_info ());
for (i = 0; (lines != NULL) && (i < lines_index); i++)
{
- printf_to_message_buffer ("%s\n", lines[i]);
+ text_buffer_printf (&message, "%s\n", lines[i]);
free (lines[i]);
}
if (lines)
free (lines);
- node = message_buffer_to_node ();
+ node = text_buffer_to_node (&message);
add_gcable_pointer (node->contents);
scan_node_contents (0, &node);
Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/info/window.c 2014-05-22 22:03:09 UTC (rev 5596)
@@ -732,6 +732,7 @@
/* Quickly guess the approximate number of lines that NODE would
take to display. This really only counts carriage returns. */
+/* FIXME: Not used anywhere. */
int
window_physical_lines (NODE *node)
{
@@ -1106,8 +1107,6 @@
}
-/* Manipulating home-made nodes. */
-
/* A place to buffer echo area messages. */
static NODE *echo_area_node = NULL;
@@ -1195,29 +1194,17 @@
}
-/* A place to build a message. */
-struct text_buffer message_buffer;
-
-/* Format MESSAGE_BUFFER with the results of printing FORMAT with ARG1 and
- ARG2. */
-static void
-build_message_buffer (const char *format, va_list ap)
-{
- text_buffer_vprintf (&message_buffer, format, ap);
-}
-
/* Build a new node which has FORMAT printed with ARG1 and ARG2 as the
contents. */
NODE *
build_message_node (const char *format, va_list ap)
{
- NODE *node;
+ struct text_buffer msg;
- initialize_message_buffer ();
- build_message_buffer (format, ap);
+ text_buffer_init (&msg);
+ text_buffer_vprintf (&msg, format, ap);
- node = message_buffer_to_node ();
- return node;
+ return text_buffer_to_node (&msg);
}
NODE *
@@ -1232,24 +1219,7 @@
return node;
}
-/* Convert the contents of the message buffer to a newly allocated node. */
NODE *
-message_buffer_to_node (void)
-{
- NODE *node;
-
- node = info_create_node ();
-
- /* Make sure that this buffer ends with a newline. */
- node->nodelen = 1 + strlen (message_buffer.base);
- node->contents = xmalloc (1 + node->nodelen);
- strcpy (node->contents, message_buffer.base);
- node->contents[node->nodelen - 1] = '\n';
- node->contents[node->nodelen] = '\0';
- return node;
-}
-
-NODE *
text_buffer_to_node (struct text_buffer *tb)
{
NODE *node;
@@ -1265,25 +1235,6 @@
return node;
}
-/* Useful functions can be called from outside of window.c. */
-void
-initialize_message_buffer (void)
-{
- message_buffer.off = 0;
-}
-
-/* Print supplied arguments using FORMAT to the end of the current message
- buffer. */
-void
-printf_to_message_buffer (const char *format, ...)
-{
- va_list ap;
-
- va_start (ap, format);
- build_message_buffer (format, ap);
- va_end (ap);
-}
-
/* Pad STRING to COUNT characters by inserting blanks. */
int
pad_to (int count, char *string)
@@ -1500,6 +1451,7 @@
return pl_num;
}
+
static void
line_map_init (LINE_MAP *map, NODE *node, int line)
{
Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-05-21 22:53:08 UTC (rev 5595)
+++ trunk/info/window.h 2014-05-22 22:03:09 UTC (rev 5596)
@@ -193,23 +193,9 @@
new node. */
extern NODE *string_to_node (char *contents);
-/* Useful functions can be called from outside of window.c. */
-extern void initialize_message_buffer (void);
-
-/* Print arguments according to FORMAT to the end of the current message
- buffer. */
-extern void printf_to_message_buffer (const char *format, ...)
- TEXINFO_PRINTFLIKE(1,2);
-
-/* Convert the contents of the message buffer to a node. */
-extern NODE *message_buffer_to_node (void);
-
struct text_buffer;
extern NODE *text_buffer_to_node (struct text_buffer *tb);
-/* Return the length of the most recently printed line in message buffer. */
-extern int message_buffer_length_this_line (void);
-
/* Pad STRING to COUNT characters by inserting blanks. */
extern int pad_to (int count, char *string);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5596] use text_buffer instead of message_buffer,
Gavin D. Smith <=