>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
Jean-Marc> Thanks for the tip. I'd rather use #include Jean-Marc> "support/snprintf.h" since this uses our own implementation Jean-Marc> if needed. Can you confirm that it works? Actually it does not work here. Since snprintf is not used anywhere else in 1.3.x, I'd rather rewrite the function using normal ostringstring stuff. Does somebody have a complaint about the following patch? It applies to 1.3.x, easy to transpose to 1.4.0cvs. JMarc
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1021.2.43 diff -u -p -r1.1021.2.43 ChangeLog --- ChangeLog 22 Oct 2004 10:25:10 -0000 1.1021.2.43 +++ ChangeLog 4 Nov 2004 10:10:46 -0000 @@ -1,3 +1,7 @@ +2004-11-04 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * lyxlength.C (asLatexString): rewrite to use a ostringstream + 2004-10-21 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * lyxfunc.C (getStatus,dispatch): handle LFUN_(PREVIOUS|NEXT)BUFFER Index: lyxlength.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlength.C,v retrieving revision 1.26.2.1 diff -u -p -r1.26.2.1 lyxlength.C --- lyxlength.C 22 Oct 2004 09:08:55 -0000 1.26.2.1 +++ lyxlength.C 4 Nov 2004 10:10:46 -0000 @@ -23,8 +23,10 @@ #include "Lsstream.h" #include <cstdlib> +#include <iomanip> using std::abs; +using std::setprecision; LyXLength::LyXLength() : val_(0), unit_(LyXLength::UNIT_NONE) @@ -59,33 +61,31 @@ string const LyXLength::asString() const string const LyXLength::asLatexString() const { - char buffer[80]; + ostringstream buffer; switch (unit_) { case PTW: - snprintf(buffer, 78, "%.2f\\textwidth", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\textwidth"; break; case PCW: - snprintf(buffer, 78, "%.2f\\columnwidth", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\columnwidth"; break; case PPW: - snprintf(buffer, 78, "%.2f\\paperwidth", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\paperwidth"; break; case PLW: - snprintf(buffer, 78, "%.2f\\linewidth", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\linewidth"; break; case PPH: - snprintf(buffer, 78, "%.2f\\paperheight", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\paperheight"; break; case PTH: - snprintf(buffer, 78, "%.2f\\textheight", val_/100.0); + buffer << setprecision(2) << val_/100.0 << "\\textheight"; break; default: - snprintf(buffer, 78, "%f%s", val_, unit_name[unit_]); + buffer << setprecision(2) << val_ << unit_name[unit_]; break; } - // paranoia - buffer[79] = 0; - return buffer; + return STRCONV(buffer.str()); }