From 009942e1ace7ace3fdc22ab8fff6b8e57ef040db Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Wed, 14 Mar 2001 15:33:45 +0000 Subject: [PATCH] made config arg to g_scanner_new() const. Fri Mar 9 18:01:43 2001 Tim Janik * gscanner.[hc]: made config arg to g_scanner_new() const. Fri Mar 9 16:42:08 2001 Tim Janik * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as a public function (was static in gobject.c before). it's a bit odd to have that function here, especially since it requires extra includes, but then it doesn't very well fit somewhere else either. * gparamspecs.c: added default/max/min checks to param spec creation functions. --- ChangeLog | 4 ++ ChangeLog.pre-2-0 | 4 ++ ChangeLog.pre-2-10 | 4 ++ ChangeLog.pre-2-12 | 4 ++ ChangeLog.pre-2-2 | 4 ++ ChangeLog.pre-2-4 | 4 ++ ChangeLog.pre-2-6 | 4 ++ ChangeLog.pre-2-8 | 4 ++ glib/gscanner.c | 52 ++++++++-------- glib/gscanner.h | 2 +- gobject/ChangeLog | 10 +++ gobject/gobject.c | 61 ------------------ gobject/gparamspecs.c | 142 ++++++++++++++++++++++++++++-------------- gobject/gvaluetypes.c | 69 ++++++++++++++++++++ gobject/gvaluetypes.h | 4 ++ gscanner.c | 52 ++++++++-------- gscanner.h | 2 +- 17 files changed, 263 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9d5fbadbc..9f9843d53 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,7 @@ +Fri Mar 9 18:01:43 2001 Tim Janik + + * gscanner.[hc]: made config arg to g_scanner_new() const. + 2001-03-12 Tor Lillqvist * tests/Makefile.am (libmoduletestplugin_b_la_LIBADD, diff --git a/glib/gscanner.c b/glib/gscanner.c index 02e801c73..540aa39a9 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c, } GScanner* -g_scanner_new (GScannerConfig *config_templ) +g_scanner_new (const GScannerConfig *config_templ) { GScanner *scanner; @@ -188,33 +188,33 @@ g_scanner_new (GScannerConfig *config_templ) scanner->config = g_new0 (GScannerConfig, 1); - scanner->config->case_sensitive = config_templ->case_sensitive; - scanner->config->cset_skip_characters = config_templ->cset_skip_characters; + scanner->config->case_sensitive = config_templ->case_sensitive; + scanner->config->cset_skip_characters = config_templ->cset_skip_characters; if (!scanner->config->cset_skip_characters) scanner->config->cset_skip_characters = ""; - scanner->config->cset_identifier_first= config_templ->cset_identifier_first; - scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth; - scanner->config->cpair_comment_single = config_templ->cpair_comment_single; - scanner->config->skip_comment_multi = config_templ->skip_comment_multi; - scanner->config->skip_comment_single = config_templ->skip_comment_single; - scanner->config->scan_comment_multi = config_templ->scan_comment_multi; - scanner->config->scan_identifier = config_templ->scan_identifier; - scanner->config->scan_identifier_1char= config_templ->scan_identifier_1char; - scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL; - scanner->config->scan_symbols = config_templ->scan_symbols; - scanner->config->scan_binary = config_templ->scan_binary; - scanner->config->scan_octal = config_templ->scan_octal; - scanner->config->scan_float = config_templ->scan_float; - scanner->config->scan_hex = config_templ->scan_hex; - scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar; - scanner->config->scan_string_sq = config_templ->scan_string_sq; - scanner->config->scan_string_dq = config_templ->scan_string_dq; - scanner->config->numbers_2_int = config_templ->numbers_2_int; - scanner->config->int_2_float = config_templ->int_2_float; - scanner->config->identifier_2_string = config_templ->identifier_2_string; - scanner->config->char_2_token = config_templ->char_2_token; - scanner->config->symbol_2_token = config_templ->symbol_2_token; - scanner->config->scope_0_fallback = config_templ->scope_0_fallback; + scanner->config->cset_identifier_first = config_templ->cset_identifier_first; + scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth; + scanner->config->cpair_comment_single = config_templ->cpair_comment_single; + scanner->config->skip_comment_multi = config_templ->skip_comment_multi; + scanner->config->skip_comment_single = config_templ->skip_comment_single; + scanner->config->scan_comment_multi = config_templ->scan_comment_multi; + scanner->config->scan_identifier = config_templ->scan_identifier; + scanner->config->scan_identifier_1char = config_templ->scan_identifier_1char; + scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL; + scanner->config->scan_symbols = config_templ->scan_symbols; + scanner->config->scan_binary = config_templ->scan_binary; + scanner->config->scan_octal = config_templ->scan_octal; + scanner->config->scan_float = config_templ->scan_float; + scanner->config->scan_hex = config_templ->scan_hex; + scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar; + scanner->config->scan_string_sq = config_templ->scan_string_sq; + scanner->config->scan_string_dq = config_templ->scan_string_dq; + scanner->config->numbers_2_int = config_templ->numbers_2_int; + scanner->config->int_2_float = config_templ->int_2_float; + scanner->config->identifier_2_string = config_templ->identifier_2_string; + scanner->config->char_2_token = config_templ->char_2_token; + scanner->config->symbol_2_token = config_templ->symbol_2_token; + scanner->config->scope_0_fallback = config_templ->scope_0_fallback; scanner->token = G_TOKEN_NONE; scanner->value.v_int = 0; diff --git a/glib/gscanner.h b/glib/gscanner.h index 8cee79b41..f489745d7 100644 --- a/glib/gscanner.h +++ b/glib/gscanner.h @@ -198,7 +198,7 @@ struct _GScanner GScannerMsgFunc msg_handler; }; -GScanner* g_scanner_new (GScannerConfig *config_templ); +GScanner* g_scanner_new (const GScannerConfig *config_templ); void g_scanner_destroy (GScanner *scanner); void g_scanner_input_file (GScanner *scanner, gint input_fd); diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 65283dc07..5510242e8 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,13 @@ +Fri Mar 9 16:42:08 2001 Tim Janik + + * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as + a public function (was static in gobject.c before). it's a bit odd + to have that function here, especially since it requires extra includes, + but then it doesn't very well fit somewhere else either. + + * gparamspecs.c: added default/max/min checks to param spec creation + functions. + 2001-03-10 Tor Lillqvist * gobject.def: Add a couple of missing entries. diff --git a/gobject/gobject.c b/gobject/gobject.c index f9ade44c5..1f269c798 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -641,67 +641,6 @@ object_get_property (GObject *object, class->get_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec); } -static gchar* -g_strdup_value_contents (const GValue *value) -{ - const gchar *src; - gchar *contents; - - g_return_val_if_fail (G_IS_VALUE (value), NULL); - - if (G_VALUE_HOLDS_STRING (value)) - { - src = g_value_get_string (value); - - if (!src) - contents = g_strdup ("NULL"); - else - { - gchar *s = g_strescape (src, NULL); - - contents = g_strdup_printf ("\"%s\"", s); - g_free (s); - } - } - else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING)) - { - GValue tmp_value = { 0, }; - - g_value_init (&tmp_value, G_TYPE_STRING); - g_value_transform (value, &tmp_value); - if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value)) - contents = g_strdup_printf ("((%s) %s)", - g_type_name (G_VALUE_TYPE (value)), - g_value_get_string (&tmp_value)); - else - { - src = g_value_get_string (&tmp_value); - contents = g_strdup (src ? src : "NULL"); - } - g_value_unset (&tmp_value); - } - else if (g_value_fits_pointer (value)) - { - gpointer p = g_value_peek_pointer (value); - - if (!p) - contents = g_strdup ("NULL"); - else if (G_VALUE_HOLDS_OBJECT (value)) - contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p); - else if (G_VALUE_HOLDS_PARAM (value)) - contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p); - else if (G_VALUE_HOLDS_BOXED (value)) - contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p); - else if (G_VALUE_HOLDS_POINTER (value)) - contents = g_strdup_printf ("((gpointer) %p)", p); - else - contents = g_strdup ("???"); - } - else - contents = g_strdup ("???"); - return contents; -} - static inline void object_set_property (GObject *object, GParamSpec *pspec, diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c index d305f2c14..5d61cf305 100644 --- a/gobject/gparamspecs.c +++ b/gobject/gparamspecs.c @@ -1199,11 +1199,15 @@ g_param_spec_char (const gchar *name, gint8 default_value, GParamFlags flags) { - GParamSpecChar *cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR, - name, - nick, - blurb, - flags); + GParamSpecChar *cspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR, + name, + nick, + blurb, + flags); cspec->minimum = minimum; cspec->maximum = maximum; @@ -1221,11 +1225,15 @@ g_param_spec_uchar (const gchar *name, guint8 default_value, GParamFlags flags) { - GParamSpecUChar *uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR, - name, - nick, - blurb, - flags); + GParamSpecUChar *uspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR, + name, + nick, + blurb, + flags); uspec->minimum = minimum; uspec->maximum = maximum; @@ -1241,11 +1249,15 @@ g_param_spec_boolean (const gchar *name, gboolean default_value, GParamFlags flags) { - GParamSpecBoolean *bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN, - name, - nick, - blurb, - flags); + GParamSpecBoolean *bspec; + + g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL); + + bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN, + name, + nick, + blurb, + flags); bspec->default_value = default_value; @@ -1261,11 +1273,15 @@ g_param_spec_int (const gchar *name, gint default_value, GParamFlags flags) { - GParamSpecInt *ispec = g_param_spec_internal (G_TYPE_PARAM_INT, - name, - nick, - blurb, - flags); + GParamSpecInt *ispec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + ispec = g_param_spec_internal (G_TYPE_PARAM_INT, + name, + nick, + blurb, + flags); ispec->minimum = minimum; ispec->maximum = maximum; @@ -1283,11 +1299,15 @@ g_param_spec_uint (const gchar *name, guint default_value, GParamFlags flags) { - GParamSpecUInt *uspec = g_param_spec_internal (G_TYPE_PARAM_UINT, - name, - nick, - blurb, - flags); + GParamSpecUInt *uspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + uspec = g_param_spec_internal (G_TYPE_PARAM_UINT, + name, + nick, + blurb, + flags); uspec->minimum = minimum; uspec->maximum = maximum; @@ -1305,11 +1325,15 @@ g_param_spec_long (const gchar *name, glong default_value, GParamFlags flags) { - GParamSpecLong *lspec = g_param_spec_internal (G_TYPE_PARAM_LONG, - name, - nick, - blurb, - flags); + GParamSpecLong *lspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + lspec = g_param_spec_internal (G_TYPE_PARAM_LONG, + name, + nick, + blurb, + flags); lspec->minimum = minimum; lspec->maximum = maximum; @@ -1327,11 +1351,15 @@ g_param_spec_ulong (const gchar *name, gulong default_value, GParamFlags flags) { - GParamSpecULong *uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG, - name, - nick, - blurb, - flags); + GParamSpecULong *uspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG, + name, + nick, + blurb, + flags); uspec->minimum = minimum; uspec->maximum = maximum; @@ -1349,8 +1377,13 @@ g_param_spec_enum (const gchar *name, GParamFlags flags) { GParamSpecEnum *espec; + GEnumClass *enum_class; g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); + + enum_class = g_type_class_ref (enum_type); + + g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL); espec = g_param_spec_internal (G_TYPE_PARAM_ENUM, name, @@ -1358,7 +1391,7 @@ g_param_spec_enum (const gchar *name, blurb, flags); - espec->enum_class = g_type_class_ref (enum_type); + espec->enum_class = enum_class; espec->default_value = default_value; G_PARAM_SPEC (espec)->value_type = enum_type; @@ -1374,8 +1407,13 @@ g_param_spec_flags (const gchar *name, GParamFlags flags) { GParamSpecFlags *fspec; + GFlagsClass *flags_class; g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL); + + flags_class = g_type_class_ref (flags_type); + + g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL); fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS, name, @@ -1383,7 +1421,7 @@ g_param_spec_flags (const gchar *name, blurb, flags); - fspec->flags_class = g_type_class_ref (flags_type); + fspec->flags_class = flags_class; fspec->default_value = default_value; G_PARAM_SPEC (fspec)->value_type = flags_type; @@ -1399,11 +1437,15 @@ g_param_spec_float (const gchar *name, gfloat default_value, GParamFlags flags) { - GParamSpecFloat *fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT, - name, - nick, - blurb, - flags); + GParamSpecFloat *fspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT, + name, + nick, + blurb, + flags); fspec->minimum = minimum; fspec->maximum = maximum; @@ -1421,11 +1463,15 @@ g_param_spec_double (const gchar *name, gdouble default_value, GParamFlags flags) { - GParamSpecDouble *dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE, - name, - nick, - blurb, - flags); + GParamSpecDouble *dspec; + + g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); + + dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE, + name, + nick, + blurb, + flags); dspec->minimum = minimum; dspec->maximum = maximum; @@ -1508,7 +1554,7 @@ g_param_spec_boxed (const gchar *name, GParamSpecBoxed *bspec; g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL); - g_return_val_if_fail (G_TYPE_IS_DERIVED (boxed_type), NULL); + g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL); bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED, name, diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c index d148f03b9..0391c89f6 100644 --- a/gobject/gvaluetypes.c +++ b/gobject/gvaluetypes.c @@ -710,3 +710,72 @@ g_value_get_pointer (const GValue *value) return value->data[0].v_pointer; } + + +/* need extra includes for g_strdup_value_contents() ;( */ +#include "gobject.h" +#include "gparam.h" +#include "gboxed.h" +#include "genums.h" + +gchar* +g_strdup_value_contents (const GValue *value) +{ + const gchar *src; + gchar *contents; + + g_return_val_if_fail (G_IS_VALUE (value), NULL); + + if (G_VALUE_HOLDS_STRING (value)) + { + src = g_value_get_string (value); + + if (!src) + contents = g_strdup ("NULL"); + else + { + gchar *s = g_strescape (src, NULL); + + contents = g_strdup_printf ("\"%s\"", s); + g_free (s); + } + } + else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING)) + { + GValue tmp_value = { 0, }; + + g_value_init (&tmp_value, G_TYPE_STRING); + g_value_transform (value, &tmp_value); + if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value)) + contents = g_strdup_printf ("((%s) %s)", + g_type_name (G_VALUE_TYPE (value)), + g_value_get_string (&tmp_value)); + else + { + src = g_value_get_string (&tmp_value); + contents = g_strdup (src ? src : "NULL"); + } + g_value_unset (&tmp_value); + } + else if (g_value_fits_pointer (value)) + { + gpointer p = g_value_peek_pointer (value); + + if (!p) + contents = g_strdup ("NULL"); + else if (G_VALUE_HOLDS_OBJECT (value)) + contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p); + else if (G_VALUE_HOLDS_PARAM (value)) + contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p); + else if (G_VALUE_HOLDS_BOXED (value)) + contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p); + else if (G_VALUE_HOLDS_POINTER (value)) + contents = g_strdup_printf ("((gpointer) %p)", p); + else + contents = g_strdup ("???"); + } + else + contents = g_strdup ("???"); + + return contents; +} diff --git a/gobject/gvaluetypes.h b/gobject/gvaluetypes.h index 5b1910cb7..8f9ac7d3b 100644 --- a/gobject/gvaluetypes.h +++ b/gobject/gvaluetypes.h @@ -79,6 +79,10 @@ void g_value_set_pointer (GValue *value, gpointer g_value_get_pointer (const GValue *value); +/* debugging aid, describe value contents as string */ +gchar* g_strdup_value_contents (const GValue *value); + + /* --- marshaller specific --- */ void g_value_set_string_take_ownership (GValue *value, gchar *v_string); diff --git a/gscanner.c b/gscanner.c index 02e801c73..540aa39a9 100644 --- a/gscanner.c +++ b/gscanner.c @@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c, } GScanner* -g_scanner_new (GScannerConfig *config_templ) +g_scanner_new (const GScannerConfig *config_templ) { GScanner *scanner; @@ -188,33 +188,33 @@ g_scanner_new (GScannerConfig *config_templ) scanner->config = g_new0 (GScannerConfig, 1); - scanner->config->case_sensitive = config_templ->case_sensitive; - scanner->config->cset_skip_characters = config_templ->cset_skip_characters; + scanner->config->case_sensitive = config_templ->case_sensitive; + scanner->config->cset_skip_characters = config_templ->cset_skip_characters; if (!scanner->config->cset_skip_characters) scanner->config->cset_skip_characters = ""; - scanner->config->cset_identifier_first= config_templ->cset_identifier_first; - scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth; - scanner->config->cpair_comment_single = config_templ->cpair_comment_single; - scanner->config->skip_comment_multi = config_templ->skip_comment_multi; - scanner->config->skip_comment_single = config_templ->skip_comment_single; - scanner->config->scan_comment_multi = config_templ->scan_comment_multi; - scanner->config->scan_identifier = config_templ->scan_identifier; - scanner->config->scan_identifier_1char= config_templ->scan_identifier_1char; - scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL; - scanner->config->scan_symbols = config_templ->scan_symbols; - scanner->config->scan_binary = config_templ->scan_binary; - scanner->config->scan_octal = config_templ->scan_octal; - scanner->config->scan_float = config_templ->scan_float; - scanner->config->scan_hex = config_templ->scan_hex; - scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar; - scanner->config->scan_string_sq = config_templ->scan_string_sq; - scanner->config->scan_string_dq = config_templ->scan_string_dq; - scanner->config->numbers_2_int = config_templ->numbers_2_int; - scanner->config->int_2_float = config_templ->int_2_float; - scanner->config->identifier_2_string = config_templ->identifier_2_string; - scanner->config->char_2_token = config_templ->char_2_token; - scanner->config->symbol_2_token = config_templ->symbol_2_token; - scanner->config->scope_0_fallback = config_templ->scope_0_fallback; + scanner->config->cset_identifier_first = config_templ->cset_identifier_first; + scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth; + scanner->config->cpair_comment_single = config_templ->cpair_comment_single; + scanner->config->skip_comment_multi = config_templ->skip_comment_multi; + scanner->config->skip_comment_single = config_templ->skip_comment_single; + scanner->config->scan_comment_multi = config_templ->scan_comment_multi; + scanner->config->scan_identifier = config_templ->scan_identifier; + scanner->config->scan_identifier_1char = config_templ->scan_identifier_1char; + scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL; + scanner->config->scan_symbols = config_templ->scan_symbols; + scanner->config->scan_binary = config_templ->scan_binary; + scanner->config->scan_octal = config_templ->scan_octal; + scanner->config->scan_float = config_templ->scan_float; + scanner->config->scan_hex = config_templ->scan_hex; + scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar; + scanner->config->scan_string_sq = config_templ->scan_string_sq; + scanner->config->scan_string_dq = config_templ->scan_string_dq; + scanner->config->numbers_2_int = config_templ->numbers_2_int; + scanner->config->int_2_float = config_templ->int_2_float; + scanner->config->identifier_2_string = config_templ->identifier_2_string; + scanner->config->char_2_token = config_templ->char_2_token; + scanner->config->symbol_2_token = config_templ->symbol_2_token; + scanner->config->scope_0_fallback = config_templ->scope_0_fallback; scanner->token = G_TOKEN_NONE; scanner->value.v_int = 0; diff --git a/gscanner.h b/gscanner.h index 8cee79b41..f489745d7 100644 --- a/gscanner.h +++ b/gscanner.h @@ -198,7 +198,7 @@ struct _GScanner GScannerMsgFunc msg_handler; }; -GScanner* g_scanner_new (GScannerConfig *config_templ); +GScanner* g_scanner_new (const GScannerConfig *config_templ); void g_scanner_destroy (GScanner *scanner); void g_scanner_input_file (GScanner *scanner, gint input_fd);