From 2fc816c8a77c926686acd49e337bef56b3c25748 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 22 Jan 2015 16:47:58 +0100 Subject: [PATCH] hoa: make the scanner interactive when reading from a pipe Otherwise autfilt will not start processing input automata before its input buffer is full. * src/hoaparse/hoascan.ll: Here. --- src/hoaparse/hoascan.ll | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/hoaparse/hoascan.ll b/src/hoaparse/hoascan.ll index 91c0d62cf..71a1c7aad 100644 --- a/src/hoaparse/hoascan.ll +++ b/src/hoaparse/hoascan.ll @@ -1,5 +1,5 @@ /* -*- coding: utf-8 -*- -** Copyright (C) 2014 Laboratoire de Recherche et Développement +** Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement ** de l'Epita (LRDE). ** ** This file is part of Spot, a model checking library. @@ -24,6 +24,7 @@ %{ #include +#include #include "hoaparse/parsedecl.hh" #include "misc/escape.hh" @@ -356,10 +357,21 @@ namespace spot int hoayyopen(const std::string &name) { + bool want_interactive = false; + // yy_flex_debug = 1; if (name == "-") { yyin = stdin; + + // If the input is a pipe, make the scanner + // interactive so that it does not wait for the input + // buffer to be full to process automata. + struct stat s; + if (fstat(fileno(stdin), &s) < 0) + throw std::runtime_error("fstat failed"); + if (S_ISFIFO(s.st_mode)) + want_interactive = true; } else { @@ -371,6 +383,8 @@ namespace spot // ended badly. YY_NEW_FILE; hoayyreset(); + if (want_interactive) + yy_set_interactive(true); return 0; }