[gnome-builder] tmpl: swallow single newline after {{foo}}
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] tmpl: swallow single newline after {{foo}}
- Date: Fri, 12 Feb 2016 16:22:21 +0000 (UTC)
commit bb411f23bb4b12c67b9eb0ff8d7320685699cb5b
Author: Christian Hergert <chergert redhat com>
Date: Fri Feb 12 08:21:54 2016 -0800
tmpl: swallow single newline after {{foo}}
contrib/tmpl/tmpl-token-input-stream.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/contrib/tmpl/tmpl-token-input-stream.c b/contrib/tmpl/tmpl-token-input-stream.c
index 94d50bc..b3a06de 100644
--- a/contrib/tmpl/tmpl-token-input-stream.c
+++ b/contrib/tmpl/tmpl-token-input-stream.c
@@ -21,6 +21,7 @@
struct _TmplTokenInputStream
{
GDataInputStream parent_instance;
+ guint swallow_newline : 1;
};
G_DEFINE_TYPE (TmplTokenInputStream, tmpl_token_input_stream, G_TYPE_DATA_INPUT_STREAM)
@@ -212,6 +213,19 @@ tmpl_token_input_stream_read_token (TmplTokenInputStream *self,
return NULL;
/*
+ * If we start with a newline, and need to swallow it (as can happen if the
+ * last tag was at the end of the line), skip past the newline.
+ */
+ if (self->swallow_newline && *text == '\n')
+ {
+ gchar *tmp = g_strdup (text + 1);
+ g_free (text);
+ text = tmp;
+ }
+
+ self->swallow_newline = FALSE;
+
+ /*
* Handle successful read up to \ or {.
*/
if (*text != '\0')
@@ -284,6 +298,8 @@ tmpl_token_input_stream_read_token (TmplTokenInputStream *self,
if (!(text = tmpl_token_input_stream_read_tag (self, &len, cancellable, error)))
return NULL;
+ self->swallow_newline = TRUE;
+
return tmpl_token_new_generic (text);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]