@@ -1032,11 +1032,7 @@ void LoadMtl(std::map<std::string, int> *material_map,
1032
1032
// set new mtl name
1033
1033
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1034
1034
token += 7 ;
1035
- #ifdef _MSC_VER
1036
- sscanf_s (token, " %s" , namebuf, (unsigned )_countof (namebuf));
1037
- #else
1038
- std::sscanf (token, " %s" , namebuf);
1039
- #endif
1035
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1040
1036
material.name = namebuf;
1041
1037
continue ;
1042
1038
}
@@ -1543,11 +1539,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
1543
1539
if ((0 == strncmp (token, " usemtl" , 6 )) && IS_SPACE ((token[6 ]))) {
1544
1540
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1545
1541
token += 7 ;
1546
- #ifdef _MSC_VER
1547
- sscanf_s (token, " %s" , namebuf, (unsigned )_countof (namebuf));
1548
- #else
1549
- std::sscanf (token, " %s" , namebuf);
1550
- #endif
1542
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1551
1543
1552
1544
int newMaterialId = -1 ;
1553
1545
if (material_map.find (namebuf) != material_map.end ()) {
@@ -1663,11 +1655,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
1663
1655
// @todo { multiple object name? }
1664
1656
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1665
1657
token += 2 ;
1666
- #ifdef _MSC_VER
1667
- sscanf_s (token, " %s" , namebuf, (unsigned )_countof (namebuf));
1668
- #else
1669
- std::sscanf (token, " %s" , namebuf);
1670
- #endif
1658
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1671
1659
name = std::string (namebuf);
1672
1660
1673
1661
continue ;
@@ -1678,11 +1666,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
1678
1666
1679
1667
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1680
1668
token += 2 ;
1681
- #ifdef _MSC_VER
1682
- sscanf_s (token, " %s" , namebuf, (unsigned )_countof (namebuf));
1683
- #else
1684
- std::sscanf (token, " %s" , namebuf);
1685
- #endif
1669
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1686
1670
tag.name = std::string (namebuf);
1687
1671
1688
1672
token += tag.name .size () + 1 ;
@@ -1706,12 +1690,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
1706
1690
for (size_t i = 0 ; i < static_cast <size_t >(ts.num_strings ); ++i) {
1707
1691
char stringValueBuffer[TINYOBJ_SSCANF_BUFFER_SIZE];
1708
1692
1709
- #ifdef _MSC_VER
1710
- sscanf_s (token, " %s" , stringValueBuffer,
1711
- (unsigned )_countof (stringValueBuffer));
1712
- #else
1713
- std::sscanf (token, " %s" , stringValueBuffer);
1714
- #endif
1693
+ std::snprintf (stringValueBuffer, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1715
1694
tag.stringValues [i] = stringValueBuffer;
1716
1695
token += tag.stringValues [i].size () + 1 ;
1717
1696
}
@@ -1853,12 +1832,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
1853
1832
if ((0 == strncmp (token, " usemtl" , 6 )) && IS_SPACE ((token[6 ]))) {
1854
1833
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1855
1834
token += 7 ;
1856
- #ifdef _MSC_VER
1857
- sscanf_s (token, " %s" , namebuf,
1858
- static_cast <unsigned int >(_countof (namebuf)));
1859
- #else
1860
- std::sscanf (token, " %s" , namebuf);
1861
- #endif
1835
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1862
1836
1863
1837
int newMaterialId = -1 ;
1864
1838
if (material_map.find (namebuf) != material_map.end ()) {
@@ -1968,11 +1942,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
1968
1942
// @todo { multiple object name? }
1969
1943
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1970
1944
token += 2 ;
1971
- #ifdef _MSC_VER
1972
- sscanf_s (token, " %s" , namebuf, (unsigned )_countof (namebuf));
1973
- #else
1974
- std::sscanf (token, " %s" , namebuf);
1975
- #endif
1945
+ std::snprintf (namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, " %s" , token);
1976
1946
std::string object_name = std::string (namebuf);
1977
1947
1978
1948
if (callback.object_cb ) {
@@ -1988,11 +1958,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
1988
1958
1989
1959
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
1990
1960
token += 2;
1991
- #ifdef _MSC_VER
1992
- sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
1993
- #else
1994
- std::sscanf(token, "%s", namebuf);
1995
- #endif
1961
+ std::snprintf(namebuf, TINYOBJ_SSCANF_BUFFER_SIZE, "%s", token);
1996
1962
tag.name = std::string(namebuf);
1997
1963
1998
1964
token += tag.name.size() + 1;
@@ -2016,12 +1982,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
2016
1982
for (size_t i = 0; i < static_cast<size_t>(ts.num_strings); ++i) {
2017
1983
char stringValueBuffer[TINYOBJ_SSCANF_BUFFER_SIZE];
2018
1984
2019
- #ifdef _MSC_VER
2020
- sscanf_s(token, "%s", stringValueBuffer,
2021
- (unsigned)_countof(stringValueBuffer));
2022
- #else
2023
- std::sscanf(token, "%s", stringValueBuffer);
2024
- #endif
1985
+ std::snprintf(stringValueBuffer, TINYOBJ_SSCANF_BUFFER_SIZE, "%s", token);
2025
1986
tag.stringValues[i] = stringValueBuffer;
2026
1987
token += tag.stringValues[i].size() + 1;
2027
1988
}
0 commit comments