monotone

monotone Mtn Source Tree

Root/src/luaext_globish.cc

1// Copyright (C) 2006 Timothy Brownawell <tbrownaw@gmail.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#include "base.hh"
11#include "lua.hh"
12#include "globish.hh"
13#include "sanity.hh"
14
15using std::string;
16
17LUAEXT(match, globish)
18{
19 const char *re = luaL_checkstring(LS, -2);
20 const char *str = luaL_checkstring(LS, -1);
21
22 bool result = false;
23 try {
24 globish g(re, origin::user);
25 result = g.matches(str);
26 } catch (recoverable_failure & e) {
27 return luaL_error(LS, e.what());
28 } catch (...) {
29 return luaL_error(LS, "Unknown error.");
30 }
31 lua_pushboolean(LS, result);
32 return 1;
33}
34
35// Local Variables:
36// mode: C++
37// fill-column: 76
38// c-file-style: "gnu"
39// indent-tabs-mode: nil
40// End:
41// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status