Skip to content

Commit 027d6b2

Browse files
techeemasatake
authored andcommitted
Fortran: introduce extended version of newTokenFrom()
Change suggested by @masatake. @mastake edited the commit log.
1 parent 1e60131 commit 027d6b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

parsers/fortran.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,22 @@ static tokenInfo *newToken (void)
468468
return token;
469469
}
470470

471-
static tokenInfo *newTokenFrom (tokenInfo *const token)
471+
static tokenInfo *newTokenFromFull (tokenInfo *const token, bool copyStr)
472472
{
473473
tokenInfo *result = xMalloc (1, tokenInfo);
474474
*result = *token;
475-
result->string = vStringNewCopy (token->string);
475+
result->string = copyStr? vStringNewCopy (token->string): vStringNew();
476476
token->secondary = NULL;
477477
token->parentType = NULL;
478478
token->signature = NULL;
479479
return result;
480480
}
481481

482+
static tokenInfo *newTokenFrom (tokenInfo *const token)
483+
{
484+
return newTokenFromFull (token, true);
485+
}
486+
482487
static void deleteToken (tokenInfo *const token)
483488
{
484489
if (token != NULL)

0 commit comments

Comments
 (0)