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:
@@ -2,6 +2,8 @@
|
|||||||
return a pointer to a string which can be modified. Now it does. Same
|
return a pointer to a string which can be modified. Now it does. Same
|
||||||
thing for dirname().
|
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)
|
c.lib 1.201 (21.9.2006)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -141,7 +141,7 @@ vfprintf(FILE * stream,const char * format, va_list arg)
|
|||||||
int buffer_mode;
|
int buffer_mode;
|
||||||
char *output_buffer;
|
char *output_buffer;
|
||||||
int output_len;
|
int output_len;
|
||||||
char *prefix;
|
const char *prefix;
|
||||||
char prefix_buffer[8];
|
char prefix_buffer[8];
|
||||||
int result = EOF;
|
int result = EOF;
|
||||||
int len = 0;
|
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. */
|
/* Get ready to prefix a sign character, if required. */
|
||||||
if(FLAG_IS_SET(format_flags,FORMATF_IsNegative))
|
if(FLAG_IS_SET(format_flags,FORMATF_IsNegative))
|
||||||
prefix = (char *)"-";
|
prefix = "-";
|
||||||
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSign))
|
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSign))
|
||||||
prefix = (char *)"+";
|
prefix = "+";
|
||||||
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSpace))
|
else if (FLAG_IS_SET(format_flags,FORMATF_ProduceSpace))
|
||||||
prefix = (char *)" ";
|
prefix = " ";
|
||||||
else if (FLAG_IS_SET(format_flags,FORMATF_ZeroPrefix))
|
else if (FLAG_IS_SET(format_flags,FORMATF_ZeroPrefix))
|
||||||
prefix = (char *)"0";
|
prefix = "0";
|
||||||
else
|
else
|
||||||
prefix = NULL;
|
prefix = NULL;
|
||||||
|
|
||||||
@@ -1528,7 +1528,6 @@ vfprintf(FILE * stream,const char * format, va_list arg)
|
|||||||
|
|
||||||
if(prefix != NULL)
|
if(prefix != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(i = 0 ; prefix[i] != '\0' ; i++)
|
for(i = 0 ; prefix[i] != '\0' ; i++)
|
||||||
{
|
{
|
||||||
/* One less character to fill the output with. */
|
/* One less character to fill the output with. */
|
||||||
|
|||||||
@@ -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
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -74,6 +74,10 @@ char *
|
|||||||
__asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
|
__asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
|
||||||
{
|
{
|
||||||
char * result = NULL;
|
char * result = NULL;
|
||||||
|
size_t offset = 0;
|
||||||
|
struct tm copy_tm;
|
||||||
|
char number[16];
|
||||||
|
const char * b;
|
||||||
|
|
||||||
ENTER();
|
ENTER();
|
||||||
|
|
||||||
@@ -91,12 +95,8 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
|
|||||||
}
|
}
|
||||||
#endif /* CHECK_FOR_NULL_POINTERS */
|
#endif /* CHECK_FOR_NULL_POINTERS */
|
||||||
|
|
||||||
if(buffer_size > 0)
|
if(buffer_size == 0)
|
||||||
{
|
goto out;
|
||||||
struct tm copy_tm;
|
|
||||||
char number[16];
|
|
||||||
const char * b;
|
|
||||||
size_t offset = 0;
|
|
||||||
|
|
||||||
buffer_size--;
|
buffer_size--;
|
||||||
|
|
||||||
@@ -174,11 +174,6 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size)
|
|||||||
buffer[offset] = '\0';
|
buffer[offset] = '\0';
|
||||||
|
|
||||||
result = buffer;
|
result = buffer;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = (char *)"";
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user