lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hallo,

Goetz.Kluge@infineon.com wrote:

static int str_or (lua_State *L) {
/* 2004-03-31 Goetz Kluge: string.orbit(str1,str2) */
 size_t l1;
 size_t l2;
 size_t i;
 luaL_Buffer b;
 const unsigned char *s1 = luaL_checklstring(L, 1, &l1);
 const unsigned char *s2 = luaL_checklstring(L, 2, &l2);
if (l1 < l2) l1 = l2;

Shouldn't it be the other way around? This way you are using the size of the largest string, not the smallest's.

 luaL_buffinit(L, &b);
 for (i=0; i<l1; i++)
   luaL_putchar(&b,(s1[i] | s2[i]));
 luaL_pushresult(&b);
 return 1;
}


-alex