X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmbiter.h;h=b274da747e8f823375a6f570bd539b95488c7230;hb=4565266f776db0d78b2c207a5fe79f929f9806ca;hp=92315c56f56e090f13bfe168f33c806dbaf2b65b;hpb=c22782c471b00dc5753385858e245fd328efaefd;p=gnulib.git diff --git a/lib/mbiter.h b/lib/mbiter.h index 92315c56f..b274da747 100644 --- a/lib/mbiter.h +++ b/lib/mbiter.h @@ -1,10 +1,10 @@ /* Iterating through multibyte strings: macros for multi-byte encodings. - Copyright (C) 2001, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2007 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,8 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with this program. If not, see . */ /* Written by Bruno Haible . */ @@ -65,6 +64,9 @@ mbi_reloc (iter, ptrdiff) relocates iterator when the string is moved by ptrdiff bytes. + mbi_copy (&destiter, &srciter) + copies srciter to destiter. + Here are the function prototypes of the macros. extern void mbi_init (mbi_iterator_t iter, @@ -74,6 +76,7 @@ extern mbchar_t mbi_cur (mbi_iterator_t iter); extern const char * mbi_cur_ptr (mbi_iterator_t iter); extern void mbi_reloc (mbi_iterator_t iter, ptrdiff_t ptrdiff); + extern void mbi_copy (mbi_iterator_t *new, const mbi_iterator_t *old); */ #ifndef _MBITER_H @@ -81,6 +84,8 @@ #include #include +#include +#include /* Tru64 with Desktop Toolkit C has a bug: must be included before . @@ -174,6 +179,18 @@ mbiter_multi_reloc (struct mbiter_multi *iter, ptrdiff_t ptrdiff) iter->limit += ptrdiff; } +static inline void +mbiter_multi_copy (struct mbiter_multi *new_iter, const struct mbiter_multi *old_iter) +{ + new_iter->limit = old_iter->limit; + if ((new_iter->in_shift = old_iter->in_shift)) + memcpy (&new_iter->state, &old_iter->state, sizeof (mbstate_t)); + else + memset (&new_iter->state, 0, sizeof (mbstate_t)); + new_iter->next_done = old_iter->next_done; + mb_copy (&new_iter->cur, &old_iter->cur); +} + /* Iteration macros. */ typedef struct mbiter_multi mbi_iterator_t; #define mbi_init(iter, startptr, length) \ @@ -192,4 +209,7 @@ typedef struct mbiter_multi mbi_iterator_t; /* Relocation. */ #define mbi_reloc(iter, ptrdiff) mbiter_multi_reloc (&iter, ptrdiff) +/* Copying an iterator. */ +#define mbi_copy mbiter_multi_copy + #endif /* _MBITER_H */