[svn-r27238] Add function prototype for local function

This commit is contained in:
Allen Byrne 2015-06-18 08:52:35 -05:00
parent f30ab55f41
commit cf7c5123cb

View File

@ -48,6 +48,7 @@
static char *h5tools_escape(char *s, size_t size);
static hbool_t h5tools_str_is_zero(const void *_mem, size_t size);
static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
void h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx);
/*-------------------------------------------------------------------------
* Function: h5tools_str_close
@ -144,16 +145,16 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap);
HDva_end(ap);
/* Note: HDvsnprintf() behaves differently on Windows as Unix, when
* buffer is smaller than source string. On Unix, this function
* returns length of the source string and copy string upto the
* buffer size with NULL at the end of the buffer. However on
* Windows with the same condition, this function returns -1 and
/* Note: HDvsnprintf() behaves differently on Windows as Unix, when
* buffer is smaller than source string. On Unix, this function
* returns length of the source string and copy string upto the
* buffer size with NULL at the end of the buffer. However on
* Windows with the same condition, this function returns -1 and
* doesn't add NULL at the end of the buffer.
* Because of this different return results, the strlen of the new string
* is used to handle when HDvsnprintf() returns -1 on Windows due
* to lack of buffer size, so try one more time after realloc more
* buffer size before return NULL.
* buffer size before return NULL.
*/
if (nchars < 0) {
/* failure, such as bad format */
@ -277,7 +278,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
if (HDstrchr(fmt, '%')) {
size_t n = sizeof(_temp);
if (str->len - start + 1 > n) {
n = str->len - start + 1;
n = str->len - start + 1;
temp = (char*)HDmalloc(n);
HDassert(temp);
}
@ -665,12 +666,12 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
*
* PVN, 28 March 2006
* added H5T_NATIVE_LDOUBLE case
*
*
* Raymond Lu, 2011-09-01
* CLANG compiler complained about the line (about 800):
* tempint = (tempint >> packed_data_offset) & packed_data_mask;
* The right shift may cause undefined behavior if PACKED_DATA_OFFSET is
* 32-bit or more. For every kind of native integers, I changed the code
* The right shift may cause undefined behavior if PACKED_DATA_OFFSET is
* 32-bit or more. For every kind of native integers, I changed the code
* to make it zero if PACKED_DATA_OFFSET is greater than or equal to the
* size of integer.
*-------------------------------------------------------------------------
@ -1371,37 +1372,37 @@ h5tools_str_is_zero(const void *_mem, size_t size)
*
* Purpose: replace all occurrences of substring.
*
* Return: char *
* Return: char *
*
* Programmer: Peter Cao
* March 8, 2012
*
* Notes:
* Applications need to call free() to free the memoery allocated for
* the return string
* Applications need to call free() to free the memoery allocated for
* the return string
*
*-------------------------------------------------------------------------
*/
char *
h5tools_str_replace ( const char *string, const char *substr, const char *replacement )
{
char *tok = NULL;
char *newstr = NULL;
char *oldstr = NULL;
char *head = NULL;
if ( substr == NULL || replacement == NULL )
return HDstrdup (string);
newstr = HDstrdup (string);
head = newstr;
while ( (tok = HDstrstr ( head, substr ))){
oldstr = newstr;
newstr = HDmalloc ( HDstrlen ( oldstr ) - HDstrlen ( substr ) + HDstrlen ( replacement ) + 1 );
char *tok = NULL;
char *newstr = NULL;
char *oldstr = NULL;
char *head = NULL;
if ( substr == NULL || replacement == NULL )
return HDstrdup (string);
newstr = HDstrdup (string);
head = newstr;
while ( (tok = HDstrstr ( head, substr ))){
oldstr = newstr;
newstr = HDmalloc ( HDstrlen ( oldstr ) - HDstrlen ( substr ) + HDstrlen ( replacement ) + 1 );
if ( newstr == NULL ){
HDfree (oldstr);
return NULL;
HDfree (oldstr);
return NULL;
}
HDmemcpy ( newstr, oldstr, tok - oldstr );
HDmemcpy ( newstr + (tok - oldstr), replacement, HDstrlen ( replacement ) );
@ -1411,6 +1412,6 @@ h5tools_str_replace ( const char *string, const char *substr, const char *replac
head = newstr + (tok - oldstr) + HDstrlen( replacement );
HDfree (oldstr);
}
return newstr;
}