FBString iomanip fix.
authorNicholas Ormrod <njormrod@fb.com>
Tue, 10 Dec 2013 22:14:00 +0000 (14:14 -0800)
committerJordan DeLong <jdelong@fb.com>
Fri, 20 Dec 2013 21:05:15 +0000 (13:05 -0800)
commit7c3790caa0c3d69c1a1b2193786470c84ba02ef7
tree8aee06bdd55f46a1c48ffb2d0acf65ef1242be1a
parent3680f888411a4eea23aae712149932f4bb37d349
FBString iomanip fix.

Summary:
D1090936 noticed some problems with fbstring iomanip behavior.
The root cause is that os.write(ostream, char*, size_t) is an
UnformattedOutputFunction, so disregards setw(), setfill(), and
left/right alignment.

The use of os.write instead of os << str.data() is intentional:
D367009 switched from the latter to the former so that strings
containing a '\0' are printed properly.

There does not seem to be a public function to write with formatting.
Where needed in libgcc, the function __ostream_insert is used. Since
FBString already uses such 'private' functions, __ostream_insert is an
appropriate solution.

@override-unit-failures

Test Plan:
Added test cases to FBStringTest.cpp to cover iomanip.
fbconfig -r folly && fbmake opt && fbmake runtests_opt

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1091474
folly/FBString.h
folly/test/FBStringTest.cpp