diff options
author | Jacek Antonelli | 2008-08-15 23:44:56 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:56 -0500 |
commit | c07901e29ed545bbb02e3bddf148fe1104b94e9f (patch) | |
tree | f1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/llmessage/lldatapacker.cpp | |
parent | Second Life viewer sources 1.15.0.2 (diff) | |
download | meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2 meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz |
Second Life viewer sources 1.15.1.3
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/lldatapacker.cpp | 80 |
1 files changed, 47 insertions, 33 deletions
diff --git a/linden/indra/llmessage/lldatapacker.cpp b/linden/indra/llmessage/lldatapacker.cpp index 2448c40..3cdaa25 100644 --- a/linden/indra/llmessage/lldatapacker.cpp +++ b/linden/indra/llmessage/lldatapacker.cpp | |||
@@ -972,11 +972,11 @@ BOOL LLDataPackerAsciiBuffer::packF32(const F32 value, const char *name) | |||
972 | int numCopied = 0; | 972 | int numCopied = 0; |
973 | if (mWriteEnabled) | 973 | if (mWriteEnabled) |
974 | { | 974 | { |
975 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g\n", value); /* Flawfinder: ignore */ | 975 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f\n", value); /* Flawfinder: ignore */ |
976 | } | 976 | } |
977 | else | 977 | else |
978 | { | 978 | { |
979 | numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%g\n", value); /* Flawfinder: ignore */ | 979 | numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%f\n", value); /* Flawfinder: ignore */ |
980 | } | 980 | } |
981 | // snprintf returns number of bytes that would have been written | 981 | // snprintf returns number of bytes that would have been written |
982 | // had the output not being truncated. In that case, it will | 982 | // had the output not being truncated. In that case, it will |
@@ -1004,7 +1004,7 @@ BOOL LLDataPackerAsciiBuffer::unpackF32(F32 &value, const char *name) | |||
1004 | return FALSE; | 1004 | return FALSE; |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | sscanf(valuestr,"%g", &value); | 1007 | sscanf(valuestr,"%f", &value); |
1008 | return success; | 1008 | return success; |
1009 | } | 1009 | } |
1010 | 1010 | ||
@@ -1016,11 +1016,11 @@ BOOL LLDataPackerAsciiBuffer::packColor4(const LLColor4 &value, const char *name | |||
1016 | int numCopied = 0; | 1016 | int numCopied = 0; |
1017 | if (mWriteEnabled) | 1017 | if (mWriteEnabled) |
1018 | { | 1018 | { |
1019 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ | 1019 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ |
1020 | } | 1020 | } |
1021 | else | 1021 | else |
1022 | { | 1022 | { |
1023 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ | 1023 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ |
1024 | } | 1024 | } |
1025 | // snprintf returns number of bytes that would have been written | 1025 | // snprintf returns number of bytes that would have been written |
1026 | // had the output not being truncated. In that case, it will | 1026 | // had the output not being truncated. In that case, it will |
@@ -1048,7 +1048,7 @@ BOOL LLDataPackerAsciiBuffer::unpackColor4(LLColor4 &value, const char *name) | |||
1048 | return FALSE; | 1048 | return FALSE; |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | sscanf(valuestr,"%g %g %g %g", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); | 1051 | sscanf(valuestr,"%f %f %f %f", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); |
1052 | return success; | 1052 | return success; |
1053 | } | 1053 | } |
1054 | 1054 | ||
@@ -1109,11 +1109,11 @@ BOOL LLDataPackerAsciiBuffer::packVector2(const LLVector2 &value, const char *na | |||
1109 | int numCopied = 0; | 1109 | int numCopied = 0; |
1110 | if (mWriteEnabled) | 1110 | if (mWriteEnabled) |
1111 | { | 1111 | { |
1112 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */ | 1112 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */ |
1113 | } | 1113 | } |
1114 | else | 1114 | else |
1115 | { | 1115 | { |
1116 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */ | 1116 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */ |
1117 | } | 1117 | } |
1118 | // snprintf returns number of bytes that would have been written | 1118 | // snprintf returns number of bytes that would have been written |
1119 | // had the output not being truncated. In that case, it will | 1119 | // had the output not being truncated. In that case, it will |
@@ -1141,7 +1141,7 @@ BOOL LLDataPackerAsciiBuffer::unpackVector2(LLVector2 &value, const char *name) | |||
1141 | return FALSE; | 1141 | return FALSE; |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | sscanf(valuestr,"%g %g", &value.mV[0], &value.mV[1]); | 1144 | sscanf(valuestr,"%f %f", &value.mV[0], &value.mV[1]); |
1145 | return success; | 1145 | return success; |
1146 | } | 1146 | } |
1147 | 1147 | ||
@@ -1153,11 +1153,11 @@ BOOL LLDataPackerAsciiBuffer::packVector3(const LLVector3 &value, const char *na | |||
1153 | int numCopied = 0; | 1153 | int numCopied = 0; |
1154 | if (mWriteEnabled) | 1154 | if (mWriteEnabled) |
1155 | { | 1155 | { |
1156 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g %g\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */ | 1156 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */ |
1157 | } | 1157 | } |
1158 | else | 1158 | else |
1159 | { | 1159 | { |
1160 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */ | 1160 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */ |
1161 | } | 1161 | } |
1162 | // snprintf returns number of bytes that would have been written | 1162 | // snprintf returns number of bytes that would have been written |
1163 | // had the output not being truncated. In that case, it will | 1163 | // had the output not being truncated. In that case, it will |
@@ -1185,7 +1185,7 @@ BOOL LLDataPackerAsciiBuffer::unpackVector3(LLVector3 &value, const char *name) | |||
1185 | return FALSE; | 1185 | return FALSE; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | sscanf(valuestr,"%g %g %g", &value.mV[0], &value.mV[1], &value.mV[2]); | 1188 | sscanf(valuestr,"%f %f %f", &value.mV[0], &value.mV[1], &value.mV[2]); |
1189 | return success; | 1189 | return success; |
1190 | } | 1190 | } |
1191 | 1191 | ||
@@ -1196,11 +1196,11 @@ BOOL LLDataPackerAsciiBuffer::packVector4(const LLVector4 &value, const char *na | |||
1196 | int numCopied = 0; | 1196 | int numCopied = 0; |
1197 | if (mWriteEnabled) | 1197 | if (mWriteEnabled) |
1198 | { | 1198 | { |
1199 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ | 1199 | numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ |
1200 | } | 1200 | } |
1201 | else | 1201 | else |
1202 | { | 1202 | { |
1203 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ | 1203 | numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ |
1204 | } | 1204 | } |
1205 | // snprintf returns number of bytes that would have been written | 1205 | // snprintf returns number of bytes that would have been written |
1206 | // had the output not being truncated. In that case, it will | 1206 | // had the output not being truncated. In that case, it will |
@@ -1228,7 +1228,7 @@ BOOL LLDataPackerAsciiBuffer::unpackVector4(LLVector4 &value, const char *name) | |||
1228 | return FALSE; | 1228 | return FALSE; |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | sscanf(valuestr,"%g %g %g %g", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); | 1231 | sscanf(valuestr,"%f %f %f %f", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); |
1232 | return success; | 1232 | return success; |
1233 | } | 1233 | } |
1234 | 1234 | ||
@@ -1359,6 +1359,19 @@ BOOL LLDataPackerAsciiBuffer::getValueStr(const char *name, char *out_value, S32 | |||
1359 | return success; | 1359 | return success; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | // helper function used by LLDataPackerAsciiFile | ||
1363 | // to convert F32 into a string. This is to avoid | ||
1364 | // << operator writing F32 value into a stream | ||
1365 | // since it does not seem to preserve the float value | ||
1366 | std::string convertF32ToString(F32 val) | ||
1367 | { | ||
1368 | std::string str; | ||
1369 | char buf[20]; | ||
1370 | snprintf(buf, 20, "%f", val); | ||
1371 | str = buf; | ||
1372 | return str; | ||
1373 | } | ||
1374 | |||
1362 | //--------------------------------------------------------------------------- | 1375 | //--------------------------------------------------------------------------- |
1363 | // LLDataPackerAsciiFile implementation | 1376 | // LLDataPackerAsciiFile implementation |
1364 | //--------------------------------------------------------------------------- | 1377 | //--------------------------------------------------------------------------- |
@@ -1633,11 +1646,11 @@ BOOL LLDataPackerAsciiFile::packF32(const F32 value, const char *name) | |||
1633 | writeIndentedName(name); | 1646 | writeIndentedName(name); |
1634 | if (mFP) | 1647 | if (mFP) |
1635 | { | 1648 | { |
1636 | fprintf(mFP,"%g\n", value); | 1649 | fprintf(mFP,"%f\n", value); |
1637 | } | 1650 | } |
1638 | else if (mOutputStream) | 1651 | else if (mOutputStream) |
1639 | { | 1652 | { |
1640 | *mOutputStream <<"" << value << "\n"; | 1653 | *mOutputStream <<"" << convertF32ToString(value) << "\n"; |
1641 | } | 1654 | } |
1642 | return success; | 1655 | return success; |
1643 | } | 1656 | } |
@@ -1652,7 +1665,7 @@ BOOL LLDataPackerAsciiFile::unpackF32(F32 &value, const char *name) | |||
1652 | return FALSE; | 1665 | return FALSE; |
1653 | } | 1666 | } |
1654 | 1667 | ||
1655 | sscanf(valuestr,"%g", &value); | 1668 | sscanf(valuestr,"%f", &value); |
1656 | return success; | 1669 | return success; |
1657 | } | 1670 | } |
1658 | 1671 | ||
@@ -1663,11 +1676,11 @@ BOOL LLDataPackerAsciiFile::packColor4(const LLColor4 &value, const char *name) | |||
1663 | writeIndentedName(name); | 1676 | writeIndentedName(name); |
1664 | if (mFP) | 1677 | if (mFP) |
1665 | { | 1678 | { |
1666 | fprintf(mFP,"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); | 1679 | fprintf(mFP,"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); |
1667 | } | 1680 | } |
1668 | else if (mOutputStream) | 1681 | else if (mOutputStream) |
1669 | { | 1682 | { |
1670 | *mOutputStream << value.mV[0] << " " << value.mV[1] << " " << value.mV[2] << " " << value.mV[3] << "\n"; | 1683 | *mOutputStream << convertF32ToString(value.mV[0]) << " " << convertF32ToString(value.mV[1]) << " " << convertF32ToString(value.mV[2]) << " " << convertF32ToString(value.mV[3]) << "\n"; |
1671 | } | 1684 | } |
1672 | return success; | 1685 | return success; |
1673 | } | 1686 | } |
@@ -1682,7 +1695,7 @@ BOOL LLDataPackerAsciiFile::unpackColor4(LLColor4 &value, const char *name) | |||
1682 | return FALSE; | 1695 | return FALSE; |
1683 | } | 1696 | } |
1684 | 1697 | ||
1685 | sscanf(valuestr,"%g %g %g %g", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); | 1698 | sscanf(valuestr,"%f %f %f %f", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); |
1686 | return success; | 1699 | return success; |
1687 | } | 1700 | } |
1688 | 1701 | ||
@@ -1728,11 +1741,11 @@ BOOL LLDataPackerAsciiFile::packVector2(const LLVector2 &value, const char *name | |||
1728 | writeIndentedName(name); | 1741 | writeIndentedName(name); |
1729 | if (mFP) | 1742 | if (mFP) |
1730 | { | 1743 | { |
1731 | fprintf(mFP,"%g %g\n", value.mV[0], value.mV[1]); | 1744 | fprintf(mFP,"%f %f\n", value.mV[0], value.mV[1]); |
1732 | } | 1745 | } |
1733 | else if (mOutputStream) | 1746 | else if (mOutputStream) |
1734 | { | 1747 | { |
1735 | *mOutputStream << value.mV[0] << " " << value.mV[1] << "\n"; | 1748 | *mOutputStream << convertF32ToString(value.mV[0]) << " " << convertF32ToString(value.mV[1]) << "\n"; |
1736 | } | 1749 | } |
1737 | return success; | 1750 | return success; |
1738 | } | 1751 | } |
@@ -1747,7 +1760,7 @@ BOOL LLDataPackerAsciiFile::unpackVector2(LLVector2 &value, const char *name) | |||
1747 | return FALSE; | 1760 | return FALSE; |
1748 | } | 1761 | } |
1749 | 1762 | ||
1750 | sscanf(valuestr,"%g %g", &value.mV[0], &value.mV[1]); | 1763 | sscanf(valuestr,"%f %f", &value.mV[0], &value.mV[1]); |
1751 | return success; | 1764 | return success; |
1752 | } | 1765 | } |
1753 | 1766 | ||
@@ -1758,11 +1771,11 @@ BOOL LLDataPackerAsciiFile::packVector3(const LLVector3 &value, const char *name | |||
1758 | writeIndentedName(name); | 1771 | writeIndentedName(name); |
1759 | if (mFP) | 1772 | if (mFP) |
1760 | { | 1773 | { |
1761 | fprintf(mFP,"%g %g %g\n", value.mV[0], value.mV[1], value.mV[2]); | 1774 | fprintf(mFP,"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]); |
1762 | } | 1775 | } |
1763 | else if (mOutputStream) | 1776 | else if (mOutputStream) |
1764 | { | 1777 | { |
1765 | *mOutputStream << value.mV[0] << " " << value.mV[1] << " " << value.mV[2] << "\n"; | 1778 | *mOutputStream << convertF32ToString(value.mV[0]) << " " << convertF32ToString(value.mV[1]) << " " << convertF32ToString(value.mV[2]) << "\n"; |
1766 | } | 1779 | } |
1767 | return success; | 1780 | return success; |
1768 | } | 1781 | } |
@@ -1777,7 +1790,7 @@ BOOL LLDataPackerAsciiFile::unpackVector3(LLVector3 &value, const char *name) | |||
1777 | return FALSE; | 1790 | return FALSE; |
1778 | } | 1791 | } |
1779 | 1792 | ||
1780 | sscanf(valuestr,"%g %g %g", &value.mV[0], &value.mV[1], &value.mV[2]); | 1793 | sscanf(valuestr,"%f %f %f", &value.mV[0], &value.mV[1], &value.mV[2]); |
1781 | return success; | 1794 | return success; |
1782 | } | 1795 | } |
1783 | 1796 | ||
@@ -1787,11 +1800,11 @@ BOOL LLDataPackerAsciiFile::packVector4(const LLVector4 &value, const char *name | |||
1787 | writeIndentedName(name); | 1800 | writeIndentedName(name); |
1788 | if (mFP) | 1801 | if (mFP) |
1789 | { | 1802 | { |
1790 | fprintf(mFP,"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); | 1803 | fprintf(mFP,"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); |
1791 | } | 1804 | } |
1792 | else if (mOutputStream) | 1805 | else if (mOutputStream) |
1793 | { | 1806 | { |
1794 | *mOutputStream << value.mV[0] << " " << value.mV[1] << " " << value.mV[2] << " " << value.mV[3] << "\n"; | 1807 | *mOutputStream << convertF32ToString(value.mV[0]) << " " << convertF32ToString(value.mV[1]) << " " << convertF32ToString(value.mV[2]) << " " << convertF32ToString(value.mV[3]) << "\n"; |
1795 | } | 1808 | } |
1796 | return success; | 1809 | return success; |
1797 | } | 1810 | } |
@@ -1806,7 +1819,7 @@ BOOL LLDataPackerAsciiFile::unpackVector4(LLVector4 &value, const char *name) | |||
1806 | return FALSE; | 1819 | return FALSE; |
1807 | } | 1820 | } |
1808 | 1821 | ||
1809 | sscanf(valuestr,"%g %g %g %g", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); | 1822 | sscanf(valuestr,"%f %f %f %f", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); |
1810 | return success; | 1823 | return success; |
1811 | } | 1824 | } |
1812 | 1825 | ||
@@ -1848,7 +1861,8 @@ BOOL LLDataPackerAsciiFile::unpackUUID(LLUUID &value, const char *name) | |||
1848 | 1861 | ||
1849 | void LLDataPackerAsciiFile::writeIndentedName(const char *name) | 1862 | void LLDataPackerAsciiFile::writeIndentedName(const char *name) |
1850 | { | 1863 | { |
1851 | char indent_buf[64]; /*Flawfinder: ignore*/ | 1864 | std::string indent_buf; |
1865 | indent_buf.reserve(mIndent+1); | ||
1852 | 1866 | ||
1853 | S32 i; | 1867 | S32 i; |
1854 | for(i = 0; i < mIndent; i++) | 1868 | for(i = 0; i < mIndent; i++) |
@@ -1858,11 +1872,11 @@ void LLDataPackerAsciiFile::writeIndentedName(const char *name) | |||
1858 | indent_buf[i] = 0; | 1872 | indent_buf[i] = 0; |
1859 | if (mFP) | 1873 | if (mFP) |
1860 | { | 1874 | { |
1861 | fprintf(mFP,"%s%s\t",indent_buf, name); | 1875 | fprintf(mFP,"%s%s\t",indent_buf.c_str(), name); |
1862 | } | 1876 | } |
1863 | else if (mOutputStream) | 1877 | else if (mOutputStream) |
1864 | { | 1878 | { |
1865 | *mOutputStream << indent_buf << name << "\t"; | 1879 | *mOutputStream << indent_buf.c_str() << name << "\t"; |
1866 | } | 1880 | } |
1867 | } | 1881 | } |
1868 | 1882 | ||