History

Make graphparser.c use av_get_token(). This also avoids the need for '\=' escaping.

Originally committed as revision 18726 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 17 years ago

Commit dd049111 parent d11dbf01 file · +4 −46Browse files

Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all

Unified · Split

libavfilter/graphparser.c+4−46
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "graphparser.h"
2727 #include "avfilter.h"
2828 #include "avfiltergraph.h"
29+#include "parseutils.h"
2930
3031 #define WHITESPACES " \n\t"
3132
@@ -43,49 +44,6 @@ static int link_filter(AVFilterContext *src, int srcpad, · 11 unmodified lines
4344 return 0;
4445 }
4546
46−/**
47− * Consumes a string from *buf.
48− * @return a copy of the consumed string, which should be free'd after use
49− */
50−static char *consume_string(const char **buf)
51−{
52− char *out = av_malloc(strlen(*buf) + 1);
53− char *ret = out;
54−
55− *buf += strspn(*buf, WHITESPACES);
56−
57− do{
58− char c = *(*buf)++;
59− switch (c) {
60− case '\\':
61− *out++ = *(*buf)++;
62− break;
63− case '\'':
64− while(**buf && **buf != '\'')
65− *out++ = *(*buf)++;
66− if(**buf) (*buf)++;
67− break;
68− case 0:
69− case ']':
70− case '[':
71− case '=':
72− case ',':
73− case ';':
74− case ' ':
75− case '\n':
76− *out++ = 0;
77− break;
78− default:
79− *out++ = c;
80− }
81− } while(out[-1]);
82−
83− (*buf)--;
84− *buf += strspn(*buf, WHITESPACES);
85−
86− return ret;
87−}
88−
8947 /**
9048 * Parse "[linkname]"
9149 * @param name a pointer (that need to be free'd after use) to the name between
@@ -97,7 +55,7 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) · 5 unmodified lines
9755 char *name;
9856 (*buf)++;
9957
100− name = consume_string(buf);
58+ name = av_get_token(buf, "]");
10159
10260 if(!name[0]) {
10361 av_log(log_ctx, AV_LOG_ERROR,
@@ -162,12 +120,12 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 58 unmodified lines
162120 int index, AVClass *log_ctx)
163121 {
164122 char *opts = NULL;
165− char *name = consume_string(buf);
123+ char *name = av_get_token(buf, "=,");
166124 AVFilterContext *ret;
167125
168126 if(**buf == '=') {
169127 (*buf)++;
170− opts = consume_string(buf);
128+ opts = av_get_token(buf, "[],\n");
171129 }
172130
173131 ret = create_filter(graph, index, name, opts, log_ctx);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t