Commit 7b67daac authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

Dynamically allocate space to hold comments, links, strings, and

2008-01-27  Kevin Cozens  <kcozens@cvs.gnome.org>

	* plug-ins/imagemap/imap_cern.l:
	* plug-ins/imagemap/imap_cern.y: 
	* plug-ins/imagemap/imap_csim.l:
	* plug-ins/imagemap/imap_csim.y:
	* plug-ins/imagemap/imap_ncsa.l:
	* plug-ins/imagemap/imap_ncsa.y: Dynamically allocate space to hold
	comments, links, strings, and co-ordinate lists. Fixes bug #511072.

	* plug-ins/imagemap/imap_cern_lex.c:
	* plug-ins/imagemap/imap_cern_parse.c:
	* plug-ins/imagemap/imap_cern_parse.h:
	* plug-ins/imagemap/imap_csim_lex.c:
	* plug-ins/imagemap/imap_csim_parse.c:
	* plug-ins/imagemap/imap_csim_parse.h:
	* plug-ins/imagemap/imap_ncsa_lex.c:
	* plug-ins/imagemap/imap_ncsa_parse.c:
	* plug-ins/imagemap/imap_ncsa_parse.h: Regenerated.

svn path=/trunk/; revision=24722
parent d1e1e0a1
2008-01-27 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/imagemap/imap_cern.l:
* plug-ins/imagemap/imap_cern.y:
* plug-ins/imagemap/imap_csim.l:
* plug-ins/imagemap/imap_csim.y:
* plug-ins/imagemap/imap_ncsa.l:
* plug-ins/imagemap/imap_ncsa.y: Dynamically allocate space to hold
comments, links, strings, and co-ordinate lists. Fixes bug #511072.
* plug-ins/imagemap/imap_cern_lex.c:
* plug-ins/imagemap/imap_cern_parse.c:
* plug-ins/imagemap/imap_cern_parse.h:
* plug-ins/imagemap/imap_csim_lex.c:
* plug-ins/imagemap/imap_csim_parse.c:
* plug-ins/imagemap/imap_csim_parse.h:
* plug-ins/imagemap/imap_ncsa_lex.c:
* plug-ins/imagemap/imap_ncsa_parse.c:
* plug-ins/imagemap/imap_ncsa_parse.h: Regenerated.
2008-01-27 Sven Neumann <sven@gimp.org>
* plug-ins/gimpressionist/gimp.c (gimpressionist_main): transfer
......
......@@ -61,7 +61,7 @@ RECT{WS}\(4096,4096\){WS}\(4096,4096\) {
<comment>.*$ {
BEGIN(INITIAL);
strcpy(cern_lval.id, yytext);
cern_lval.id = g_strndup (yytext, yyleng);
return COMMENT;
}
......@@ -74,7 +74,7 @@ POLY return POLYGON;
DEFAULT return DEFAULT;
[^ ,\t\n]+$ {
strcpy(cern_lval.id, yytext);
cern_lval.id = g_strndup (yytext, yyleng);
return LINK;
}
......
......@@ -47,7 +47,7 @@ static Object_t *current_object;
%union {
int val;
double value;
char id[256];
char *id;
}
%token<val> RECTANGLE POLYGON CIRCLE DEFAULT
......@@ -75,6 +75,7 @@ default : DEFAULT LINK
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->default_url, $2);
g_free ($2);
}
;
......@@ -88,6 +89,7 @@ rectangle : RECTANGLE '(' FLOAT ',' FLOAT ')' '(' FLOAT ',' FLOAT ')' LINK
current_object = create_rectangle(x, y, width, height);
object_set_url(current_object, $12);
add_shape(current_object);
g_free ($12);
}
;
......@@ -99,6 +101,7 @@ circle : CIRCLE '(' FLOAT ',' FLOAT ')' FLOAT LINK
current_object = create_circle(x, y, r);
object_set_url(current_object, $8);
add_shape(current_object);
g_free ($8);
}
;
......@@ -106,6 +109,7 @@ polygon : POLYGON {current_object = create_polygon(NULL);} coord_list LINK
{
object_set_url(current_object, $4);
add_shape(current_object);
g_free ($4);
}
;
......@@ -131,6 +135,7 @@ comment_line : author_line
real_comment : BEGIN_COMMENT COMMENT
{
g_free ($2);
}
;
......@@ -138,7 +143,7 @@ author_line : AUTHOR COMMENT
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->author, $2);
g_free ($2);
}
;
......@@ -150,6 +155,7 @@ description_line: DESCRIPTION COMMENT
description = g_strconcat(info->description, $2, "\n",
NULL);
g_strreplace(&info->description, description);
g_free ($2);
}
;
......
......@@ -5,6 +5,25 @@
/* A lexical scanner generated by flex */
#define yy_create_buffer cern__create_buffer
#define yy_delete_buffer cern__delete_buffer
#define yy_flex_debug cern__flex_debug
#define yy_init_buffer cern__init_buffer
#define yy_flush_buffer cern__flush_buffer
#define yy_load_buffer_state cern__load_buffer_state
#define yy_switch_to_buffer cern__switch_to_buffer
#define yyin cern_in
#define yyleng cern_leng
#define yylex cern_lex
#define yylineno cern_lineno
#define yyout cern_out
#define yyrestart cern_restart
#define yytext cern_text
#define yywrap cern_wrap
#define yyalloc cern_alloc
#define yyrealloc cern_realloc
#define yyfree cern_free
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
......@@ -335,7 +354,7 @@ void cern_free (void * );
/* Begin user sect3 */
#define cern_wrap() 1
#define cern_wrap(n) 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
......@@ -570,7 +589,7 @@ char *cern_text;
#endif /* FLEX_SCANNER */
#line 574 "<stdout>"
#line 593 "<stdout>"
#define INITIAL 0
#define comment 1
......@@ -727,7 +746,7 @@ YY_DECL
#line 45 "imap_cern.l"
#line 731 "<stdout>"
#line 750 "<stdout>"
if ( !(yy_init) )
{
......@@ -845,7 +864,7 @@ YY_RULE_SETUP
#line 62 "imap_cern.l"
{
BEGIN(INITIAL);
strcpy(cern_lval.id, cern_text);
cern_lval.id = g_strndup (cern_text, cern_leng);
return COMMENT;
}
YY_BREAK
......@@ -876,7 +895,7 @@ YY_DO_BEFORE_ACTION; /* set up cern_text again */
YY_RULE_SETUP
#line 76 "imap_cern.l"
{
strcpy(cern_lval.id, cern_text);
cern_lval.id = g_strndup (cern_text, cern_leng);
return LINK;
}
YY_BREAK
......@@ -904,7 +923,7 @@ YY_RULE_SETUP
#line 90 "imap_cern.l"
ECHO;
YY_BREAK
#line 908 "<stdout>"
#line 927 "<stdout>"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(comment):
yyterminate();
......@@ -1136,7 +1155,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
......@@ -1637,7 +1656,7 @@ YY_BUFFER_STATE cern__scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to cern_lex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param str a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
......
......@@ -173,7 +173,7 @@ typedef union YYSTYPE
{
int val;
double value;
char id[256];
char *id;
}
/* Line 187 of yacc.c. */
#line 180 "y.tab.c"
......@@ -481,8 +481,8 @@ static const yytype_int8 yyrhs[] =
static const yytype_uint8 yyrline[] =
{
0, 60, 60, 63, 64, 67, 68, 69, 70, 71,
74, 82, 94, 105, 105, 112, 113, 118, 127, 128,
129, 132, 137, 145
74, 83, 96, 108, 108, 116, 117, 122, 131, 132,
133, 136, 142, 150
};
#endif
......@@ -1414,11 +1414,12 @@ yyreduce:
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->default_url, (yyvsp[(2) - (2)].id));
g_free ((yyvsp[(2) - (2)].id));
}
break;
case 11:
#line 83 "imap_cern.y"
#line 84 "imap_cern.y"
{
gint x = (gint) (yyvsp[(3) - (12)].value);
gint y = (gint) (yyvsp[(5) - (12)].value);
......@@ -1427,11 +1428,12 @@ yyreduce:
current_object = create_rectangle(x, y, width, height);
object_set_url(current_object, (yyvsp[(12) - (12)].id));
add_shape(current_object);
g_free ((yyvsp[(12) - (12)].id));
}
break;
case 12:
#line 95 "imap_cern.y"
#line 97 "imap_cern.y"
{
gint x = (gint) (yyvsp[(3) - (8)].value);
gint y = (gint) (yyvsp[(5) - (8)].value);
......@@ -1439,30 +1441,32 @@ yyreduce:
current_object = create_circle(x, y, r);
object_set_url(current_object, (yyvsp[(8) - (8)].id));
add_shape(current_object);
g_free ((yyvsp[(8) - (8)].id));
}
break;
case 13:
#line 105 "imap_cern.y"
#line 108 "imap_cern.y"
{current_object = create_polygon(NULL);}
break;
case 14:
#line 106 "imap_cern.y"
#line 109 "imap_cern.y"
{
object_set_url(current_object, (yyvsp[(4) - (4)].id));
add_shape(current_object);
g_free ((yyvsp[(4) - (4)].id));
}
break;
case 16:
#line 114 "imap_cern.y"
#line 118 "imap_cern.y"
{
}
break;
case 17:
#line 119 "imap_cern.y"
#line 123 "imap_cern.y"
{
Polygon_t *polygon = ObjectToPolygon(current_object);
GdkPoint *point = new_point((gint) (yyvsp[(2) - (5)].value), (gint) (yyvsp[(4) - (5)].value));
......@@ -1472,22 +1476,23 @@ yyreduce:
break;
case 21:
#line 133 "imap_cern.y"
#line 137 "imap_cern.y"
{
g_free ((yyvsp[(2) - (2)].id));
}
break;
case 22:
#line 138 "imap_cern.y"
#line 143 "imap_cern.y"
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->author, (yyvsp[(2) - (2)].id));
g_free ((yyvsp[(2) - (2)].id));
}
break;
case 23:
#line 146 "imap_cern.y"
#line 151 "imap_cern.y"
{
MapInfo_t *info = get_map_info();
gchar *description;
......@@ -1495,12 +1500,13 @@ yyreduce:
description = g_strconcat(info->description, (yyvsp[(2) - (2)].id), "\n",
NULL);
g_strreplace(&info->description, description);
g_free ((yyvsp[(2) - (2)].id));
}
break;
/* Line 1267 of yacc.c. */
#line 1504 "y.tab.c"
#line 1510 "y.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
......@@ -1714,7 +1720,7 @@ yyreturn:
}
#line 157 "imap_cern.y"
#line 163 "imap_cern.y"
static void
......
......@@ -72,7 +72,7 @@ typedef union YYSTYPE
{
int val;
double value;
char id[256];
char *id;
}
/* Line 1489 of yacc.c. */
#line 79 "y.tab.h"
......
......@@ -66,8 +66,7 @@ WS [ \t\n]+
}
<comment>.*/--\> {
strcpy(csim_lval.id, yytext);
csim_lval.id[yyleng - 1] = '\0';
csim_lval.id = g_strndup (yytext, yyleng);
return STRING;
}
......@@ -113,7 +112,6 @@ NOHREF return NOHREF;
\" {
BEGIN(quoted_string);
*csim_lval.id = 0;
}
<quoted_string>\" {
......@@ -121,7 +119,9 @@ NOHREF return NOHREF;
return STRING;
}
<quoted_string>[^\"]* strcpy(csim_lval.id, yytext);
<quoted_string>[^\"]* {
csim_lval.id = g_strndup (yytext, yyleng);
}
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
csim_lval.value = g_ascii_strtod (yytext, NULL);
......
......@@ -49,7 +49,7 @@ static MapInfo_t *_map_info;
%union {
int val;
double value;
char id[4096]; /* Large enough to hold all polygon points! */
char *id;
}
%token<val> IMG SRC WIDTH HEIGHT BORDER USEMAP
......@@ -69,6 +69,7 @@ csim_file : image start_map comment_lines area_list end_map
image : '<' IMG SRC '=' STRING image_tags xhtml_close
{
g_strreplace(&_map_info->image_name, $5);
g_free ($5);
}
;
......@@ -79,8 +80,8 @@ image_tags : /* Empty */
image_tag : image_width
| image_height
| BORDER '=' integer_value {}
| USEMAP '=' STRING {}
| ALT '=' STRING {}
| USEMAP '=' STRING { g_free ($3); }
| ALT '=' STRING { g_free ($3); }
;
image_width : WIDTH '=' integer_value
......@@ -102,12 +103,14 @@ integer_value : FLOAT
| STRING
{
$$ = (gint) g_ascii_strtod ($1, NULL);
g_free ($1);
}
;
start_map : '<' START_MAP NAME '=' STRING '>'
{
g_strreplace(&_map_info->title, $5);
g_free ($5);
}
;
......@@ -122,13 +125,14 @@ comment_line : author_line
real_comment : BEGIN_COMMENT STRING END_COMMENT
{
g_free ($2);
}
;
author_line : AUTHOR STRING END_COMMENT
{
g_strreplace(&_map_info->author, $2);
g_free ($2);
}
;
......@@ -139,6 +143,7 @@ description_line: DESCRIPTION STRING END_COMMENT
description = g_strconcat(_map_info->description, $2, "\n",
NULL);
g_strreplace(&_map_info->description, description);
g_free ($2);
}
;
......@@ -187,6 +192,7 @@ shape_tag : SHAPE '=' STRING
} else if (!g_ascii_strcasecmp($3, "DEFAULT")) {
current_type = UNDEFINED;
}
g_free ($3);
}
;
......@@ -245,6 +251,8 @@ coords_tag : COORDS '=' STRING
polygon_remove_last_point(polygon);
polygon->points = points;
}
g_free ($3);
}
;
......@@ -255,6 +263,7 @@ href_tag : HREF '=' STRING
} else {
object_set_url(current_object, $3);
}
g_free ($3);
}
;
......@@ -266,42 +275,49 @@ nohref_tag : NOHREF optional_value
optional_value : /* Empty */
| '=' STRING
{
g_free ($2);
}
;
alt_tag : ALT '=' STRING
{
object_set_comment(current_object, $3);
g_free ($3);
}
;
target_tag : TARGET '=' STRING
{
object_set_target(current_object, $3);
g_free ($3);
}
;
onmouseover_tag : ONMOUSEOVER '=' STRING
{
object_set_mouse_over(current_object, $3);
g_free ($3);
}
;
onmouseout_tag : ONMOUSEOUT '=' STRING
{
object_set_mouse_out(current_object, $3);
g_free ($3);
}
;
onfocus_tag : ONFOCUS '=' STRING
{
object_set_focus(current_object, $3);
g_free ($3);
}
;
onblur_tag : ONBLUR '=' STRING
{
object_set_blur(current_object, $3);
g_free ($3);
}
;
......
......@@ -5,6 +5,25 @@
/* A lexical scanner generated by flex */
#define yy_create_buffer csim__create_buffer
#define yy_delete_buffer csim__delete_buffer
#define yy_flex_debug csim__flex_debug
#define yy_init_buffer csim__init_buffer
#define yy_flush_buffer csim__flush_buffer
#define yy_load_buffer_state csim__load_buffer_state
#define yy_switch_to_buffer csim__switch_to_buffer
#define yyin csim_in
#define yyleng csim_leng
#define yylex csim_lex
#define yylineno csim_lineno
#define yyout csim_out
#define yyrestart csim_restart
#define yytext csim_text
#define yywrap csim_wrap
#define yyalloc csim_alloc
#define yyrealloc csim_realloc
#define yyfree csim_free
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
......@@ -335,7 +354,7 @@ void csim_free (void * );
/* Begin user sect3 */
#define csim_wrap() 1
#define csim_wrap(n) 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
......@@ -589,7 +608,7 @@ char *csim_text;
#line 593 "<stdout>"
#line 612 "<stdout>"
#define INITIAL 0
#define quoted_string 1
......@@ -747,7 +766,7 @@ YY_DECL
#line 46 "imap_csim.l"
#line 751 "<stdout>"
#line 770 "<stdout>"
if ( !(yy_init) )
{
......@@ -869,122 +888,120 @@ YY_DO_BEFORE_ACTION; /* set up csim_text again */
YY_RULE_SETUP
#line 68 "imap_csim.l"
{
strcpy(csim_lval.id, csim_text);
csim_lval.id[csim_leng - 1] = '\0';
csim_lval.id = g_strndup (csim_text, csim_leng);
return STRING;
}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 74 "imap_csim.l"
#line 73 "imap_csim.l"
return IMG;
YY_BREAK
case 7:
YY_RULE_SETUP
#line 76 "imap_csim.l"
#line 75 "imap_csim.l"
return SRC;
YY_BREAK
case 8:
YY_RULE_SETUP
#line 78 "imap_csim.l"
#line 77 "imap_csim.l"
return WIDTH;
YY_BREAK
case 9:
YY_RULE_SETUP
#line 80 "imap_csim.l"
#line 79 "imap_csim.l"
return HEIGHT;
YY_BREAK
case 10:
YY_RULE_SETUP
#line 82 "imap_csim.l"
#line 81 "imap_csim.l"
return BORDER;
YY_BREAK
case 11:
YY_RULE_SETUP
#line 84 "imap_csim.l"
#line 83 "imap_csim.l"
return USEMAP;
YY_BREAK
case 12:
YY_RULE_SETUP
#line 86 "imap_csim.l"
#line 85 "imap_csim.l"
return START_MAP;
YY_BREAK
case 13:
YY_RULE_SETUP
#line 88 "imap_csim.l"
#line 87 "imap_csim.l"
return END_MAP;
YY_BREAK
case 14:
YY_RULE_SETUP
#line 90 "imap_csim.l"
#line 89 "imap_csim.l"
return NAME;
YY_BREAK
case 15:
YY_RULE_SETUP
#line 92 "imap_csim.l"
#line 91 "imap_csim.l"
return AREA;
YY_BREAK
case 16:
YY_RULE_SETUP
#line 94 "imap_csim.l"
#line 93 "imap_csim.l"
return SHAPE;
YY_BREAK
case 17:
YY_RULE_SETUP
#line 96 "imap_csim.l"
#line 95 "imap_csim.l"
return COORDS;
YY_BREAK
case 18:
YY_RULE_SETUP
#line 98 "imap_csim.l"
#line 97 "imap_csim.l"
return TARGET;
YY_BREAK
case 19:
YY_RULE_SETUP
#line 100 "imap_csim.l"
#line 99 "imap_csim.l"
return ONMOUSEOVER;
YY_BREAK
case 20:
YY_RULE_SETUP
#line 102 "imap_csim.l"
#line 101 "imap_csim.l"
return ONMOUSEOUT;
YY_BREAK
case 21:
YY_RULE_SETUP
#line 104 "imap_csim.l"
#line 103 "imap_csim.l"
return ONFOCUS;
YY_BREAK
case 22:
YY_RULE_SETUP
#line 106 "imap_csim.l"
#line 105 "imap_csim.l"
return ONBLUR;
YY_BREAK
case 23:
YY_RULE_SETUP
#line 108 "imap_csim.l"
#line 107 "imap_csim.l"
return ALT;
YY_BREAK
case 24:
YY_RULE_SETUP
#line 110 "imap_csim.l"
#line 109 "imap_csim.l"
return HREF;
YY_BREAK
case 25:
YY_RULE_SETUP
#line 112 "imap_csim.l"
#line 111 "imap_csim.l"
return NOHREF;
YY_BREAK
case 26:
YY_RULE_SETUP
#line 114 "imap_csim.l"
#line 113 "imap_csim.l"
{
BEGIN(quoted_string);
*csim_lval.id = 0;
}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 119 "imap_csim.l"
#line 117 "imap_csim.l"
{
BEGIN(INITIAL);
return STRING;
......@@ -993,8 +1010,10 @@ YY_RULE_SETUP
case 28:
/* rule 28 can match eol */
YY_RULE_SETUP
#line 124 "imap_csim.l"
strcpy(csim_lval.id, csim_text);
#line 122 "imap_csim.l"
{
csim_lval.id = g_strndup (csim_text, csim_leng);
}
YY_BREAK
case 29:
YY_RULE_SETUP
......@@ -1020,7 +1039,7 @@ YY_RULE_SETUP
#line 135 "imap_csim.l"
ECHO;
YY_BREAK
#line 1024 "<stdout>"
#line 1043 "<stdout>"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(quoted_string):
case YY_STATE_EOF(comment):
......@@ -1253,7 +1272,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
......@@ -1754,7 +1773,7 @@ YY_BUFFER_STATE csim__scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to csim_lex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param str a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
......
......@@ -207,7 +207,7 @@ typedef union YYSTYPE
{
int val;
double value;
char id[4096]; /* Large enough to hold all polygon points! */
char *id;
}
/* Line 187 of yacc.c. */
#line 214 "y.tab.c"
......@@ -528,12 +528,12 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 66, 66, 69, 75, 76, 79, 80, 81, 82,
83, 86, 92, 98, 102, 108, 114, 115, 118, 119,
120, 123, 128, 135, 145, 146, 149, 156, 157, 160,
161, 164, 165, 166, 167, 168, 169, 170, 171, 172,
173, 176, 193, 251, 261, 266, 267, 272, 278, 284,
290, 296, 302, 308
0, 66, 66, 69, 76, 77, 80, 81