Language:
C     Change language:
Pastebin: 117018
Author: Anonymous
Subject: Untitled
Created: 2009-07-03 13:33:42
Download and save
Toggle line numbers
1static int str_sub (lua_State *L) { 
2  size_t l; 
3  const char *s = luaL_checklstring(L, 1, &l); 
4  ptrdiff_t start = posrelat(luaL_checkint32(L, 2), l); 
5  ptrdiff_t end = posrelat(luaL_optint32(L, 3, -1), l); 
6  if (start < 1) start = 1
7  if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; 
8  if (start <= end) 
9    lua_pushlstring(L, s+start-1, end-start+1); 
10  else lua_pushliteral(L, ""); 
11  return 1
12
13 
Thread:
[117018] Untitled by Anonymous at 2009-07-03 13:33:42
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.