Mercurial > hg > octave-lyh
changeset 4527:c0a23a13eea2
[project @ 2003-10-03 02:52:46 by jwe]
author | jwe |
---|---|
date | Fri, 03 Oct 2003 02:52:46 +0000 |
parents | 8952973c6837 |
children | 7a85d54d0cbd |
files | liboctave/ChangeLog liboctave/cmd-edit.cc liboctave/lo-utils.cc liboctave/lo-utils.h |
diffstat | 4 files changed, 29 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2003-10-02 John W. Eaton <jwe@bevo.che.wisc.edu> + + * cmd-edit.cc (do_readline): Pass eof to octave_fgetl. + * lo-utils.cc (octave_fgets, octave_fgetl): New overloaded + versions with eof arg. + 2003-09-20 John W. Eaton <jwe@bevo.che.wisc.edu> * Array.h (dimensions): Now public.
--- a/liboctave/cmd-edit.cc +++ b/liboctave/cmd-edit.cc @@ -481,12 +481,10 @@ std::string default_command_editor::do_readline (const std::string& prompt, bool& eof) { - eof = false; - fprintf (output_stream, prompt.c_str ()); fflush (output_stream); - return octave_fgetl (input_stream); + return octave_fgetl (input_stream, eof); } void
--- a/liboctave/lo-utils.cc +++ b/liboctave/lo-utils.cc @@ -105,6 +105,15 @@ std::string octave_fgets (FILE *f) { + bool eof; + return octave_fgets (f, eof); +} + +std::string +octave_fgets (FILE *f, bool& eof) +{ + eof = false; + std::string retval; int grow_size = 1024; @@ -147,6 +156,8 @@ { if (len == 0) { + eof = true; + free (buf); buf = 0; @@ -166,7 +177,14 @@ std::string octave_fgetl (FILE *f) { - std::string retval = octave_fgets (f); + bool eof; + return octave_fgetl (f, eof); +} + +std::string +octave_fgetl (FILE *f, bool& eof) +{ + std::string retval = octave_fgets (f, eof); size_t len = retval.length ();
--- a/liboctave/lo-utils.h +++ b/liboctave/lo-utils.h @@ -38,8 +38,10 @@ extern void octave_putenv (const std::string&, const std::string&); extern std::string octave_fgets (std::FILE *); +extern std::string octave_fgetl (std::FILE *); -extern std::string octave_fgetl (std::FILE *); +extern std::string octave_fgets (std::FILE *, bool& eof); +extern std::string octave_fgetl (std::FILE *, bool& eof); extern "C" int octave_gethostname (char *, int);