Changeset 2248
- Timestamp:
- Nov 22, 2008, 10:25:45 PM (16 years ago)
- Location:
- code/branches/buildsystem/src/tolua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem/src/tolua/lua/package.lua
r2239 r2248 250 250 -- open input file, if any 251 251 if fn then 252 local st, msg = readfrom(flags.f) 252 local file 253 if flags.f then 254 if string.sub(flags.f, 1, 1) == '/' or string.sub(flags.f, 1, 1) == '\\' then 255 file = flags.f 256 else 257 file = flags.w..'/'..flags.f 258 end 259 else 260 file = flags.f 261 end 262 local st, msg = readfrom(file) 253 263 if not st then 254 error('#'..msg )264 error('#'..msg..' path: '..flags.f) 255 265 end 256 266 local _; _, _, ext = strfind(fn,".*%.(.*)$") -
code/branches/buildsystem/src/tolua/tolua.c
r2236 r2248 86 86 int main (int argc, char* argv[]) 87 87 { 88 char* working_directory = ""; 89 char* lua_source = ""; 90 88 91 #ifdef LUA_VERSION_NUM /* lua 5.1 */ 89 92 lua_State* L = luaL_newstate(); … … 102 105 lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); 103 106 104 char* working_directory = "";105 char* lua_source = "";106 107 107 108 if (argc==1) … … 163 164 char path[BUFSIZ]; 164 165 char file[BUFSIZ]; 165 166 if (lua_source[0] == '/' || lua_source[0] == '\\') 166 path[0] = '\0'; 167 file[0] = '\0'; 168 169 if (strlen(lua_source) > 0 && 170 lua_source[0] != '/' && 171 lua_source[0] != '\\' && 172 strlen(lua_source) > 1 && 173 lua_source[1] != ':') 167 174 { 168 strcpy(path, lua_source); 169 char* p = strrchr(path, '/'); 170 if (p == NULL) 171 p = strrchr(path, '\\'); 172 p = (p == NULL) ? path : p + 1; 173 strcpy(file, p); 174 *p = '\0'; 175 } 176 else 177 { 175 /* Relative path, prefix working directory */ 178 176 strcpy(path, working_directory); 179 strcpy(file, "all.lua"); 180 177 /* Make sure there is '\\' or '/' at the end of the path */ 181 178 if (strlen(path) > 0) 182 179 { … … 187 184 } 188 185 186 strcat(path, lua_source); 187 188 /* Extract the full path */ 189 { 190 char* p; 191 p = strrchr(path, '/'); 192 if (p == NULL) 193 p = strrchr(path, '\\'); 194 p = (p == NULL) ? path : p + 1; 195 strcpy(file, p); 196 *p = '\0'; 197 } 198 if (strlen(file) == 0) 199 strcpy(file, "all.lua"); 200 189 201 lua_pushstring(L, path); 190 202 lua_setglobal(L, "path"); 191 203 strcat(path, file); 204 #ifdef LUA_VERSION_NUM /* lua 5.1 */ 205 luaL_dofile(L, path); 206 #else 192 207 lua_dofile(L, path); 208 #endif 193 209 } 194 210 return 0;
Note: See TracChangeset
for help on using the changeset viewer.