From 954c6da53067cbebbb6fe71c7871f183cc2582d6 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Sat, 12 Aug 2006 16:46:32 +0200 Subject: [PATCH] _sprintf('O') must not have noticeable side effects and must be able to handle an object in any state. Rev: src/modules/Mysql/mysql.c:1.102 --- src/modules/Mysql/mysql.c | 46 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/modules/Mysql/mysql.c b/src/modules/Mysql/mysql.c index 12f482e32f..7c3e63ce16 100644 --- a/src/modules/Mysql/mysql.c +++ b/src/modules/Mysql/mysql.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: mysql.c,v 1.101 2006/08/12 14:07:48 mast Exp $ +|| $Id: mysql.c,v 1.102 2006/08/12 14:46:32 mast Exp $ */ /* @@ -691,35 +691,29 @@ static void mysql__sprintf(INT32 args) { case 'O': { - struct pike_string *res; - MYSQL *socket; - const char *info; - - if(!PIKE_MYSQL->socket) - pike_mysql_reconnect (1); - socket = PIKE_MYSQL->socket; - - MYSQL_ALLOW(); - info = mysql_get_host_info(socket); - MYSQL_DISALLOW(); - - push_text("mysql(/* %s %s*/)"); - push_text(info); + MYSQL *socket = PIKE_MYSQL->socket; + + if (socket) { + const char *info; + MYSQL_ALLOW(); + info = mysql_get_host_info(socket); + MYSQL_DISALLOW(); + push_text("mysql(/*%s%s*/)"); + push_text(info); #ifdef HAVE_MYSQL_SSL - if (PIKE_MYSQL->mysql->options.use_ssl) { - push_text("using SSL "); - } - else - push_empty_string(); + if (PIKE_MYSQL->mysql->options.use_ssl) { + push_text(", SSL"); + } + else + push_empty_string(); #else - push_empty_string(); + push_empty_string(); #endif /* HAVE_MYSQL_SSL */ + f_sprintf(3); + } + else + push_constant_text ("mysql()"); - f_sprintf(3); - - res = Pike_sp[-1].u.string; - Pike_sp--; - push_string(res); return; } -- GitLab