bstr: add bstr_xappend0

This commit is contained in:
Guido Cella authored and Kacper Michajłow committed 2024-11-27 15:37:42 +01:00
1 parent b9e6030053
commit f7e2a8c1cc
4 files changed
+11 -9

No files matched your search

+5
View File
@@ -150,6 +150,11 @@ struct bstr bstr_strip_linebreaks(struct bstr str);
*/
void bstr_xappend(void *talloc_ctx, bstr *s, bstr append);
static inline void bstr_xappend0(void *talloc_ctx, bstr *s, const char *append)
{
return bstr_xappend(talloc_ctx, s, bstr0(append));
}
/**
* @brief Append a formatted string to the existing bstr.
*
-1
View File
@@ -358,7 +358,6 @@ bool str_in_list(bstr str, char **list)
bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
first = false; \
} while(0)
#define bstr_xappend0(ctx, dst, s) bstr_xappend(ctx, dst, bstr0(s))
char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang)
{
-2
View File
@@ -185,8 +185,6 @@ void gl_sc_enable_extension(struct gl_shader_cache *sc, char *name)
MP_TARRAY_APPEND(sc, sc->exts, sc->num_exts, talloc_strdup(sc, name));
}
#define bstr_xappend0(sc, b, s) bstr_xappend(sc, b, bstr0(s))
void gl_sc_add(struct gl_shader_cache *sc, const char *text)
{
bstr_xappend0(sc, &sc->text, text);
+6 -6
View File
@@ -118,14 +118,14 @@ static void print_seq3(bstr *frame, struct lut_item *lut, bstr prefix,
bstr_xappend(NULL, frame, (bstr){ lut[r].str, lut[r].width });
bstr_xappend(NULL, frame, (bstr){ lut[g].str, lut[g].width });
bstr_xappend(NULL, frame, (bstr){ lut[b].str, lut[b].width });
bstr_xappend(NULL, frame, (bstr)bstr0_lit("m"));
bstr_xappend0(NULL, frame, "m");
}
static void print_seq1(bstr *frame, struct lut_item *lut, bstr prefix, uint8_t c)
{
bstr_xappend(NULL, frame, prefix);
bstr_xappend(NULL, frame, (bstr){ lut[c].str, lut[c].width });
bstr_xappend(NULL, frame, (bstr)bstr0_lit("m"));
bstr_xappend0(NULL, frame, "m");
}
static void print_buffer(bstr *frame)
@@ -155,11 +155,11 @@ static void write_plain(bstr *frame,
} else {
print_seq3(frame, lut, TERM_ESC_COLOR24BIT_BG, r, g, b);
}
bstr_xappend(NULL, frame, (bstr)bstr0_lit(" "));
bstr_xappend0(NULL, frame, " ");
if (buffering <= VO_TCT_BUFFER_PIXEL)
print_buffer(frame);
}
bstr_xappend(NULL, frame, (bstr)bstr0_lit(TERM_ESC_CLEAR_COLORS));
bstr_xappend0(NULL, frame, TERM_ESC_CLEAR_COLORS);
if (buffering <= VO_TCT_BUFFER_LINE)
print_buffer(frame);
}
@@ -196,7 +196,7 @@ static void write_half_blocks(bstr *frame,
if (buffering <= VO_TCT_BUFFER_PIXEL)
print_buffer(frame);
}
bstr_xappend(NULL, frame, (bstr)bstr0_lit(TERM_ESC_CLEAR_COLORS));
bstr_xappend0(NULL, frame, TERM_ESC_CLEAR_COLORS);
if (buffering <= VO_TCT_BUFFER_LINE)
print_buffer(frame);
}
@@ -288,7 +288,7 @@ static void flip_page(struct vo *vo)
p->opts.term256, p->lut, p->opts.buffering);
}
bstr_xappend(NULL, &p->frame_buf, (bstr)bstr0_lit("\n"));
bstr_xappend0(NULL, &p->frame_buf, "\n");
if (p->opts.buffering <= VO_TCT_BUFFER_FRAME)
print_buffer(&p->frame_buf);