Branimir Karadžić 7 years ago
parent
commit
5579ac4686
4 changed files with 29 additions and 17 deletions
  1. 22 12
      tools/geometryc/geometryc.cpp
  2. 1 1
      tools/shaderc/shaderc.cpp
  3. 0 2
      tools/shaderc/shaderc.h
  4. 6 2
      tools/shaderc/shaderc_glsl.cpp

+ 22 - 12
tools/geometryc/geometryc.cpp

@@ -450,7 +450,10 @@ int main(int _argc, const char* _argv[])
 	const char* scaleArg = cmdLine.findOption('s', "scale");
 	if (NULL != scaleArg)
 	{
-		scale = (float)atof(scaleArg);
+		if (!bx::fromString(&scale, scaleArg))
+		{
+			scale = 1.0f;
+		}
 	}
 
 	bool compress = cmdLine.hasArg('c', "compress");
@@ -640,9 +643,9 @@ int main(int _argc, const char* _argv[])
 				if (0 == bx::strCmp(argv[0], "vn") )
 				{
 					Vector3 normal;
-					normal.x = (float)atof(argv[1]);
-					normal.y = (float)atof(argv[2]);
-					normal.z = (float)atof(argv[3]);
+					bx::fromString(&normal.x, argv[1]);
+					bx::fromString(&normal.y, argv[2]);
+					bx::fromString(&normal.z, argv[3]);
 
 					normals.push_back(normal);
 				}
@@ -658,17 +661,19 @@ int main(int _argc, const char* _argv[])
 				else if (0 == bx::strCmp(argv[0], "vt") )
 				{
 					Vector3 texcoord;
-					texcoord.x = (float)atof(argv[1]);
 					texcoord.y = 0.0f;
 					texcoord.z = 0.0f;
+
+					bx::fromString(&texcoord.x, argv[1]);
+
 					switch (argc)
 					{
 					case 4:
-						texcoord.z = (float)atof(argv[3]);
+						bx::fromString(&texcoord.z, argv[3]);
 						BX_FALLTHROUGH;
 
 					case 3:
-						texcoord.y = (float)atof(argv[2]);
+						bx::fromString(&texcoord.y, argv[2]);
 						break;
 
 					default:
@@ -679,13 +684,18 @@ int main(int _argc, const char* _argv[])
 				}
 				else
 				{
-					float px = (float)atof(argv[1]);
-					float py = (float)atof(argv[2]);
-					float pz = (float)atof(argv[3]);
-					float pw = 1.0f;
+					float px, py, pz, pw;
+					bx::fromString(&px, argv[1]);
+					bx::fromString(&py, argv[2]);
+					bx::fromString(&pz, argv[3]);
+
 					if (argc > 4)
 					{
-						pw = (float)atof(argv[4]);
+						bx::fromString(&pw, argv[4]);
+					}
+					else
+					{
+						pw = 1.0f;
 					}
 
 					float invW = scale/pw;

+ 1 - 1
tools/shaderc/shaderc.cpp

@@ -922,7 +922,7 @@ namespace bgfx
 			}
 			else
 			{
-				glsl = atoi(profile);
+				bx::fromString(&glsl, profile);
 			}
 		}
 		else

+ 0 - 2
tools/shaderc/shaderc.h

@@ -45,9 +45,7 @@ namespace bgfx
 #endif // SHADERC_CONFIG_HLSL
 
 #include <alloca.h>
-#include <stdio.h>
 #include <stdint.h>
-#include <stdlib.h>
 #include <string.h>
 #include <algorithm>
 #include <string>

+ 6 - 2
tools/shaderc/shaderc_glsl.cpp

@@ -178,7 +178,9 @@ namespace bgfx { namespace glsl
 						char arraySize[32];
 						bx::StringView end = bx::strFind(bx::StringView(array.getPtr(), int32_t(eol.getPtr()-array.getPtr() ) ), "]");
 						bx::strCopy(arraySize, int32_t(end.getPtr()-array.getPtr() ), array.getPtr()+1);
-						num = uint8_t(atoi(arraySize) );
+						uint32_t tmp;
+						bx::fromString(&tmp, arraySize);
+						num = uint8_t(tmp);
 					}
 					else
 					{
@@ -239,7 +241,9 @@ namespace bgfx { namespace glsl
 						char arraySize[32];
 						bx::StringView arrayEnd = bx::strFind(bx::StringView(array.getPtr(), int32_t(eol.getPtr()-array.getPtr() ) ), "]");
 						bx::strCopy(arraySize, int32_t(arrayEnd.getPtr()-array.getPtr() ), array.getPtr()+1);
-						num = uint8_t(atoi(arraySize) );
+						uint32_t tmp;
+						bx::fromString(&tmp, arraySize);
+						num = uint8_t(tmp);
 					}
 					else
 					{