From 8e4829bc5f9bf7529944900f3cd8bacb2ddae4d4 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 20 Oct 2018 21:04:28 +0000 Subject: [PATCH] move a largish block of code around to trick a GCC warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (the fallthrough detection is thrown off by the other comments, and it doesn’t recognise NOTREACHED anyway…) --- funcs.c | 64 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/funcs.c b/funcs.c index 11c9488..a42c310 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.354 2018/08/10 02:53:34 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.355 2018/10/20 21:04:28 tg Exp $"); #if HAVE_KILLPG /* @@ -2964,6 +2964,37 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, case TO_STGT: return (strcmp(opnd1, opnd2) > 0); + /* -nt */ + case TO_FILNT: + /* + * ksh88/ksh93 succeed if file2 can't be stated + * (subtly different from 'does not exist'). + */ + return (stat(opnd1, &b1) == 0 && + (((s = stat(opnd2, &b2)) == 0 && + b1.st_mtime > b2.st_mtime) || s < 0)); + + /* -ot */ + case TO_FILOT: + /* + * ksh88/ksh93 succeed if file1 can't be stated + * (subtly different from 'does not exist'). + */ + return (stat(opnd2, &b2) == 0 && + (((s = stat(opnd1, &b1)) == 0 && + b1.st_mtime < b2.st_mtime) || s < 0)); + + /* -ef */ + case TO_FILEQ: + return (stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 && + b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino); + + /* all other cases */ + case TO_NONOP: + case TO_NONNULL: + /* throw the error */ + break; + /* -eq */ case TO_INTEQ: /* -ne */ @@ -3000,37 +3031,6 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, break; } /* NOTREACHED */ - - /* -nt */ - case TO_FILNT: - /* - * ksh88/ksh93 succeed if file2 can't be stated - * (subtly different from 'does not exist'). - */ - return (stat(opnd1, &b1) == 0 && - (((s = stat(opnd2, &b2)) == 0 && - b1.st_mtime > b2.st_mtime) || s < 0)); - - /* -ot */ - case TO_FILOT: - /* - * ksh88/ksh93 succeed if file1 can't be stated - * (subtly different from 'does not exist'). - */ - return (stat(opnd2, &b2) == 0 && - (((s = stat(opnd1, &b1)) == 0 && - b1.st_mtime < b2.st_mtime) || s < 0)); - - /* -ef */ - case TO_FILEQ: - return (stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 && - b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino); - - /* all other cases */ - case TO_NONOP: - case TO_NONNULL: - /* throw the error */ - break; } (*te->error)(te, 0, "internal error: unknown op"); return (1);