From 1a012a829fbbca941d2751ff4388fb67532f9cab Mon Sep 17 00:00:00 2001 From: Solar Designer Date: Sat, 18 May 2024 21:33:42 +0200 Subject: [PATCH 1/2] External modes: Add test on "make check" --- src/Makefile.in | 3 +++ src/tests/test_externals.md5 | 1 + src/tests/test_externals.sh | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/tests/test_externals.md5 create mode 100755 src/tests/test_externals.sh diff --git a/src/Makefile.in b/src/Makefile.in index 247b96378b..4425893cf2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -758,6 +758,9 @@ check: default $(MAKE) unit-tests ../run/john --test=0 --verbosity=2 --format=cpu ../run/john --test=0 --verbosity=2 --format=+dynamic,all + if [ -x /usr/bin/md5sum ]; then \ + JOHN=../run/john tests/test_externals.sh | md5sum -c tests/test_externals.md5; \ + fi depend: makedepend -fMakefile.dep -Y *.c 2>> /dev/null diff --git a/src/tests/test_externals.md5 b/src/tests/test_externals.md5 new file mode 100644 index 0000000000..d8cefc64f3 --- /dev/null +++ b/src/tests/test_externals.md5 @@ -0,0 +1 @@ +fb58e1c442718dc91b0d6bc6faf1ec31 - diff --git a/src/tests/test_externals.sh b/src/tests/test_externals.sh new file mode 100755 index 0000000000..98851cad04 --- /dev/null +++ b/src/tests/test_externals.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +test -n "$JOHN" || JOHN=../../run/john + +set -x + +for mode in `$JOHN --list=ext-modes`; do +# KDEPaste's output depends on the current time + if [ $mode != kdepaste ]; then + $JOHN --external=$mode --stdout --max-candidates=100000 + fi +done + +for mode in `$JOHN --list=ext-hybrids` `./john --list=ext-filters`; do + $JOHN -w --external=$mode --stdout --max-candidates=100000 +done From 7ca0da3fb62956dec4fdb3ee046835983f5e0c8f Mon Sep 17 00:00:00 2001 From: Solar Designer Date: Sat, 18 May 2024 21:48:35 +0200 Subject: [PATCH 2/2] External mode compiler: Optimize negative integer constants --- src/compiler.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler.c b/src/compiler.c index 3d90ebdff0..2ff4c58dc3 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -537,8 +537,17 @@ static int c_expr(char term, struct c_ident *vars, char *token, int pop) left = 1; } else - if ((c >= '0' && c <= '9') || c == '\'') { + if ((c >= '0' && c <= '9') || c == '\'' || (c == '-' && !left)) { + if (c == '-') { + lookahead = c_getchar(0); + c_ungetchar(lookahead); + if (lookahead < '0' || lookahead > '9') + goto other; + token = c_gettoken(); + } value.imm = c_getint(token); + if (c == '-') + value.imm = -value.imm; last = c_push(last, c_op_push_imm, &value); left = 1; balance++; @@ -552,6 +561,7 @@ static int c_expr(char term, struct c_ident *vars, char *token, int pop) left = 0; } else if (c != ' ') { +other: if (c_isident[ARCH_INDEX(c)]) var = c_find_ident(vars, NULL, token); else