bwstring.h (d1d015864103b253b3fcb2f72a0da5b0cfeb31b6) | bwstring.h (b1a409863f4784ab8a7a9fa04b3e9b3c92e7fd72) |
---|---|
1/* $FreeBSD$ */ 2 3/*- 4 * Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org> 5 * Copyright (C) 2012 Oleg Moskalenko <mom040267@gmail.com> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if !defined(__BWSTRING_H__) | 1/* $FreeBSD$ */ 2 3/*- 4 * Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org> 5 * Copyright (C) 2012 Oleg Moskalenko <mom040267@gmail.com> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if !defined(__BWSTRING_H__) |
31#define __BWSTRING_H__ | 31#define __BWSTRING_H__ |
32 33#include <stdbool.h> 34#include <stdio.h> 35#include <errno.h> 36#include <sysexits.h> 37#include <wchar.h> 38 39#include "mem.h" 40 41extern bool byte_sort; 42 43/* wchar_t is of 4 bytes: */ | 32 33#include <stdbool.h> 34#include <stdio.h> 35#include <errno.h> 36#include <sysexits.h> 37#include <wchar.h> 38 39#include "mem.h" 40 41extern bool byte_sort; 42 43/* wchar_t is of 4 bytes: */ |
44#define SIZEOF_WCHAR_STRING(LEN) ((LEN)*sizeof(wchar_t)) | 44#define SIZEOF_WCHAR_STRING(LEN) ((LEN)*sizeof(wchar_t)) |
45 46/* 47 * Binary "wide" string 48 */ 49struct bwstring 50{ 51 size_t len; 52 union --- 6 unchanged lines hidden (view full) --- 59struct reader_buffer 60{ 61 wchar_t *fgetwln_z_buffer; 62 size_t fgetwln_z_buffer_size; 63}; 64 65typedef void *bwstring_iterator; 66 | 45 46/* 47 * Binary "wide" string 48 */ 49struct bwstring 50{ 51 size_t len; 52 union --- 6 unchanged lines hidden (view full) --- 59struct reader_buffer 60{ 61 wchar_t *fgetwln_z_buffer; 62 size_t fgetwln_z_buffer_size; 63}; 64 65typedef void *bwstring_iterator; 66 |
67#define BWSLEN(s) ((s)->len) | 67#define BWSLEN(s) ((s)->len) |
68 69struct bwstring *bwsalloc(size_t sz); 70 71size_t bwsrawlen(const struct bwstring *bws); 72const void* bwsrawdata(const struct bwstring *bws); 73void bws_setlen(struct bwstring *bws, size_t newlen); 74size_t bws_memsize(const struct bwstring *bws); 75double bwstod(struct bwstring *s0, bool *empty); --- 54 unchanged lines hidden (view full) --- 130 return *((unsigned char *) iter); 131 else 132 return *((wchar_t*) iter); 133} 134 135int 136bws_iterator_cmp(bwstring_iterator iter1, bwstring_iterator iter2, size_t len); 137 | 68 69struct bwstring *bwsalloc(size_t sz); 70 71size_t bwsrawlen(const struct bwstring *bws); 72const void* bwsrawdata(const struct bwstring *bws); 73void bws_setlen(struct bwstring *bws, size_t newlen); 74size_t bws_memsize(const struct bwstring *bws); 75double bwstod(struct bwstring *s0, bool *empty); --- 54 unchanged lines hidden (view full) --- 130 return *((unsigned char *) iter); 131 else 132 return *((wchar_t*) iter); 133} 134 135int 136bws_iterator_cmp(bwstring_iterator iter1, bwstring_iterator iter2, size_t len); 137 |
138#define BWS_GET(bws, pos) ((MB_CUR_MAX == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) | 138#define BWS_GET(bws, pos) ((MB_CUR_MAX == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) |
139 140void initialise_months(void); 141 142#endif /* __BWSTRING_H__ */ | 139 140void initialise_months(void); 141 142#endif /* __BWSTRING_H__ */ |