亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lstrlib.cpp

?? 這是整套橫掃千軍3D版游戲的源碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/


#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define lstrlib_c
#define LUA_LIB

#include "lua.h"

#include "lauxlib.h"
#include "lualib.h"


/* macro to `unsign' a character */
#define uchar(c)        ((unsigned char)(c))



static int str_len (lua_State *L) {
  size_t l;
  luaL_checklstring(L, 1, &l);
  lua_pushinteger(L, l);
  return 1;
}


static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
  /* relative string position: negative means back from end */
  return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
}


static int str_sub (lua_State *L) {
  size_t l;
  const char *s = luaL_checklstring(L, 1, &l);
  ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
  ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
  if (start < 1) start = 1;
  if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
  if (start <= end)
    lua_pushlstring(L, s+start-1, end-start+1);
  else lua_pushliteral(L, "");
  return 1;
}


static int str_reverse (lua_State *L) {
  size_t l;
  luaL_Buffer b;
  const char *s = luaL_checklstring(L, 1, &l);
  luaL_buffinit(L, &b);
  while (l--) luaL_addchar(&b, s[l]);
  luaL_pushresult(&b);
  return 1;
}


static int str_lower (lua_State *L) {
  size_t l;
  size_t i;
  luaL_Buffer b;
  const char *s = luaL_checklstring(L, 1, &l);
  luaL_buffinit(L, &b);
  for (i=0; i<l; i++)
    luaL_addchar(&b, tolower(uchar(s[i])));
  luaL_pushresult(&b);
  return 1;
}


static int str_upper (lua_State *L) {
  size_t l;
  size_t i;
  luaL_Buffer b;
  const char *s = luaL_checklstring(L, 1, &l);
  luaL_buffinit(L, &b);
  for (i=0; i<l; i++)
    luaL_addchar(&b, toupper(uchar(s[i])));
  luaL_pushresult(&b);
  return 1;
}

static int str_rep (lua_State *L) {
  size_t l;
  luaL_Buffer b;
  const char *s = luaL_checklstring(L, 1, &l);
  int n = luaL_checkint(L, 2);
  luaL_buffinit(L, &b);
  while (n-- > 0)
    luaL_addlstring(&b, s, l);
  luaL_pushresult(&b);
  return 1;
}


static int str_byte (lua_State *L) {
  size_t l;
  const char *s = luaL_checklstring(L, 1, &l);
  ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
  ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
  int n, i;
  if (posi <= 0) posi = 1;
  if ((size_t)pose > l) pose = l;
  if (posi > pose) return 0;  /* empty interval; return no values */
  n = (int)(pose -  posi + 1);
  if (posi + n <= pose)  /* overflow? */
    luaL_error(L, "string slice too long");
  luaL_checkstack(L, n, "string slice too long");
  for (i=0; i<n; i++)
    lua_pushinteger(L, uchar(s[posi+i-1]));
  return n;
}


static int str_char (lua_State *L) {
  int n = lua_gettop(L);  /* number of arguments */
  int i;
  luaL_Buffer b;
  luaL_buffinit(L, &b);
  for (i=1; i<=n; i++) {
    int c = luaL_checkint(L, i);
    luaL_argcheck(L, uchar(c) == c, i, "invalid value");
    luaL_addchar(&b, uchar(c));
  }
  luaL_pushresult(&b);
  return 1;
}


static int writer (lua_State *L, const void* b, size_t size, void* B) {
  (void)L;
  luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
  return 0;
}


static int str_dump (lua_State *L) {
  luaL_Buffer b;
  luaL_checktype(L, 1, LUA_TFUNCTION);
  lua_settop(L, 1);
  luaL_buffinit(L,&b);
  if (lua_dump(L, writer, &b) != 0)
    luaL_error(L, "unable to dump given function");
  luaL_pushresult(&b);
  return 1;
}



/*
** {======================================================
** PATTERN MATCHING
** =======================================================
*/


#define CAP_UNFINISHED	(-1)
#define CAP_POSITION	(-2)

typedef struct MatchState {
  const char *src_init;  /* init of source string */
  const char *src_end;  /* end (`\0') of source string */
  lua_State *L;
  int level;  /* total number of captures (finished or unfinished) */
  struct {
    const char *init;
    ptrdiff_t len;
  } capture[LUA_MAXCAPTURES];
} MatchState;


#define L_ESC		'%'
#define SPECIALS	"^$*+?.([%-"


static int check_capture (MatchState *ms, int l) {
  l -= '1';
  if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
    return luaL_error(ms->L, "invalid capture index");
  return l;
}


