summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-04-30 21:10:29 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-04-30 21:10:29 +0000
commitf941749af15974163b2af2cf5aa89ecd2db12cf6 (patch)
tree32ea0e4ba39dea2bb9f4017110e3ca2995f34310
parent7f83e6c8fec9c7e2cc997fd4f1ec2d5a1d009823 (diff)
Replace regex match string in results (some new magic entries use this).
-rw-r--r--usr.bin/file/magic-test.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/file/magic-test.c b/usr.bin/file/magic-test.c
index 6beffe8ffc4..1101de18f1e 100644
--- a/usr.bin/file/magic-test.c
+++ b/usr.bin/file/magic-test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic-test.c,v 1.16 2016/02/20 15:29:37 nicm Exp $ */
+/* $OpenBSD: magic-test.c,v 1.17 2016/04/30 21:10:28 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -936,8 +936,10 @@ magic_test_type_regex(struct magic_line *ml, struct magic_state *ms)
result = (regexec(&re, ms->base, 1, &m, REG_STARTEND) == 0);
if (result == !ml->test_not) {
- if (ml->result != NULL)
- magic_add_result(ms, ml, "%s", "");
+ if (ml->result != NULL) {
+ magic_add_string(ms, ml, ms->base + m.rm_so,
+ m.rm_eo - m.rm_so);
+ }
if (result) {
if (sflag)
ms->offset = m.rm_so;