summaryrefslogtreecommitdiff
path: root/src/scanners.re
diff options
context:
space:
mode:
Diffstat (limited to 'src/scanners.re')
-rw-r--r--src/scanners.re38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/scanners.re b/src/scanners.re
index 5ac7c15..71103f6 100644
--- a/src/scanners.re
+++ b/src/scanners.re
@@ -1,15 +1,12 @@
-#include "scanners.h"
+#include <stdlib.h>
#define SCAN_DATA \
const unsigned char *marker = NULL; \
- const unsigned char *p = c->data + offset; \
const unsigned char *start = p; \
- const unsigned char *end = c->data + c->len
/*!re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = p;
- re2c:define:YYLIMIT = end;
re2c:define:YYMARKER = marker;
re2c:define:YYCTXMARKER = marker;
re2c:yyfill:enable = 0;
@@ -62,7 +59,7 @@
*/
// Try to match URI autolink after first <, returning number of chars matched.
-extern int scan_autolink_uri(chunk *c, int offset)
+extern int _scan_autolink_uri(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -72,7 +69,7 @@ extern int scan_autolink_uri(chunk *c, int offset)
}
// Try to match email autolink after first <, returning num of chars matched.
-extern int scan_autolink_email(chunk *c, int offset)
+extern int _scan_autolink_email(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -86,7 +83,7 @@ extern int scan_autolink_email(chunk *c, int offset)
}
// Try to match an HTML tag after first <, returning num of chars matched.
-extern int scan_html_tag(chunk *c, int offset)
+extern int _scan_html_tag(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -97,7 +94,7 @@ extern int scan_html_tag(chunk *c, int offset)
// Try to match an HTML block tag including first <,
// returning num of chars matched.
-extern int scan_html_block_tag(chunk *c, int offset)
+extern int _scan_html_block_tag(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -112,7 +109,7 @@ extern int scan_html_block_tag(chunk *c, int offset)
// This may optionally be contained in <..>; otherwise
// whitespace and unbalanced right parentheses aren't allowed.
// Newlines aren't ever allowed.
-extern int scan_link_url(chunk *c, int offset)
+extern int _scan_link_url(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -125,7 +122,7 @@ extern int scan_link_url(chunk *c, int offset)
// Try to match a link title (in single quotes, in double quotes, or
// in parentheses), returning number of chars matched. Allow one
// level of internal nesting (quotes within quotes).
-extern int scan_link_title(chunk *c, int offset)
+extern int _scan_link_title(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -137,7 +134,7 @@ extern int scan_link_title(chunk *c, int offset)
}
// Match space characters, including newlines.
-extern int scan_spacechars(chunk *c, int offset)
+extern int _scan_spacechars(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -147,7 +144,7 @@ extern int scan_spacechars(chunk *c, int offset)
}
// Match ATX header start.
-extern int scan_atx_header_start(chunk *c, int offset)
+extern int _scan_atx_header_start(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -158,7 +155,7 @@ extern int scan_atx_header_start(chunk *c, int offset)
// Match sexext header line. Return 1 for level-1 header,
// 2 for level-2, 0 for no match.
-extern int scan_setext_header_line(chunk *c, int offset)
+extern int _scan_setext_header_line(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -171,7 +168,7 @@ extern int scan_setext_header_line(chunk *c, int offset)
// Scan a horizontal rule line: "...three or more hyphens, asterisks,
// or underscores on a line by themselves. If you wish, you may use
// spaces between the hyphens or asterisks."
-extern int scan_hrule(chunk *c, int offset)
+extern int _scan_hrule(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -183,7 +180,7 @@ extern int scan_hrule(chunk *c, int offset)
}
// Scan an opening code fence.
-extern int scan_open_code_fence(chunk *c, int offset)
+extern int _scan_open_code_fence(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
@@ -194,23 +191,18 @@ extern int scan_open_code_fence(chunk *c, int offset)
}
// Scan a closing code fence with length at least len.
-extern int scan_close_code_fence(chunk *c, int offset, int len)
+extern int _scan_close_code_fence(const unsigned char *p)
{
SCAN_DATA;
/*!re2c
- ([`]{3,} | [~]{3,}) / spacechar* [\n]
- { if (p - start > len) {
- return (p - start);
- } else {
- return 0;
- } }
+ ([`]{3,} | [~]{3,}) / spacechar* [\n] { return (p - start); }
.? { return 0; }
*/
}
// Scans an entity.
// Returns number of chars matched.
-extern int scan_entity(chunk *c, int offset)
+extern int _scan_entity(const unsigned char *p)
{
SCAN_DATA;
/*!re2c