You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2005/11/26 01:03:11 UTC
svn commit: r349040 - /incubator/stdcxx/trunk/tests/src/printf.cpp
Author: sebor
Date: Fri Nov 25 16:03:08 2005
New Revision: 349040
URL: http://svn.apache.org/viewcvs?rev=349040&view=rev
Log:
2005-11-25 Martin Sebor <se...@roguewave.com>
* printf.cpp: (_rw_vfprintf): Flushed out stream in case it isn't
line-buffered (e.g., when stderr is determined not to refer to a
terminal device, for example after it has been redirected to a file).
(_rw_fmtsignal): Used _rw_fmtstr() to format the signal name to take
advantage of the string justification capabilities of the function.
Modified:
incubator/stdcxx/trunk/tests/src/printf.cpp
Modified: incubator/stdcxx/trunk/tests/src/printf.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/printf.cpp?rev=349040&r1=349039&r2=349040&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/printf.cpp Fri Nov 25 16:03:08 2005
@@ -2184,19 +2184,12 @@
}
}
- int len;
-
if (0 == name) {
- len = sprintf (buffer, "SIG#%d", val);
+ sprintf (buffer, "SIG#%d", val);
name = buffer;
}
- else
- len = int (strlen (name));
-
- if (0 == _rw_bufcat (pbuf, pbufsize, name, size_t (len)))
- return -1;
- return len;
+ return _rw_fmtstr (spec, pbuf, pbufsize, name, _RWSTD_SIZE_MAX);
}
/********************************************************************/
@@ -3328,9 +3321,17 @@
const int nchars = rw_vasnprintf (&buf, &bufsize, fmt, va);
+ // FIXME: implement this in terms of POSIX write()
+ // for async-signal safety
+ FILE* const stdio_file = _RWSTD_REINTERPRET_CAST (FILE*, file);
+
const int nwrote = 0 < nchars ?
- fwrite (buf, 1, nchars, _RWSTD_REINTERPRET_CAST (FILE*, file))
- : nchars;
+ fwrite (buf, 1, nchars, stdio_file) : nchars;
+
+ // flush in case stderr isn't line-buffered (e.g., when
+ // it's determined not to refer to a terminal device,
+ // for example after it has been redirected to a file)
+ fflush (stdio_file);
#ifdef _MSC_VER