Regexes
- Added support for \< and \> for Solaris (thanks to Owen Clarke).
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <A3.h>
|
#include <A3.h>
|
||||||
|
#include <cmake.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
@@ -1012,7 +1013,11 @@ const A3 A3::expand (const A3& input) const
|
|||||||
{
|
{
|
||||||
expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom));
|
expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom));
|
||||||
expanded.push_back (Arg ("~", Arg::cat_op));
|
expanded.push_back (Arg ("~", Arg::cat_op));
|
||||||
|
#ifdef SOLARIS
|
||||||
|
expanded.push_back (Arg ("\\<" + value + "\\>", Arg::type_string, Arg::cat_rx));
|
||||||
|
#else
|
||||||
expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx));
|
expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// name.noword:value --> name !~ \bvalue\n
|
// name.noword:value --> name !~ \bvalue\n
|
||||||
@@ -1020,7 +1025,11 @@ const A3 A3::expand (const A3& input) const
|
|||||||
{
|
{
|
||||||
expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom));
|
expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom));
|
||||||
expanded.push_back (Arg ("!~", Arg::cat_op));
|
expanded.push_back (Arg ("!~", Arg::cat_op));
|
||||||
|
#ifdef SOLARIS
|
||||||
|
expanded.push_back (Arg ("\\<" + value + "\\>", Arg::type_string, Arg::cat_rx));
|
||||||
|
#else
|
||||||
expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx));
|
expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_A3_UNKNOWN_ATTMOD, mod);
|
throw format (STRING_A3_UNKNOWN_ATTMOD, mod);
|
||||||
|
|||||||
@@ -93,6 +93,17 @@ int main (int argc, char** argv)
|
|||||||
ut.pass (text + " =~ /\\bthe/");
|
ut.pass (text + " =~ /\\bthe/");
|
||||||
ut.pass (text + " =~ /the\\b/");
|
ut.pass (text + " =~ /the\\b/");
|
||||||
ut.pass (text + " =~ /\\bthe\\b/");
|
ut.pass (text + " =~ /\\bthe\\b/");
|
||||||
|
#else
|
||||||
|
#ifdef SOLARIS
|
||||||
|
RX r10 ("\\<the");
|
||||||
|
text = "this is the end.";
|
||||||
|
ut.ok (r10.match (text), text + " =~ /\\<the/");
|
||||||
|
|
||||||
|
RX r11 ("the\\>");
|
||||||
|
ut.ok (r11.match (text), text + " =~ /the\\>/");
|
||||||
|
|
||||||
|
RX r12 ("\\<the\\>");
|
||||||
|
ut.ok (r12.match (text), text + " =~ /\\<the\\>/");
|
||||||
#else
|
#else
|
||||||
RX r10 ("\\bthe");
|
RX r10 ("\\bthe");
|
||||||
text = "this is the end.";
|
text = "this is the end.";
|
||||||
@@ -103,6 +114,7 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
RX r12 ("\\bthe\\b");
|
RX r12 ("\\bthe\\b");
|
||||||
ut.ok (r12.match (text), text + " =~ /\\bthe\\b/");
|
ut.ok (r12.match (text), text + " =~ /\\bthe\\b/");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user