Mail Archives: djgpp-workers/2000/11/18/03:01:40
[Sorry for a long delay, I'm very busy these days.]
> Date: Wed, 15 Nov 2000 23:46:45 +0000
> From: Richard Dawe <richdawe AT bigfoot DOT com>
>
> * I added a note on the maximum value of 'n' for snprintf(), vsnprintf().
> The value of errno is not documented, since errno is only set for the case
> where n is too big. This seems to be OK according to the C spec - we can
> set errno to whatever we like, since snprintf() does not have a defined
> effect on errno.
Nevertheless, I think we should document what value does our
implementation put into errno, when it does.
> + _strbuf._flag = _IOWRT | _IOSTRG | _IONTERM;
> + _strbuf._ptr = str;
> + _strbuf._cnt = n - 1;
> + len = _doprnt(fmt, &(fmt)+1, &_strbuf);
> + if (n != 0)
> + *_strbuf._ptr = 0;
> + return len;
This doesn't seem to handle the case where N is zero. In this case,
STR may or may not be a NULL (if it is, I think _doprnt will bomb, at
least for some formats, like %c; or am I missing something?), and we
still need to return ``the number of characters that would have been
written had N been sufficiently large'', to quote from C9x.
> + @port-note ansi For DJGPP, the maximum accepted value of @var{n} is
> INT_MAX. An error is returned if @var{n} is greater than this limit.
Please use @code{INT_MAX}, and I think it would be a good idea to say
that it is defined in <limits.h>.
Also, please leave two blanks after the dots which end statements.
> + @portability ansi
> \ No newline at end of file
Please add the missing newline.
> *** /develop/djgpp/tests/libc/ansi/stdio/snprintf.c Sun Nov 12 21:57:18 2000
> --- /develop/djgpp.dev/tests/libc/ansi/stdio/snprintf.c Wed Nov 15 22:41:26 2000
This doesn't test the special cases of a NULL pointer STR argument,
zero N argument (with or without STR == NULL), and the case where ``an
encoding error'' happens (which I understand as an invalid format
specifier, or something else that causes _doprnt to return -1). I
think we want at least some of these cases in the test suite, to make
sure the implementation is working as expected.
- Raw text -