mirror of https://git.ffmpeg.org/ffmpeg.git
lavf/segment: Simplify CSV field quoting code
Should also be faster (though I doubt that hardly ever matters for the usage here). Also remove the pointer copy. Since we do not need to reset the pointer to the start of the string, it is not needed anymore. Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
This commit is contained in:
parent
aefed6ca87
commit
bac1b31bf6
|
@ -76,23 +76,15 @@ typedef struct {
|
||||||
|
|
||||||
static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
|
static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
|
||||||
{
|
{
|
||||||
const char *p;
|
int quote = !!str[strcspn(str, "\",\n\r")];
|
||||||
int quote = 0;
|
|
||||||
|
|
||||||
/* check if input needs quoting */
|
|
||||||
for (p = str; *p; p++)
|
|
||||||
if (strchr("\",\n\r", *p)) {
|
|
||||||
quote = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quote)
|
if (quote)
|
||||||
avio_w8(ctx, '"');
|
avio_w8(ctx, '"');
|
||||||
|
|
||||||
for (p = str; *p; p++) {
|
for (; *str; str++) {
|
||||||
if (*p == '"')
|
if (*str == '"')
|
||||||
avio_w8(ctx, '"');
|
avio_w8(ctx, '"');
|
||||||
avio_w8(ctx, *p);
|
avio_w8(ctx, *str);
|
||||||
}
|
}
|
||||||
if (quote)
|
if (quote)
|
||||||
avio_w8(ctx, '"');
|
avio_w8(ctx, '"');
|
||||||
|
|
Loading…
Reference in New Issue