[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * info/nodes.c (get_tags_of_indirect_tags_table):
From: |
Gavin D. Smith |
Subject: |
branch master updated: * info/nodes.c (get_tags_of_indirect_tags_table): Reduce indentation of code. |
Date: |
Sun, 25 Apr 2021 11:05:51 -0400 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new ac9f3c4 * info/nodes.c (get_tags_of_indirect_tags_table): Reduce
indentation of code.
ac9f3c4 is described below
commit ac9f3c49933320cc7708dc3b7f5b4711625fdffa
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Apr 25 16:05:45 2021 +0100
* info/nodes.c (get_tags_of_indirect_tags_table):
Reduce indentation of code.
---
ChangeLog | 5 ++
info/nodes.c | 203 +++++++++++++++++++++++++++++------------------------------
2 files changed, 106 insertions(+), 102 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1220b05..5a8a7c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-25 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * info/nodes.c (get_tags_of_indirect_tags_table):
+ Reduce indentation of code.
+
2021-04-25 Vitezslav Crhonek <vcrhonek@redhat.com> (tiny change)
Fix memory leaks.
diff --git a/info/nodes.c b/info/nodes.c
index 631e7af..397fa5b 100644
--- a/info/nodes.c
+++ b/info/nodes.c
@@ -361,33 +361,33 @@ get_tags_of_indirect_tags_table (FILE_BUFFER *file_buffer,
/* We have the list of tags in file_buffer->tags. Get the list of
subfiles from the indirect table. */
{
- char *start, *end, *line;
- SUBFILE *subfile;
+ char *start, *end, *line;
+ SUBFILE *subfile;
- start = indirect_binding->buffer + indirect_binding->start;
- end = indirect_binding->buffer + indirect_binding->end;
- line = start;
+ start = indirect_binding->buffer + indirect_binding->start;
+ end = indirect_binding->buffer + indirect_binding->end;
+ line = start;
- while (line < end)
- {
- int colon;
+ while (line < end)
+ {
+ int colon;
- colon = string_in_line (":", line);
+ colon = string_in_line (":", line);
- if (colon == -1)
- break;
+ if (colon == -1)
+ break;
- subfile = xmalloc (sizeof (SUBFILE));
- subfile->filename = xmalloc (colon);
- strncpy (subfile->filename, line, colon - 1);
- subfile->filename[colon - 1] = 0;
- subfile->first_byte = (long) atol (line + colon);
+ subfile = xmalloc (sizeof (SUBFILE));
+ subfile->filename = xmalloc (colon);
+ strncpy (subfile->filename, line, colon - 1);
+ subfile->filename[colon - 1] = 0;
+ subfile->first_byte = (long) atol (line + colon);
- add_pointer_to_array (subfile, subfiles_index, subfiles,
- subfiles_slots, 10);
+ add_pointer_to_array (subfile, subfiles_index, subfiles,
+ subfiles_slots, 10);
- while (*line++ != '\n');
- }
+ while (*line++ != '\n');
+ }
}
/* If we have successfully built the indirect files table, then
@@ -397,102 +397,101 @@ get_tags_of_indirect_tags_table (FILE_BUFFER
*file_buffer,
free_file_buffer_tags (file_buffer);
return;
}
- else
+
+ {
+ int tags_index;
+ long header_length;
+ SEARCH_BINDING binding;
+
+ char *containing_dir;
+ char *temp;
+ int len_containing_dir;
+
+ /* Find the length of the header of the file containing the indirect
+ tags table. This header appears at the start of every file. We
+ want the absolute position of each node within each subfile, so
+ we subtract the start of the containing subfile from the logical
+ position of the node, and then add the length of the header in. */
+ binding.buffer = file_buffer->contents;
+ binding.start = 0;
+ binding.end = file_buffer->filesize;
+ binding.flags = S_FoldCase;
+
+ header_length = find_node_separator (&binding);
+ if (header_length == -1)
+ header_length = 0;
+
+ /* Build the file buffer's list of subfiles. */
+ containing_dir = xstrdup (file_buffer->fullpath);
+ temp = filename_non_directory (containing_dir);
+
+ if (temp > containing_dir)
{
- int tags_index;
- long header_length;
- SEARCH_BINDING binding;
-
- /* Find the length of the header of the file containing the indirect
- tags table. This header appears at the start of every file. We
- want the absolute position of each node within each subfile, so
- we subtract the start of the containing subfile from the logical
- position of the node, and then add the length of the header in. */
- binding.buffer = file_buffer->contents;
- binding.start = 0;
- binding.end = file_buffer->filesize;
- binding.flags = S_FoldCase;
-
- header_length = find_node_separator (&binding);
- if (header_length == -1)
- header_length = 0;
-
- /* Build the file buffer's list of subfiles. */
- {
- char *containing_dir = xstrdup (file_buffer->fullpath);
- char *temp = filename_non_directory (containing_dir);
- int len_containing_dir;
-
- if (temp > containing_dir)
- {
- if (HAVE_DRIVE (file_buffer->fullpath) &&
- temp == containing_dir + 2)
- {
- /* Avoid converting "d:foo" into "d:/foo" below. */
- *temp = '.';
- temp += 2;
- }
- temp[-1] = 0;
- }
+ if (HAVE_DRIVE (file_buffer->fullpath) &&
+ temp == containing_dir + 2)
+ {
+ /* Avoid converting "d:foo" into "d:/foo" below. */
+ *temp = '.';
+ temp += 2;
+ }
+ temp[-1] = 0;
+ }
- len_containing_dir = strlen (containing_dir);
+ len_containing_dir = strlen (containing_dir);
- for (i = 0; subfiles[i]; i++);
+ for (i = 0; subfiles[i]; i++);
+ file_buffer->subfiles = xmalloc ((1 + i) * sizeof (char *));
- file_buffer->subfiles = xmalloc ((1 + i) * sizeof (char *));
+ for (i = 0; subfiles[i]; i++)
+ {
+ char *fullpath;
+ fullpath = xmalloc
+ (2 + strlen (subfiles[i]->filename) + len_containing_dir);
- for (i = 0; subfiles[i]; i++)
- {
- char *fullpath;
+ sprintf (fullpath, "%s/%s",
+ containing_dir, subfiles[i]->filename);
- fullpath = xmalloc
- (2 + strlen (subfiles[i]->filename) + len_containing_dir);
+ file_buffer->subfiles[i] = fullpath;
+ }
+ file_buffer->subfiles[i] = NULL;
+ free (containing_dir);
- sprintf (fullpath, "%s/%s",
- containing_dir, subfiles[i]->filename);
+ /* For each node in the file's tags table, remember the starting
+ position. */
+ for (tags_index = 0; (entry = file_buffer->tags[tags_index]);
+ tags_index++)
+ {
+ for (i = 0;
+ subfiles[i] && entry->nodestart >= subfiles[i]->first_byte;
+ i++);
- file_buffer->subfiles[i] = fullpath;
- }
- file_buffer->subfiles[i] = NULL;
- free (containing_dir);
- }
-
- /* For each node in the file's tags table, remember the starting
- position. */
- for (tags_index = 0; (entry = file_buffer->tags[tags_index]);
- tags_index++)
+ /* If the Info file containing the indirect tags table is
+ malformed, then give up. */
+ if (!i)
{
- for (i = 0;
- subfiles[i] && entry->nodestart >= subfiles[i]->first_byte;
- i++);
-
- /* If the Info file containing the indirect tags table is
- malformed, then give up. */
- if (!i)
+ /* The Info file containing the indirect tags table is
+ malformed. Give up. */
+ for (i = 0; subfiles[i]; i++)
{
- /* The Info file containing the indirect tags table is
- malformed. Give up. */
- for (i = 0; subfiles[i]; i++)
- {
- free (subfiles[i]->filename);
- free (subfiles[i]);
- free (file_buffer->subfiles[i]);
- }
- file_buffer->subfiles = NULL;
- free_file_buffer_tags (file_buffer);
- return;
+ free (subfiles[i]->filename);
+ free (subfiles[i]);
+ free (file_buffer->subfiles[i]);
}
+ file_buffer->subfiles = NULL;
+ free_file_buffer_tags (file_buffer);
+ return;
+ }
- /* SUBFILES[i] is the index of the first subfile whose logical
- first byte is greater than the logical offset of this node's
- starting position. This means that the subfile directly
- preceding this one is the one containing the node. */
+ /* SUBFILES[i] is the index of the first subfile whose logical
+ first byte is greater than the logical offset of this node's
+ starting position. This means that the subfile directly
+ preceding this one is the one containing the node. */
- entry->filename = file_buffer->subfiles[i - 1];
- entry->nodestart -= subfiles[i - 1]->first_byte;
- entry->nodestart += header_length;
- }
+ entry->filename = file_buffer->subfiles[i - 1];
+ entry->nodestart -= subfiles[i - 1]->first_byte;
+ entry->nodestart += header_length;
}
+ }
/* Free the structures assigned to SUBFILES. Free the names as well
as the structures themselves, then finally, the array. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * info/nodes.c (get_tags_of_indirect_tags_table): Reduce indentation of code.,
Gavin D. Smith <=