Lines Matching refs:s
45 const char *s = luaL_checklstring(L, 1, &l); in str_sub() local
51 lua_pushlstring(L, s+start-1, end-start+1); in str_sub()
60 const char *s = luaL_checklstring(L, 1, &l); in str_reverse() local
62 while (l--) luaL_addchar(&b, s[l]); in str_reverse()
72 const char *s = luaL_checklstring(L, 1, &l); in str_lower() local
75 luaL_addchar(&b, tolower(uchar(s[i]))); in str_lower()
85 const char *s = luaL_checklstring(L, 1, &l); in str_upper() local
88 luaL_addchar(&b, toupper(uchar(s[i]))); in str_upper()
96 const char *s = luaL_checklstring(L, 1, &l); in str_rep() local
100 luaL_addlstring(&b, s, l); in str_rep()
108 const char *s = luaL_checklstring(L, 1, &l); in str_byte() local
120 lua_pushinteger(L, uchar(s[posi+i-1])); in str_byte()
278 static const char *match (MatchState *ms, const char *s, const char *p);
281 static const char *matchbalance (MatchState *ms, const char *s, in matchbalance() argument
285 if (*s != *p) return NULL; in matchbalance()
290 while (++s < ms->src_end) { in matchbalance()
291 if (*s == e) { in matchbalance()
292 if (--cont == 0) return s+1; in matchbalance()
294 else if (*s == b) cont++; in matchbalance()
301 static const char *max_expand (MatchState *ms, const char *s, in max_expand() argument
304 while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep)) in max_expand()
308 const char *res = match(ms, (s+i), ep+1); in max_expand()
316 static const char *min_expand (MatchState *ms, const char *s, in min_expand() argument
319 const char *res = match(ms, s, ep+1); in min_expand()
322 else if (s<ms->src_end && singlematch(uchar(*s), p, ep)) in min_expand()
323 s++; /* try with one more repetition */ in min_expand()
329 static const char *start_capture (MatchState *ms, const char *s, in start_capture() argument
334 ms->capture[level].init = s; in start_capture()
337 if ((res=match(ms, s, p)) == NULL) /* match failed? */ in start_capture()
343 static const char *end_capture (MatchState *ms, const char *s, in end_capture() argument
347 ms->capture[l].len = s - ms->capture[l].init; /* close capture */ in end_capture()
348 if ((res = match(ms, s, p)) == NULL) /* match failed? */ in end_capture()
354 static const char *match_capture (MatchState *ms, const char *s, int l) { in match_capture() argument
358 if ((size_t)(ms->src_end-s) >= len && in match_capture()
359 memcmp(ms->capture[l].init, s, len) == 0) in match_capture()
360 return s+len; in match_capture()
365 static const char *match (MatchState *ms, const char *s, const char *p) { in match() argument
370 return start_capture(ms, s, p+2, CAP_POSITION); in match()
372 return start_capture(ms, s, p+1, CAP_UNFINISHED); in match()
375 return end_capture(ms, s, p+1); in match()
380 s = matchbalance(ms, s, p+2); in match()
381 if (s == NULL) return NULL; in match()
391 previous = (s == ms->src_init) ? '\0' : *(s-1); in match()
393 !matchbracketclass(uchar(*s), p, ep-1)) return NULL; in match()
398 s = match_capture(ms, s, uchar(*(p+1))); in match()
399 if (s == NULL) return NULL; in match()
407 return s; /* match succeeded */ in match()
411 return (s == ms->src_end) ? s : NULL; /* check end of string */ in match()
416 int m = s<ms->src_end && singlematch(uchar(*s), p, ep); in match()
420 if (m && ((res=match(ms, s+1, ep+1)) != NULL)) in match()
425 return max_expand(ms, s, p, ep); in match()
428 return (m ? max_expand(ms, s+1, p, ep) : NULL); in match()
431 return min_expand(ms, s, p, ep); in match()
435 s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ in match()
466 static void push_onecapture (MatchState *ms, int i, const char *s, in push_onecapture() argument
470 lua_pushlstring(ms->L, s, e - s); /* add whole match */ in push_onecapture()
485 static int push_captures (MatchState *ms, const char *s, const char *e) { in push_captures() argument
487 int nlevels = (ms->level == 0 && s) ? 1 : ms->level; in push_captures()
490 push_onecapture(ms, i, s, e); in push_captures()
497 const char *s = luaL_checklstring(L, 1, &l1); in str_find_aux() local
505 const char *s2 = lmemfind(s+init, l1-init, p, l2); in str_find_aux()
507 lua_pushinteger(L, s2-s+1); in str_find_aux()
508 lua_pushinteger(L, s2-s+l2); in str_find_aux()
515 const char *s1=s+init; in str_find_aux()
517 ms.src_init = s; in str_find_aux()
518 ms.src_end = s+l1; in str_find_aux()
524 lua_pushinteger(L, s1-s+1); /* start */ in str_find_aux()
525 lua_pushinteger(L, res-s); /* end */ in str_find_aux()
551 const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); in gmatch_aux() local
555 ms.src_init = s; in gmatch_aux()
556 ms.src_end = s+ls; in gmatch_aux()
557 for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); in gmatch_aux()
563 lua_Integer newstart = e-s; in gmatch_aux()
590 static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, in add_s() argument
602 luaL_addlstring(b, s, e - s); in add_s()
604 push_onecapture(ms, news[i] - '1', s, e); in add_s()
612 static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, in add_value() argument
618 add_s(ms, b, s, e); in add_value()
624 n = push_captures(ms, s, e); in add_value()
629 push_onecapture(ms, 0, s, e); in add_value()
636 lua_pushlstring(L, s, e - s); /* keep original text */ in add_value()
698 const char *s = luaL_checklstring(L, arg, &l); in addquoted() local
701 switch (*s) { in addquoted()
704 luaL_addchar(b, *s); in addquoted()
716 luaL_addchar(b, *s); in addquoted()
720 s++; in addquoted()
801 const char *s = luaL_checklstring(L, arg, &l); in str_format() local
810 sprintf(buff, form, s); in str_format()