1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- asctime_r() now returns NULL if the buffer is too short to hold even a single

byte of data.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15146 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-09-25 13:43:06 +00:00
parent 2c450a1e48
commit 74b2838663
3 changed files with 88 additions and 92 deletions

View File

@@ -2,6 +2,8 @@
return a pointer to a string which can be modified. Now it does. Same
thing for dirname().
- asctime_r() now returns NULL if the buffer is too short to hold even a single
byte of data.
c.lib 1.201 (21.9.2006)

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio_vfprintf.c,v 1.22 2006-09-22 09:02:51 obarthel Exp $
* $Id: stdio_vfprintf.c,v 1.23 2006-09-25 13:43:06 obarthel Exp $
*
* :ts=4
*
@@ -141,7 +141,7 @@ vfprintf(FILE * stream,const char * format, va_list arg)
int buffer_mode;
char *output_buffer;
int output_len;
char *prefix;
const char *prefix;
char prefix_buffer[8];
int result = EOF;
int len = 0;
@@ -1504,13 +1504,13 @@ vfprintf(FILE * stream,const char * format, va_list arg)
/* Get ready to prefix a sign character, if required. */
if(FLAG_IS_SET(format_flags,FORMATF_IsNegative))
prefix = (char *)"-";
prefix = "-";
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSign))
prefix = (char *)"+";
prefix = "+";
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSpace))
prefix = (char *)" ";
prefix = " ";
else if (FLAG_IS_SET(format_flags,FORMATF_ZeroPrefix))
prefix = (char *)"0";
prefix = "0";
else
prefix = NULL;
@@ -1528,7 +1528,6 @@ vfprintf(FILE * stream,const char * format, va_list arg)
if(prefix != NULL)
{
for(i = 0 ; prefix[i] != '\0' ; i++)
{
/* One less character to fill the output with. */

View File

@@ -1,5 +1,5 @@
/*
* $Id: time_asctime_r.c,v 1.9 2006-09-22 09:02:51 obarthel Exp $
* $Id: time_asctime_r.c,v 1.10 2006-09-25 13:43:06 obarthel Exp $
*
* :ts=4
*
@@ -74,6 +74,10 @@ char *
__asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
{
char * result = NULL;
size_t offset = 0;
struct tm copy_tm;
char number[16];
const char * b;
ENTER();
@@ -91,12 +95,8 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
}
#endif /* CHECK_FOR_NULL_POINTERS */
if(buffer_size > 0)
{
struct tm copy_tm;
char number[16];
const char * b;
size_t offset = 0;
if(buffer_size == 0)
goto out;
buffer_size--;
@@ -174,11 +174,6 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
buffer[offset] = '\0';
result = buffer;
}
else
{
result = (char *)"";
}
out: