Skip to content

Commit 43b925b

Browse files
committed
Merge branch 'colorfilter-parser-comments' into 'master'
colorfilter: Fix parsing comments See merge request compiz/compiz-plugins-main!85
2 parents eb914fa + 5782bd9 commit 43b925b

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

data/filters/contrast

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ TEMP dark;
66

77
TEX input, fragment.texcoord[0], texture[0], RECT;
88

9-
# Subtract color by 0.51 => everything with more then 0.51 will have at least 0 ;
9+
# Subtract color by 0.51 => everything with more then 0.51 will have at least 0
1010
SUB output.rgb, input, 0.51;
1111

12-
# Create a dark color..;
12+
# Create a dark color..
1313
SUB dark.rgb, input, 0.3;
14-
# ..and a bright color ;
14+
# ..and a bright color
1515
ADD bright.rgb, input, 0.3;
1616

17-
# All colors which are < 0 (original color - 0.51 < 0) get a dark color and everything else a bright color ;
17+
# All colors which are < 0 (original color - 0.51 < 0) get a dark color and everything else a bright color
1818
CMP output.rgb, output, dark, bright;
1919

2020
MOV result.color, output;

data/filters/negative-lightness

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ negative-lightness.frag
1212
#const c1 = 4 60 360 120
1313
#const c2 = 180 240 0.016666668
1414
TEMP R0;
15-
TEMP R0;
1615
TEMP R1;
1716
TEMP R2;
1817
TEMP R3;

src/colorfilter/parser.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,21 @@ programParseSource (CompFunctionData *data,
352352
source++;
353353
}
354354

355-
/* Strip linefeeds */
355+
/* Strip linefeeds and comments */
356356
next = source;
357-
while ((next = strstr (next, "\n")))
358-
*next = ' ';
357+
while ((next = strpbrk (next, "#\n\r")))
358+
{
359+
if (*next == '#')
360+
{
361+
char *line_end = strpbrk (next, "\r\n");
362+
if (! line_end)
363+
*next = '\0';
364+
else
365+
memmove (next, line_end, strlen (line_end) + 1);
366+
}
367+
else
368+
*next = ' ';
369+
}
359370

360371
line = strtok_r (source, ";", &strtok_ptr);
361372
/* Parse each instruction */
@@ -367,16 +378,6 @@ programParseSource (CompFunctionData *data,
367378
/* Find instruction type */
368379
type = NoOp;
369380

370-
/* Comments */
371-
if (strncmp (current, "#", 1) == 0)
372-
{
373-
free (line);
374-
line = strtok_r (NULL, ";", &strtok_ptr);
375-
continue;
376-
}
377-
if ((next = strstr (current, "#")))
378-
*next = 0;
379-
380381
/* Data ops */
381382
if (strncmp (current, "END", 3) == 0)
382383
type = NoOp;

0 commit comments

Comments
 (0)