[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6849] parsetexi update (floats)
From: |
Gavin D. Smith |
Subject: |
[6849] parsetexi update (floats) |
Date: |
Fri, 11 Dec 2015 23:34:02 +0000 |
Revision: 6849
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6849
Author: gavin
Date: 2015-12-11 23:34:01 +0000 (Fri, 11 Dec 2015)
Log Message:
-----------
parsetexi update (floats)
Modified Paths:
--------------
trunk/parsetexi/api.c
trunk/parsetexi/end_line.c
trunk/parsetexi/extra.c
trunk/parsetexi/handle_commands.c
trunk/parsetexi/indices.c
trunk/parsetexi/parser.h
trunk/parsetexi/separator.c
trunk/parsetexi/tree_types.h
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/api.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -235,7 +235,8 @@
|| e->cmd == CM_TeX
|| (command_data(e->cmd).flags & CF_brace
&& (command_data(e->cmd).data > 0 // 4838
- || command_data(e->cmd).data == BRACE_style))
+ || command_data(e->cmd).data == BRACE_style
+ || command_data(e->cmd).data == BRACE_context))
|| e->cmd == CM_node) // FIXME special case
{
AV *av;
@@ -475,6 +476,19 @@
break;
}
+ case extra_float_type:
+ {
+ EXTRA_FLOAT_TYPE *eft = (EXTRA_FLOAT_TYPE *) f;
+ HV *type = newHV ();
+ if (eft->content)
+ hv_store (type, "content", strlen ("content"),
+ build_perl_array (&eft->content->contents), 0);
+ if (eft->normalized)
+ hv_store (type, "normalized", strlen ("normalized"),
+ newSVpv (eft->normalized, 0), 0);
+ STORE(newRV_inc ((SV *)type));
+ break;
+ }
default:
abort ();
break;
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/end_line.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -801,6 +801,41 @@
return result;
}
+int
+parse_float_type (ELEMENT *current)
+{
+ ELEMENT *type_contents;
+ EXTRA_FLOAT_TYPE *eft;
+ eft = malloc (sizeof (EXTRA_FLOAT_TYPE));
+ eft->content = 0;
+ eft->normalized = 0;
+
+ if (current->args.number > 0)
+ {
+ type_contents = trim_spaces_comment_from_content
+ (args_child_by_index(current, 0));
+ if (type_contents->contents.number > 0)
+ {
+ char *normalized;
+ normalized = convert_to_normalized (type_contents);
+ eft->content = type_contents;
+ if (normalized[strspn (normalized, "-")] != '\0')
+ eft->normalized = normalized;
+ /* TODO: why do we check there's a character that isn't '-'? */
+
+ add_extra_float_type (current, "type", eft);
+ return 1;
+ }
+ else
+ {
+ destroy_element (type_contents);
+ }
+ }
+ eft->normalized = "";
+ add_extra_float_type (current, "type", eft);
+ return 0;
+}
+
/* Actions to be taken at the end of a line that started a block that
has to be ended with "@end". */
ELEMENT *
@@ -894,7 +929,11 @@
{
// TODO 2950
}
+ parse_float_type (current->parent);
+ //type = ;
}
+ // add to global 'floats' array and set 'float_section' directly
+ // on $float.
}
current = current->parent; //2965
//counter_pop (&count_remaining_args);
@@ -1001,7 +1040,7 @@
// 3100
/* Actions to be taken at the end of an argument to a line command
- not starting a block. */
+ not starting a block. @end is processed in here. */
static ELEMENT *
end_line_misc_line (ELEMENT *current)
{
@@ -1186,6 +1225,7 @@
}
else if (current->cmd == CM_listoffloats) /* 3248 */
{
+ parse_float_type (current);
}
else
{
Modified: trunk/parsetexi/extra.c
===================================================================
--- trunk/parsetexi/extra.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/extra.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -107,6 +107,13 @@
}
void
+add_extra_float_type (ELEMENT *e, char *key, EXTRA_FLOAT_TYPE *value)
+{
+ add_extra_key (e, key, (ELEMENT *) value);
+ e->extra[e->extra_number - 1].type = extra_float_type;
+}
+
+void
add_extra_string (ELEMENT *e, char *key, char *value)
{
add_extra_key (e, key, (ELEMENT *) value);
Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/handle_commands.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -686,7 +686,8 @@
// 258 keep_line_nr_brace_commands
if (e->cmd == CM_titlefont || e->cmd == CM_anchor
|| command_data(e->cmd).data > 0
- || command_data(e->cmd).data == BRACE_style)
+ || command_data(e->cmd).data == BRACE_style
+ || command_data(e->cmd).data == BRACE_context)
{
e->line_nr = line_nr;
}
Modified: trunk/parsetexi/indices.c
===================================================================
--- trunk/parsetexi/indices.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/indices.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -146,8 +146,6 @@
char name[] = "?index";
char name2[] = "??index";
- number_of_indices = 0;
-
#define MAX (10 * 2)
#define X(command) CM_##command, CM_##command##x
@@ -186,6 +184,8 @@
};
#undef X
+ number_of_indices = 0;
+
for (p = default_indices; p->name; p++)
{
/* Both @cindex and @cpindex are added. */
Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/parser.h 2015-12-11 23:34:01 UTC (rev 6849)
@@ -83,6 +83,7 @@
void add_extra_node_spec (ELEMENT *e, char *key, NODE_SPEC_EXTRA *value);
void add_extra_node_spec_array (ELEMENT *, char *, NODE_SPEC_EXTRA **value);
void add_extra_def_args (ELEMENT *e, char *key, DEF_ARGS_EXTRA *value);
+void add_extra_float_type (ELEMENT *e, char *key, EXTRA_FLOAT_TYPE *value);
void add_extra_string (ELEMENT *e, char *key, char *value);
KEY_PAIR *lookup_extra_key (ELEMENT *e, char *key);
Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/separator.c 2015-12-11 23:34:01 UTC (rev 6849)
@@ -89,7 +89,41 @@
{
if (command == CM_caption || command == CM_shortcaption)
{
- }
+#define float floatxx
+ ELEMENT *float;
+ if (!current->parent->parent
+ || current->parent->parent->cmd != CM_float)
+ {
+ float = current->parent;
+ while (float->parent && float->cmd != CM_float)
+ float = float->parent;
+ if (float->cmd != CM_float)
+ {
+ line_errorf ("@%s is not meaningful outside "
+ "address@hidden' environment",
+ command_name(command));
+ float = 0;
+ }
+ else
+ line_warnf ("@%s should be right below address@hidden'",
+ command_name(command));
+ }
+ else
+ float = current->parent->parent;
+ if (float)
+ {
+ if (lookup_extra_key (float, command_name(command)))
+ line_warnf ("ignoring multiple @%s",
+ command_name(command));
+ else
+ {
+ add_extra_key_element (current->parent, "float", float);
+ add_extra_key_element (float, command_name(command),
+ current->parent);
+ }
+ }
+#undef float
+ }
/* Add to context stack. */
switch (command)
Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h 2015-12-11 17:20:47 UTC (rev 6848)
+++ trunk/parsetexi/tree_types.h 2015-12-11 23:34:01 UTC (rev 6849)
@@ -36,6 +36,7 @@
extra_node_spec_array,
extra_string,
extra_def_args,
+ extra_float_type,
extra_deleted
};
@@ -158,4 +159,9 @@
int space;
} DEF_ARGS_EXTRA;
+typedef struct {
+ ELEMENT *content;
+ char *normalized;
+} EXTRA_FLOAT_TYPE;
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6849] parsetexi update (floats),
Gavin D. Smith <=