mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-20 14:19:16 +02:00
Move doc to toplevel element, write <any> for unknown containers
Moving to <doc> allows us to better preserve whitespace. XML has no facility for whitespace-preserving attributes. Second, for arrays and lists, both types with unknown element_type can occur in the current scanner; it's least wrong if we write out an <any> type.
This commit is contained in:
parent
3d0dc7d214
commit
68b4fb43bb
27
girparser.c
27
girparser.c
@ -76,6 +76,7 @@ typedef enum
|
|||||||
STATE_ALIAS, /* 30 */
|
STATE_ALIAS, /* 30 */
|
||||||
STATE_TYPE,
|
STATE_TYPE,
|
||||||
STATE_ATTRIBUTE,
|
STATE_ATTRIBUTE,
|
||||||
|
STATE_DOC,
|
||||||
STATE_PASSTHROUGH
|
STATE_PASSTHROUGH
|
||||||
} ParseState;
|
} ParseState;
|
||||||
|
|
||||||
@ -1957,6 +1958,22 @@ end_type (ParseContext *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
start_doc (GMarkupParseContext *context,
|
||||||
|
const gchar *element_name,
|
||||||
|
const gchar **attribute_names,
|
||||||
|
const gchar **attribute_values,
|
||||||
|
ParseContext *ctx,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (strcmp (element_name, "doc") != 0 || ctx->node_stack == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
state_switch (ctx, STATE_DOC);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
start_attribute (GMarkupParseContext *context,
|
start_attribute (GMarkupParseContext *context,
|
||||||
const gchar *element_name,
|
const gchar *element_name,
|
||||||
@ -2570,6 +2587,9 @@ start_element_handler (GMarkupParseContext *context,
|
|||||||
attribute_names, attribute_values,
|
attribute_names, attribute_values,
|
||||||
ctx, error))
|
ctx, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
else if (start_doc (context, element_name, attribute_names,
|
||||||
|
attribute_values, ctx, error))
|
||||||
|
goto out;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
@ -3207,6 +3227,13 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case STATE_DOC:
|
||||||
|
if (strcmp ("doc", element_name) == 0)
|
||||||
|
{
|
||||||
|
state_switch (ctx, ctx->prev_state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_PASSTHROUGH:
|
case STATE_PASSTHROUGH:
|
||||||
ctx->unknown_depth -= 1;
|
ctx->unknown_depth -= 1;
|
||||||
if (ctx->unknown_depth == 0)
|
if (ctx->unknown_depth == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user