1 /* -*-comment-start: "//";comment-end:""-*-
2 * GNU Mes --- Maxwell Equations of Software
3 * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of GNU Mes.
7 * GNU Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * GNU Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
24 #include <sys/resource.h>
27 int __ungetc_buf[__FILEDES_MAX + 1] = { 0 };
30 __ungetc_p (int filedes)
32 return __ungetc_buf[filedes] >= 0;
38 if (__ungetc_buf[__FILEDES_MAX] == 0)
39 memset (__ungetc_buf, -1, (__FILEDES_MAX + 1) * sizeof (int));
43 __ungetc_clear (int filedes)
45 __ungetc_buf[filedes] = -1;
49 __ungetc_set (int filedes, int c)
51 __ungetc_buf[filedes] = c;
60 int i = __ungetc_buf[fd];
62 __ungetc_buf[fd] = -1;
65 int r = read (fd, &c, 1);