static int capture_to_close (MatchState *ms) {
  int level = ms->level;
  for (level--; level>=0; level--)
    if (ms->capture[level].len == CAP_UNFINISHED) return level;
  return luaL_error(ms->L, "invalid pattern capture");
}


static const char *classend (MatchState *ms, const char *p) {
  switch (*p++) {
    case L_ESC: {
      if (*p == '\0')
        luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
      return p+1;
    }
    case '[': {
      if (*p == '^') p++;
      do {  /* look for a `]' */
        if (*p == '\0')
          luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
        if (*(p++) == L_ESC && *p != '\0')
          p++;  /* skip escapes (e.g. `%]') */
      } while (*p != ']');
      return p+1;
    }
    default: {
      return p;
    }
  }
}


static int match_class (int c, int cl) {
  int res;
  switch (tolower(cl)) {
    case 'a' : res = isalpha(c); break;
    case 'c' : res = iscntrl(c); break;
    case 'd' : res = isdigit(c); break;
    case 'l' : res = islower(c); break;
    case 'p' : res = ispunct(c); break;
    case 's' : res = isspace(c); break;
    case 'u' : res = isupper(c); break;
    case 'w' : res = isalnum(c); break;
    case 'x' : res = isxdigit(c); break;
    case 'z' : res = (c == 0); break;
    default: return (cl == c);
  }
  return (islower(cl) ? res : !res);
}


static int matchbracketclass (int c, const char *p, const char *ec) {
  int sig = 1;
  if (*(p+1) == '^') {
    sig = 0;
    p++;  /* skip the `^' */
  }
  while (++p < ec) {
    if (*p == L_ESC) {
      p++;
      if (match_class(c, uchar(*p)))
        return sig;
    }
    else if ((*(p+1) == '-') && (p+2 < ec)) {
      p+=2;
      if (uchar(*(p-2)) <= c && c <= uchar(*p))
        return sig;
    }
    else if (uchar(*p) == c) return sig;
  }
  return !sig;
}


static int singlematch (int c, const char *p, const char *ep) {
  switch (*p) {
    case '.': return 1;  /* matches any char */
    case L_ESC: return match_class(c, uchar(*(p+1)));
    case '[': return matchbracketclass(c, p, ep-1);
    default:  return (uchar(*p) == c);
  }
}


static const char *match (MatchState *ms, const char *s, const char *p);


static const char *matchbalance (MatchState *ms, const char *s,
                                   const char *p) {
  if (*p == 0 || *(p+1) == 0)
    luaL_error(ms->L, "unbalanced pattern");
  if (*s != *p) return NULL;
  else {
    int b = *p;
    int e = *(p+1);
    int cont = 1;
    while (++s < ms->src_end) {
      if (*s == e) {
        if (--cont == 0) return s+1;
      }
      else if (*s == b) cont++;
    }
  }
  return NULL;  /* string ends out of balance */
}


static const char *max_expand (MatchState *ms, const char *s,
                                 const char *p, const char *ep) {
  ptrdiff_t i = 0;  /* counts maximum expand for item */
  while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
    i++;
  /* keeps trying to match with the maximum repetitions */
  while (i>=0) {
    const char *res = match(ms, (s+i), ep+1);
    if (res) return res;
    i--;  /* else didn't match; reduce 1 repetition to try again */
  }
  return NULL;
}


static const char *min_expand (MatchState *ms, const char *s,
                                 const char *p, const char *ep) {
  for (;;) {
    const char *res = match(ms, s, ep+1);
    if (res != NULL)
      return res;
    else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
      s++;  /* try with one more repetition */
    else return NULL;
  }
}


static const char *start_capture (MatchState *ms, const char *s,
                                    const char *p, int what) {
  const char *res;
  int level = ms->level;
  if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
  ms->capture[level].init = s;
  ms->capture[level].len = what;
  ms->level = level+1;
  if ((res=match(ms, s, p)) == NULL)  /* match failed? */
    ms->level--;  /* undo capture */
  return res;
}


static const char *end_capture (MatchState *ms, const char *s,
                                  const char *p) {
  int l = capture_to_close(ms);
  const char *res;
  ms->capture[l].len = s - ms->capture[l].init;  /* close capture */
  if ((res = match(ms, s, p)) == NULL)  /* match failed? */
    ms->capture[l].len = CAP_UNFINISHED;  /* undo capture */
  return res;
}


static const char *match_capture (MatchState *ms, const char *s, int l) {
  size_t len;
  l = check_capture(ms, l);
  len = ms->capture[l].len;
  if ((size_t)(ms->src_end-s) >= len &&
      memcmp(ms->capture[l].init, s, len) == 0)
    return s+len;
  else return NULL;
}


