From 66c1674cd519155febbb878cf09a130d24b39d11 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 29 Oct 2008 20:57:33 +0000 Subject: Use the same ostringstream formatting for protocol logging to file that we use for standard logging, to fix 64bit platform warnings reported by Matt Brown. --- lib/server/makeprotocol.pl.in | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/server/makeprotocol.pl.in b/lib/server/makeprotocol.pl.in index 0cc66f35..91ba55b0 100755 --- a/lib/server/makeprotocol.pl.in +++ b/lib/server/makeprotocol.pl.in @@ -538,11 +538,13 @@ __E } if($implement_filelog) { - my ($format,$args) = make_log_strings($cmd); + my ($log) = make_log_strings_framework($cmd); print CPP <<__E; void ${class}LogFile(const char *Action, FILE *File) const { - ::fprintf(File,"%s $format\\n",Action$args); + std::ostringstream oss; + oss << $log; + ::fprintf(File, "%s\\n", oss.str().c_str()); ::fflush(File); } __E @@ -1051,10 +1053,22 @@ sub make_log_strings_framework my ($format,$arg) = @{$log_display_types{$ty}}; $arg =~ s/VAR/m$nm/g; - if ($format =~ m'x$') + if ($format eq '\\"%s\\"') + { + $arg = "\"\\\"\" << $arg << \"\\\"\""; + } + elsif ($format =~ m'x$') { - $arg = "std::hex << std::showbase " . - "<< $arg << std::dec"; + # my $width = 0; + # $ty =~ /^int(\d+)$/ and $width = $1 / 4; + $arg = "($arg == 0 ? \"0x\" : \"\") " . + "<< std::hex " . + "<< std::showbase " . + # "<< std::setw($width) " . + # "<< std::setfill('0') " . + # "<< std::internal " . + "<< $arg " . + "<< std::dec"; } push @args, $arg; -- cgit v1.2.3