Beispiel #1
0
/*
** Main match function
*/
static int lp_match (lua_State *L) {
  Capture capture[INITCAPSIZE];
  const char *r;
  size_t l;
  Pattern *p = (getpatt(L, 1, NULL), getpattern(L, 1));
  Instruction *code = (p->code != NULL) ? p->code : prepcompile(L, p, 1);
  const char *s = luaL_checklstring(L, SUBJIDX, &l);
  size_t i = initposition(L, l);
  int ptop = lua_gettop(L);
  lua_pushnil(L);  /* initialize subscache */
  lua_pushlightuserdata(L, capture);  /* initialize caplistidx */
  lua_getfenv(L, 1);  /* initialize penvidx */
  r = match(L, s, s + i, s + l, code, capture, ptop);
  if (r == NULL) {
    lua_pushnil(L);
    return 1;
  }
  return getcaptures(L, s, r, ptop);
}
Beispiel #2
0
/*
  int main() {
*/
int memocheck() {
  FILE *fp;
  char line[MAXCHARSIZE];
  char *ret;
  int i;

  /*メモしてあるファイルは memo.txt として読み込む*/
  fp = fopen("memo.txt","r");

  if(fp==NULL){/*memo.txtが見つからなかった*/
  fprintf(stderr,"ERROR! : memo.txtを作成し、商品名を入力してください\n");
  return -1;
}
  do {
    ret = fgets(line,MAXCHARSIZE,fp);
    if( ret != NULL ) {
      tokenAdd(line);
    }
  } while( ret != NULL );
  fclose(fp);

  initshopitemlist();
  addshopitemlist();
  initposition();
  for(i = 0; i < maxmenucount; i++) {
    position[i] = whereitem(menu[i]);

    printf("-----Memo Result-----\n");
    if(position[i] == -1) {
      printf("「%s」 は売ってないか見つかりませんでした.\n",menu[i]);
    } else {
      printf("menu[%d] = %s  position = %3d\n",i,menu[i],position[i]);
    }
    printf("---------------------\n");
  }
  
    return 0;
  
}