[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7163] parsetexi more conditionals
From: |
gavinsmith0123 |
Subject: |
[7163] parsetexi more conditionals |
Date: |
Fri, 13 May 2016 20:13:38 +0000 (UTC) |
Revision: 7163
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7163
Author: gavin
Date: 2016-05-13 20:13:38 +0000 (Fri, 13 May 2016)
Log Message:
-----------
parsetexi more conditionals
Modified Paths:
--------------
trunk/tp/parsetexi/close.c
trunk/tp/parsetexi/end_line.c
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/parser.c
Modified: trunk/tp/parsetexi/close.c
===================================================================
--- trunk/tp/parsetexi/close.c 2016-05-12 21:02:43 UTC (rev 7162)
+++ trunk/tp/parsetexi/close.c 2016-05-13 20:13:38 UTC (rev 7163)
@@ -270,7 +270,12 @@
{
line_error ("no matching address@hidden %s'",
command_name(current->cmd));
- // TODO: ignored conditional
+
+ /* Ignored conditional. */
+ if (command_data(current->cmd).data == BLOCK_conditional)
+ destroy_element (pop_element_from_contents (current->parent));
+ /* FIXME: Why not avoid adding the element
+ in the first place? */
}
current = current->parent;
}
Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c 2016-05-12 21:02:43 UTC (rev 7162)
+++ trunk/tp/parsetexi/end_line.c 2016-05-13 20:13:38 UTC (rev 7163)
@@ -357,7 +357,7 @@
new_cmd = add_texinfo_command (new_command);
new_cmd &= ~USER_COMMAND_BIT;
user_defined_command_data[new_cmd].flags
- |= (CF_INFOENCLOSE & CF_brace);
+ |= (CF_INFOENCLOSE | CF_brace);
/* TODO: Remember the data. */
ADD_ARG(new_command); free (new_command);
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-05-12 21:02:43 UTC (rev
7162)
+++ trunk/tp/parsetexi/handle_commands.c 2016-05-13 20:13:38 UTC (rev
7163)
@@ -786,15 +786,41 @@
}
}
- else if (!memcmp (command_name(cmd), "ifnot", 5))
+ else if (!memcmp (command_name(cmd), "if", 2)) //4687
{
- /* FIXME: Check @ifnot* a nicer way. */
- // TODO
+ int i; char *p;
+ /* Handle @if* and @ifnot* */
+ /* FIXME: Check @if and @ifnot* a nicer way, without memcmp. */
+
+ struct expanded_format {
+ char *format;
+ int expandedp;
+ };
+ static struct expanded_format expanded_formats[] = {
+ "html", 0,
+ "docbook", 0,
+ "plaintext", 1,
+ "tex", 0,
+ "xml", 0,
+ "info", 1,
+ };
+ /* TODO: Allow user to change which formats are true. */
+
+ p = command_name(cmd) + 2; /* After "if". */
+ if (!memcmp (p, "not", 3))
+ p += 3; /* After "not". */
+ for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
+ i++)
+ {
+ if (!strcmp (p, expanded_formats[i].format))
+ {
+ iftrue = expanded_formats[i].expandedp;
+ break;
+ }
+ }
+ if (!memcmp (command_name(cmd), "ifnot", 5))
+ iftrue = !iftrue;
}
- else if (!memcmp (command_name(cmd), "if", 2))
- {
- // TODO
- }
else
abort (); // BUG
Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-05-12 21:02:43 UTC (rev 7162)
+++ trunk/tp/parsetexi/parser.c 2016-05-13 20:13:38 UTC (rev 7163)
@@ -672,6 +672,7 @@
char *line_after_command;
int retval = 1; /* Return value of function */
enum command_id end_cmd;
+ char *p;
enum command_id cmd = CM_NONE;
@@ -736,6 +737,7 @@
}
/* 3755 Else check if line is "@end ..." for current command. */
+ p = line;
if (is_end_current_command (current, &line, &end_cmd))
{
ELEMENT *last_child;
@@ -743,10 +745,20 @@
last_child = last_contents_child (current);
- if (last_child
- && last_child->type == ET_raw
- && current->cmd != CM_verbatim)
+ if (strchr (whitespace_chars, *p))
{
+ ELEMENT *e;
+ int n = strspn (line, whitespace_chars);
+ e = new_element (ET_raw);
+ text_append_n (&e->text, line, n);
+ line += n;
+ line_warn ("@end %s should only appear at the "
+ "beginning of a line", command_name(end_cmd));
+ }
+ else if (last_child
+ && last_child->type == ET_raw
+ && current->cmd != CM_verbatim)
+ {
if (last_child->text.end > 0
&& last_child->text.text[last_child->text.end - 1] == '\n')
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7163] parsetexi more conditionals,
gavinsmith0123 <=