]> granicus.if.org Git - graphviz/commitdiff
fix macOS lexer compilation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 22 Aug 2020 20:12:16 +0000 (13:12 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 22 Aug 2020 20:12:16 +0000 (13:12 -0700)
Commits 3b00c1fc6b949cc9744d075e0d2b2ed4b1c46763 and
5162bfe8e72624ef7988b217e289476325365810 removed find-and-replace of an isatty
string, which exposed the following compilation error on macOS:

  [ 69%] Building C object lib/cgraph/CMakeFiles/cgraph.dir/grammar.c.o
  [ 70%] Building C object lib/cgraph/CMakeFiles/cgraph.dir/scan.c.o
  /Users/north/src/graphviz/build/lib/cgraph/scan.c:1706:12: error: expected
        identifier or '('
  extern int isatty (int );
             ^
  scan.l:44:19: note: expanded from macro 'isatty'
  #define isatty(x) 0
                    ^
  1 error generated.
  make[2]: *** [lib/cgraph/CMakeFiles/cgraph.dir/scan.c.o] Error 1
  make[1]: *** [lib/cgraph/CMakeFiles/cgraph.dir/all] Error 2
  make: *** [all] Error 2

which conveniently explained why this find-and-replace had existed in the first
place. Rather than reverting this, the present change uses a more principled way
of instructing Flex not to call isatty().

This reverts 40a5a33ac76e4d3d22662fd51e7c0e1d2be3100b. Related to #1796, !1522,
!1523.

lib/cgraph/scan.l

index dee062982e2bbc6b26390123a1e4d04d0598b55f..5961ee2d3165cbe0aa790a2e695aa31e222c107b 100644 (file)
@@ -41,7 +41,6 @@ void agsetfile(char* f) { InputFile = f; line_num = 1; }
  */
 void aglexinit(Agdisc_t *disc, void *ifile) { Disc = disc; Ifile = ifile; graphType = 0;}
 
-#define isatty(x) 0
 #ifndef YY_INPUT
 #define YY_INPUT(buf,result,max_size) \
        if ((result = Disc->io->afread(Ifile, buf, max_size)) < 0) \
@@ -171,6 +170,15 @@ static int chkNum(void) {
  * harm. (Presumably undefined characters will be ignored in display.) And,
  * it allows a greater wealth of names. */
 %}
+
+  /* By default, Flex calls isatty() to determine whether the input it is
+   * scanning is coming from the user typing or from a file. However, our input
+   * is being provided by Graphviz' I/O channel mechanism, which does not have a
+   * valid file descriptor that supports isatty(). To suppress Flex's behavior,
+   * we tell it that the input is unconditionally a file.
+   */
+%option never-interactive
+
 GRAPH_EOF_TOKEN                                [@]     
 LETTER [A-Za-z_\200-\377]
 DIGIT  [0-9]