diff options
| author | Kenichi Handa <handa@m17n.org> | 2003-01-16 04:31:29 +0000 |
|---|---|---|
| committer | Kenichi Handa <handa@m17n.org> | 2003-01-16 04:31:29 +0000 |
| commit | d3985b787890f24be1be7c7dd1850c1bc4714c47 (patch) | |
| tree | 235ab0af2539c331279204bcfb33b1da90f4d65d /src | |
| parent | 35ef97a54d856c4a7a9b389a4ffd9b9ceced8ba5 (diff) | |
| download | emacs-d3985b787890f24be1be7c7dd1850c1bc4714c47.tar.gz | |
(NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/charset.h b/src/charset.h index 2b58f88f840..23a46326678 100644 --- a/src/charset.h +++ b/src/charset.h @@ -634,6 +634,34 @@ else ? 1 \ : multibyte_form_length (str, len)) +/* If P is before LIMIT, advance P to the next character boundary. It + assumes that P is already at a character boundary of the sane + mulitbyte form whose end address is LIMIT. */ + +#define NEXT_CHAR_BOUNDARY(p, limit) \ + do { \ + if ((p) < (limit)) \ + (p) += BYTES_BY_CHAR_HEAD (*(p)); \ + } while (0) + + +/* If P is after LIMIT, advance P to the previous character boundary. + It assumes that P is already at a character boundary of the sane + mulitbyte form whose beginning address is LIMIT. */ + +#define PREV_CHAR_BOUNDARY(p, limit) \ + do { \ + if ((p) > (limit)) \ + { \ + const unsigned char *p0 = (p); \ + do { \ + p0--; \ + } while (p0 >= limit && ! CHAR_HEAD_P (*p0)); \ + (p) = (BYTES_BY_CHAR_HEAD (*p0) == (p) - p0) ? p0 : (p) - 1; \ + } \ + } while (0) + + #ifdef emacs /* Increase the buffer byte position POS_BYTE of the current buffer to |
