summaryrefslogtreecommitdiff
path: root/usr.bin/file/magic-test.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-08-12 09:39:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-08-12 09:39:44 +0000
commit179a46c665f87de609b661e91719bc89b0971e1c (patch)
treed4d5383c6c1a1ef233fb6d830e189db576489acb /usr.bin/file/magic-test.c
parent379105626c53b43f7f3da25741af78726ec22439 (diff)
Support + and - for dates.
Diffstat (limited to 'usr.bin/file/magic-test.c')
-rw-r--r--usr.bin/file/magic-test.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/file/magic-test.c b/usr.bin/file/magic-test.c
index 26d9592ada4..f2c72ea90a5 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.12 2015/08/12 09:29:49 nicm Exp $ */
+/* $OpenBSD: magic-test.c,v 1.13 2015/08/12 09:39:43 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -702,6 +702,10 @@ magic_test_type_date(struct magic_line *ml, struct magic_state *ms)
if (ml->type_operator == '&')
value &= (int32_t)ml->type_operand;
+ else if (ml->type_operator == '-')
+ value -= (int32_t)ml->type_operand;
+ else if (ml->type_operator == '+')
+ value += (int32_t)ml->type_operand;
else if (ml->type_operator != ' ')
return (-1);
@@ -744,6 +748,10 @@ magic_test_type_qdate(struct magic_line *ml, struct magic_state *ms)
if (ml->type_operator == '&')
value &= (int64_t)ml->type_operand;
+ else if (ml->type_operator == '-')
+ value -= (int64_t)ml->type_operand;
+ else if (ml->type_operator == '+')
+ value += (int64_t)ml->type_operand;
else if (ml->type_operator != ' ')
return (-1);
@@ -786,6 +794,10 @@ magic_test_type_udate(struct magic_line *ml, struct magic_state *ms)
if (ml->type_operator == '&')
value &= (uint32_t)ml->type_operand;
+ else if (ml->type_operator == '-')
+ value -= (uint32_t)ml->type_operand;
+ else if (ml->type_operator == '+')
+ value += (uint32_t)ml->type_operand;
else if (ml->type_operator != ' ')
return (-1);
@@ -828,6 +840,10 @@ magic_test_type_uqdate(struct magic_line *ml, struct magic_state *ms)
if (ml->type_operator == '&')
value &= (uint64_t)ml->type_operand;
+ else if (ml->type_operator == '-')
+ value -= (uint64_t)ml->type_operand;
+ else if (ml->type_operator == '+')
+ value += (uint64_t)ml->type_operand;
else if (ml->type_operator != ' ')
return (-1);