Handle anychar (.) correctly with bounded repeaat regex expression.
[crypto.git] / lib / silcutil / tests / test_silcregex.c
index 0e7f4527125406c92323ec375721b69a91cec1cf..41c51ad3fc969a19d036f053b76b48b9946071a3 100644 (file)
@@ -18,6 +18,22 @@ int main(int argc, char **argv)
     silc_log_set_debug_string("*regex*,*errno*");
   }
 
+  regex = ".{5}";
+  SILC_LOG_DEBUG(("Regex %s", regex));
+  string = "abcdefghijklmn";
+  SILC_LOG_DEBUG(("Match %s", string));
+  if (!silc_regex(string, regex, &bmatch, NULL))
+    goto err;
+  silc_buffer_printf(&bmatch, TRUE);
+
+  regex = ".....";
+  SILC_LOG_DEBUG(("Regex %s", regex));
+  string = "abcdefghijklmn";
+  SILC_LOG_DEBUG(("Match %s", string));
+  if (!silc_regex(string, regex, &bmatch, NULL))
+    goto err;
+  silc_buffer_printf(&bmatch, TRUE);
+
   regex = "^a{0}$";
   SILC_LOG_DEBUG(("Regex %s", regex));
   string = "";
@@ -184,15 +200,6 @@ int main(int argc, char **argv)
     goto err;
 
 
-  regex = "^a{2,3}$";
-  SILC_LOG_DEBUG(("Regex %s", regex));
-  string = "aaa";
-  SILC_LOG_DEBUG(("Match %s", string));
-  if (!silc_regex(string, regex, &bmatch, NULL))
-    goto err;
-  silc_file_write(1, silc_buffer_data(&bmatch), silc_buffer_len(&bmatch));
-  fflush(stdout);
-
   regex = "(H..).(o..)";
   SILC_LOG_DEBUG(("Regex %s", regex));
   if (!silc_regex_compile(&reg, regex, 0))