+ for (i = 0; lines[i]; i++) {
+ /* Skip leading whitespace. */
+ const char *line = lines[i] + strspn(lines[i], " \t");
+ unsigned len = strspn(line, IDENT_CHARS);
+
+ if (!line[0] || cisspace(line[0]) || strstarts(line, "//"))
+ continue;
+
+ assert(line[strlen(line)-1] != '\n');
+
+ /* The winners. */
+ if (strstarts(line, "if") && len == 2) {
+ *why = cast_const(char *, "starts with if");
+ return true;
+ }
+ if (strstarts(line, "for") && len == 3) {
+ *why = cast_const(char *, "starts with for");
+ return true;
+ }
+ if (strstarts(line, "while") && len == 5) {
+ *why = cast_const(char *, "starts with while");
+ return true;
+ }
+ if (strstarts(line, "do") && len == 2) {
+ *why = cast_const(char *, "starts with do");
+ return true;
+ }
+
+ /* The losers. */
+ if (strstarts(line, "#include")) {
+ *why = cast_const(char *, "starts with #include");
+ return false;
+ }
+
+ if (last_ended && strchr(line, '(')) {
+ if (strstarts(line, "static")) {
+ *why = cast_const(char *,
+ "starts with static"
+ " and contains (");
+ return false;
+ }
+ if (strends(line, ")")) {
+ *why = cast_const(char *,
+ "contains ( and ends with )");
+ return false;
+ }
+ }
+
+ /* Previously prepended. */
+ if (strstr(line, "didn't seem to belong inside a function")) {
+ *why = cast_const(char *, "Comment said so");
+ return false;
+ }
+
+ /* Single identifier then operator == inside function. */
+ if (last_ended && len
+ && cispunct(line[len+strspn(line+len, " ")])) {
+ *why = cast_const(char *, "starts with identifier"
+ " then punctuation");
+ return true;
+ }
+
+ last_ended = (strends(line, "}")
+ || strends(line, ";")
+ || strends(line, "*/")
+ || streq(line, "..."));
+ }
+
+ /* No idea... Say yes? */
+ *why = cast_const(char *, "gave no clues");
+ return true;