X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginsh%2Fginsh_lexer.lpp;h=c201fad3aa87ef2a8c6052022e703c93331f3f6f;hp=56fa047f704e114b6b1a7838879f417e9cf12f44;hb=HEAD;hpb=761d1597532504762c1f9b438c7727c4f74d7da3 diff --git a/ginsh/ginsh_lexer.lpp b/ginsh/ginsh_lexer.lpp index 56fa047f..449ce6b5 100644 --- a/ginsh/ginsh_lexer.lpp +++ b/ginsh/ginsh_lexer.lpp @@ -4,7 +4,7 @@ * This file must be processed with flex. */ /* - * GiNaC Copyright (C) 1999-2017 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2024 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,9 @@ #include "ginsh.h" #include "ginsh_parser.hpp" +using namespace std; +using namespace GiNaC; + #define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size)) // Table of all used symbols @@ -200,8 +203,16 @@ static int ginsh_input(char *buf, int max_size) YY_FATAL_ERROR("input in flex scanner failed"); result = n; #endif - } else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin)) - YY_FATAL_ERROR("input in flex scanner failed"); + } else { + int c = '*', n; + for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) + buf[n] = (char)c; + if (c == '\n') + buf[n++] = (char)c; + if (c == EOF && ferror(yyin)) + YY_FATAL_ERROR("input in flex scanner failed"); + result = n; + } return result; }