am b57e9efd: am c2e634dd: Merge "Fix regoff_t for LP32 and _FILE_OFFSET_BITS=64."

* commit 'b57e9efd40d5765f9ff62f2aa3b6b2ca8523b024':
  Fix regoff_t for LP32 and _FILE_OFFSET_BITS=64.
This commit is contained in:
Elliott Hughes 2015-08-27 23:32:58 +00:00 committed by Android Git Automerger
commit 0f0c7197b5
2 changed files with 13 additions and 2 deletions

View File

@ -42,8 +42,9 @@
#include <sys/cdefs.h>
#include <sys/types.h>
/* types */
typedef off_t regoff_t;
/* POSIX says regoff_t is at least as large as the larger of ptrdiff_t and
* ssize_t. BSD uses off_t, but that interacts badly with _FILE_OFFSET_BITS. */
typedef ssize_t regoff_t;
typedef struct {
int re_magic;

View File

@ -36,3 +36,13 @@ TEST(regex, smoke) {
regfree(&re);
}
TEST(regex, match_offsets) {
regex_t re;
regmatch_t matches[1];
ASSERT_EQ(0, regcomp(&re, "b", 0));
ASSERT_EQ(0, regexec(&re, "abc", 1, matches, 0));
ASSERT_EQ(1, matches[0].rm_so);
ASSERT_EQ(2, matches[0].rm_eo);
regfree(&re);
}