From 0aa7e74a05d95ab46ced6714486cf3c52aba191b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Mon, 11 Feb 2008 22:22:24 +0000 Subject: [PATCH] removed function Make_String() git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1007 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 6 ++++++ jtag/src/bsdl/bsdl.h | 2 -- jtag/src/bsdl/bsdl_bison.y | 32 +++++++++++++------------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 7aad379e..be0b7227 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,9 @@ +2008-02-11 Arnim Laeuger + + * src/bsdl/bsdl_bison.y (Store_Text): removed function Make_String() + the QUOTED_STRING is directly copied to buffer_for_switch + * src/bsdl/bsdl.h: memeber String_Val of parser_priv obseleted + 2008-02-10 Arnim Laeuger * src/tap/cable/ft2232.c (ft2232_generic_init, ft2232_jtagkey_init) diff --git a/jtag/src/bsdl/bsdl.h b/jtag/src/bsdl/bsdl.h index 1ae5ee6e..5de957ef 100644 --- a/jtag/src/bsdl/bsdl.h +++ b/jtag/src/bsdl/bsdl.h @@ -122,12 +122,10 @@ struct jtag_ctrl { /* private data of the bison parser used to store variables the would end up as globals otherwise */ struct parser_priv { - char String_Val[150]; char Package_File_Name[100]; int Reading_Package; char *buffer_for_switch; size_t len_buffer_for_switch; - int idx_to_buffer; void *scanner; struct jtag_ctrl jtag_ctrl; }; diff --git a/jtag/src/bsdl/bsdl_bison.y b/jtag/src/bsdl/bsdl_bison.y index 5ab77cc8..4710db08 100644 --- a/jtag/src/bsdl/bsdl_bison.y +++ b/jtag/src/bsdl/bsdl_bison.y @@ -147,7 +147,6 @@ int yylex (YYSTYPE *, void *); static void Init_Text(parser_priv_t *); static void Store_Text(parser_priv_t *, char *); -static void Make_String(char *, char *); static void Print_Error(parser_priv_t *, const char *); static void Print_Warning(parser_priv_t *, const char *); static void Give_Up_And_Quit(parser_priv_t *); @@ -876,13 +875,11 @@ BSDL_Compliance_Pattern: LPAREN Physical_Pin_List RPAREN { free($5); } ; Quoted_String : QUOTED_STRING - {Make_String($1, priv_data->String_Val); - Init_Text(priv_data); - Store_Text(priv_data, priv_data->String_Val); + {Init_Text(priv_data); + Store_Text(priv_data, $1); free($1); } | Quoted_String CONCATENATE QUOTED_STRING - {Make_String($3, priv_data->String_Val); - Store_Text(priv_data, priv_data->String_Val); + {Store_Text(priv_data, $3); free($3); } ; %% /* End rules, begin programs */ @@ -894,29 +891,26 @@ static void Init_Text(parser_priv_t *priv_data) priv_data->len_buffer_for_switch = 160; } priv_data->buffer_for_switch[0] = '\0'; - priv_data->idx_to_buffer = 0; } /*----------------------------------------------------------------------*/ -static void Store_Text(parser_priv_t *priv_data, char *String) +static void Store_Text(parser_priv_t *priv_data, char *Source) { /* Save characters from VHDL string in local string buffer. */ size_t req_len; + char *SourceEnd; - req_len = strlen(priv_data->buffer_for_switch) + strlen(String) + 1; + SourceEnd = ++Source; /* skip leading '"' */ + while (*SourceEnd && (*SourceEnd != '"') && (*SourceEnd != '\n')) + SourceEnd++; + /* terminate Source string with NUL character */ + *SourceEnd = '\0'; + + req_len = strlen(priv_data->buffer_for_switch) + strlen(Source) + 1; if (req_len > priv_data->len_buffer_for_switch) { priv_data->buffer_for_switch = (char *)realloc(priv_data->buffer_for_switch, req_len); priv_data->len_buffer_for_switch = req_len; } - strcpy(&(priv_data->buffer_for_switch[priv_data->idx_to_buffer]), String); - priv_data->idx_to_buffer += strlen(String); -} -/*----------------------------------------------------------------------*/ -static void Make_String(char *Source, char *Dest) -{ - char Ch; - for (Source++; Ch = *Source, (Ch != '"') && (Ch != '\n'); Source++, Dest++) - *Dest = *Source; - *Dest = '\0'; + strcat(priv_data->buffer_for_switch, Source); } /*----------------------------------------------------------------------*/ static void Print_Error(parser_priv_t *priv_data, const char *Errmess)