From b42822a0ad9a910fe91f9fdc0fbe56bd216bf8ef Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 20 May 2018 18:27:29 +0200 Subject: [PATCH] -pedantic improvements; less noise in tests --- Makefile | 5 +++-- mines.c | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9e6b34e..b2611d2 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,12 @@ clean: define TESTS echo -e '\033[7mTODOs:\033[0m' - grep -ni --color=always 'xxx\|note\|warn\|todo\|[^:]\/\/' *.c *.h + grep -ni --color=always 'xxx\|todo\|[^:]\/\/' *.c *.h + # grep -ni --color=always 'note\|warn' *.c *.h echo -e '\n\033[7m>80:\033[0m' for myFILE in *.c *.h - do sed 's/\t/ /g' < $$myFILE|grep -En --color=always '.{81}'|sed "s/^/\x1B[35m$$myFILE:/" + do sed 's/\t/ /g' < $$myFILE|grep -En --color=always '.{81}'|sed "s/^/\x1B[35m$$myFILE\x1B[36m:/" done echo -e '\n\033[7m-Wall:\033[0m' diff --git a/mines.c b/mines.c index 321c529..63e3f4c 100644 --- a/mines.c +++ b/mines.c @@ -237,7 +237,7 @@ int wait_mouse_up (int l, int c) { /* TODO: should not take minefield-coords but /* ignore mouse wheel events: */ if (mouse2[0] & 0x40) continue; - else if (mouse2[0]&3 == 3) level--; /* release event */ + else if((mouse2[0]&3) == 3) level--; /* release event */ else level++; /* another button pressed */ } } @@ -422,20 +422,21 @@ void to_next_boundary (int l, int c, char direction) { for (int c = g.p[1]+plusminus; c >= 0 && c < f.w; c+=plusminus) \ if (CONDITION) { \ move_hi (g.p[0], c); \ - return 1; \ + return 1; /* NOTE: break didn't work */ \ } \ + return 0; \ } while(0) int find (int what, char direction) { switch (what) { - case ' ': what = '0'; /* numbers, opened; fallthrough */ + case ' ': what = '0'; /* fallthrough */ case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': + case '6': case '7': case '8': /* numbers, opened */ FIND_WHAT(CELL.o && CELL.n == what-'0', direction); - case 'f': case 'i': FIND_WHAT(CELL.f==FLAG, direction); /* is flagged */ case 'o': FIND_WHAT(CELL.o, direction); /* any opened */ - case '?': FIND_WHAT(CELL.f==QUESM, direction);/* questioned */ case 'c': FIND_WHAT(!CELL.o, direction); /* any closed */ + case 'f': case 'i': FIND_WHAT(CELL.f==FLAG, direction); /* is flagged */ + case '?': FIND_WHAT(CELL.f==QUESM, direction);/* questioned */ } return 0; -- 2.39.3