static const char *match (MatchState *ms, const char *s, const char *p) {
  init: /* using goto's to optimize tail recursion */
  switch (*p) {
    case '(': {  /* start capture */
      if (*(p+1) == ')')  /* position capture? */
        return start_capture(ms, s, p+2, CAP_POSITION);
      else
        return start_capture(ms, s, p+1, CAP_UNFINISHED);
    }
    case ')': {  /* end capture */
      return end_capture(ms, s, p+1);
    }
    case L_ESC: {
      switch (*(p+1)) {
        case 'b': {  /* balanced string? */
          s = matchbalance(ms, s, p+2);
          if (s == NULL) return NULL;
          p+=4; goto init;  /* else return match(ms, s, p+4); */
        }
        case 'f': {  /* frontier? */
          const char *ep; char previous;
          p += 2;
          if (*p != '[')
            luaL_error(ms->L, "missing " LUA_QL("[") " after "
                               LUA_QL("%%f") " in pattern");
          ep = classend(ms, p);  /* points to what is next */
          previous = (s == ms->src_init) ? '\0' : *(s-1);
          if (matchbracketclass(uchar(previous), p, ep-1) ||
             !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
          p=ep; goto init;  /* else return match(ms, s, ep); */
        }
        default: {
          if (isdigit(uchar(*(p+1)))) {  /* capture results (%0-%9)? */
            s = match_capture(ms, s, uchar(*(p+1)));
            if (s == NULL) return NULL;
            p+=2; goto init;  /* else return match(ms, s, p+2) */
          }
          goto dflt;  /* case default */
        }
      }
    }
    case '\0': {  /* end of pattern */
      return s;  /* match succeeded */
    }
    case '$': {
      if (*(p+1) == '\0')  /* is the `$' the last char in pattern? */
        return (s == ms->src_end) ? s : NULL;  /* check end of string */
      else goto dflt;
    }
    default: dflt: {  /* it is a pattern item */
      const char *ep = classend(ms, p);  /* points to what is next */
      int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
      switch (*ep) {
        case '?': {  /* optional */
          const char *res;
          if (m && ((res=match(ms, s+1, ep+1)) != NULL))
            return res;
          p=ep+1; goto init;  /* else return match(ms, s, ep+1); */
        }
        case '*': {  /* 0 or more repetitions */
          return max_expand(ms, s, p, ep);
        }
        case '+': {  /* 1 or more repetitions */
          return (m ? max_expand(ms, s+1, p, ep) : NULL);
        }
        case '-': {  /* 0 or more repetitions (minimum) */
          return min_expand(ms, s, p, ep);
        }
        default: {
          if (!m) return NULL;
          s++; p=ep; goto init;  /* else return match(ms, s+1, ep); */
        }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本高清成人免费播放| 欧美大片在线观看| 国产女主播在线一区二区| 日韩久久一区二区| 成人一区二区三区视频| 国产片一区二区| 国产成人免费av在线| 国产日产欧美精品一区二区三区| 热久久一区二区| 欧美日韩专区在线| 日韩精品视频网| 欧美性生活一区| 91麻豆视频网站| 自拍偷拍国产亚洲| 欧美无砖专区一中文字| 国产精选一区二区三区| 国产欧美精品一区aⅴ影院| 成人午夜av电影| 亚洲欧美色一区| 在线观看一区二区视频| 日韩国产精品久久久| 日韩一区二区精品| 国产成人啪午夜精品网站男同| 欧美国产精品一区二区| 色先锋久久av资源部| 午夜成人在线视频| 国产日韩欧美a| 色94色欧美sute亚洲线路二| 亚洲一区免费观看| 欧美一级视频精品观看| 国产一区二三区好的| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 国产蜜臀av在线一区二区三区| 九一九一国产精品| 日本一区二区视频在线观看| 91蜜桃传媒精品久久久一区二区| 日韩专区欧美专区| 国产无一区二区| 欧美性猛交xxxx乱大交退制版| 色久综合一二码| 日本不卡的三区四区五区| 久久蜜桃一区二区| 在线精品国精品国产尤物884a| 久久精品免费观看| 国产精品久久久久一区二区三区 | 中文字幕一区在线观看视频| 欧美日韩免费一区二区三区| 国产在线精品一区二区夜色| 亚洲色图一区二区| 日韩视频免费观看高清完整版| 波多野结衣中文字幕一区二区三区| 国产精品三级在线观看| 欧美麻豆精品久久久久久| 国产成人亚洲综合a∨婷婷图片| 亚洲一区二区三区视频在线 | 久久只精品国产| 91久久奴性调教| 国产老女人精品毛片久久| 亚洲成人激情av| 国产精品欧美极品| 精品国产网站在线观看| 欧美影院一区二区| www.在线成人| 蜜臀av性久久久久av蜜臀妖精| 国产精品久久精品日日| 日韩一级完整毛片| 在线中文字幕一区二区| 丁香天五香天堂综合| 日韩在线观看一区二区| 中文字幕亚洲欧美在线不卡| 精品粉嫩aⅴ一区二区三区四区| 欧美日韩一级大片网址| 99re66热这里只有精品3直播| 国精品**一区二区三区在线蜜桃| 日韩国产欧美三级| 五月综合激情网| 一级做a爱片久久| 国产精品超碰97尤物18| 久久精品亚洲麻豆av一区二区 | 亚洲狠狠丁香婷婷综合久久久| 久久久久9999亚洲精品| 精品国产伦理网| 欧美xingq一区二区| 日韩欧美国产麻豆| 欧美大片在线观看| 欧美日韩一区在线观看| 欧美色图天堂网| 色婷婷精品久久二区二区蜜臀av| 国产一区二区三区蝌蚪| 久久er精品视频| 国内精品写真在线观看| 国产一区二区三区在线观看免费 | 美女看a上一区| 午夜日韩在线电影| 亚洲高清免费观看 | 国产精品1区2区| 奇米色一区二区三区四区| 亚洲高清一区二区三区| 亚洲第一福利一区| 午夜电影一区二区三区| 免费成人在线网站| 久久99精品国产| 国产原创一区二区| 国产99久久久久| 97久久精品人人做人人爽| 色婷婷综合久久久久中文一区二区 | 欧美成人欧美edvon| 精品日韩欧美一区二区| 国产日产亚洲精品系列| 最新国产成人在线观看| 亚洲午夜国产一区99re久久| 丝袜亚洲精品中文字幕一区| 免费三级欧美电影| 国产在线精品不卡| 国产激情一区二区三区| 99视频精品免费视频| 在线观看中文字幕不卡| 欧美精品欧美精品系列| 欧美成人a在线| 亚洲欧洲性图库| 亚洲妇熟xx妇色黄| 国内外精品视频| 色婷婷av一区二区| 欧美一级理论性理论a| 91精品国产91久久综合桃花| 欧美电影免费观看高清完整版在 | 国产精品日韩成人| 夜夜嗨av一区二区三区中文字幕| 欧美艳星brazzers| 91精品国产综合久久香蕉的特点| 久久一区二区三区国产精品| 亚洲色大成网站www久久九九| 午夜在线成人av| 粉嫩嫩av羞羞动漫久久久| 欧美亚一区二区| 久久久影视传媒| 亚洲成a人v欧美综合天堂| 国产精品影音先锋| 欧美性猛片aaaaaaa做受| 久久久亚洲综合| 亚洲精品精品亚洲| 国内一区二区在线| 欧美日韩一级片网站| 中文字幕不卡三区| 久久99日本精品| 在线日韩av片| 国产精品福利电影一区二区三区四区| 亚洲第一综合色| 99精品热视频| 精品国产91亚洲一区二区三区婷婷 | 日韩在线观看一区二区| voyeur盗摄精品| 久久一日本道色综合| 亚洲欧美日韩国产综合| 免费成人你懂的| 69堂成人精品免费视频| 亚洲一区二区三区在线看| 91浏览器在线视频| 亚洲人成在线观看一区二区| 成人黄色小视频| 亚洲丝袜另类动漫二区| av一区二区三区黑人| 亚洲日本va在线观看| 99热精品一区二区| 中文字幕日韩精品一区| 91啪亚洲精品| 一区二区在线观看免费| 一本大道久久a久久精二百| 一区二区三区视频在线看| 欧美色视频一区| 五月天精品一区二区三区| 6080yy午夜一二三区久久| 日韩av一区二区三区| 日韩视频一区二区三区在线播放 | 亚洲欧洲日产国产综合网| 91在线视频播放| 亚洲资源中文字幕| 欧美精品一卡二卡| 青草av.久久免费一区| 久久久久99精品一区| 成人av免费观看| 玉米视频成人免费看| 91精品国产手机| 国产尤物一区二区| 国产精品麻豆99久久久久久| 色噜噜狠狠色综合中国| 偷偷要91色婷婷| 欧美精品一区二区三区一线天视频| 国产成人免费av在线| 樱桃视频在线观看一区| 欧美福利视频导航| 国产麻豆精品在线观看| 亚洲人成伊人成综合网小说| 欧美久久久一区| 国产在线播放一区| 一区二区在线观看av| 日韩欧美专区在线| jizz一区二区| 日本中文一区二区三区| 国产精品亲子伦对白|