X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib%2Fgscanner.c;h=52b770a61fdf89f1a949bb38ea0c9f5c949ef71a;hb=13e15733f38a40c6ef6a1baede91cce81c86ebaa;hp=e7628f4ce369a7f578840836bdea2e17fe652992;hpb=117e534091d7cf21ab48c56141a3340a15c74390;p=platform%2Fupstream%2Fglib.git diff --git a/glib/gscanner.c b/glib/gscanner.c index e7628f4..52b770a 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -15,9 +15,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . */ /* @@ -38,9 +36,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gscanner.h" @@ -49,8 +44,11 @@ #include "gstring.h" #include "gtestutils.h" +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 -#include /* For _read() */ +#include #endif @@ -90,6 +88,14 @@ */ /** + * G_CSET_DIGITS: + * + * The set of ASCII digits. + * Used for specifying valid identifier characters + * in #GScannerConfig. + */ + +/** * G_CSET_LATINC: * * The set of uppercase ISO 8859-1 alphabet characters @@ -112,7 +118,26 @@ * @G_TOKEN_EOF: the end of the file * @G_TOKEN_LEFT_PAREN: a '(' character * @G_TOKEN_LEFT_CURLY: a '{' character + * @G_TOKEN_LEFT_BRACE: a '[' character * @G_TOKEN_RIGHT_CURLY: a '}' character + * @G_TOKEN_RIGHT_PAREN: a ')' character + * @G_TOKEN_RIGHT_BRACE: a ']' character + * @G_TOKEN_EQUAL_SIGN: a '=' character + * @G_TOKEN_COMMA: a ',' character + * @G_TOKEN_NONE: not a token + * @G_TOKEN_ERROR: an error occurred + * @G_TOKEN_CHAR: a character + * @G_TOKEN_BINARY: a binary integer + * @G_TOKEN_OCTAL: an octal integer + * @G_TOKEN_INT: an integer + * @G_TOKEN_HEX: a hex integer + * @G_TOKEN_FLOAT: a floating point number + * @G_TOKEN_STRING: a string + * @G_TOKEN_SYMBOL: a symbol + * @G_TOKEN_IDENTIFIER: an identifier + * @G_TOKEN_IDENTIFIER_NULL: a null identifier + * @G_TOKEN_COMMENT_SINGLE: one line comment + * @G_TOKEN_COMMENT_MULTI: multi line comment * * The possible types of token returned from each * g_scanner_get_next_token() call. @@ -120,6 +145,18 @@ /** * GTokenValue: + * @v_symbol: token symbol value + * @v_identifier: token identifier value + * @v_binary: token binary integer value + * @v_octal: octal integer value + * @v_int: integer value + * @v_int64: 64-bit integer value + * @v_float: floating point value + * @v_hex: hex integer value + * @v_string: string value + * @v_comment: comment value + * @v_char: character value + * @v_error: error value * * A union holding the value of the token. */ @@ -136,17 +173,17 @@ * @G_ERR_FLOAT_MALFORMED: malformed floating point number * * The possible errors, used in the @v_error field - * of #GTokenValue, when the token is a #G_TOKEN_ERROR. + * of #GTokenValue, when the token is a %G_TOKEN_ERROR. */ /** * GScanner: - * @user_data: - * @max_parse_errors: - * @parse_errors: - * @input_name: - * @qdata: - * @config: + * @user_data: unused + * @max_parse_errors: unused + * @parse_errors: g_scanner_error() increments this field + * @input_name: name of input stream, featured by the default message handler + * @qdata: quarked data + * @config: link into the scanner configuration * @token: token parsed by the last g_scanner_get_next_token() * @value: value of the last token from g_scanner_get_next_token() * @line: line number of the last token from g_scanner_get_next_token() @@ -155,12 +192,7 @@ * @next_value: value of the last token from g_scanner_peek_next_token() * @next_line: line number of the last token from g_scanner_peek_next_token() * @next_position: char number of the last token from g_scanner_peek_next_token() - * @symbol_table: - * @input_fd: - * @text: - * @text_end: - * @buffer: - * @scope_id: + * @msg_handler: handler function for _warn and _error * * The data structure representing a lexical scanner. * @@ -206,7 +238,7 @@ * @scan_identifier_1char: specifies if single-character * identifiers are recognized (the default is %FALSE). * @scan_identifier_NULL: specifies if %NULL is reported as - * #G_TOKEN_IDENTIFIER_NULL (the default is %FALSE). + * %G_TOKEN_IDENTIFIER_NULL (the default is %FALSE). * @scan_symbols: specifies if symbols are recognized (the default * is %TRUE). * @scan_binary: specifies if binary numbers are recognized (the @@ -225,19 +257,17 @@ * quotes (the default is %TRUE). * @numbers_2_int: specifies if binary, octal and hexadecimal numbers * are reported as #G_TOKEN_INT (the default is %TRUE). - * @int_2_float: specifies if all numbers are reported as #G_TOKEN_FLOAT + * @int_2_float: specifies if all numbers are reported as %G_TOKEN_FLOAT * (the default is %FALSE). * @identifier_2_string: specifies if identifiers are reported as strings * (the default is %FALSE). * @char_2_token: specifies if characters are reported by setting - * token = ch or as #G_TOKEN_CHAR (the default - * is %TRUE). + * `token = ch` or as %G_TOKEN_CHAR (the default is %TRUE). * @symbol_2_token: specifies if symbols are reported by setting - * token = v_symbol or as #G_TOKEN_SYMBOL (the - * default is %FALSE). + * `token = v_symbol` or as %G_TOKEN_SYMBOL (the default is %FALSE). * @scope_0_fallback: specifies if a symbol is searched for in the * default scope in addition to the current scope (the default is %FALSE). - * @store_int64: + * @store_int64: use value.v_int64 rather than v_int * * Specifies the #GScanner parser configuration. Most settings can * be changed during the parsing phase and will affect the lexical @@ -633,7 +663,7 @@ g_scanner_lookup_internal (GScanner *scanner, } /** - * g_scanner_add_symbol + * g_scanner_add_symbol: * @scanner: a #GScanner * @symbol: the symbol to add * @value: the value of the symbol @@ -1269,12 +1299,12 @@ g_scanner_get_char (GScanner *scanner, * @expected_token: the expected token * @identifier_spec: a string describing how the scanner's user * refers to identifiers (%NULL defaults to "identifier"). - * This is used if @expected_token is #G_TOKEN_IDENTIFIER or - * #G_TOKEN_IDENTIFIER_NULL. + * This is used if @expected_token is %G_TOKEN_IDENTIFIER or + * %G_TOKEN_IDENTIFIER_NULL. * @symbol_spec: a string describing how the scanner's user refers * to symbols (%NULL defaults to "symbol"). This is used if - * @expected_token is #G_TOKEN_SYMBOL or any token value greater - * than #G_TOKEN_LAST. + * @expected_token is %G_TOKEN_SYMBOL or any token value greater + * than %G_TOKEN_LAST. * @symbol_name: the name of the symbol, if the scanner's current * token is a symbol. * @message: a message string to output at the end of the @@ -1337,9 +1367,9 @@ g_scanner_unexp_token (GScanner *scanner, if ((scanner->token >= ' ' && scanner->token <= '~') || strchr (scanner->config->cset_identifier_first, scanner->token) || strchr (scanner->config->cset_identifier_nth, scanner->token)) - _g_snprintf (token_string, token_string_len, "character `%c'", scanner->token); + _g_snprintf (token_string, token_string_len, "character '%c'", scanner->token); else - _g_snprintf (token_string, token_string_len, "character `\\%o'", scanner->token); + _g_snprintf (token_string, token_string_len, "character '\\%o'", scanner->token); break; } else if (!scanner->config->symbol_2_token) @@ -1356,7 +1386,7 @@ g_scanner_unexp_token (GScanner *scanner, if (symbol_name) _g_snprintf (token_string, token_string_len, - "%s%s `%s'", + "%s%s '%s'", print_unexp ? "" : "invalid ", symbol_spec, symbol_name); @@ -1409,7 +1439,7 @@ g_scanner_unexp_token (GScanner *scanner, break; case G_TOKEN_CHAR: - _g_snprintf (token_string, token_string_len, "character `%c'", scanner->value.v_char); + _g_snprintf (token_string, token_string_len, "character '%c'", scanner->value.v_char); break; case G_TOKEN_IDENTIFIER: @@ -1419,7 +1449,7 @@ g_scanner_unexp_token (GScanner *scanner, print_unexp = FALSE; _g_snprintf (token_string, token_string_len, - "%s%s `%s'", + "%s%s '%s'", print_unexp ? "" : "invalid ", identifier_spec, scanner->token == G_TOKEN_IDENTIFIER ? scanner->value.v_string : "null"); @@ -1430,13 +1460,13 @@ g_scanner_unexp_token (GScanner *scanner, case G_TOKEN_INT: case G_TOKEN_HEX: if (scanner->config->store_int64) - _g_snprintf (token_string, token_string_len, "number `%" G_GUINT64_FORMAT "'", scanner->value.v_int64); + _g_snprintf (token_string, token_string_len, "number '%" G_GUINT64_FORMAT "'", scanner->value.v_int64); else - _g_snprintf (token_string, token_string_len, "number `%lu'", scanner->value.v_int); + _g_snprintf (token_string, token_string_len, "number '%lu'", scanner->value.v_int); break; case G_TOKEN_FLOAT: - _g_snprintf (token_string, token_string_len, "number `%.3f'", scanner->value.v_float); + _g_snprintf (token_string, token_string_len, "number '%.3f'", scanner->value.v_float); break; case G_TOKEN_STRING: @@ -1482,9 +1512,9 @@ g_scanner_unexp_token (GScanner *scanner, if ((expected_token >= ' ' && expected_token <= '~') || strchr (scanner->config->cset_identifier_first, expected_token) || strchr (scanner->config->cset_identifier_nth, expected_token)) - _g_snprintf (expected_string, expected_string_len, "character `%c'", expected_token); + _g_snprintf (expected_string, expected_string_len, "character '%c'", expected_token); else - _g_snprintf (expected_string, expected_string_len, "character `\\%o'", expected_token); + _g_snprintf (expected_string, expected_string_len, "character '\\%o'", expected_token); break; } else if (!scanner->config->symbol_2_token)