mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2025-04-21 12:27:27 +03:00
qpkg/gobble.c (EXPECT): added variant that just skips over expected text
If the package database is sane, then we don't need to check that all the field names match what we expect. This saves a few more CPU cycles. However, if anything goes wrong, the consequences may be unpleasant. Thus, we default to the slow but safe approach.
This commit is contained in:
@@ -15,16 +15,24 @@
|
|||||||
#define CHARS_AFTER_ERROR 20
|
#define CHARS_AFTER_ERROR 20
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef BREAKNECK_SPEED
|
||||||
|
|
||||||
|
#define EXPECT(s) do { buf += sizeof(s)-1; } while (0)
|
||||||
|
|
||||||
|
#else /* !BREAKNECK_SPEED */
|
||||||
|
|
||||||
#define EXPECT(s) \
|
#define EXPECT(s) \
|
||||||
do { \
|
do { \
|
||||||
if (end-buf < sizeof(s)-1) \
|
if (end-buf < sizeof(s)-1) \
|
||||||
FAIL; \
|
FAIL; \
|
||||||
if (memcmp(buf, s, sizeof(s)-1)) \
|
if (memcmp(buf, s, sizeof(s)-1)) \
|
||||||
FAIL; \
|
FAIL; \
|
||||||
buf += sizeof(s)-1; \
|
buf += sizeof(s)-1; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define NEXT (buf == end ? '?' : *buf++)
|
#define NEXT (buf == end ? '?' : *buf++)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user