From 5bbfeafea58d4779de609289268eb8205ecd931e Mon Sep 17 00:00:00 2001 From: Matthias Jurenz Date: Mon, 3 Nov 2008 19:21:52 +0000 Subject: [PATCH] Use an easier format string for the new snprintf wrapper This commit was SVN r19894. --- ompi/contrib/vt/vt/tools/opari/tool/opari.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ompi/contrib/vt/vt/tools/opari/tool/opari.cc b/ompi/contrib/vt/vt/tools/opari/tool/opari.cc index 56ef3ca487..ab69cf94c4 100644 --- a/ompi/contrib/vt/vt/tools/opari/tool/opari.cc +++ b/ompi/contrib/vt/vt/tools/opari/tool/opari.cc @@ -5,7 +5,7 @@ ** Copyright (c) 1998-2008 ** ** Forschungszentrum Juelich, Juelich Supercomputing Centre ** ** ** -** See the file COPYING in the package base directory for details ** +** See the file COPYING in the package base directory for details ** ****************************************************************************/ #include @@ -164,8 +164,12 @@ int main (int argc, char *argv[]) { out_filename = new char[strlen(infile)+5]; char* dot = (char *) strrchr(infile, '.'); if ( dot != 0 ) { - vt_snprintf(out_filename, strlen(infile)+5, "%.*s.mod%s", - (int)(dot - infile), infile, dot); + char* infile_prefix = new char[strlen(infile)]; + strncpy(infile_prefix, infile, (int)(dot - infile)); + infile_prefix[(int)(dot-infile)] = '\0'; + + vt_snprintf(out_filename, strlen(infile)+5, "%s.mod%s", + infile_prefix, dot); if ( keepSrcInfo && (lang & L_FORTRAN) ) { dot = strrchr(out_filename, '.'); @@ -177,6 +181,8 @@ int main (int argc, char *argv[]) { cerr << "ERROR: cannot open output file " << out_filename << "\n"; errFlag = true; } + + delete [] infile_prefix; } else { cerr << "ERROR: cannot generate output file name\n"; errFlag =true;