This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: call regcurly instead of duplicating code
[perl5.git] / dquote_static.c
CommitLineData
04e98a4d
AD
1/* dquote_static.c
2 *
3 * This file contains static inline functions that are related to
4 * parsing double-quotish expressions, but are used in more than
5 * one file.
6 *
7 * It is currently #included by regcomp.c and toke.c.
8*/
9
10/*
11 - regcurly - a little FSA that accepts {\d+,?\d*}
12 Pulled from regcomp.c.
13 */
14
15/* embed.pl doesn't yet know how to handle static inline functions, so
16 manually decorate it here with gcc-style attributes.
17*/
18PERL_STATIC_INLINE I32
19regcurly(register const char *s)
20 __attribute__warn_unused_result__
21 __attribute__pure__
22 __attribute__nonnull__(1);
23
24PERL_STATIC_INLINE I32
25regcurly(register const char *s)
26{
27 assert(s);
28
29 if (*s++ != '{')
30 return FALSE;
31 if (!isDIGIT(*s))
32 return FALSE;
33 while (isDIGIT(*s))
34 s++;
35 if (*s == ',')
36 s++;
37 while (isDIGIT(*s))
38 s++;
39 if (*s != '}')
40 return FALSE;
41 return TRUE;
42}
43/*
44 * Local variables:
45 * c-indentation-style: bsd
46 * c-basic-offset: 4
47 * indent-tabs-mode: t
48 * End:
49 *
50 * ex: set ts=8 sts=4 sw=4 noet:
51 */