Commit 49d7ab5b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Add 'string_opt_quote' and use it in a few productions that do not care


2000-06-29  Jody Goldberg <jgoldberg@home.com>

	* src/parser.y : Add 'string_opt_quote' and use it in a few
	  productions that do not care about the quote state of the token.

	* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
	  need to be quoted. (#15720)
parent 69d94bfa
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
2000-06-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Add 'string_opt_quote' and use it in a few
productions that do not care about the quote state of the token.
* src/sheet.c (sheet_name_quote) : Sheet names that begin with digits
need to be quoted. (#15720)
2000-06-28 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_tree_new_funcall) : Ref the function here.
......
......@@ -325,8 +325,8 @@ int yyparse(void);
GList *list;
Sheet *sheet;
}
%type <tree> exp array_exp
%type <list> arg_list array_row, array_cols
%type <tree> exp array_exp string_opt_quote
%token <tree> STRING QUOTED_STRING CONSTANT CELLREF GTE LTE NE
%token SEPARATOR
%type <tree> cellref
......@@ -396,7 +396,11 @@ exp: CONSTANT { $$ = $1; }
}
;
sheetref: STRING SHEET_SEP {
string_opt_quote : STRING
| QUOTED_STRING
;
sheetref: string_opt_quote SHEET_SEP {
Sheet *sheet = sheet_lookup_by_name (parser_pos->wb, $1->constant.value->v_str.val->str);
unregister_allocation ($1); expr_tree_unref ($1);
if (sheet == NULL) {
......@@ -407,13 +411,13 @@ sheetref: STRING SHEET_SEP {
$$ = sheet;
}
| '[' STRING ']' STRING SHEET_SEP {
| '[' string_opt_quote ']' string_opt_quote SHEET_SEP {
/* TODO : Get rid of ParseErr and replace it with something richer.
* The replace ment should include more detail as to what the error
* was, and where in the expr string to highlight.
*
* e.g. for =1+Shhet!A1+2
* We should return "Unknow Sheet 'Shhet'" and the indicies 3:7
* We should return "Unknow Sheet 'Sheet'" and the indicies 3:7
* to mark the offending region.
*/
Workbook * wb =
......@@ -497,9 +501,9 @@ arg_list: exp {
| { $$ = NULL; }
;
array_exp: CONSTANT { $$ = $1; }
| STRING { parse_string_as_value ($1); $$ = $1; }
;
array_exp: CONSTANT { $$ = $1; }
| string_opt_quote { parse_string_as_value ($1); $$ = $1; }
;
array_row: array_exp {
unregister_allocation ($1);
......
......@@ -2610,22 +2610,23 @@ sheet_show_cursor (Sheet *sheet)
char *
sheet_name_quote (const char *name_unquoted)
{
int i, j, quotes_embedded;
gboolean quote;
static char quote_chr [] = { '=', '<', '>', '+', '-', ' ', '^', '&', '%', '\0' };
int i, j, quotes_embedded = 0;
gboolean needs_quotes;
static char quote_chr [] = { '=', '<', '>', '+', '-', ' ', '^', '&', '%', ':', '\0' };
g_return_val_if_fail (name_unquoted != NULL, NULL);
quote = FALSE;
for (i = 0, quotes_embedded = 0; name_unquoted [i]; i++) {
for (j = 0; quote_chr [j]; j++)
if (name_unquoted [i] == quote_chr [j])
quote = TRUE;
if (name_unquoted [i] == '"')
quotes_embedded++;
}
needs_quotes = isdigit (*name_unquoted);
if (!needs_quotes)
for (i = 0, quotes_embedded = 0; name_unquoted [i]; i++) {
for (j = 0; quote_chr [j]; j++)
if (name_unquoted [i] == quote_chr [j])
needs_quotes = TRUE;
if (name_unquoted [i] == '"')
quotes_embedded++;
}
if (quote) {
if (needs_quotes) {
int len_quoted = strlen (name_unquoted) + quotes_embedded + 3;
char *ret = g_malloc (len_quoted);
const char *src;
......@@ -2645,7 +2646,6 @@ sheet_name_quote (const char *name_unquoted)
return g_strdup (name_unquoted);
}
void
sheet_mark_clean (Sheet *sheet)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment