Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2248 for code/branches


Ignore:
Timestamp:
Nov 22, 2008, 10:25:45 PM (16 years ago)
Author:
rgrieder
Message:
  • Bugfix in tolua.c: Paths like "D:\" weren't considered absolute paths.
  • Bugfix in package.lua: Package file's relativity to working directory got forgotten.
Location:
code/branches/buildsystem/src/tolua
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem/src/tolua/lua/package.lua

    r2239 r2248  
    250250    -- open input file, if any
    251251    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)
    253263        if not st then
    254             error('#'..msg)
     264            error('#'..msg..' path: '..flags.f)
    255265        end
    256266        local _; _, _, ext = strfind(fn,".*%.(.*)$")
  • code/branches/buildsystem/src/tolua/tolua.c

    r2236 r2248  
    8686int main (int argc, char* argv[])
    8787{
     88 char* working_directory = "";
     89 char* lua_source = "";
     90
    8891 #ifdef LUA_VERSION_NUM /* lua 5.1 */
    8992 lua_State* L = luaL_newstate();
     
    102105 lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION");
    103106
    104  char* working_directory = "";
    105  char* lua_source = "";
    106107
    107108 if (argc==1)
     
    163164  char path[BUFSIZ];
    164165  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] != ':')
    167174  {
    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 */
    178176   strcpy(path, working_directory);
    179    strcpy(file, "all.lua");
    180 
     177   /* Make sure there is '\\' or '/' at the end of the path */
    181178   if (strlen(path) > 0)
    182179   {
     
    187184  }
    188185
     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
    189201  lua_pushstring(L, path);
    190202  lua_setglobal(L, "path");
    191203  strcat(path, file);
     204#ifdef LUA_VERSION_NUM /* lua 5.1 */
     205  luaL_dofile(L, path);
     206#else
    192207  lua_dofile(L, path);
     208#endif
    193209 }
    194210 return 0;
Note: See TracChangeset for help on using the changeset viewer.