aboutsummaryrefslogtreecommitdiff
path: root/src/lexer-generic.c
blob: b8418865f30bc479c70fdf67e458f4b873012dae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdbool.h>

#include "common.h"
#include "types.h"

bool
skpcmnt(const uchar **ptr, const uchar *end)
{
	int nst = 1;
	const uchar *p = *ptr;

	for (p++; likely(p < end); p++) {
		if (p + 1 < end) {
			if (p[0] == '*' && p[1] == '/') {
				p++;
				if (--nst == 0) {
					*ptr = ++p;
					return true;
				}
			} else if (p[0] == '/' && p[1] == '*') {
				p++;
				nst++;
			}
		}
	}

	return false;
}