[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5447] consolidate NODE creation
From: |
Gavin D. Smith |
Subject: |
[5447] consolidate NODE creation |
Date: |
Mon, 14 Apr 2014 13:29:15 +0000 |
Revision: 5447
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5447
Author: gavin
Date: 2014-04-14 13:29:13 +0000 (Mon, 14 Apr 2014)
Log Message:
-----------
consolidate NODE creation
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/footnotes.c
trunk/info/indices.c
trunk/info/man.c
trunk/info/nodes.c
trunk/info/nodes.h
trunk/info/session.c
trunk/info/window.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/ChangeLog 2014-04-14 13:29:13 UTC (rev 5447)
@@ -1,3 +1,18 @@
+2014-04-14 Gavin Smith <address@hidden>
+
+ * nodes.c (info_create_node): New function initializing
+ created NODE structures.
+ * footnotes.c (make_footnotes_node)
+ * indices.c (create_virtindex_node)
+ * man.c (manpage_node_of_file_buffer)
+ * nodes.c (info_get_node_of_file_buffer)
+ (info_node_of_file_buffer_tags)
+ * window.c (string_to_node, message_buffer_to_node): Call
+ info_create_node.
+
+ * session.c (kill_node): Copy whole NODE structure at once instead
+ of field-by-field.
+
2014-04-13 Gavin Smith <address@hidden>
* session.c (forward_move_node_structure)
Modified: trunk/info/footnotes.c
===================================================================
--- trunk/info/footnotes.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/footnotes.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -113,9 +113,7 @@
return NULL;
/* Make the new node. */
- result = xmalloc (sizeof (NODE));
- result->flags = 0;
- result->display_pos = 0;
+ result = info_create_node ();
/* Get the size of the footnotes appearing within this node. */
{
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/indices.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -823,18 +823,13 @@
text += skip_node_separator (text);
- node = xmalloc (sizeof (NODE));
+ node = info_create_node ();
node->filename = file_buffer->filename;
node->nodename = xstrdup (tag->nodename);
node->contents = text;
node->nodelen = strlen (text);
node->body_start = strcspn(node->contents, "\n");
- node->flags = 0;
- node->display_pos = 0;
- node->parent = NULL;
- node->flags = 0;
-
return node;
}
Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/man.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -401,15 +401,12 @@
if (tag)
{
- node = xmalloc (sizeof (NODE));
+ node = info_create_node ();
node->filename = file_buffer->filename;
node->nodename = xstrdup (tag->nodename);
node->contents = file_buffer->contents + tag->nodestart;
node->nodelen = tag->nodelen;
- node->flags = 0;
- node->display_pos = 0;
- node->parent = NULL;
- node->flags = (N_HasTagsTable | N_IsManPage);
+ node->flags |= (N_HasTagsTable | N_IsManPage);
node->contents += skip_node_separator (node->contents);
node->body_start = strcspn(node->contents, "\n");
}
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/nodes.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -863,7 +863,7 @@
}
-/* Functions for node retrieval. */
+/* Functions for node creation and retrieval. */
/* Magic number that RMS used to decide how much a tags table pointer could
be off by. I feel that it should be much smaller, like 4. */
@@ -879,6 +879,25 @@
static NODE *info_node_of_file_buffer_tags (FILE_BUFFER *file_buffer,
char *nodename);
+/* Return a pointer to a newly allocated NODE structure, with
+ fields filled in. */
+NODE *
+info_create_node (void)
+{
+ NODE *n = xmalloc (sizeof (NODE));
+
+ n->filename = 0;
+ n->parent = 0;
+ n->nodename = 0;
+ n->contents = 0;
+ n->nodelen = -1;
+ n->display_pos = 0;
+ n->body_start = 0;
+ n->flags = 0;
+
+ return n;
+}
+
/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME,
using WINDOW for defaults. If WINDOW is null, the defaults are:
- If FILENAME is NULL, `dir' is used.
@@ -1017,14 +1036,11 @@
a node. */
if (strcmp (nodename, "*") == 0)
{
- node = xmalloc (sizeof (NODE));
+ node = info_create_node ();
node->filename = file_buffer->fullpath;
- node->parent = NULL;
node->nodename = xstrdup ("*");
node->contents = file_buffer->contents;
node->nodelen = file_buffer->filesize;
- node->flags = 0;
- node->display_pos = 0;
node_set_body_start (node);
}
#if defined (HANDLE_MAN_PAGES)
@@ -1233,9 +1249,8 @@
if (!(tag->nodestart >= 0 && tag->nodestart < subfile->filesize))
return NULL;
- node = xmalloc (sizeof (NODE));
+ node = info_create_node ();
node->filename = subfile->fullpath;
- node->parent = NULL;
node->nodename = tag->nodename;
if (tag->content_cache)
@@ -1243,8 +1258,6 @@
else
node->contents = subfile->contents + tag->nodestart;
- node->display_pos = 0;
- node->flags = 0;
node_set_body_start (node);
if (file_buffer->flags & N_HasTagsTable)
Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/nodes.h 2014-04-14 13:29:13 UTC (rev 5447)
@@ -134,6 +134,9 @@
a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */
extern FILE_BUFFER *info_load_file (char *filename);
+/* Return a pointer to a new NODE structure. */
+extern NODE *info_create_node (void);
+
/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME.
FILENAME can be passed as NULL, in which case the filename of "dir" is used.
NODENAME can be passed as NULL, in which case the nodename of "Top" is used.
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/session.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -3366,21 +3366,10 @@
/* Copy this node. */
{
- NODE *copy = xmalloc (sizeof (NODE));
-
- temp = stealer->nodes[which];
+ temp = xmalloc (sizeof (NODE));
+ *temp = *stealer->nodes[which];
point = stealer->points[which];
pagetop = stealer->pagetops[which];
-
- copy->filename = temp->filename;
- copy->parent = temp->parent;
- copy->nodename = temp->nodename;
- copy->contents = temp->contents;
- copy->nodelen = temp->nodelen;
- copy->flags = temp->flags;
- copy->display_pos = temp->display_pos;
-
- temp = copy;
}
window_set_node_of_window (info_win->window, temp);
Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-04-13 18:05:19 UTC (rev 5446)
+++ trunk/info/window.c 2014-04-14 13:29:13 UTC (rev 5447)
@@ -1293,12 +1293,7 @@
{
NODE *node;
- node = xzalloc (sizeof (NODE));
- node->filename = NULL;
- node->parent = NULL;
- node->nodename = NULL;
- node->flags = 0;
- node->display_pos =0;
+ node = info_create_node ();
/* Make sure that this buffer ends with a newline. */
node->nodelen = 1 + strlen (contents);
@@ -1312,12 +1307,7 @@
{
NODE *node;
- node = xzalloc (sizeof (NODE));
- node->filename = NULL;
- node->parent = NULL;
- node->nodename = NULL;
- node->flags = 0;
- node->display_pos =0;
+ node = info_create_node ();
/* Make sure that this buffer ends with a newline. */
node->nodelen = 1 + strlen (message_buffer.base);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5447] consolidate NODE creation,
Gavin D. Smith <=