diff options
author | Brian Paul <brianp@vmware.com> | 2010-02-19 12:56:49 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2010-02-19 12:56:49 -0700 |
commit | 78a0c353d0f87c85feaa6dcb3042fc25d424f21b (patch) | |
tree | ea638e071a08127708883560bdb96b8c0547d854 | |
parent | 8de5a292f70dba854a4bf06a2210bc38381e6bcf (diff) | |
download | external_mesa3d-78a0c353d0f87c85feaa6dcb3042fc25d424f21b.zip external_mesa3d-78a0c353d0f87c85feaa6dcb3042fc25d424f21b.tar.gz external_mesa3d-78a0c353d0f87c85feaa6dcb3042fc25d424f21b.tar.bz2 |
mesa: restore _mesa_snprintf() - it's needed for Windows
This reverts part of commit 298be2b028263b2c343a707662c6fbfa18293cb2
-rw-r--r-- | src/mesa/drivers/common/meta.c | 6 | ||||
-rw-r--r-- | src/mesa/main/imports.c | 19 | ||||
-rw-r--r-- | src/mesa/main/imports.h | 3 | ||||
-rw-r--r-- | src/mesa/main/version.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/prog_instruction.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/prog_print.c | 6 | ||||
-rw-r--r-- | src/mesa/shader/program_parse.tab.c | 14 | ||||
-rw-r--r-- | src/mesa/shader/program_parse.y | 10 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 4 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_link.c | 4 |
12 files changed, 45 insertions, 29 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 3aa70dd..42ab7d4 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1047,7 +1047,7 @@ init_blit_depth_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - snprintf(program2, sizeof(program2), program, texTarget); + _mesa_snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &blit->DepthFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP); @@ -1670,7 +1670,7 @@ init_draw_stencil_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - snprintf(program2, sizeof(program2), program, texTarget); + _mesa_snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &drawpix->StencilFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP); @@ -1704,7 +1704,7 @@ init_draw_depth_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - snprintf(program2, sizeof(program2), program, texTarget); + _mesa_snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &drawpix->DepthFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP); diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 1124909..56e8195 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -827,6 +827,19 @@ _mesa_str_checksum(const char *str) /*@}*/ +/** Wrapper around vsnprintf() */ +int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) +{ + int r; + va_list args; + va_start( args, fmt ); + r = vsnprintf( str, size, fmt, args ); + va_end( args ); + return r; +} + + /**********************************************************************/ /** \name Diagnostics */ /*@{*/ @@ -866,7 +879,7 @@ output_if_debug(const char *prefixString, const char *outputString, * visible, so communicate with the debugger instead */ { char buf[4096]; - snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); + _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); OutputDebugStringA(buf); } #endif @@ -915,7 +928,7 @@ flush_delayed_errors( GLcontext *ctx ) char s[MAXSTRING]; if (ctx->ErrorDebugCount) { - snprintf(s, MAXSTRING, "%d similar %s errors", + _mesa_snprintf(s, MAXSTRING, "%d similar %s errors", ctx->ErrorDebugCount, error_string(ctx->ErrorValue)); @@ -1022,7 +1035,7 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) vsnprintf(s, MAXSTRING, fmtString, args); va_end(args); - snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); + _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); output_if_debug("Mesa: User error", s2, GL_TRUE); ctx->ErrorDebugFmtString = fmtString; diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 269d985..ac3a7b5 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -583,6 +583,9 @@ _mesa_strtod( const char *s, char **end ); extern unsigned int _mesa_str_checksum(const char *str); +extern int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ); + extern void _mesa_warning( __GLcontext *gc, const char *fmtString, ... ); diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 0d01f16..a39b680 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -124,7 +124,7 @@ _mesa_compute_version(GLcontext *ctx) ctx->VersionString = (char *) malloc(max); if (ctx->VersionString) { - snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING, + _mesa_snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING, ctx->VersionMajor, ctx->VersionMinor); } } diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index e5534b2..81099cb 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -345,7 +345,7 @@ _mesa_opcode_string(gl_inst_opcode opcode) return InstInfo[opcode].Name; else { static char s[20]; - snprintf(s, sizeof(s), "OP%u", opcode); + _mesa_snprintf(s, sizeof(s), "OP%u", opcode); return s; } } diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index b4905ab..0af70af 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -77,7 +77,7 @@ file_string(gl_register_file f, gl_prog_print_mode mode) default: { static char s[20]; - snprintf(s, sizeof(s), "FILE%u", f); + _mesa_snprintf(s, sizeof(s), "FILE%u", f); return s; } } @@ -997,7 +997,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) else type = "vert"; - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "w"); if (!f) { fprintf(stderr, "Unable to open %s for writing\n", filename); @@ -1047,7 +1047,7 @@ _mesa_append_uniforms_to_file(const struct gl_shader *shader, else type = "vert"; - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "a"); /* append */ if (!f) { fprintf(stderr, "Unable to open %s for appending\n", filename); diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index 3f26f9f..52f6084 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -2984,7 +2984,7 @@ yyreduce: { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) { char s[100]; - snprintf(s, sizeof(s), + _mesa_snprintf(s, sizeof(s), "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); yyerror(& (yylsp[(1) - (1)]), state, s); YYERROR; @@ -3001,7 +3001,7 @@ yyreduce: { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) { char s[100]; - snprintf(s, sizeof(s), + _mesa_snprintf(s, sizeof(s), "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); yyerror(& (yylsp[(1) - (1)]), state, s); YYERROR; @@ -4915,7 +4915,7 @@ yyreduce: if (exist != NULL) { char m[1000]; - snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); + _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); free((yyvsp[(2) - (4)].string)); yyerror(& (yylsp[(2) - (4)]), state, m); YYERROR; @@ -5559,18 +5559,18 @@ make_error_string(const char *fmt, ...) va_start(args, fmt); - /* Call vsnprintf once to determine how large the final string is. Call it - * again to do the actual formatting. from the vsnprintf manual page: + /* Call v_mesa_snprintf once to determine how large the final string is. Call it + * again to do the actual formatting. from the v_mesa_snprintf manual page: * * Upon successful return, these functions return the number of * characters printed (not including the trailing '\0' used to end * output to strings). */ - length = 1 + vsnprintf(NULL, 0, fmt, args); + length = 1 + v_mesa_snprintf(NULL, 0, fmt, args); str = malloc(length); if (str) { - vsnprintf(str, length, fmt, args); + v_mesa_snprintf(str, length, fmt, args); } va_end(args); diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 1c856d8..75cb4cf 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -936,7 +936,7 @@ addrRegPosOffset: INTEGER { if (($1 < 0) || ($1 > 63)) { char s[100]; - snprintf(s, sizeof(s), + _mesa_snprintf(s, sizeof(s), "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; @@ -950,7 +950,7 @@ addrRegNegOffset: INTEGER { if (($1 < 0) || ($1 > 64)) { char s[100]; - snprintf(s, sizeof(s), + _mesa_snprintf(s, sizeof(s), "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; @@ -2173,7 +2173,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER if (exist != NULL) { char m[1000]; - snprintf(m, sizeof(m), "redeclared identifier: %s", $2); + _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); free($2); yyerror(& @2, state, m); YYERROR; @@ -2599,7 +2599,7 @@ make_error_string(const char *fmt, ...) va_start(args, fmt); /* Call vsnprintf once to determine how large the final string is. Call it - * again to do the actual formatting. from the vsnprintf manual page: + * again to do the actual formatting. from the v_mesa_snprintf manual page: * * Upon successful return, these functions return the number of * characters printed (not including the trailing '\0' used to end @@ -2609,7 +2609,7 @@ make_error_string(const char *fmt, ...) str = malloc(length); if (str) { - vsnprintf(str, length, fmt, args); + v_mesa_snprintf(str, length, fmt, args); } va_end(args); diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 8bd780b..129a973 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -2076,7 +2076,7 @@ validate_samplers(GLcontext *ctx, const struct gl_program *prog, char *errMsg) unit = prog->SamplerUnits[sampler]; target = prog->SamplerTargets[sampler]; if (targetUsed[unit] != -1 && targetUsed[unit] != target) { - snprintf(errMsg, 100, + _mesa_snprintf(errMsg, 100, "Texture unit %d is accessed both as %s and %s", unit, targetName[targetUsed[unit]], targetName[target]); return GL_FALSE; diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index b17256b..6901b93 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -1643,7 +1643,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, if (A->pragmas->Debug) { char s[1000]; - snprintf(s, sizeof(s), "Call/inline %s()", (char *) fun->header.a_name); + _mesa_snprintf(s, sizeof(s), "Call/inline %s()", (char *) fun->header.a_name); n->Comment = _slang_strdup(s); } @@ -2190,7 +2190,7 @@ _slang_make_array_constructor(slang_assemble_ctx *A, slang_operation *oper) */ slang_variable *p = slang_variable_scope_grow(fun->parameters); char name[10]; - snprintf(name, sizeof(name), "p%d", i); + _mesa_snprintf(name, sizeof(name), "p%d", i); p->a_name = slang_atom_pool_atom(A->atoms, name); p->type.qualifier = SLANG_QUAL_CONST; p->type.specifier.type = baseType; diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 52fe786..7c0ea0c 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -2303,7 +2303,7 @@ emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n) /* error */ char s[100]; /* XXX isn't this really an out of memory/resources error? */ - snprintf(s, sizeof(s), "Undefined variable '%s'", + _mesa_snprintf(s, sizeof(s), "Undefined variable '%s'", (char *) n->Var->a_name); slang_info_log_error(emitInfo->log, s); return NULL; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index b59fc0a..7c7bfbd 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -139,7 +139,7 @@ link_varying_vars(GLcontext *ctx, } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) { char msg[100]; - snprintf(msg, sizeof(msg), + _mesa_snprintf(msg, sizeof(msg), "centroid modifier mismatch for '%s'", var->Name); link_error(shProg, msg); free(map); @@ -147,7 +147,7 @@ link_varying_vars(GLcontext *ctx, } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) { char msg[100]; - snprintf(msg, sizeof(msg), + _mesa_snprintf(msg, sizeof(msg), "invariant modifier mismatch for '%s'", var->Name); link_error(shProg, msg); free(map); |