#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_string.h"
#include "tgsi_dump.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
{
char str[36];
- sprintf( str, "0x%x", ui );
+ util_snprintf( str, sizeof(str), "0x%x", ui );
gen_dump_str( dump, str );
}
{
char str[16];
- sprintf( str, "%u", ui );
+ util_snprintf( str, sizeof(str), "%u", ui );
gen_dump_str( dump, str );
}
{
char str[16];
- sprintf( str, "%d", si );
+ util_snprintf( str, sizeof(str), "%d", si );
gen_dump_str( dump, str );
}
{
char str[48];
- sprintf( str, "%10.4f", flt );
+ util_snprintf( str, sizeof(str), "%10.4f", flt );
gen_dump_str( dump, str );
}
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "util/u_string.h"
#ifdef WIN32
/* EngDebugPrint does not handle float point arguments, so we need to use
* our own vsnprintf implementation */
char buf[512 + 1];
- vsnprintf(buf, sizeof(buf), format, ap);
+ util_vsnprintf(buf, sizeof(buf), format, ap);
_EngDebugPrint("%s", buf);
#else
/* TODO: Implement debug print for WINCE */
++names;
}
- snprintf(rest, sizeof(rest), "0x%08lx", value);
+ util_snprintf(rest, sizeof(rest), "0x%08lx", value);
return rest;
}
else
first = 0;
- snprintf(rest, sizeof(rest), "0x%08lx", value);
+ util_snprintf(rest, sizeof(rest), "0x%08lx", value);
strncat(output, rest, sizeof(output));
}
#include <config.h>
#else
#ifdef WIN32
-#define vsnprintf rpl_vsnprintf
-#define snprintf rpl_snprintf
+#define vsnprintf util_vsnprintf
+#define snprintf util_snprintf
#define HAVE_VSNPRINTF 0
#define HAVE_SNPRINTF 0
#define HAVE_VASPRINTF 1 /* not needed */
static LDOUBLE mypow10(int);
int
-rpl_vsnprintf(char *str, size_t size, const char *format, va_list args)
+util_vsnprintf(char *str, size_t size, const char *format, va_list args)
{
LDOUBLE fvalue;
INTMAX_T value;
#endif /* NEED_MYMEMCPY */
int
-rpl_vasprintf(char **ret, const char *format, va_list ap)
+util_vasprintf(char **ret, const char *format, va_list ap)
{
size_t size;
int len;
#if !HAVE_SNPRINTF
#if HAVE_STDARG_H
int
-rpl_snprintf(char *str, size_t size, const char *format, ...)
+util_snprintf(char *str, size_t size, const char *format, ...)
#else
int
-rpl_snprintf(va_alist) va_dcl
+util_snprintf(va_alist) va_dcl
#endif /* HAVE_STDARG_H */
{
#if !HAVE_STDARG_H
#if !HAVE_ASPRINTF
#if HAVE_STDARG_H
int
-rpl_asprintf(char **ret, const char *format, ...)
+util_asprintf(char **ret, const char *format, ...)
#else
int
-rpl_asprintf(va_alist) va_dcl
+util_asprintf(va_alist) va_dcl
#endif /* HAVE_STDARG_H */
{
#if !HAVE_STDARG_H
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Platform independent functions for string manipulation.
+ *
+ * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+#ifndef U_STRING_H_
+#define U_STRING_H_
+
+#ifndef WIN32
+#include <stdio.h>
+#endif
+#include <stddef.h>
+#include <stdarg.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef WIN32
+int util_vsnprintf(char *, size_t, const char *, va_list);
+int util_snprintf(char *str, size_t size, const char *format, ...);
+#else
+#define util_vsnprintf vsnprintf
+#define util_snprintf snprintf
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_STRING_H_ */
#include "i915_fpc.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_string.h"
#include "tgsi/util/tgsi_parse.h"
#include "tgsi/util/tgsi_dump.h"
debug_printf("i915_program_error: ");
va_start( args, msg );
- vsprintf( buffer, msg, args );
+ util_vsnprintf( buffer, sizeof(buffer), msg, args );
va_end( args );
debug_printf(buffer);
debug_printf("\n");
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_string.h"
#include "i915_reg.h"
#include "i915_context.h"
break;
}
- sprintf(buffer, "i915 (chipset: %s)", chipset);
+ util_snprintf(buffer, sizeof(buffer), "i915 (chipset: %s)", chipset);
return buffer;
}
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_string.h"
#include "brw_context.h"
#include "brw_screen.h"
break;
}
- sprintf(buffer, "i965 (chipset: %s)", chipset);
+ util_snprintf(buffer, sizeof(buffer), "i965 (chipset: %s)", chipset);
return buffer;
}
#ifndef PIPE_FORMAT_H
#define PIPE_FORMAT_H
-#include <stdio.h> /* for sprintf */
+#include "util/u_string.h"
#include "p_compiler.h"
#include "p_debug.h"
strcat( str, "S" );
break;
}
- sprintf( &str[strlen( str )], "%u", size * scale );
+ util_snprintf( &str[strlen( str )], 32, "%u", size * scale );
}
if (i != 0) {
strcat( str, "_" );
#define GETENV( X ) debug_get_option( X, NULL )
-#ifdef WIN32
-int rpl_vsnprintf(char *, size_t, const char *, va_list);
-int rpl_snprintf(char *str, size_t size, const char *format, ...);
-#define vsnprintf rpl_vsnprintf
-#define snprintf rpl_snprintf
-#endif
-
-
/**
* Return memory on given byte alignment
*/