From 8c3d04bf4e6e6abb6c0700fdd418d058fc0ab202 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 10 Jul 2021 08:59:25 -0700 Subject: [PATCH] simplify twoDots The compiler can likely see this equivalence already. But this change makes the code clearer to both it and to human readers. --- lib/cgraph/scan.l | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 8968e4c57..2c9259508 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -27,7 +27,9 @@ #include #include #include +#include #include +#include // #define YY_BUF_SIZE 128000 #define GRAPH_EOF_TOKEN '@' /* lex class must be defined below */ /* this is a workaround for linux flex */ @@ -146,14 +148,10 @@ static void ppDirective (void) * Return true if token has more than one '.'; * we know the last character is a '.'. */ -static int twoDots(void) -{ - int i; - for (i = aagleng-2; i >= 0; i--) { - if ((unsigned char)aagtext[i] == '.') - return 1; - } - return 0; +static bool twoDots(void) { + const char *dot = strchr(aagtext, '.'); + // was there a dot and was it not the last character? + return dot != NULL && dot != &aagtext[aagleng - 1]; } /* chkNum: -- 2.40.0