mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 01:51:33 +02:00
b2/subex.c (compose): use stralloc_n instead of open-coding its functionality
This commit is contained in:
parent
78bcb8d3de
commit
db279b7920
@ -92,7 +92,7 @@ static char *compose(const struct chunk *c,
|
|||||||
const char *s, const regmatch_t *match, const char *units)
|
const char *s, const regmatch_t *match, const char *units)
|
||||||
{
|
{
|
||||||
char *res = stralloc("");
|
char *res = stralloc("");
|
||||||
int res_len = 0, len;
|
int res_len = 0;
|
||||||
const char *val;
|
const char *val;
|
||||||
char *tmp, *tmp2;
|
char *tmp, *tmp2;
|
||||||
int n;
|
int n;
|
||||||
@ -118,10 +118,8 @@ static char *compose(const struct chunk *c,
|
|||||||
}
|
}
|
||||||
if (match[n].rm_so == -1)
|
if (match[n].rm_so == -1)
|
||||||
break;
|
break;
|
||||||
len = match[n].rm_eo-match[n].rm_so;
|
tmp = stralloc_n(s+match[n].rm_so,
|
||||||
tmp = alloc_size(len);
|
match[n].rm_eo-match[n].rm_so);
|
||||||
memcpy(tmp, s+match[n].rm_so, len);
|
|
||||||
tmp[len] = 0;
|
|
||||||
tmp2 = canonicalize(tmp, units ? units[n-1] : 0);
|
tmp2 = canonicalize(tmp, units ? units[n-1] : 0);
|
||||||
append(&res, &res_len, tmp2);
|
append(&res, &res_len, tmp2);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
Loading…
Reference in New Issue
Block a user