monotone

monotone Mtn Source Tree

Root/luaext_globish.cc

1#include "base.hh"
2#include "lua.hh"
3
4#include "globish.hh"
5#include "sanity.hh"
6
7using std::string;
8
9LUAEXT(match, globish)
10{
11 const char *re = luaL_checkstring(L, -2);
12 const char *str = luaL_checkstring(L, -1);
13
14 bool result = false;
15 try {
16 string r(re);
17 string n;
18 string s(str);
19 result = globish_matcher(globish(r), globish(n))(s);
20 } catch (informative_failure & e) {
21 return luaL_error(L, e.what());
22 } catch (boost::bad_pattern & e) {
23 return luaL_error(L, e.what());
24 } catch (...) {
25 return luaL_error(L, "Unknown error.");
26 }
27 lua_pushboolean(L, result);
28 return 1;
29}
30
31
32
33// Local Variables:
34// mode: C++
35// fill-column: 76
36// c-file-style: "gnu"
37// indent-tabs-mode: nil
38// End:
39// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
40

Archive Download this file

Branches

Tags

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