|
@@ -28,6 +28,7 @@
|
|
|
|
|
|
#include "scripts/graphics.lua.h"
|
|
#include "scripts/graphics.lua.h"
|
|
#include <cassert>
|
|
#include <cassert>
|
|
|
|
+#include <cstring>
|
|
|
|
|
|
namespace love
|
|
namespace love
|
|
{
|
|
{
|
|
@@ -403,6 +404,19 @@ int w_newShader(lua_State *L)
|
|
lua_call(L, 1, 1);
|
|
lua_call(L, 1, 1);
|
|
lua_replace(L, i);
|
|
lua_replace(L, i);
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // Check if the argument looks like a filepath - we want a nicer
|
|
|
|
+ // error for misspelled filepath arguments.
|
|
|
|
+ size_t slen = 0;
|
|
|
|
+ const char *str = lua_tolstring(L, i, &slen);
|
|
|
|
+ if (slen > 0 && slen < 256 && !strchr(str, '\n'))
|
|
|
|
+ {
|
|
|
|
+ const char *ext = strchr(str, '.');
|
|
|
|
+ if (ext != nullptr && !strchr(ext, ';') && !strchr(ext, ' '))
|
|
|
|
+ return luaL_error(L, "Could not open file %s. Does not exist.", str);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
bool has_arg1 = lua_isstring(L, 1);
|
|
bool has_arg1 = lua_isstring(L, 1);
|