From d8ea5db966d300d416c1c616b0a4e5808a2ea616 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Fri, 17 May 2002 22:46:49 +0000 Subject: [PATCH] [merged from stable] Sat May 18 00:21:51 2002 Tim Janik [merged from stable] * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for expected_token. --- ChangeLog | 7 ++++ ChangeLog.pre-2-10 | 7 ++++ ChangeLog.pre-2-12 | 7 ++++ ChangeLog.pre-2-2 | 7 ++++ ChangeLog.pre-2-4 | 7 ++++ ChangeLog.pre-2-6 | 7 ++++ ChangeLog.pre-2-8 | 7 ++++ glib/gscanner.c | 101 ++++++++++++++++++++++++++++++--------------- 8 files changed, 117 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56cc141d4..024e7a57e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 56cc141d4..024e7a57e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Sat May 18 00:21:51 2002 Tim Janik + + [merged from stable] + + * glib/gscanner.c (g_scanner_unexp_token): fix missing cases for + expected_token. + 2002-05-17 Tor Lillqvist * config.h.win32.in: Match new additions in a configure-produced diff --git a/glib/gscanner.c b/glib/gscanner.c index 659137f35..26c414a31 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -177,7 +177,7 @@ g_scanner_new (const GScannerConfig *config_templ) scanner = g_new0 (GScanner, 1); scanner->user_data = NULL; - scanner->max_parse_errors = 0; + scanner->max_parse_errors = 1; scanner->parse_errors = 0; scanner->input_name = NULL; g_datalist_init (&scanner->qdata); @@ -994,7 +994,10 @@ g_scanner_unexp_token (GScanner *scanner, switch (expected_token) { gboolean need_valid; - + gchar *tstring; + case G_TOKEN_EOF: + g_snprintf (expected_string, expected_string_len, "end of file"); + break; default: if (expected_token >= 1 && expected_token <= 255) { @@ -1023,39 +1026,64 @@ g_scanner_unexp_token (GScanner *scanner, symbol_spec); /* FIXME: should we attempt to lookup the symbol_name for symbol_2_token? */ break; - + case G_TOKEN_CHAR: + g_snprintf (expected_string, expected_string_len, "%scharacter", + scanner->token == G_TOKEN_CHAR ? "valid " : ""); + break; + case G_TOKEN_BINARY: + tstring = "binary"; + g_snprintf (expected_string, expected_string_len, "%snumber (%s)", + scanner->token == expected_token ? "valid " : "", tstring); + break; + case G_TOKEN_OCTAL: + tstring = "octal"; + g_snprintf (expected_string, expected_string_len, "%snumber (%s)", + scanner->token == expected_token ? "valid " : "", tstring); + break; case G_TOKEN_INT: - g_snprintf (expected_string, expected_string_len, "%snumber (integer)", - scanner->token == G_TOKEN_INT ? "valid " : ""); + tstring = "integer"; + g_snprintf (expected_string, expected_string_len, "%snumber (%s)", + scanner->token == expected_token ? "valid " : "", tstring); + break; + case G_TOKEN_HEX: + tstring = "hexadecimal"; + g_snprintf (expected_string, expected_string_len, "%snumber (%s)", + scanner->token == expected_token ? "valid " : "", tstring); break; - case G_TOKEN_FLOAT: - g_snprintf (expected_string, expected_string_len, "%snumber (float)", - scanner->token == G_TOKEN_FLOAT ? "valid " : ""); + tstring = "float"; + g_snprintf (expected_string, expected_string_len, "%snumber (%s)", + scanner->token == expected_token ? "valid " : "", tstring); break; - case G_TOKEN_STRING: g_snprintf (expected_string, expected_string_len, "%sstring constant", scanner->token == G_TOKEN_STRING ? "valid " : ""); break; - case G_TOKEN_IDENTIFIER: case G_TOKEN_IDENTIFIER_NULL: + need_valid = (scanner->token == G_TOKEN_IDENTIFIER_NULL || + scanner->token == G_TOKEN_IDENTIFIER); g_snprintf (expected_string, expected_string_len, "%s%s", - (scanner->token == G_TOKEN_IDENTIFIER_NULL || - scanner->token == G_TOKEN_IDENTIFIER ? "valid " : ""), + need_valid ? "valid " : "", identifier_spec); break; - - case G_TOKEN_EOF: - g_snprintf (expected_string, expected_string_len, "end of file"); + case G_TOKEN_COMMENT_SINGLE: + tstring = "single-line"; + g_snprintf (expected_string, expected_string_len, "%scomment (%s)", + scanner->token == expected_token ? "valid " : "", tstring); + break; + case G_TOKEN_COMMENT_MULTI: + tstring = "multi-line"; + g_snprintf (expected_string, expected_string_len, "%scomment (%s)", + scanner->token == expected_token ? "valid " : "", tstring); break; - case G_TOKEN_NONE: + case G_TOKEN_ERROR: + /* this is handled upon printout */ break; } @@ -1066,8 +1094,30 @@ g_scanner_unexp_token (GScanner *scanner, message_prefix = ""; message = ""; } - - if (expected_token != G_TOKEN_NONE) + if (expected_token == G_TOKEN_ERROR) + { + msg_handler (scanner, + "failure around %s%s%s", + token_string, + message_prefix, + message); + } + else if (expected_token == G_TOKEN_NONE) + { + if (print_unexp) + msg_handler (scanner, + "unexpected %s%s%s", + token_string, + message_prefix, + message); + else + msg_handler (scanner, + "%s%s%s", + token_string, + message_prefix, + message); + } + else { if (print_unexp) msg_handler (scanner, @@ -1084,21 +1134,6 @@ g_scanner_unexp_token (GScanner *scanner, message_prefix, message); } - else - { - if (print_unexp) - msg_handler (scanner, - "unexpected %s%s%s", - token_string, - message_prefix, - message); - else - msg_handler (scanner, - "%s%s%s", - token_string, - message_prefix, - message); - } g_free (token_string); g_free (expected_string);