STDIO (Re: TRUE and FALSE)

Peter da Silva peter at ficc.ferranti.com
Fri Sep 7 11:36:30 AEST 1990


In article <17632 at haddock.ima.isc.com> karl at kelp.ima.isc.com (Karl Heuer) writes:
> Fine; functions that have that property can be declared with a type other than
> "bool".  Functions that don't have any useful value to return on success can
> and should return TRUE.  (fgets() was another mistake.)

Fgets() has a useful value to return: the number of characters read. A
0 length read from fgets should be an EOF (think about it).

For that matter, the whole stdio suite is fubar. But, it's a standard.
Perhaps a new library could be designed in alt.lang.cfutures

	FILE *openf(name, mode);
	char *name;
	int mode;	/* From fcntl.h */

	int readf(fp, buf, len);
	FILE *fp;
	char *buf;
	int len;

	int readlnf(fp, buf, len);
	FILE *fp;
	char *buf;
	int len;

	int parsef(fp, fmt, args...)
	FILE *fp;
	char *fmt;

	int readln(buf, len);
	char *buf;
	int len;

	int formatf(fp, fmt, args...);
	FILE *fp;
	char *fmt;

	int formats(buf, len, fmt, args...);
	char *buf;
	int len;
	char *fmt;

Fp, when present, always comes first. Buffers are always associated with
a length. Consistent rules for the syntax would make things a lot easier
to remember.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter at ferranti.com



More information about the Comp.lang.c mailing list