}
if (value != NULL) {
- line = concatstr(3, line, value, endpos + 1);
+ xasprintf(&line, "%s%s%s", line, value, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
if (strcmp(value, "$") == 0) {
(*pos_p)++;
char *filename;
text *txt;
- filename = concatstr(7,purpose,"-",action,"-",reason,"-",type);
- filenamelen = strlen(filename);
+ filenamelen = xasprintf(&filename, "%s-%s-%s-%s",
+ purpose != NULL ? purpose : "",
+ action != NULL ? action : "",
+ reason != NULL ? reason : "",
+ type != NULL ? type: "");
do {
if ((txt = open_text_file(listfd, filename)) != NULL) break;
len = type ? strlen(type) : 0;
free(tmp);
tmp = esc;
}
- line = concatstr(2, line, tmp);
+ xasprintf(&line, "%s%s", line, tmp);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
return;
}
if (!transparent) str = unistr_escaped_to_utf8(str);
- line = concatstr(2, line, str);
+ xasprintf(&line, "%s%s", line, str);
/* The suffix will be added back in get_processed_text_line() */
*pos_p = line + strlen(*line_p);
free(*line_p);
if (*skipwhite_p) {
while (*pos == ' ' || *pos == '\t') pos++;
}
- line = concatstr(2, line, pos);
+ xasprintf(&line, "%s%s", line, pos);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
while (*endpos == ' ' || *endpos == '\t')
endpos++;
}
- line = concatstr(2, line, endpos);
+ xasprintf(&line, "%s%s", line, endpos);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
while (*endpos == ' ' || *endpos == '\t')
endpos++;
}
- line = concatstr(2, line, endpos);
+ xasprintf(&line, "%s%s", line, endpos);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
*skipwhite_p = 0;
if(strcmp(token, "") == 0) {
- line = concatstr(3, line, "%", endpos + 1);
+ xasprintf(&line, "%s%%%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p) + 1;
(*width_p)++;
free(*line_p);
} else if(strcmp(token, "^") == 0) {
if (txt->src->prefixlen != 0) {
line[txt->src->prefixlen] = '\0';
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*width_p = txt->src->prefixwidth;
} else {
line = xstrdup(endpos + 1);
} else if(strcmp(token, "comment") == 0 || strcmp(token, "$") == 0 ) {
pos = endpos + 1;
while (*pos != '\0' && *pos != '\r' && *pos != '\n') pos++;
- line = concatstr(2, line, pos);
+ xasprintf(&line, "%s%s", line, pos);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
if (limit != 0) {
txt->wrapindent = *width_p;
txt->wrapwidth = limit;
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
}
} else if(strcmp(token, "nowrap") == 0) {
txt->wrapwidth = 0;
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
if (*token == 'w') txt->wrapmode = WRAP_WORD;
if (*token == 'c') txt->wrapmode = WRAP_CHAR;
if (*token == 'u') txt->wrapmode = WRAP_USER;
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
return 0;
} else if(strcmp(token, "thin") == 0) {
txt->widthreckoning = WIDTH_THIN;
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
return 0;
} else if(strcmp(token, "wide") == 0) {
txt->widthreckoning = WIDTH_WIDE;
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
token += 5;
if (txt->zerowidth != NULL) free(txt->zerowidth);
txt->zerowidth = xstrdup(token);
- line = concatstr(2, line, endpos + 1);
+ xasprintf(&line, "%s%s", line, endpos + 1);
*pos_p = line + (*pos_p - *line_p);
free(*line_p);
*line_p = line;
} else {
if (txt->wrapmode == WRAP_WORD &&
len > wrapindentlen) {
- tmp = concatstr(3, prev, " ", pos);
- len++;
- width++;
+ xasprintf(&tmp, "%s %s", prev, pos);
+ len++;
+ width++;
} else {
- tmp = concatstr(2, prev, pos);
+ xasprintf(&tmp, "%s%s", prev, pos);
}
}
free(line);
else inhibitbreak = 0;
}
*pos = '\0';
- tmp = concatstr(2, line, tmp);
+ xasprintf(&tmp, "%s%s", line, tmp);
pos = tmp + len;
free(line);
line = tmp;
/* Time to cut */
if (pos - line != incision) {
line[incision] = '\0';
- tmp = concatstr(2, line, pos);
+ xasprintf(&tmp, "%s%s", line, pos);
pos = tmp + incision;
free(line);
line = tmp;
/* If something's coming up, it's because
* it was a new line. */
if (*(line + linebreak) != '\0') {
- tmp = concatstr(3, line + linebreak,
- "\n", txt->src->upcoming);
+ xasprintf(&tmp, "%s\n%s",
+ line + linebreak, txt->src->upcoming);
free(txt->src->upcoming);
} else {
tmp = txt->src->upcoming;
txt->src->processedwidth = width;
} else {
tmp = txt->src->upcoming;
- txt->src->upcoming = concatstr(3,
- line, "\n",
- txt->src->upcoming);
+ xasprintf(&txt->src->upcoming, "%s\n%s",
+ line, txt->src->upcoming);
txt->src->processedlen = len;
txt->src->processedwidth = width;
free(line);