FLTK logo

STR #1644

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]

STR #1644

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:3 - Applies to all machines and operating systems
Subsystem:Documentation
Summary:Fl_Text_Buffer::*file() methods need docs for return value
Version:1.1-current
Created By:greg.ercolano
Assigned To:matt
Fix Version:1.1-current (SVN: v5790)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 greg.ercolano
21:56 Mar 31, 2007
These Fl_Text_Buffer methods need their return value documented:

appendfile()
insertfile()
loadfile()

Should probably at least say:
"Returns 0 on success, 1 on error loading file (strerror() contains reason)."
 
 
#2 greg.ercolano
22:14 Mar 31, 2007
Looks like there are multiple error codes: 1=open error, 2=ferror().
Maybe it should say instead:

"Returns 0 on success, non-zero on error (strerror() contains reason).
 1 indicates open for read failed (no data loaded). 2 indicates error occurred while reading data (data was *partially* loaded)."

Also: outputfile() needs docs on its return value as well. Same as above, but for writing data.
 
 
#3 matt
07:30 May 01, 2007
Thanks for seeing this. Are those return values verified?  
 
#4 greg.ercolano
08:46 May 01, 2007
> Are those return values verified?

Yes, proofs shown below. I was looking at the source when I determined those return values (0/1/2), and wrote those revised docs.

The only code used for reference was the definition for Fl_Text_Buffer::insertfile() in Fl_Text_Buffer.cxx:

----
Fl_Text_Buffer::insertfile(const char *file, int pos, int buflen) {
..
  if (!(fp = fopen(file, "r"))) return 1;  // OPEN FAILS: 1
..
  for (; (r = fread(buffer, 1, buflen - 1, fp)) > 0; pos += r) {
..
  }
  int e = ferror(fp) ? 2 : 0;  // READ LOOP: OK=0, FAIL=2
..
  return e;
}
----

The other methods appendfile() and loadfile() are just convenience wrappers for the above, defined in Fl_Text_Buffer.H:

----
    int appendfile(const char *file, int buflen = 128*1024)
      { return insertfile(file, length(), buflen); }
    int loadfile(const char *file, int buflen = 128*1024)
      { select(0, length()); remove_selection(); return appendfile(file, buflen); }
----

.. so these all inherit the same return values:
 
 
#5 matt
09:00 May 01, 2007
Fixed in Subversion repository.  
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.