=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/file/magic-test.c,v retrieving revision 1.19 retrieving revision 1.20 diff -c -r1.19 -r1.20 *** src/usr.bin/file/magic-test.c 2016/04/30 22:03:30 1.19 --- src/usr.bin/file/magic-test.c 2016/05/01 08:48:39 1.20 *************** *** 1,4 **** ! /* $OpenBSD: magic-test.c,v 1.19 2016/04/30 22:03:30 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: magic-test.c,v 1.20 2016/05/01 08:48:39 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott *************** *** 1053,1061 **** --- 1053,1072 ---- static int magic_test_type_default(__unused struct magic_line *ml, struct magic_state *ms) { + if (!ms->matched && ml->result != NULL) + magic_add_result(ms, ml, "%s", ""); return (!ms->matched); } + static int + magic_test_type_clear(__unused struct magic_line *ml, + __unused struct magic_state *ms) + { + if (ml->result != NULL) + magic_add_result(ms, ml, "%s", ""); + return (1); + } + static int (*magic_test_functions[])(struct magic_line *, struct magic_state *) = { magic_test_type_none, *************** *** 1119,1124 **** --- 1130,1136 ---- magic_test_type_regex, magic_test_type_search, magic_test_type_default, + magic_test_type_clear, }; static int *************** *** 1225,1231 **** magic_test_line(child, ms); } ! ms->matched = 1; return (ml->result != NULL); } --- 1237,1246 ---- magic_test_line(child, ms); } ! if (ml->type == MAGIC_TYPE_CLEAR) ! ms->matched = 0; ! else ! ms->matched = 1; return (ml->result != NULL); }