[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6452] node quoting
From: |
Gavin D. Smith |
Subject: |
[6452] node quoting |
Date: |
Thu, 23 Jul 2015 09:10:31 +0000 |
Revision: 6452
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6452
Author: gavin
Date: 2015-07-23 09:10:29 +0000 (Thu, 23 Jul 2015)
Log Message:
-----------
node quoting
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/Makefile.am
trunk/info/info-utils.c
trunk/info/nodes.c
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-07-22 16:00:14 UTC (rev 6451)
+++ trunk/ChangeLog 2015-07-23 09:10:29 UTC (rev 6452)
@@ -1,3 +1,23 @@
+2015-07-23 Gavin Smith <address@hidden>
+
+ * info/info-utils.c (read_quoted_string) [QUOTE_NODENAMES]: Make
+ unconditional.
+ (printed_representation): Suppress display of character \177.
+ (parse_top_node_line): Get length of filename in node pointers
+ separately.
+ (read_bracketed_filename): Update comment. Allow out parameter
+ to take a null value.
+ (info_parse_node): Call read_quoted_string to get node name.
+ (scan_reference_label): Don't remove quoting.
+ (scan_reference_target): Add TODO to remove it here instead.
+
+ * info/session.c (info_handle_pointer): Call info_parse_node on
+ pointer text.
+ (info_parse_and_select): Call info_parse_node.
+
+ * info/nodes.c (get_filename_and_nodename): Don't call
+ info_parse_node.
+
2015-07-22 Gavin Smith <address@hidden>
* tp/tests/Makefile.am: Give a clue for what "onetst" stands
Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am 2015-07-22 16:00:14 UTC (rev 6451)
+++ trunk/info/Makefile.am 2015-07-23 09:10:29 UTC (rev 6452)
@@ -159,13 +159,6 @@
t/next-quoted.sh \
t/help.sh
-XFAIL_TESTS = \
- t/quoted-label-as-target.sh \
- t/quoted-target.sh \
- t/quoted-label-and-target.sh \
- t/goto-quoted.sh \
- t/next-quoted.sh
-
EXTRA_DIST += $(TESTS) $(XFAIL_TESTS) \
t/README t/infodir \
t/Init-inter.inc t/Init-test.inc t/Timeout-test.inc \
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2015-07-22 16:00:14 UTC (rev 6451)
+++ trunk/info/info-utils.c 2015-07-23 09:10:29 UTC (rev 6452)
@@ -56,8 +56,8 @@
char *info_parsed_nodename = NULL;
/* Read a filename surrounded by "(" and ")", accounting for matching
- characters. Return length of read filename. On error, set *FILENAME
- to null and return 0. */
+ characters, and place it in *FILENAME if FILENAME is not null. Return
+ length of read filename. On error, set *FILENAME to null and return 0. */
int
read_bracketed_filename (char *string, char **filename)
{
@@ -65,7 +65,6 @@
int count = 0; /* Level of nesting. */
int first_close = -1; /* First ")" encountered. */
- *filename = 0;
if (*string != '(')
return 0;
@@ -91,13 +90,19 @@
if (count > 0)
{
if (first_close == -1)
- return 0;
+ {
+ if (filename)
+ *filename = 0;
+ return 0;
+ }
i = first_close;
}
- /* Remember parsed filename. */
- *filename = xcalloc (1, i + 1);
- memcpy (*filename, string, i);
+ if (filename)
+ {
+ *filename = xcalloc (1, i + 1);
+ memcpy (*filename, string, i);
+ }
return i + 2; /* Length of filename plus "(" and ")". */
}
@@ -126,11 +131,10 @@
/* Parse out nodename. */
string += skip_whitespace_and_newlines (string);
- nodename_len = strlen (string);
+ nodename_len = read_quoted_string (string, "", 0, &info_parsed_nodename);
if (nodename_len != 0)
{
- info_parsed_nodename = xstrdup (string);
canonicalize_whitespace (info_parsed_nodename);
}
}
@@ -141,9 +145,7 @@
TERMINATOR is an empty string, finish at a null character. LINES is
the number of lines that the string can span. If LINES is zero, there is no
limit. Return length of string including any quoting characters. Return
- 0 if input was invalid.
-
- TODO: Decide on best method of quoting. */
+ 0 if input was invalid. */
long
read_quoted_string (char *start, char *terminator, int lines, char **output)
{
@@ -184,7 +186,6 @@
(*output)[len] = '\0';
}
}
-#ifdef QUOTE_NODENAMES
else
{
len = strcspn (start + 1, "\177");
@@ -203,13 +204,6 @@
len += 2;
}
-#else /* ! QUOTE_NODENAMES */
- else
- {
- *output = xstrdup ("");
- len = 0;
- }
-#endif
if (nl)
*nl = saved_char;
@@ -580,10 +574,8 @@
}
else if (*cur_ptr == DEL)
{
- *pchars = 2;
- *pbytes = 2;
- text_buffer_add_char (rep, '^');
- text_buffer_add_char (rep, '?');
+ *pchars = 0;
+ *pbytes = 0;
return text_buffer_base (rep);
}
else
@@ -1092,15 +1084,14 @@
static void
parse_top_node_line (NODE *node)
{
- char **store_in, *dummy = 0;
+ char **store_in;
+ char *nodename;
int value_length;
/* If the first line is empty, leave it in. This is the case
in the index-apropos window. */
if (*inptr == '\n')
- {
- return;
- }
+ return;
node->next = node->prev = node->up = 0;
@@ -1114,12 +1105,10 @@
if (!strncasecmp (inptr, INFO_FILE_LABEL, strlen(INFO_FILE_LABEL)))
{
skip_input (strlen(INFO_FILE_LABEL));
- store_in = &dummy;
}
else if (!strncasecmp (inptr, INFO_NODE_LABEL, strlen(INFO_NODE_LABEL)))
{
skip_input (strlen(INFO_NODE_LABEL));
- store_in = &dummy;
}
else if (!strncasecmp (inptr, INFO_PREV_LABEL, strlen(INFO_PREV_LABEL)))
{
@@ -1144,20 +1133,31 @@
}
else
{
- store_in = &dummy;
+ store_in = 0;
/* Not recognized - code below will skip to next comma */
}
skip_input (skip_whitespace (inptr));
+ if (*inptr != '(')
+ value_length = 0;
+ else
+ {
+ value_length = read_bracketed_filename (inptr, 0);
+ }
+
/* Separate at commas or newlines, so it will work for
filenames including full stops. */
- /* TODO: Account for "(dir)" and "(DIR)". */
- value_length = read_quoted_string (inptr, "\n\r\t,", 1, store_in);
+ value_length += read_quoted_string (inptr + value_length,
+ "\n\r\t,", 1, &nodename);
+ if (store_in)
+ {
+ *store_in = xmalloc (value_length + 1);
+ strncpy (*store_in, inptr, value_length);
+ (*store_in)[value_length] = '\0';
+ }
- free (dummy); dummy = 0;
-
- /* Skip past value and any quoting or separating characters. */
+ free (nodename);
skip_input (value_length);
if (*inptr == '\n')
@@ -1209,7 +1209,7 @@
return 0;
}
-/* Output, replace or hide text introducing a reference. inptr starts on
+/* Output, replace or hide text introducing a reference. INPTR starts on
the first byte of a sequence introducing a reference and finishes on the
first (non-whitespace) byte of the reference label. */
static int
@@ -1283,52 +1283,36 @@
static int
scan_reference_label (REFERENCE *entry)
{
- char *end;
- char *label = 0;
+ char *dummy;
long label_len;
/* Search forward to ":" to get label name. Cross-references may have
a newline in the middle. */
if (entry->type == REFERENCE_MENU_ITEM)
- label_len = read_quoted_string (inptr, ":", 1, &label);
+ label_len = read_quoted_string (inptr, ":", 1, &dummy);
else
- label_len = read_quoted_string (inptr, ":", 2, &label);
+ label_len = read_quoted_string (inptr, ":", 2, &dummy);
+ free (dummy);
if (label_len == 0)
- {
- free (label);
- return 0;
- }
+ return 0;
- entry->label = label;
+ entry->label = xmalloc (label_len + 1);
+ memcpy (entry->label, inptr, label_len);
+ entry->label[label_len] = '\0';
canonicalize_whitespace (entry->label);
-#ifdef QUOTE_NODENAMES
- if (inptr[0] == '\177')
- {
- skip_input (1);
- label_len -= 2;
- }
-#endif
-
- end = inptr + label_len;
-
if (preprocess_nodes_p)
entry->start = text_buffer_off (&output_buf);
/* Write text of label. */
- copy_input_to_output (end - inptr);
+ copy_input_to_output (label_len);
if (rewrite_p)
entry->end = text_buffer_off (&output_buf);
else
- entry->end = end - input_start;
+ entry->end = inptr - input_start;
-#ifdef QUOTE_NODENAMES
- if (inptr[0] == '\177')
- skip_input (1);
-#endif
-
/* Colon after label. */
skip_input (1);
/* Don't mess up the margin of a menu description. */
@@ -1345,16 +1329,26 @@
{
int i;
- /* If this reference entry continues with another ':' then the reference is
- within the same file, and the nodename is the same as the label. */
+ /* If this reference entry continues with another ':' then the target
+ of the reference is given by the label. */
if (*inptr == ':')
{
skip_input (1);
if (entry->type == REFERENCE_MENU_ITEM)
write_extra_bytes_to_output (" ", 1);
- entry->filename = 0;
- entry->nodename = xstrdup (entry->label);
+ info_parse_node (entry->label);
+ if (info_parsed_filename)
+ entry->filename = xstrdup (info_parsed_filename);
+ if (info_parsed_nodename)
+ entry->nodename = xstrdup (info_parsed_nodename);
+
+ if (inptr[-1] == '\177')
+ {
+ /* TODO: Remove the DEL bytes. We don't do this until after calling
+ info_parse_node so that ^?(FOO)BAR^?:: refers to a node called
+ "(FOO)BAR" within the current manual. */
+ }
return 1;
}
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2015-07-22 16:00:14 UTC (rev 6451)
+++ trunk/info/nodes.c 2015-07-23 09:10:29 UTC (rev 6452)
@@ -971,35 +971,30 @@
return info_get_node_with_defaults (filename_in, nodename_in, 0);
}
-/* Get filename and nodename of node to load using defaults from NODE. Output
- values should be freed by caller. */
+/* Get filename and nodename of node to load using defaults from NODE.
+ Output values should be freed by caller. */
static void
get_filename_and_nodename (NODE *node,
char **filename, char **nodename,
char *filename_in, char *nodename_in)
{
- /* Get file name, nodename */
- info_parse_node (nodename_in);
+ *filename = filename_in;
- if (info_parsed_filename)
- *filename = info_parsed_filename;
- else if (filename_in)
- *filename = filename_in;
-
/* If FILENAME is not specified, it defaults to "dir". */
- if (!*filename)
+ if (filename_in)
+ *filename = xstrdup (filename_in);
+ else
{
if (node)
- *filename = node->fullpath;
+ *filename = xstrdup (node->fullpath);
else
- *filename = "dir";
+ *filename = xstrdup ("dir");
}
- *filename = xstrdup (*filename);
- if (info_parsed_nodename)
- *nodename = xstrdup (info_parsed_nodename);
- /* If NODENAME is not specified, it defaults to "Top". */
+ if (nodename_in && *nodename_in)
+ *nodename = xstrdup (nodename_in);
else
+ /* If NODENAME is not specified, it defaults to "Top". */
*nodename = xstrdup ("Top");
}
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2015-07-22 16:00:14 UTC (rev 6451)
+++ trunk/info/session.c 2015-07-23 09:10:29 UTC (rev 6452)
@@ -2003,7 +2003,6 @@
char *label = entry->label;
int line_number = entry->line_number;
- /* problem here: this call can free 'entry' if the tag table is rewritten. */
node = info_get_node_with_defaults (filename, nodename, window->node);
/* Try something a little weird. If the node couldn't be found, and the
@@ -2079,9 +2078,9 @@
{
REFERENCE entry;
- /* info_parse_node will be called on 'line' in subsequent functions. */
- entry.nodename = line;
- entry.filename = 0;
+ info_parse_node (line);
+ entry.filename = info_parsed_filename;
+ entry.nodename = info_parsed_nodename;
entry.line_number = 0;
entry.label = "*info-parse-and-select*";
@@ -2855,7 +2854,10 @@
return 0;
}
- node = info_get_node_with_defaults (0, description, window->node);
+ info_parse_node (description);
+ node = info_get_node_with_defaults (info_parsed_filename,
+ info_parsed_nodename,
+ window->node);
if (!node)
{
if (info_recent_file_error)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6452] node quoting,
Gavin D. Smith <=