monotone

monotone Mtn Source Tree

Root/luaext_globish.cc

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

Archive Download this file

Branches

Tags

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