[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5884] process Info tags as starting with a null byte, and remove them f
From: |
Gavin D. Smith |
Subject: |
[5884] process Info tags as starting with a null byte, and remove them from the node |
Date: |
Wed, 22 Oct 2014 22:19:04 +0000 |
Revision: 5884
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5884
Author: gavin
Date: 2014-10-22 22:19:04 +0000 (Wed, 22 Oct 2014)
Log Message:
-----------
process Info tags as starting with a null byte, and remove them from the node
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/filesys.c
trunk/info/indices.c
trunk/info/info-utils.c
trunk/info/session.c
trunk/info/tag.c
trunk/info/window.c
trunk/info/window.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/ChangeLog 2014-10-22 22:19:04 UTC (rev 5884)
@@ -7,6 +7,26 @@
* info/indices.c (info_indices_of_file_buffer): Call strstr
instead of string_in_line.
+ * info/filesys.c (convert_eols): Don't convert nulls in Info
+ tags into spaces any more.
+ * info/indices.c (info_index_apropos, info_virtual_index),
+ * info/session.c (allfiles_create_node): Add index tag with
+ nulls instead of spaces.
+
+ * info/info-utils.c (forward_to_info_syntax, scan_info_tag):
+ Look for tags starting with nulls instead of spaces. This is
+ slightly faster because nodes generally contain many space
+ characters.
+ (skip_tag_contents): New function.
+ (scan_info_tag): Call it.
+ * info/tag.c (tag_expand): Look for tag starting with a null
+ instead of a space. Skip past the tag even if no handler for it
+ was found (for example, an index tag).
+
+ * info/info-utils.c (printed_representation): Don't check for an
+ Info tag, as they should have been removed already.
+ * info/window.c (info_tag): Function removed.
+
2014-10-21 Karl Berry <address@hidden>
* tp/texi2any.pl (makeinfo_help),
Modified: trunk/info/filesys.c
===================================================================
--- trunk/info/filesys.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/filesys.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -289,10 +289,7 @@
we afford converting them into newlines as well? Maybe implement some
heuristics here, like in Emacs 20.
- FIXME: is it a good idea to show the EOL type on the modeline?
-
- Additionally, convert null bytes in "Info tags" to spaces. This simplifies
- processing of node contents. */
+ FIXME: is it a good idea to show the EOL type on the modeline? */
static long
convert_eols (char *text, long int textlen)
{
@@ -306,13 +303,7 @@
s++;
textlen--;
}
- *d = *s++;
-
- if (d[0] == '\0' && d[1] == '\010'
- && (d[2] == '[' || d[2] == ']'))
- d[0] = ' ';
-
- d++;
+ *d++ = *s++;
}
return d - text;
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/indices.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -653,7 +653,7 @@
text_buffer_printf (&message, _("Index entries containing "
"'%s':\n"), index_search);
text_buffer_printf (&message, "\n* Menu:");
- text_buffer_printf (&message, " \b[index \b]");
+ text_buffer_add_string (&message, "\0\b[index\0\b]", 11);
text_buffer_add_char (&message, '\n');
for (i = 0; apropos_list[i]; i++)
@@ -810,8 +810,9 @@
"File: %s, Node: Index for '%s'\n\n"
"Virtual Index\n"
"*************\n\n"
- "Index entries that match '%s':\n"
- " \b[index \b]"
+ "Index entries that match '%s':\n");
+ text_buffer_add_string (&text, "\0\b[index\0\b]", 11);
+ text_buffer_printf (&text,
"\n* Menu:\n\n",
fb->filename, index_search, index_search);
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/info-utils.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -504,21 +504,11 @@
if (mb_isprint (mbi_cur (*iter)))
{
- if (info_tag (*iter, &cur_len))
- {
- *pchars = 0;
- *pbytes = 0;
- ITER_SETBYTES (*iter, cur_len);
- return cur_ptr;
- }
- else
- {
- /* cur.wc gives a wchar_t object. See mbiter.h in the
- gnulib/lib directory. */
- *pchars = wcwidth ((*iter).cur.wc);
- *pbytes = cur_len;
- return cur_ptr;
- }
+ /* cur.wc gives a wchar_t object. See mbiter.h in the
+ gnulib/lib directory. */
+ *pchars = wcwidth ((*iter).cur.wc);
+ *pbytes = cur_len;
+ return cur_ptr;
}
else if (cur_len == 1)
{
@@ -1053,6 +1043,17 @@
}
}
+/* Like skip_input, but skip even when !preprocess_nodes_p. */
+static void
+skip_tag_contents (long n)
+{
+ if (rewrite_p)
+ {
+ inptr += n;
+ output_bytes_difference += n;
+ }
+}
+
/* ANSI escape codes */
#define ANSI_UNDERLINING_OFF "\033[24m"
#define ANSI_UNDERLINING_ON "\033[4m"
@@ -1533,8 +1534,7 @@
}
/* Process an in index marker ("address@hidden@^H]") or an image marker
- ("address@hidden address@hidden"). The null bytes here were converted into
spaces in
- the convert_eols function in filesys.c. */
+ ("address@hidden address@hidden"). */
static void
scan_info_tag (NODE *node, int *in_index, FILE_BUFFER *fb)
{
@@ -1568,7 +1568,7 @@
write_tag_contents (text_buffer_base (expansion),
text_buffer_off (expansion));
/* Skip past body of tag. */
- skip_input (p1 - inptr);
+ skip_tag_contents (p1 - inptr);
}
else
{
@@ -1593,7 +1593,7 @@
if (looking_at_string (contents, INFO_MENU_ENTRY_LABEL)
|| looking_at_string (contents, INFO_MENU_LABEL)
|| looking_at_string (contents, INFO_XREF_LABEL)
- || !memcmp (contents, " \b[", 3))
+ || !memcmp (contents, "\0\b[", 3))
return contents;
contents++;
}
@@ -1689,7 +1689,7 @@
skip_input (strspn (inptr, "\n") - 1); /* Keep one newline. */
}
- else if (match[0] == ' ') /* Info tag */
+ else if (match[0] == '\0') /* Info tag */
{
scan_info_tag (node, &in_index, fb);
}
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/session.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -86,7 +86,7 @@
term, term);
/* Mark as an index so that destinations are never hidden. */
- text_buffer_add_string (&text, "\040\010[index\040\010]", 11);
+ text_buffer_add_string (&text, "\0\b[index\0\b]", 11);
text_buffer_printf (&text, "\n* Menu:\n\n");
for (i = 0; fref[i]; i++)
Modified: trunk/info/tag.c
===================================================================
--- trunk/info/tag.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/tag.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -213,13 +213,13 @@
size_t len;
struct tag_handler *tp;
- if (memcmp(p, " \b[", 3) != 0) /* opening magic? */
+ if (memcmp(p, "\0\b[", 3) != 0) /* opening magic? */
return 0;
p += 3;
- q = strstr (p, " \b]"); /* closing magic? */
- if (!q)
- return 0;
+ q = p + strlen (p);
+ if (memcmp (q + 1, "\b]", 2)) /* closing magic? */
+ return 0; /* Not a proper tag. */
/* Output is different for index nodes */
if (!strncmp ("index", p, strlen ("index")))
@@ -227,21 +227,13 @@
len = strcspn (p, " \t"); /* tag name */
tp = find_tag_handler (p, len);
- if (tp)
+ if (tp && tp->handler)
{
while (p[len] == ' ' || p[len] == '\t')
++len; /* move past whitespace */
- q[0] = '\0';
-
- if (!tp->handler || tp->handler (p + len, outbuf) == 0)
- {
- *input = q + 3;
- q[0] = ' ';
-
- return 1;
- }
- q[0] = ' ';
+ tp->handler (p + len, outbuf);
}
- return 0;
+ *input = q + 3;
+ return 1;
}
Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/window.c 2014-10-22 22:19:04 UTC (rev 5884)
@@ -1186,36 +1186,6 @@
}
-/* If ITER points to an info tag, set PLEN to its length in bytes and
- return 1. Otherwise, return 0.
-*/
-int
-info_tag (mbi_iterator_t iter, size_t *plen)
-{
- if (*mbi_cur_ptr (iter) == ' ' && mbi_avail (iter))
- {
- mbi_advance (iter);
- if (*mbi_cur_ptr (iter) == '\b' && mbi_avail (iter))
- {
- mbi_advance (iter);
- if (*mbi_cur_ptr (iter) == '[' && mbi_avail (iter))
- {
- const char *ptr, *end;
- mbi_advance (iter);
- ptr = mbi_cur_ptr (iter);
- end = memmem (ptr, ITER_LIMIT (iter), " \b]", 3);
- if (end)
- {
- *plen = end - ptr + 6;
- return 1;
- }
- }
- }
- }
-
- return 0;
-}
-
/* Process contents of the current node from WIN, beginning from START, using
callback function FUN.
Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-10-22 21:00:10 UTC (rev 5883)
+++ trunk/info/window.h 2014-10-22 22:19:04 UTC (rev 5884)
@@ -226,8 +226,6 @@
int (*fun) (WINDOW *, size_t, size_t, size_t, char *,
size_t, size_t));
-int info_tag (mbi_iterator_t iter, size_t *plen);
-
extern void window_compute_line_map (WINDOW *win);
extern int window_point_to_column (WINDOW *win, long point, long *np);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5884] process Info tags as starting with a null byte, and remove them from the node,
Gavin D. Smith <=