[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6195] parsetexi def line enter index entry
From: |
Gavin D. Smith |
Subject: |
[6195] parsetexi def line enter index entry |
Date: |
Sat, 28 Mar 2015 13:07:14 +0000 |
Revision: 6195
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6195
Author: gavin
Date: 2015-03-28 13:07:12 +0000 (Sat, 28 Mar 2015)
Log Message:
-----------
parsetexi def line enter index entry
Modified Paths:
--------------
trunk/parsetexi/api.c
trunk/parsetexi/def.c
trunk/parsetexi/dump_perl.c
trunk/parsetexi/end_line.c
trunk/parsetexi/indices.c
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-03-26 17:23:40 UTC (rev 6194)
+++ trunk/parsetexi/api.c 2015-03-28 13:07:12 UTC (rev 6195)
@@ -500,6 +500,12 @@
if (e->content)
{
SV **contents_array;
+ if (!e->content->hv)
+ {
+ if (e->content->parent_type != route_not_in_tree)
+ abort ();
+ element_to_perl_hash (e->content);
+ }
contents_array = hv_fetch (e->content->hv,
"contents", strlen ("contents"), 0);
Modified: trunk/parsetexi/def.c
===================================================================
--- trunk/parsetexi/def.c 2015-03-26 17:23:40 UTC (rev 6194)
+++ trunk/parsetexi/def.c 2015-03-28 13:07:12 UTC (rev 6195)
@@ -183,7 +183,6 @@
0, 0, 0
};
-/* Note that ARG should not be an element in the main tree. */
static void
add_to_def_args_extra (DEF_ARGS_EXTRA *d, char *label, ELEMENT *arg)
{
@@ -225,7 +224,8 @@
/* Copy contents of argument line. */
arg_line = new_element (ET_NONE);
- for (i = 0; i < contents.number; i++)
+ for (i = contents.list[0]->type != ET_empty_spaces_after_command ? 0 : 1;
+ i < contents.number; i++)
{
if (contents.list[i]->text.space > 0)
{
Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-03-26 17:23:40 UTC (rev 6194)
+++ trunk/parsetexi/dump_perl.c 2015-03-28 13:07:12 UTC (rev 6195)
@@ -569,7 +569,10 @@
if (e->content)
{
text_printf (&indices_dump, "'content' => ");
- dump_route_to_element (e->content, &indices_dump);
+ if (e->content->parent_type != route_not_in_tree)
+ dump_route_to_element (e->content, &indices_dump);
+ else
+ dump_element (e->content, &indices_dump);
text_printf (&indices_dump, "{'contents'}");
text_printf (&indices_dump, ",\n");
}
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-03-26 17:23:40 UTC (rev 6194)
+++ trunk/parsetexi/end_line.c 2015-03-28 13:07:12 UTC (rev 6195)
@@ -1187,7 +1187,7 @@
/* End of a definition line, like @deffn */ // 2778
else if (current->parent && current->parent->type == ET_def_line)
{
- enum element_type def_command;
+ enum command_id def_command, original_def_command;
DEF_ARGS_EXTRA *arguments = 0;
if (pop_context () != ct_def)
@@ -1195,7 +1195,7 @@
/* current->parent is a ET_def_line, and current->parent->parent
the def command. */
- def_command = current->parent->parent->cmd;
+ original_def_command = def_command = current->parent->parent->cmd;
/* Strip an trailing x from the command, e.g. @deffnx -> @deffn */
if (command_data(def_command).flags & CF_misc)
{
@@ -1228,32 +1228,38 @@
if (name) // 2811
{
- if (name->type == ET_bracketed_def_content
- && (name->contents.number == 0
- || (name->contents.number == 1
-&& name->contents.list[0]->text.text[
-strspn (name->contents.list[0]->text.text, whitespace_chars)] == '\0')))
+ /* Set index_entry unless an empty ET_bracketed_def_content. */
+ if (name->type != ET_bracketed_def_content
+ || name->contents.number >= 2)
+ index_entry = name;
+ else if (name->contents.number == 1)
{
+ char *t = name->contents.list[0]->text.text;
+ if (t[strspn (t, whitespace_chars)] != '\0')
+ index_entry = name;
}
- else
- index_entry = name;
}
if (index_entry) // 2822
{
-
- // enter_index_entry (); // 2853
+ ELEMENT *index_contents = new_element (ET_NONE);
+ index_contents->parent_type = route_not_in_tree;
+ add_to_contents_as_array (index_contents, index_entry);
+ enter_index_entry (def_command,
+ original_def_command,
+ current->parent,
+ index_contents); // 2853
}
else
{
command_warnf ("missing name for @%s",
- "<original_def_cmdname>"); // TODO
+ command_name (original_def_command));
}
}
else
{
command_warnf ("missing category for @%s",
- "<original_def_cmdname>"); // TODO
+ command_name (original_def_command));
}
current = current->parent->parent; // 2868
Modified: trunk/parsetexi/indices.c
===================================================================
--- trunk/parsetexi/indices.c 2015-03-26 17:23:40 UTC (rev 6194)
+++ trunk/parsetexi/indices.c 2015-03-28 13:07:12 UTC (rev 6195)
@@ -63,7 +63,10 @@
return 0;
}
-void
+
+/* Save a new Texinfo command with the name CMDNAME and record that it
+ creates index entries in IDX. */
+static void
add_index_command (char *cmdname, INDEX *idx)
{
enum command_id new = add_texinfo_command (cmdname);
@@ -77,7 +80,6 @@
add_index_internal (char *name, int in_code)
{
INDEX *idx = malloc (sizeof (INDEX));
- char *cmdname;
memset (idx, 0, sizeof *idx);
idx->name = name;
@@ -90,20 +92,37 @@
}
index_names[number_of_indices++] = idx;
index_names[number_of_indices] = 0;
-
- /* For example, "rq" -> "rqindex". */
- asprintf (&cmdname, "%s%s", name, "index");
- add_index_command (cmdname, idx);
- free (cmdname);
return idx;
}
+/* NAME is the name of an index, e.g. "cp" */
+static INDEX *
+index_by_name (char *name)
+{
+ int i;
+
+ for (i = 0; i < num_index_commands; i++)
+ {
+ if (!strcmp (index_names[i]->name, name))
+ return index_names[i];
+ }
+ return 0;
+}
+
+
+/* Add a user defined index with the name NAME */
void
add_index (char *name, int in_code)
{
INDEX *idx;
+ char *cmdname;
idx = add_index_internal (name, in_code);
+
+ /* For example, "rq" -> "rqindex". */
+ asprintf (&cmdname, "%s%s", name, "index");
+ add_index_command (cmdname, idx);
+ free (cmdname);
}
void
@@ -112,23 +131,87 @@
INDEX *idx;
char **p;
char *default_indices[] = {
- "cp",
- "fn",
- "vr",
- "ky",
- "pg",
- "tp",
+ "cp", /* concepts */
+ "fn", /* functions */
+ "vr", /* variables */
+ "ky", /* keystrokes */
+ "pg", /* programs */
+ "tp", /* types */
0,
};
+ int i, j;
+
char name[] = "?index";
+ char name2[] = "??index";
+#define MAX (10 * 2)
+
+#define X(command) CM_##command, CM_##command##x
+ struct def_cmds { char *name; enum command_id id[MAX]; }
+ def_command_indices[] = {
+ "fn",
+
+ {X(deffn),
+ X(deftypefn),
+ X(deftypeop),
+ X(defop),
+ X(defun),
+ X(defmac),
+ X(defspec),
+ X(deftypefun),
+ X(defmethod),
+ X(deftypemethod),
+ },
+
+ "vr",
+
+ {X(defvr),
+ X(deftypevr),
+ X(defcv),
+ X(deftypecv),
+ X(defvar),
+ X(defivar),
+ X(defopt),
+ X(deftypevar),
+ X(deftypeivar),
+ },
+
+ "tp",
+
+ {X(deftp),}
+ };
+#undef X
+
for (p = default_indices; *p; p++)
{
- /* Both @cpindex and @cindex are added. */
+ /* Both @cindex and @cpindex are added. */
idx = add_index_internal (*p, 0);
+
*name = **p;
- add_index_command (name, idx);
+ add_index_command (name, idx); /* @cindex */
+
+ name2[0] = (*p)[0];
+ name2[1] = (*p)[1];
+ add_index_command (name2, idx); /* @cpindex */
}
+
+ for (i = 0;
+ i < sizeof (def_command_indices) / sizeof (def_command_indices[0]);
+ i++)
+ {
+ enum command_id cmd;
+ idx = index_by_name (def_command_indices[i].name);
+ if (idx)
+ {
+ for (j = 0; j < MAX; j++)
+ {
+ cmd = def_command_indices[i].id[j];
+ if (cmd)
+ associate_command_to_index (cmd, idx);
+ }
+ }
+ }
+#undef MAX
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6195] parsetexi def line enter index entry,
Gavin D. Smith <=