diff --git a/ChangeLog b/ChangeLog index d1f23b5a8a..370ab16865 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2008-01-27 Kevin Cozens + + * 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 * plug-ins/gimpressionist/gimp.c (gimpressionist_main): transfer diff --git a/plug-ins/imagemap/imap_cern.l b/plug-ins/imagemap/imap_cern.l index 1e5ee8ebd0..31948b64e0 100755 --- a/plug-ins/imagemap/imap_cern.l +++ b/plug-ins/imagemap/imap_cern.l @@ -61,7 +61,7 @@ RECT{WS}\(4096,4096\){WS}\(4096,4096\) { .*$ { 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; } diff --git a/plug-ins/imagemap/imap_cern.y b/plug-ins/imagemap/imap_cern.y index 367afa46cf..286536a0e4 100755 --- a/plug-ins/imagemap/imap_cern.y +++ b/plug-ins/imagemap/imap_cern.y @@ -47,7 +47,7 @@ static Object_t *current_object; %union { int val; double value; - char id[256]; + char *id; } %token 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); } ; diff --git a/plug-ins/imagemap/imap_cern_lex.c b/plug-ins/imagemap/imap_cern_lex.c index 36ef1e5189..2ddaabc62e 100644 --- a/plug-ins/imagemap/imap_cern_lex.c +++ b/plug-ins/imagemap/imap_cern_lex.c @@ -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 "" +#line 593 "" #define INITIAL 0 #define comment 1 @@ -727,7 +746,7 @@ YY_DECL #line 45 "imap_cern.l" -#line 731 "" +#line 750 "" 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 "" +#line 927 "" 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 diff --git a/plug-ins/imagemap/imap_cern_parse.c b/plug-ins/imagemap/imap_cern_parse.c index 8af5076503..85243cc8d9 100644 --- a/plug-ins/imagemap/imap_cern_parse.c +++ b/plug-ins/imagemap/imap_cern_parse.c @@ -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 diff --git a/plug-ins/imagemap/imap_cern_parse.h b/plug-ins/imagemap/imap_cern_parse.h index 70718c2212..e8a021a84c 100644 --- a/plug-ins/imagemap/imap_cern_parse.h +++ b/plug-ins/imagemap/imap_cern_parse.h @@ -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" diff --git a/plug-ins/imagemap/imap_csim.l b/plug-ins/imagemap/imap_csim.l index 0a70f4904f..c3168591f7 100755 --- a/plug-ins/imagemap/imap_csim.l +++ b/plug-ins/imagemap/imap_csim.l @@ -66,8 +66,7 @@ WS [ \t\n]+ } .*/--\> { - 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; } \" { @@ -121,7 +119,9 @@ NOHREF return NOHREF; return STRING; } -[^\"]* strcpy(csim_lval.id, yytext); +[^\"]* { + csim_lval.id = g_strndup (yytext, yyleng); + } -?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? { csim_lval.value = g_ascii_strtod (yytext, NULL); diff --git a/plug-ins/imagemap/imap_csim.y b/plug-ins/imagemap/imap_csim.y index 33df533409..7ada0205ce 100755 --- a/plug-ins/imagemap/imap_csim.y +++ b/plug-ins/imagemap/imap_csim.y @@ -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 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); } ; diff --git a/plug-ins/imagemap/imap_csim_lex.c b/plug-ins/imagemap/imap_csim_lex.c index 90176f4357..f21f0159db 100644 --- a/plug-ins/imagemap/imap_csim_lex.c +++ b/plug-ins/imagemap/imap_csim_lex.c @@ -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 "" +#line 612 "" #define INITIAL 0 #define quoted_string 1 @@ -747,7 +766,7 @@ YY_DECL #line 46 "imap_csim.l" -#line 751 "" +#line 770 "" 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 "" +#line 1043 "" 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 diff --git a/plug-ins/imagemap/imap_csim_parse.c b/plug-ins/imagemap/imap_csim_parse.c index 109d8854c9..bc4aec2376 100644 --- a/plug-ins/imagemap/imap_csim_parse.c +++ b/plug-ins/imagemap/imap_csim_parse.c @@ -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, 82, 83, + 84, 87, 93, 99, 103, 110, 117, 118, 121, 122, + 123, 126, 132, 139, 150, 151, 154, 161, 162, 165, + 166, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 181, 199, 259, 270, 275, 276, 282, 289, 296, + 303, 310, 317, 324 }; #endif @@ -1508,86 +1508,91 @@ yyreduce: #line 70 "imap_csim.y" { g_strreplace(&_map_info->image_name, (yyvsp[(5) - (7)].id)); + g_free ((yyvsp[(5) - (7)].id)); } break; case 8: -#line 81 "imap_csim.y" - {} - break; - - case 9: #line 82 "imap_csim.y" {} break; - case 10: + case 9: #line 83 "imap_csim.y" - {} + { g_free ((yyvsp[(3) - (3)].id)); } + break; + + case 10: +#line 84 "imap_csim.y" + { g_free ((yyvsp[(3) - (3)].id)); } break; case 11: -#line 87 "imap_csim.y" +#line 88 "imap_csim.y" { _map_info->old_image_width = (yyvsp[(3) - (3)].val); } break; case 12: -#line 93 "imap_csim.y" +#line 94 "imap_csim.y" { _map_info->old_image_height = (yyvsp[(3) - (3)].val); } break; case 13: -#line 99 "imap_csim.y" +#line 100 "imap_csim.y" { (yyval.val) = (gint) (yyvsp[(1) - (1)].value); } break; case 14: -#line 103 "imap_csim.y" +#line 104 "imap_csim.y" { (yyval.val) = (gint) g_ascii_strtod ((yyvsp[(1) - (1)].id), NULL); + g_free ((yyvsp[(1) - (1)].id)); } break; case 15: -#line 109 "imap_csim.y" +#line 111 "imap_csim.y" { g_strreplace(&_map_info->title, (yyvsp[(5) - (6)].id)); + g_free ((yyvsp[(5) - (6)].id)); } break; case 21: -#line 124 "imap_csim.y" +#line 127 "imap_csim.y" { + g_free ((yyvsp[(2) - (3)].id)); } break; case 22: -#line 129 "imap_csim.y" +#line 133 "imap_csim.y" { g_strreplace(&_map_info->author, (yyvsp[(2) - (3)].id)); - + g_free ((yyvsp[(2) - (3)].id)); } break; case 23: -#line 136 "imap_csim.y" +#line 140 "imap_csim.y" { gchar *description; description = g_strconcat(_map_info->description, (yyvsp[(2) - (3)].id), "\n", NULL); g_strreplace(&_map_info->description, description); + g_free ((yyvsp[(2) - (3)].id)); } break; case 26: -#line 150 "imap_csim.y" +#line 155 "imap_csim.y" { if (current_type != UNDEFINED) add_shape(current_object); @@ -1595,7 +1600,7 @@ yyreduce: break; case 41: -#line 177 "imap_csim.y" +#line 182 "imap_csim.y" { if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "RECT")) { current_object = create_rectangle(0, 0, 0, 0); @@ -1609,11 +1614,12 @@ yyreduce: } else if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "DEFAULT")) { current_type = UNDEFINED; } + g_free ((yyvsp[(3) - (3)].id)); } break; case 42: -#line 194 "imap_csim.y" +#line 200 "imap_csim.y" { char *p; if (current_type == RECTANGLE) { @@ -1668,77 +1674,87 @@ yyreduce: polygon_remove_last_point(polygon); polygon->points = points; } + + g_free ((yyvsp[(3) - (3)].id)); } break; case 43: -#line 252 "imap_csim.y" +#line 260 "imap_csim.y" { if (current_type == UNDEFINED) { g_strreplace(&_map_info->default_url, (yyvsp[(3) - (3)].id)); } else { object_set_url(current_object, (yyvsp[(3) - (3)].id)); } + g_free ((yyvsp[(3) - (3)].id)); } break; case 44: -#line 262 "imap_csim.y" +#line 271 "imap_csim.y" { } break; case 46: -#line 268 "imap_csim.y" +#line 277 "imap_csim.y" { + g_free ((yyvsp[(2) - (2)].id)); } break; case 47: -#line 273 "imap_csim.y" +#line 283 "imap_csim.y" { object_set_comment(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; case 48: -#line 279 "imap_csim.y" +#line 290 "imap_csim.y" { object_set_target(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; case 49: -#line 285 "imap_csim.y" +#line 297 "imap_csim.y" { object_set_mouse_over(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; case 50: -#line 291 "imap_csim.y" +#line 304 "imap_csim.y" { object_set_mouse_out(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; case 51: -#line 297 "imap_csim.y" +#line 311 "imap_csim.y" { object_set_focus(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; case 52: -#line 303 "imap_csim.y" +#line 318 "imap_csim.y" { object_set_blur(current_object, (yyvsp[(3) - (3)].id)); + g_free ((yyvsp[(3) - (3)].id)); } break; /* Line 1267 of yacc.c. */ -#line 1742 "y.tab.c" +#line 1758 "y.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1952,7 +1968,7 @@ yyreturn: } -#line 311 "imap_csim.y" +#line 327 "imap_csim.y" static void diff --git a/plug-ins/imagemap/imap_csim_parse.h b/plug-ins/imagemap/imap_csim_parse.h index ca58a917a7..41eb6f9378 100644 --- a/plug-ins/imagemap/imap_csim_parse.h +++ b/plug-ins/imagemap/imap_csim_parse.h @@ -104,7 +104,7 @@ typedef union YYSTYPE { int val; double value; - char id[4096]; /* Large enough to hold all polygon points! */ + char *id; } /* Line 1489 of yacc.c. */ #line 111 "y.tab.h" diff --git a/plug-ins/imagemap/imap_ncsa.l b/plug-ins/imagemap/imap_ncsa.l index 6a5b73cc08..2d09a49fa9 100755 --- a/plug-ins/imagemap/imap_ncsa.l +++ b/plug-ins/imagemap/imap_ncsa.l @@ -67,7 +67,7 @@ WS [ \t\n]+ .* { BEGIN(INITIAL); - strcpy(ncsa_lval.id, yytext); + ncsa_lval.id = g_strndup (yytext, yyleng); return COMMENT; } @@ -93,8 +93,7 @@ DEFAULT { [^ ,\t\n]+ { BEGIN(INITIAL); - strcpy(ncsa_lval.id, yytext); - ncsa_lval.id[yyleng - 1] = '\0'; + ncsa_lval.id = g_strndup (yytext, yyleng); return LINK; } diff --git a/plug-ins/imagemap/imap_ncsa.y b/plug-ins/imagemap/imap_ncsa.y index 977e89b3b9..6738c6b5d1 100755 --- a/plug-ins/imagemap/imap_ncsa.y +++ b/plug-ins/imagemap/imap_ncsa.y @@ -46,7 +46,7 @@ static Object_t *current_object; %union { int val; double value; - char id[256]; + char *id; } %token RECTANGLE POLYGON CIRCLE DEFAULT @@ -71,6 +71,7 @@ comment_line : author_line real_comment : BEGIN_COMMENT COMMENT { + g_free ($2); } ; @@ -78,6 +79,7 @@ author_line : AUTHOR COMMENT { MapInfo_t *info = get_map_info(); g_strreplace(&info->author, $2); + g_free ($2); } ; @@ -85,6 +87,7 @@ title_line : TITLE COMMENT { MapInfo_t *info = get_map_info(); g_strreplace(&info->title, $2); + g_free ($2); } ; @@ -96,6 +99,7 @@ description_line: DESCRIPTION COMMENT description = g_strconcat(info->description, $2, "\n", NULL); g_strreplace(&info->description, description); + g_free ($2); } ; @@ -114,6 +118,7 @@ default : DEFAULT LINK { MapInfo_t *info = get_map_info(); g_strreplace(&info->default_url, $2); + g_free ($2); } ; @@ -127,6 +132,7 @@ rectangle : RECTANGLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT current_object = create_rectangle(x, y, width, height); object_set_url(current_object, $2); add_shape(current_object); + g_free ($2); } ; @@ -138,6 +144,7 @@ circle : CIRCLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT current_object = create_circle(x, y, r); object_set_url(current_object, $2); add_shape(current_object); + g_free ($2); } ; @@ -145,6 +152,7 @@ polygon : POLYGON LINK {current_object = create_polygon(NULL);} coord_list { object_set_url(current_object, $2); add_shape(current_object); + g_free ($2); } ; diff --git a/plug-ins/imagemap/imap_ncsa_lex.c b/plug-ins/imagemap/imap_ncsa_lex.c index 3c265740a0..a469007816 100644 --- a/plug-ins/imagemap/imap_ncsa_lex.c +++ b/plug-ins/imagemap/imap_ncsa_lex.c @@ -5,6 +5,25 @@ /* A lexical scanner generated by flex */ +#define yy_create_buffer ncsa__create_buffer +#define yy_delete_buffer ncsa__delete_buffer +#define yy_flex_debug ncsa__flex_debug +#define yy_init_buffer ncsa__init_buffer +#define yy_flush_buffer ncsa__flush_buffer +#define yy_load_buffer_state ncsa__load_buffer_state +#define yy_switch_to_buffer ncsa__switch_to_buffer +#define yyin ncsa_in +#define yyleng ncsa_leng +#define yylex ncsa_lex +#define yylineno ncsa_lineno +#define yyout ncsa_out +#define yyrestart ncsa_restart +#define yytext ncsa_text +#define yywrap ncsa_wrap +#define yyalloc ncsa_alloc +#define yyrealloc ncsa_realloc +#define yyfree ncsa_free + #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 @@ -335,7 +354,7 @@ void ncsa_free (void * ); /* Begin user sect3 */ -#define ncsa_wrap() 1 +#define ncsa_wrap(n) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; @@ -541,7 +560,7 @@ char *ncsa_text; -#line 545 "" +#line 564 "" #define INITIAL 0 #define imap_link 1 @@ -699,7 +718,7 @@ YY_DECL #line 46 "imap_ncsa.l" -#line 703 "" +#line 722 "" if ( !(yy_init) ) { @@ -819,7 +838,7 @@ YY_RULE_SETUP #line 68 "imap_ncsa.l" { BEGIN(INITIAL); - strcpy(ncsa_lval.id, ncsa_text); + ncsa_lval.id = g_strndup (ncsa_text, ncsa_leng); return COMMENT; } YY_BREAK @@ -860,14 +879,13 @@ YY_RULE_SETUP #line 94 "imap_ncsa.l" { BEGIN(INITIAL); - strcpy(ncsa_lval.id, ncsa_text); - ncsa_lval.id[ncsa_leng - 1] = '\0'; + ncsa_lval.id = g_strndup (ncsa_text, ncsa_leng); return LINK; } YY_BREAK case 11: YY_RULE_SETUP -#line 101 "imap_ncsa.l" +#line 100 "imap_ncsa.l" { ncsa_lval.value = g_ascii_strtod (ncsa_text, NULL); return FLOAT; @@ -876,20 +894,20 @@ YY_RULE_SETUP case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 106 "imap_ncsa.l" +#line 105 "imap_ncsa.l" ; /* Eat white space */ YY_BREAK case 13: YY_RULE_SETUP -#line 108 "imap_ncsa.l" +#line 107 "imap_ncsa.l" return *ncsa_text; YY_BREAK case 14: YY_RULE_SETUP -#line 110 "imap_ncsa.l" +#line 109 "imap_ncsa.l" ECHO; YY_BREAK -#line 893 "" +#line 911 "" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(imap_link): case YY_STATE_EOF(comment): @@ -1122,7 +1140,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); } @@ -1623,7 +1641,7 @@ YY_BUFFER_STATE ncsa__scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to ncsa_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 @@ -1877,7 +1895,7 @@ void ncsa_free (void * ptr ) #define YYTABLES_NAME "yytables" -#line 110 "imap_ncsa.l" +#line 109 "imap_ncsa.l" diff --git a/plug-ins/imagemap/imap_ncsa_parse.c b/plug-ins/imagemap/imap_ncsa_parse.c index 8c11e9d4ae..1d29ae3efd 100644 --- a/plug-ins/imagemap/imap_ncsa_parse.c +++ b/plug-ins/imagemap/imap_ncsa_parse.c @@ -174,7 +174,7 @@ typedef union YYSTYPE { int val; double value; - char id[256]; + char *id; } /* Line 187 of yacc.c. */ #line 181 "y.tab.c" @@ -482,8 +482,8 @@ static const yytype_int8 yyrhs[] = static const yytype_uint8 yyrline[] = { 0, 59, 59, 62, 63, 66, 67, 68, 69, 72, - 77, 84, 91, 102, 103, 106, 107, 108, 109, 110, - 113, 121, 133, 144, 144, 151, 152, 157 + 78, 86, 94, 106, 107, 110, 111, 112, 113, 114, + 117, 126, 139, 151, 151, 159, 160, 165 }; #endif @@ -1411,27 +1411,30 @@ yyreduce: case 9: #line 73 "imap_ncsa.y" { + g_free ((yyvsp[(2) - (2)].id)); } break; case 10: -#line 78 "imap_ncsa.y" +#line 79 "imap_ncsa.y" { MapInfo_t *info = get_map_info(); g_strreplace(&info->author, (yyvsp[(2) - (2)].id)); + g_free ((yyvsp[(2) - (2)].id)); } break; case 11: -#line 85 "imap_ncsa.y" +#line 87 "imap_ncsa.y" { MapInfo_t *info = get_map_info(); g_strreplace(&info->title, (yyvsp[(2) - (2)].id)); + g_free ((yyvsp[(2) - (2)].id)); } break; case 12: -#line 92 "imap_ncsa.y" +#line 95 "imap_ncsa.y" { MapInfo_t *info = get_map_info(); gchar *description; @@ -1439,19 +1442,21 @@ yyreduce: description = g_strconcat(info->description, (yyvsp[(2) - (2)].id), "\n", NULL); g_strreplace(&info->description, description); + g_free ((yyvsp[(2) - (2)].id)); } break; case 20: -#line 114 "imap_ncsa.y" +#line 118 "imap_ncsa.y" { MapInfo_t *info = get_map_info(); g_strreplace(&info->default_url, (yyvsp[(2) - (2)].id)); + g_free ((yyvsp[(2) - (2)].id)); } break; case 21: -#line 122 "imap_ncsa.y" +#line 127 "imap_ncsa.y" { gint x = (gint) (yyvsp[(3) - (8)].value); gint y = (gint) (yyvsp[(5) - (8)].value); @@ -1460,11 +1465,12 @@ yyreduce: current_object = create_rectangle(x, y, width, height); object_set_url(current_object, (yyvsp[(2) - (8)].id)); add_shape(current_object); + g_free ((yyvsp[(2) - (8)].id)); } break; case 22: -#line 134 "imap_ncsa.y" +#line 140 "imap_ncsa.y" { gint x = (gint) (yyvsp[(3) - (8)].value); gint y = (gint) (yyvsp[(5) - (8)].value); @@ -1472,30 +1478,32 @@ yyreduce: current_object = create_circle(x, y, r); object_set_url(current_object, (yyvsp[(2) - (8)].id)); add_shape(current_object); + g_free ((yyvsp[(2) - (8)].id)); } break; case 23: -#line 144 "imap_ncsa.y" +#line 151 "imap_ncsa.y" {current_object = create_polygon(NULL);} break; case 24: -#line 145 "imap_ncsa.y" +#line 152 "imap_ncsa.y" { object_set_url(current_object, (yyvsp[(2) - (4)].id)); add_shape(current_object); + g_free ((yyvsp[(2) - (4)].id)); } break; case 26: -#line 153 "imap_ncsa.y" +#line 161 "imap_ncsa.y" { } break; case 27: -#line 158 "imap_ncsa.y" +#line 166 "imap_ncsa.y" { Polygon_t *polygon = ObjectToPolygon(current_object); GdkPoint *point = new_point((gint) (yyvsp[(1) - (3)].value), (gint) (yyvsp[(3) - (3)].value)); @@ -1506,7 +1514,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1510 "y.tab.c" +#line 1518 "y.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1720,7 +1728,7 @@ yyreturn: } -#line 166 "imap_ncsa.y" +#line 174 "imap_ncsa.y" static void diff --git a/plug-ins/imagemap/imap_ncsa_parse.h b/plug-ins/imagemap/imap_ncsa_parse.h index 9dc93f16e4..5ba27d0e0e 100644 --- a/plug-ins/imagemap/imap_ncsa_parse.h +++ b/plug-ins/imagemap/imap_ncsa_parse.h @@ -74,7 +74,7 @@ typedef union YYSTYPE { int val; double value; - char id[256]; + char *id; } /* Line 1489 of yacc.c. */ #line 81 "y.tab.h"