Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/sort/bwstring.h
Show All 32 Lines | |||||
#define __BWSTRING_H__ | #define __BWSTRING_H__ | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <sysexits.h> | #include <sysexits.h> | ||||
#include <wchar.h> | #include <wchar.h> | ||||
#include "sort.h" | |||||
#include "mem.h" | #include "mem.h" | ||||
extern bool byte_sort; | extern bool byte_sort; | ||||
/* wchar_t is of 4 bytes: */ | /* wchar_t is of 4 bytes: */ | ||||
#define SIZEOF_WCHAR_STRING(LEN) ((LEN)*sizeof(wchar_t)) | #define SIZEOF_WCHAR_STRING(LEN) ((LEN)*sizeof(wchar_t)) | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | bws_begin(struct bwstring *bws) | ||||
return (bwstring_iterator) (&(bws->data)); | return (bwstring_iterator) (&(bws->data)); | ||||
} | } | ||||
static inline bwstring_iterator | static inline bwstring_iterator | ||||
bws_end(struct bwstring *bws) | bws_end(struct bwstring *bws) | ||||
{ | { | ||||
return ((MB_CUR_MAX == 1) ? | return ((mb_cur_max == 1) ? | ||||
(bwstring_iterator) (bws->data.cstr + bws->len) : | (bwstring_iterator) (bws->data.cstr + bws->len) : | ||||
(bwstring_iterator) (bws->data.wstr + bws->len)); | (bwstring_iterator) (bws->data.wstr + bws->len)); | ||||
} | } | ||||
static inline bwstring_iterator | static inline bwstring_iterator | ||||
bws_iterator_inc(bwstring_iterator iter, size_t pos) | bws_iterator_inc(bwstring_iterator iter, size_t pos) | ||||
{ | { | ||||
if (MB_CUR_MAX == 1) | if (mb_cur_max == 1) | ||||
return ((unsigned char *) iter) + pos; | return ((unsigned char *) iter) + pos; | ||||
else | else | ||||
return ((wchar_t*) iter) + pos; | return ((wchar_t*) iter) + pos; | ||||
} | } | ||||
static inline wchar_t | static inline wchar_t | ||||
bws_get_iter_value(bwstring_iterator iter) | bws_get_iter_value(bwstring_iterator iter) | ||||
{ | { | ||||
if (MB_CUR_MAX == 1) | if (mb_cur_max == 1) | ||||
return *((unsigned char *) iter); | return *((unsigned char *) iter); | ||||
else | else | ||||
return *((wchar_t*) iter); | return *((wchar_t*) iter); | ||||
} | } | ||||
int | int | ||||
bws_iterator_cmp(bwstring_iterator iter1, bwstring_iterator iter2, size_t len); | bws_iterator_cmp(bwstring_iterator iter1, bwstring_iterator iter2, size_t len); | ||||
#define BWS_GET(bws, pos) ((MB_CUR_MAX == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) | #define BWS_GET(bws, pos) ((mb_cur_max == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) | ||||
void initialise_months(void); | void initialise_months(void); | ||||
#endif /* __BWSTRING_H__ */ | #endif /* __BWSTRING_H__ */ |