Fix regoff_t for LP32 and _FILE_OFFSET_BITS=64.
bionic is built without _FILE_OFFSET_BITS=64, so internally regoff_t was 32-bit on LP32, but code compiled with _FILE_OFFSET_BITS would expect rm_so and rm_eo in struct regmatch_t to be 64-bit, leading to confusion. Bug: http://b/23566443 Change-Id: Iae92fa545104068e4f64ce1977f5ec616859638c
This commit is contained in:
parent
bfaee4bd6a
commit
adf5c7237d
@ -42,8 +42,9 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/* types */
|
/* POSIX says regoff_t is at least as large as the larger of ptrdiff_t and
|
||||||
typedef off_t regoff_t;
|
* ssize_t. BSD uses off_t, but that interacts badly with _FILE_OFFSET_BITS. */
|
||||||
|
typedef ssize_t regoff_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int re_magic;
|
int re_magic;
|
||||||
|
@ -36,3 +36,13 @@ TEST(regex, smoke) {
|
|||||||
|
|
||||||
regfree(&re);
|
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);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user