Commit 9a6de12
committed
wildmatch: explicitly mark intentional use of the comma operator
The comma operator is a somewhat obscure C feature that is often used by
mistake and can even cause unintentional code flow. That is why the
`-Wcomma` option of clang was introduced: To identify unintentional uses
of the comma operator.
To mark such a usage as intentional, the value needs to be cast to
`void`, which we do here.
In this instance, the usage is intentional because it allows storing the
value of the current character as `prev_ch` before making the next
character the current one, all of which happens in the loop condition
that lets the loop stop at a closing bracket.
The alternative to using the comma operator would be to move those
assignments from the condition into the loop body; In this particular
case that would require the assignments to either be duplicated or to
introduce and use a `goto` target before the assignments, though,
because the loop body contains a `continue` for the case where a
character class is found that starts with `[:` but does not end in `:]`
(and the assignments should occur even when that code path is taken).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 5e0e832 commit 9a6de12
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
0 commit comments