From: Matthew Fernandez Date: Sat, 10 Jul 2021 15:59:25 +0000 (-0700) Subject: simplify twoDots X-Git-Tag: 2.49.0~63^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c3d04bf4e6e6abb6c0700fdd418d058fc0ab202;p=graphviz simplify twoDots The compiler can likely see this equivalence already. But this change makes the code clearer to both it and to human readers. --- 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: