cbits/field.c
static inline bool match_ymd(const char *buf, size_t n) {
	/* The shortest thing we're willing to call a "date" at this
	   point is YYYYMMDD. */
	if (n < 8) {
		return FALSE;
	}

	/* 0xc0 = 0x80 | 0x40 - if these bits are set, the byte is too
	   high to be a digit or a separator. */
	static const int64_t ymd_mask = 0xc0c0c0c0c0c0ffff;

	/* No 0x80 or 0x40 set anywhere, and the first two bytes must
	   be "20". */
	static const int64_t ymd_bits = 0x0000000000003032;
	int64_t *p = (int64_t *) buf;

	/* First, we drop everything which doesn't start with '20' and
	   have eight bytes compatible with a YYYYxMMxDD format. */
	if (!(((*p & ymd_mask) == ymd_bits) && is_digit(buf[2]) && is_digit(buf[3]))) {
		return FALSE;
	}

	/* YYYY-MM-DD */
	if (is_separator(buf[4])) {
		return (n >= 10 &&
			is_digit(buf[5]) &&
			is_digit(buf[6]) &&
			is_separator(buf[7]) &&
			is_digit(buf[8]) &&
			is_digit(buf[9]));
	}

	/* YYYYMMDD */
	return (is_digit(buf[4]) &&
		is_digit(buf[5]) &&
		is_digit(buf[6]) &&
		is_digit(buf[7]));

}
/* Match a year in the 20xx century, in big-endian date format with or
   without separators. */
Match a year in the 20xx century, in big-endian date format with or
without separators.
Match a year in the 20xx century in big - endian date format with or without separators .
static inline bool match_ymd(const char *buf, size_t n) {
	if (n < 8) {
		return FALSE;
	}
	static const int64_t ymd_mask = 0xc0c0c0c0c0c0ffff;
	static const int64_t ymd_bits = 0x0000000000003032;
	int64_t *p = (int64_t *) buf;
	if (!(((*p & ymd_mask) == ymd_bits) && is_digit(buf[2]) && is_digit(buf[3]))) {
		return FALSE;
	}
	if (is_separator(buf[4])) {
		return (n >= 10 &&
			is_digit(buf[5]) &&
			is_digit(buf[6]) &&
			is_separator(buf[7]) &&
			is_digit(buf[8]) &&
			is_digit(buf[9]));
	}
	return (is_digit(buf[4]) &&
		is_digit(buf[5]) &&
		is_digit(buf[6]) &&
		is_digit(buf[7]));
}
static inline bool match_ymd ( const char * buf , size_t n ) { if ( n < 8 ) { return FALSE ; } static const int64_t ymd_mask = 0xc0c0c0c0c0c0ffff ; static const int64_t ymd_bits = 0x0000000000003032 ; int64_t * p = ( int64_t * ) buf ; if ( ! ( ( ( * p & ymd_mask ) == ymd_bits ) && is_digit ( buf [ 2 ] ) && is_digit ( buf [ 3 ] ) ) ) { return FALSE ; } if ( is_separator ( buf [ 4 ] ) ) { return ( n >= 10 && is_digit ( buf [ 5 ] ) && is_digit ( buf [ 6 ] ) && is_separator ( buf [ 7 ] ) && is_digit ( buf [ 8 ] ) && is_digit ( buf [ 9 ] ) ) ; } return ( is_digit ( buf [ 4 ] ) && is_digit ( buf [ 5 ] ) && is_digit ( buf [ 6 ] ) && is_digit ( buf [ 7 ] ) ) ; }
Match a year in the 20xx century, in big-endian date format with or
without separators.
Match a year in the 20xx century in big - endian date format with or without separators .
/* The shortest thing we're willing to call a "date" at this
	   point is YYYYMMDD. */ /* 0xc0 = 0x80 | 0x40 - if these bits are set, the byte is too
	   high to be a digit or a separator. */ /* No 0x80 or 0x40 set anywhere, and the first two bytes must
	   be "20". */ /* First, we drop everything which doesn't start with '20' and
	   have eight bytes compatible with a YYYYxMMxDD format. */ /* YYYY-MM-DD */ /* YYYYMMDD */