local s = selection.match([[...]]); */
| 679 | |
| 680 | /* local s = selection.match([[...]]); */ |
| 681 | staticfn int |
| 682 | l_selection_match(lua_State *L) |
| 683 | { |
| 684 | int argc = lua_gettop(L); |
| 685 | struct selectionvar *sel = (struct selectionvar *) 0; |
| 686 | struct mapfragment *mf = (struct mapfragment *) 0; |
| 687 | int x, y; |
| 688 | |
| 689 | if (argc == 1) { |
| 690 | const char *err; |
| 691 | char *mapstr = dupstr(luaL_checkstring(L, 1)); |
| 692 | lua_pop(L, 1); |
| 693 | (void) l_selection_new(L); |
| 694 | sel = l_selection_check(L, 1); |
| 695 | |
| 696 | mf = mapfrag_fromstr(mapstr); |
| 697 | free(mapstr); |
| 698 | |
| 699 | if ((err = mapfrag_error(mf)) != NULL) { |
| 700 | nhl_error(L, err); |
| 701 | /*NOTREACHED*/ |
| 702 | } |
| 703 | |
| 704 | } else { |
| 705 | nhl_error(L, "wrong parameters"); |
| 706 | /*NOTREACHED*/ |
| 707 | } |
| 708 | |
| 709 | for (y = 0; y <= sel->hei; y++) |
| 710 | for (x = 1; x < sel->wid; x++) |
| 711 | selection_setpoint(x, y, sel, mapfrag_match(mf, x,y) ? 1 : 0); |
| 712 | |
| 713 | /* unless the (0, 1) coordinate is a match, this would wind up with a |
| 714 | selection with lx=COLNO, hx=0, etc, so fix the boundaries */ |
| 715 | selection_recalc_bounds(sel); |
| 716 | |
| 717 | mapfrag_free(&mf); |
| 718 | |
| 719 | return 1; |
| 720 | } |
| 721 | |
| 722 | |
| 723 | /* local s = selection.floodfill(x,y); */ |
nothing calls this directly
no test coverage detected