commit 0261d86f0c3b97d0402bb7f0253ff57b1102555b Author: Gavin Smith Date: Sun Mar 9 17:30:33 2014 +0000 * info-utils.c, info-utils.h (info_menu_of_node, info_xrefs_of_node) (info_menu_items, info_xrefs, info_references_internal): Functions deleted. * info-utils.c (info_parse_label): Function and associated macros deleted diff --git a/info-utils.c b/info-utils.c index d23e971..c23f65c 100644 --- a/info-utils.c +++ b/info-utils.c @@ -54,10 +54,6 @@ static void saven_filename (char *filename, int len); static void save_nodename (char *nodename); static void saven_nodename (char *nodename, int len); -/* How to get a reference (either menu or cross). */ -static REFERENCE **info_references_internal (char *label, - SEARCH_BINDING *binding); - /* Parse the filename and nodename out of STRING. Return length of node specification. If STRING doesn't contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set INFO_PARSED_FILENAME to NULL. The @@ -177,31 +173,6 @@ info_parse_node (char *string, int flag) return length; } -/* Return the node addressed by LABEL in NODE (usually one of "Prev:", - "Next:", "Up:", "File:", or "Node:". After a call to this function, - the global INFO_PARSED_NODENAME and INFO_PARSED_FILENAME contain - the information. */ -void -info_parse_label (char *label, NODE *node) -{ - register int i; - char *nodeline; - - /* Default answer to failure. */ - save_nodename (NULL); - save_filename (NULL); - - /* Find the label in the first line of this node. */ - nodeline = node->contents; - i = string_in_line (label, nodeline); - - if (i == -1) - return; - - nodeline += i; - nodeline += skip_whitespace (nodeline); - info_parse_node (nodeline, PARSE_NODE_DFLT); -} /* **************************************************************** */ /* */ @@ -209,167 +180,6 @@ info_parse_label (char *label, NODE *node) /* */ /* **************************************************************** */ -/* Return a NULL terminated array of REFERENCE * which represents the menu - found in NODE. If there is no menu in NODE, just return a NULL pointer. */ -REFERENCE ** -info_menu_of_node (NODE *node) -{ - long position; - SEARCH_BINDING tmp_search; - REFERENCE **menu = NULL; - - tmp_search.buffer = node->contents; - tmp_search.start = 0; - tmp_search.end = node->nodelen; - tmp_search.flags = S_FoldCase; - - /* Find the start of the menu. */ - if (search_forward (INFO_MENU_LABEL, &tmp_search, &position) - != search_success) - return NULL; - - /* We have the start of the menu now. Glean menu items from the rest - of the node. */ - tmp_search.start = position + strlen (INFO_MENU_LABEL); - tmp_search.start += skip_line (tmp_search.buffer + tmp_search.start); - tmp_search.start--; - menu = info_menu_items (&tmp_search); - return menu; -} - -/* Return a NULL terminated array of REFERENCE * which represents the cross - refrences found in NODE. If there are no cross references in NODE, just - return a NULL pointer. */ -REFERENCE ** -info_xrefs_of_node (NODE *node) -{ - SEARCH_BINDING tmp_search; - -#if defined (HANDLE_MAN_PAGES) - if (node->flags & N_IsManPage) - return xrefs_of_manpage (node); -#endif - - tmp_search.buffer = node->contents; - tmp_search.start = 0; - tmp_search.end = node->nodelen; - tmp_search.flags = S_FoldCase; - - return info_xrefs (&tmp_search); -} - -/* Glean menu entries from BINDING->buffer + BINDING->start until we - have looked at the entire contents of BINDING. Return an array - of REFERENCE * that represents each menu item in this range. */ -REFERENCE ** -info_menu_items (SEARCH_BINDING *binding) -{ - return info_references_internal (INFO_MENU_ENTRY_LABEL, binding); -} - -/* Glean cross references from BINDING->buffer + BINDING->start until - BINDING->end. Return an array of REFERENCE * that represents each - cross reference in this range. */ -REFERENCE ** -info_xrefs (SEARCH_BINDING *binding) -{ - return info_references_internal (INFO_XREF_LABEL, binding); -} - -/* Glean cross references or menu items from BINDING. Return an array - of REFERENCE * that represents the items found. */ -static REFERENCE ** -info_references_internal (char *label, SEARCH_BINDING *binding) -{ - SEARCH_BINDING tmp_search; - REFERENCE **refs = NULL; - size_t refs_index = 0, refs_slots = 0; - int searching_for_menu_items = 0; - long position; - - tmp_search.buffer = binding->buffer; - tmp_search.start = binding->start; - tmp_search.end = binding->end; - tmp_search.flags = S_FoldCase | S_SkipDest; - - searching_for_menu_items = (mbscasecmp (label, INFO_MENU_ENTRY_LABEL) == 0); - - while (search_forward (label, &tmp_search, &position) == search_success) - { - int offset, start; - char *refdef; - REFERENCE *entry; - - tmp_search.start = position; - tmp_search.start += skip_whitespace (tmp_search.buffer + tmp_search.start); - start = tmp_search.start - binding->start; - refdef = tmp_search.buffer + tmp_search.start; - offset = string_in_line (":", refdef); - - /* When searching for menu items, if no colon, there is no - menu item on this line. */ - if (offset == -1) - { - if (searching_for_menu_items) - continue; - else - { - int temp; - - temp = skip_line (refdef); - offset = string_in_line (":", refdef + temp); - if (offset == -1) - continue; /* Give up? */ - else - offset += temp; - } - } - - entry = xmalloc (sizeof (REFERENCE)); - entry->filename = NULL; - entry->nodename = NULL; - entry->label = xmalloc (offset); - strncpy (entry->label, refdef, offset - 1); - entry->label[offset - 1] = '\0'; - canonicalize_whitespace (entry->label); - entry->line_number = 0; - - refdef += offset; - entry->start = start; - entry->end = refdef - binding->buffer; - - /* If this reference entry continues with another ':' then the - nodename is the same as the label. */ - if (*refdef == ':') - { - entry->nodename = xstrdup (entry->label); - } - else - { - /* This entry continues with a specific nodename. Parse the - nodename from the specification. */ - - refdef += skip_whitespace_and_newlines (refdef); - - if (searching_for_menu_items) - info_parse_node (refdef, PARSE_NODE_DFLT); - else - info_parse_node (refdef, PARSE_NODE_SKIP_NEWLINES); - - if (info_parsed_filename) - entry->filename = xstrdup (info_parsed_filename); - - if (info_parsed_nodename) - entry->nodename = xstrdup (info_parsed_nodename); - - entry->line_number = info_parsed_line_number; - } - - add_pointer_to_array (entry, refs_index, refs, refs_slots, 50); - } - return refs; -} - /* Get the entry associated with LABEL in REFERENCES. Return a pointer to the ENTRY if found, or NULL. */ REFERENCE * diff --git a/info-utils.h b/info-utils.h index bd3b1ed..0074c0a 100644 --- a/info-utils.h +++ b/info-utils.h @@ -56,20 +56,6 @@ extern char *info_parsed_nodename; */ int info_parse_node (char *string, int flag); -/* Return a NULL terminated array of REFERENCE * which represents the menu - found in NODE. If there is no menu in NODE, just return a NULL pointer. */ -extern REFERENCE **info_menu_of_node (NODE *node); - -/* Return a NULL terminated array of REFERENCE * which represents the cross - refrences found in NODE. If there are no cross references in NODE, just - return a NULL pointer. */ -extern REFERENCE **info_xrefs_of_node (NODE *node); - -/* Glean cross references from BINDING->buffer + BINDING->start until - BINDING->end. Return an array of REFERENCE * that represents each - cross reference in this range. */ -extern REFERENCE **info_xrefs (SEARCH_BINDING *binding); - /* If preprocess_nodes_p=On, remove syntax from NODE->contents. Set NODE->references and other fields. */ void scan_node_contents (NODE *node); @@ -79,11 +65,6 @@ void scan_node_contents (NODE *node); extern REFERENCE *info_get_labeled_reference (char *label, REFERENCE **references); -/* Glean menu entries from BINDING->buffer + BINDING->start until we - have looked at the entire contents of BINDING. Return an array - of REFERENCE * that represents each menu item in this range. */ -extern REFERENCE **info_menu_items (SEARCH_BINDING *binding); - /* A utility function for concatenating REFERENCE **. Returns a new REFERENCE ** which is the concatenation of REF1 and REF2. The REF1 and REF2 arrays are freed, but their contents are not. */ @@ -124,22 +105,6 @@ extern WINDOW *get_internal_info_window (char *name); /* Return a window displaying the node NODE. */ extern WINDOW *get_window_of_node (NODE *node); -/* Return the node addressed by LABEL in NODE (usually one of "Prev:", - "Next:", "Up:", "File:", or "Node:". After a call to this function, - the globals `info_parsed_nodename' and `info_parsed_filename' contain - the information. */ -extern void info_parse_label (char *label, NODE *node); - -#define info_file_label_of_node(n) info_parse_label (INFO_FILE_LABEL, n) -#define info_next_label_of_node(n) info_parse_label (INFO_NEXT_LABEL, n) -#define info_up_label_of_node(n) info_parse_label (INFO_UP_LABEL, n) -#define info_prev_label_of_node(n) \ - do { \ - info_parse_label (INFO_PREV_LABEL, n); \ - if (!info_parsed_nodename && !info_parsed_filename) \ - info_parse_label (INFO_ALTPREV_LABEL, n); \ - } while (0) - struct text_buffer { char *base;