Skip to content
Snippets Groups Projects
Commit 8e02a524 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

StrCat can now concatenate any number of strings

parent f3c1c49c
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -5046,13 +5046,20 @@ StringExpr :
Free($3);
Free($5);
}
| tStrCat LP StringExprVar ',' StringExprVar RP
| tStrCat LP RecursiveListOfStringExprVar RP
{
$$ = (char *)Malloc((strlen($3) + strlen($5) + 1) * sizeof(char));
strcpy($$, $3);
strcat($$, $5);
Free($3);
Free($5);
int size = 1;
for(int i = 0; i < List_Nbr($3); i++)
size += strlen(*(char**)List_Pointer($3, i)) + 1;
$$ = (char*)Malloc(size * sizeof(char));
$$[0] = '\0';
for(int i = 0; i < List_Nbr($3); i++){
char *s;
List_Read($3, i, &s);
strcat($$, s);
Free(s);
}
List_Delete($3);
}
| tStrPrefix '(' StringExprVar ')'
{
......@@ -5096,7 +5103,7 @@ StringExpr :
}
| tStr LP RecursiveListOfStringExprVar RP
{
int size = 0;
int size = 1;
for(int i = 0; i < List_Nbr($3); i++)
size += strlen(*(char**)List_Pointer($3, i)) + 1;
$$ = (char*)Malloc(size * sizeof(char));
......
......@@ -1109,8 +1109,8 @@ Character expressions are defined as:
Today | OnelabAction |
StrPrefix ( @var{char-expression} ) |
StrRelative ( @var{char-expression} ) |
StrCat ( @var{char-expression} , @var{char-expression} ) |
Str ( @var{char-expression} , @dots{} ) |
StrCat ( @var{char-expression} <,@dots{}> ) |
Str ( @var{char-expression} <,@dots{}> ) |
Sprintf ( @var{char-expression} , @var{expression-list} ) |
Sprintf ( @var{char-expression} ) |
Sprintf ( @var{char-option} ) |
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment