Fix code style for pointers
This commit is contained in:
66
CgeStr.h
66
CgeStr.h
@@ -4,15 +4,15 @@
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct CgeStr {
|
||||
const char* data;
|
||||
const char *data;
|
||||
size_t size;
|
||||
} CgeStr;
|
||||
|
||||
#define CGE_STR_LIT(s) \
|
||||
{(s), sizeof(s) - 1}
|
||||
|
||||
typedef void (*CgeStrIterCb)(uint32_t rune, void* user);
|
||||
typedef void (*CgeStrWriteCb)(const char* data, size_t size, void* user);
|
||||
typedef void (*CgeStrIterCb)(uint32_t rune, void *user);
|
||||
typedef void (*CgeStrWriteCb)(const char *data, size_t size, void *user);
|
||||
|
||||
enum CgeCat {
|
||||
CGE_CAT_LU, CGE_CAT_LL, CGE_CAT_LT, CGE_CAT_LM, CGE_CAT_LO, CGE_CAT_MN,
|
||||
@@ -27,10 +27,10 @@ uint32_t CgeRuneLower(uint32_t rune);
|
||||
uint32_t CgeRuneUpper(uint32_t rune);
|
||||
uint32_t CgeRuneTitle(uint32_t rune);
|
||||
uint32_t CgeRuneFold(uint32_t rune);
|
||||
size_t CgeRuneLowerFull(uint32_t rune, uint32_t* out);
|
||||
size_t CgeRuneUpperFull(uint32_t rune, uint32_t* out);
|
||||
size_t CgeRuneTitleFull(uint32_t rune, uint32_t* out);
|
||||
size_t CgeRuneFoldFull(uint32_t rune, uint32_t* out);
|
||||
size_t CgeRuneLowerFull(uint32_t rune, uint32_t *out);
|
||||
size_t CgeRuneUpperFull(uint32_t rune, uint32_t *out);
|
||||
size_t CgeRuneTitleFull(uint32_t rune, uint32_t *out);
|
||||
size_t CgeRuneFoldFull(uint32_t rune, uint32_t *out);
|
||||
|
||||
int CgeRuneIsControl(uint32_t rune);
|
||||
int CgeRuneIsDigit(uint32_t rune);
|
||||
@@ -46,33 +46,33 @@ int CgeRuneIsSymbol(uint32_t rune);
|
||||
int CgeRuneIsTitle(uint32_t rune);
|
||||
int CgeRuneIsUpper(uint32_t rune);
|
||||
|
||||
int CgeUtf8Encode(uint32_t rune, char* data);
|
||||
int CgeUtf8EncodeLax(uint32_t rune, char* data);
|
||||
int CgeUtf8Decode(const char* data, size_t size, uint32_t* rune);
|
||||
int CgeUtf8DecodeLax(const char* data, size_t size, uint32_t* rune);
|
||||
int CgeUtf8Encode(uint32_t rune, char *data);
|
||||
int CgeUtf8EncodeLax(uint32_t rune, char *data);
|
||||
int CgeUtf8Decode(const char *data, size_t size, uint32_t *rune);
|
||||
int CgeUtf8DecodeLax(const char *data, size_t size, uint32_t *rune);
|
||||
|
||||
int CgeUtf16Encode(uint32_t rune, uint16_t* data);
|
||||
int CgeUtf16EncodeLax(uint32_t rune, uint16_t* data);
|
||||
int CgeUtf16Decode(const uint16_t* data, size_t size, uint32_t* rune);
|
||||
int CgeUtf16DecodeLax(const uint16_t* data, size_t size, uint32_t* rune);
|
||||
int CgeUtf16Encode(uint32_t rune, uint16_t *data);
|
||||
int CgeUtf16EncodeLax(uint32_t rune, uint16_t *data);
|
||||
int CgeUtf16Decode(const uint16_t *data, size_t size, uint32_t *rune);
|
||||
int CgeUtf16DecodeLax(const uint16_t *data, size_t size, uint32_t *rune);
|
||||
|
||||
void CgeStrIter(const CgeStr* str, CgeStrIterCb cb, void* user);
|
||||
void CgeStrToLower(const CgeStr* str, CgeStrWriteCb cb, void* user);
|
||||
void CgeStrToUpper(const CgeStr* str, CgeStrWriteCb cb, void* user);
|
||||
void CgeStrFold(const CgeStr* str, CgeStrWriteCb cb, void* user);
|
||||
int CgeStrCmp(const CgeStr* lhs, const CgeStr* rhs);
|
||||
int CgeStrICmp(const CgeStr* lhs, const CgeStr* rhs);
|
||||
size_t CgeStrIndexRune(const CgeStr* str, uint32_t rune);
|
||||
size_t CgeStrLastIndexRune(const CgeStr* str, uint32_t rune);
|
||||
size_t CgeStrIndexRuneLax(const CgeStr* str, uint32_t rune);
|
||||
size_t CgeStrLastIndexRuneLax(const CgeStr* str, uint32_t rune);
|
||||
size_t CgeStrIndexStr(const CgeStr* str, const CgeStr* substr);
|
||||
size_t CgeStrLastIndexStr(const CgeStr* str, const CgeStr* substr);
|
||||
int CgeStrHasPrefix(const CgeStr* str, const CgeStr* prefix);
|
||||
int CgeStrHasSuffix(const CgeStr* str, const CgeStr* suffix);
|
||||
void CgeStrTrimLeft(const CgeStr* str, CgeStr* out);
|
||||
void CgeStrTrimRight(const CgeStr* str, CgeStr* out);
|
||||
void CgeStrTrim(const CgeStr* str, CgeStr* out);
|
||||
void CgeStrSplit(CgeStr* str, CgeStr* prefix, uint32_t delim);
|
||||
void CgeStrIter(const CgeStr *str, CgeStrIterCb cb, void *user);
|
||||
void CgeStrToLower(const CgeStr *str, CgeStrWriteCb cb, void *user);
|
||||
void CgeStrToUpper(const CgeStr *str, CgeStrWriteCb cb, void *user);
|
||||
void CgeStrFold(const CgeStr *str, CgeStrWriteCb cb, void *user);
|
||||
int CgeStrCmp(const CgeStr *lhs, const CgeStr *rhs);
|
||||
int CgeStrICmp(const CgeStr *lhs, const CgeStr *rhs);
|
||||
size_t CgeStrIndexRune(const CgeStr *str, uint32_t rune);
|
||||
size_t CgeStrLastIndexRune(const CgeStr *str, uint32_t rune);
|
||||
size_t CgeStrIndexRuneLax(const CgeStr *str, uint32_t rune);
|
||||
size_t CgeStrLastIndexRuneLax(const CgeStr *str, uint32_t rune);
|
||||
size_t CgeStrIndexStr(const CgeStr *str, const CgeStr *substr);
|
||||
size_t CgeStrLastIndexStr(const CgeStr *str, const CgeStr *substr);
|
||||
int CgeStrHasPrefix(const CgeStr *str, const CgeStr *prefix);
|
||||
int CgeStrHasSuffix(const CgeStr *str, const CgeStr *suffix);
|
||||
void CgeStrTrimLeft(const CgeStr *str, CgeStr *out);
|
||||
void CgeStrTrimRight(const CgeStr *str, CgeStr *out);
|
||||
void CgeStrTrim(const CgeStr *str, CgeStr *out);
|
||||
void CgeStrSplit(CgeStr *str, CgeStr *prefix, uint32_t delim);
|
||||
|
||||
#endif /* CGE_STR_H */
|
||||
|
||||
@@ -33,7 +33,7 @@ Builds a static library. No shared library or external dependencies.
|
||||
#include "CgeStr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void print_rune(uint32_t rune, void* user) {
|
||||
void print_rune(uint32_t rune, void *user) {
|
||||
printf("U+%04X ", rune);
|
||||
}
|
||||
|
||||
|
||||
64
Str.c
64
Str.c
@@ -12,7 +12,7 @@ struct UniStream {
|
||||
size_t size;
|
||||
};
|
||||
|
||||
static int uniStreamPut(struct UniStream* stream, uint32_t rune) {
|
||||
static int uniStreamPut(struct UniStream *stream, uint32_t rune) {
|
||||
if (stream->size >= MAX_UNI_STREAM)
|
||||
return 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ static int uniStreamPut(struct UniStream* stream, uint32_t rune) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int uniStreamGet(struct UniStream* stream, uint32_t* rune) {
|
||||
static int uniStreamGet(struct UniStream *stream, uint32_t *rune) {
|
||||
if (!stream->size)
|
||||
return 0;
|
||||
|
||||
@@ -32,9 +32,9 @@ static int uniStreamGet(struct UniStream* stream, uint32_t* rune) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CgeStrIter(const CgeStr* str, CgeStrIterCb cb, void* user) {
|
||||
const char* current = str->data;
|
||||
const char* end = str->data + str->size;
|
||||
void CgeStrIter(const CgeStr *str, CgeStrIterCb cb, void *user) {
|
||||
const char *current = str->data;
|
||||
const char *end = str->data + str->size;
|
||||
|
||||
while (current < end) {
|
||||
uint32_t rune;
|
||||
@@ -44,9 +44,9 @@ void CgeStrIter(const CgeStr* str, CgeStrIterCb cb, void* user) {
|
||||
}
|
||||
}
|
||||
|
||||
void CgeStrToLower(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
const char* current = str->data;
|
||||
const char* end = str->data + str->size;
|
||||
void CgeStrToLower(const CgeStr *str, CgeStrWriteCb cb, void *user) {
|
||||
const char *current = str->data;
|
||||
const char *end = str->data + str->size;
|
||||
|
||||
while (current < end) {
|
||||
uint32_t rune;
|
||||
@@ -63,9 +63,9 @@ void CgeStrToLower(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
}
|
||||
}
|
||||
|
||||
void CgeStrToUpper(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
const char* current = str->data;
|
||||
const char* end = str->data + str->size;
|
||||
void CgeStrToUpper(const CgeStr *str, CgeStrWriteCb cb, void *user) {
|
||||
const char *current = str->data;
|
||||
const char *end = str->data + str->size;
|
||||
|
||||
while (current < end) {
|
||||
uint32_t rune;
|
||||
@@ -82,9 +82,9 @@ void CgeStrToUpper(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
}
|
||||
}
|
||||
|
||||
void CgeStrFold(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
const char* current = str->data;
|
||||
const char* end = str->data + str->size;
|
||||
void CgeStrFold(const CgeStr *str, CgeStrWriteCb cb, void *user) {
|
||||
const char *current = str->data;
|
||||
const char *end = str->data + str->size;
|
||||
|
||||
while (current < end) {
|
||||
uint32_t rune;
|
||||
@@ -101,7 +101,7 @@ void CgeStrFold(const CgeStr* str, CgeStrWriteCb cb, void* user) {
|
||||
}
|
||||
}
|
||||
|
||||
int CgeStrCmp(const CgeStr* lhs, const CgeStr* rhs) {
|
||||
int CgeStrCmp(const CgeStr *lhs, const CgeStr *rhs) {
|
||||
size_t leastSize;
|
||||
int result;
|
||||
|
||||
@@ -120,14 +120,14 @@ int CgeStrCmp(const CgeStr* lhs, const CgeStr* rhs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CgeStrICmp(const CgeStr* lhs, const CgeStr* rhs) {
|
||||
int CgeStrICmp(const CgeStr *lhs, const CgeStr *rhs) {
|
||||
struct UniStream buf1 = {{0}, 0, 0, 0};
|
||||
struct UniStream buf2 = {{0}, 0, 0, 0};
|
||||
|
||||
const char* current1 = lhs->data;
|
||||
const char* current2 = rhs->data;
|
||||
const char* end1 = lhs->data + lhs->size;
|
||||
const char* end2 = rhs->data + rhs->size;
|
||||
const char *current1 = lhs->data;
|
||||
const char *current2 = rhs->data;
|
||||
const char *end1 = lhs->data + lhs->size;
|
||||
const char *end2 = rhs->data + rhs->size;
|
||||
|
||||
while (1) {
|
||||
uint32_t rune1, rune2;
|
||||
@@ -168,7 +168,7 @@ int CgeStrICmp(const CgeStr* lhs, const CgeStr* rhs) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t CgeStrIndexRune(const CgeStr* str, uint32_t rune) {
|
||||
size_t CgeStrIndexRune(const CgeStr *str, uint32_t rune) {
|
||||
char scratch[4];
|
||||
CgeStr tmp;
|
||||
|
||||
@@ -179,7 +179,7 @@ size_t CgeStrIndexRune(const CgeStr* str, uint32_t rune) {
|
||||
return CgeStrIndexStr(str, &tmp);
|
||||
}
|
||||
|
||||
size_t CgeStrLastIndexRune(const CgeStr* str, uint32_t rune) {
|
||||
size_t CgeStrLastIndexRune(const CgeStr *str, uint32_t rune) {
|
||||
char scratch[4];
|
||||
CgeStr tmp;
|
||||
|
||||
@@ -190,7 +190,7 @@ size_t CgeStrLastIndexRune(const CgeStr* str, uint32_t rune) {
|
||||
return CgeStrLastIndexStr(str, &tmp);
|
||||
}
|
||||
|
||||
size_t CgeStrIndexRuneLax(const CgeStr* str, uint32_t rune) {
|
||||
size_t CgeStrIndexRuneLax(const CgeStr *str, uint32_t rune) {
|
||||
size_t i = 0;
|
||||
while (i < str->size) {
|
||||
uint32_t r;
|
||||
@@ -204,7 +204,7 @@ size_t CgeStrIndexRuneLax(const CgeStr* str, uint32_t rune) {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
size_t CgeStrLastIndexRuneLax(const CgeStr* str, uint32_t rune) {
|
||||
size_t CgeStrLastIndexRuneLax(const CgeStr *str, uint32_t rune) {
|
||||
size_t i = str->size;
|
||||
|
||||
while (i > 0) {
|
||||
@@ -224,7 +224,7 @@ size_t CgeStrLastIndexRuneLax(const CgeStr* str, uint32_t rune) {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
size_t CgeStrIndexStr(const CgeStr* str, const CgeStr* substr) {
|
||||
size_t CgeStrIndexStr(const CgeStr *str, const CgeStr *substr) {
|
||||
size_t i;
|
||||
|
||||
if (!substr->size)
|
||||
@@ -239,7 +239,7 @@ size_t CgeStrIndexStr(const CgeStr* str, const CgeStr* substr) {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
size_t CgeStrLastIndexStr(const CgeStr* str, const CgeStr* substr) {
|
||||
size_t CgeStrLastIndexStr(const CgeStr *str, const CgeStr *substr) {
|
||||
size_t i;
|
||||
|
||||
if (!substr->size)
|
||||
@@ -254,21 +254,21 @@ size_t CgeStrLastIndexStr(const CgeStr* str, const CgeStr* substr) {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
int CgeStrHasPrefix(const CgeStr* str, const CgeStr* prefix) {
|
||||
int CgeStrHasPrefix(const CgeStr *str, const CgeStr *prefix) {
|
||||
if (prefix->size > str->size)
|
||||
return 0;
|
||||
|
||||
return !memcmp(str->data, prefix->data, prefix->size);
|
||||
}
|
||||
|
||||
int CgeStrHasSuffix(const CgeStr* str, const CgeStr* suffix) {
|
||||
int CgeStrHasSuffix(const CgeStr *str, const CgeStr *suffix) {
|
||||
if (suffix->size > str->size)
|
||||
return 0;
|
||||
|
||||
return !memcmp(str->data + str->size - suffix->size, suffix->data, suffix->size);
|
||||
}
|
||||
|
||||
void CgeStrTrimLeft(const CgeStr* str, CgeStr* out) {
|
||||
void CgeStrTrimLeft(const CgeStr *str, CgeStr *out) {
|
||||
out->data = str->data;
|
||||
out->size = str->size;
|
||||
|
||||
@@ -285,7 +285,7 @@ void CgeStrTrimLeft(const CgeStr* str, CgeStr* out) {
|
||||
}
|
||||
}
|
||||
|
||||
void CgeStrTrimRight(const CgeStr* str, CgeStr* out) {
|
||||
void CgeStrTrimRight(const CgeStr *str, CgeStr *out) {
|
||||
out->data = str->data;
|
||||
out->size = str->size;
|
||||
|
||||
@@ -306,12 +306,12 @@ void CgeStrTrimRight(const CgeStr* str, CgeStr* out) {
|
||||
}
|
||||
}
|
||||
|
||||
void CgeStrTrim(const CgeStr* str, CgeStr* out) {
|
||||
void CgeStrTrim(const CgeStr *str, CgeStr *out) {
|
||||
CgeStrTrimLeft(str, out);
|
||||
CgeStrTrimRight(out, out);
|
||||
}
|
||||
|
||||
void CgeStrSplit(CgeStr* str, CgeStr* prefix, uint32_t delim) {
|
||||
void CgeStrSplit(CgeStr *str, CgeStr *prefix, uint32_t delim) {
|
||||
uint32_t r;
|
||||
size_t pos;
|
||||
int count;
|
||||
|
||||
8
Utf16.c
8
Utf16.c
@@ -2,7 +2,7 @@
|
||||
|
||||
#define INVALID_RUNE 0xFFFD
|
||||
|
||||
int CgeUtf16Encode(uint32_t rune, uint16_t* data) {
|
||||
int CgeUtf16Encode(uint32_t rune, uint16_t *data) {
|
||||
if (rune <= 0xFFFF) {
|
||||
if (rune >= 0xD800 && rune <= 0xDFFF)
|
||||
return -1;
|
||||
@@ -18,7 +18,7 @@ int CgeUtf16Encode(uint32_t rune, uint16_t* data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CgeUtf16EncodeLax(uint32_t rune, uint16_t* data) {
|
||||
int CgeUtf16EncodeLax(uint32_t rune, uint16_t *data) {
|
||||
int result;
|
||||
|
||||
result = CgeUtf16Encode(rune, data);
|
||||
@@ -28,7 +28,7 @@ int CgeUtf16EncodeLax(uint32_t rune, uint16_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int CgeUtf16Decode(const uint16_t* data, size_t size, uint32_t* rune) {
|
||||
int CgeUtf16Decode(const uint16_t *data, size_t size, uint32_t *rune) {
|
||||
uint16_t trail, lead = data[0];
|
||||
|
||||
if (size == 0)
|
||||
@@ -51,7 +51,7 @@ int CgeUtf16Decode(const uint16_t* data, size_t size, uint32_t* rune) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CgeUtf16DecodeLax(const uint16_t* data, size_t size, uint32_t* rune) {
|
||||
int CgeUtf16DecodeLax(const uint16_t *data, size_t size, uint32_t *rune) {
|
||||
int result;
|
||||
|
||||
result = CgeUtf16Decode(data, size, rune);
|
||||
|
||||
8
Utf8.c
8
Utf8.c
@@ -2,7 +2,7 @@
|
||||
|
||||
#define INVALID_RUNE 0xFFFD
|
||||
|
||||
int CgeUtf8Encode(uint32_t rune, char* data) {
|
||||
int CgeUtf8Encode(uint32_t rune, char *data) {
|
||||
if (rune < 0x80) {
|
||||
data[0] = (char)rune;
|
||||
return 1;
|
||||
@@ -30,7 +30,7 @@ int CgeUtf8Encode(uint32_t rune, char* data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CgeUtf8EncodeLax(uint32_t rune, char* data) {
|
||||
int CgeUtf8EncodeLax(uint32_t rune, char *data) {
|
||||
int result;
|
||||
|
||||
result = CgeUtf8Encode(rune, data);
|
||||
@@ -40,7 +40,7 @@ int CgeUtf8EncodeLax(uint32_t rune, char* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int CgeUtf8Decode(const char* data, size_t size, uint32_t* rune) {
|
||||
int CgeUtf8Decode(const char *data, size_t size, uint32_t *rune) {
|
||||
unsigned char byte = (unsigned char)data[0];
|
||||
int i, n;
|
||||
|
||||
@@ -88,7 +88,7 @@ int CgeUtf8Decode(const char* data, size_t size, uint32_t* rune) {
|
||||
return n;
|
||||
}
|
||||
|
||||
int CgeUtf8DecodeLax(const char* data, size_t size, uint32_t* rune) {
|
||||
int CgeUtf8DecodeLax(const char *data, size_t size, uint32_t *rune) {
|
||||
int result;
|
||||
|
||||
result = CgeUtf8Decode(data, size, rune);
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
#include "ValueList.h"
|
||||
|
||||
struct BlockLevel {
|
||||
long* data;
|
||||
long *data;
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
struct ValueList* list;
|
||||
struct ValueList *list;
|
||||
};
|
||||
|
||||
struct Blocks {
|
||||
struct BlockLevel* levels;
|
||||
struct BlockLevel *levels;
|
||||
size_t depth;
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ static int ilog2(unsigned long value) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static long blockInsert(struct Blocks* blocks, long value, size_t depth) {
|
||||
struct BlockLevel* level = blocks->levels + depth;
|
||||
static long blockInsert(struct Blocks *blocks, long value, size_t depth) {
|
||||
struct BlockLevel *level = blocks->levels + depth;
|
||||
|
||||
if (blocks->depth - 1 != depth) {
|
||||
if ((value = blockInsert(blocks, value, depth + 1)) == -1)
|
||||
@@ -44,9 +44,9 @@ static long blockInsert(struct Blocks* blocks, long value, size_t depth) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static long blockFindR(struct Blocks* blocks, long value, long offset, size_t depth) {
|
||||
struct BlockLevel* level = &blocks->levels[depth];
|
||||
struct ValueList* current;
|
||||
static long blockFindR(struct Blocks *blocks, long value, long offset, size_t depth) {
|
||||
struct BlockLevel *level = &blocks->levels[depth];
|
||||
struct ValueList *current;
|
||||
size_t i, bits = 0;
|
||||
|
||||
for (i = depth + 1; i < blocks->depth; i++) {
|
||||
@@ -65,7 +65,7 @@ static long blockFindR(struct Blocks* blocks, long value, long offset, size_t de
|
||||
return offset;
|
||||
}
|
||||
|
||||
static long blockFind(struct Blocks* blocks, long value) {
|
||||
static long blockFind(struct Blocks *blocks, long value) {
|
||||
size_t i, bits = 0;
|
||||
long offset;
|
||||
|
||||
@@ -77,7 +77,7 @@ static long blockFind(struct Blocks* blocks, long value) {
|
||||
return blockFindR(blocks, value, offset, 0);
|
||||
}
|
||||
|
||||
static void blockInit(struct Blocks* blocks, size_t depth, ...) {
|
||||
static void blockInit(struct Blocks *blocks, size_t depth, ...) {
|
||||
va_list args;
|
||||
|
||||
blocks->depth = 0;
|
||||
@@ -87,7 +87,7 @@ static void blockInit(struct Blocks* blocks, size_t depth, ...) {
|
||||
va_start(args, depth);
|
||||
|
||||
while (blocks->depth < depth) {
|
||||
struct BlockLevel* level = &blocks->levels[blocks->depth];
|
||||
struct BlockLevel *level = &blocks->levels[blocks->depth];
|
||||
|
||||
level->list = NULL;
|
||||
level->size = 0;
|
||||
@@ -100,10 +100,10 @@ static void blockInit(struct Blocks* blocks, size_t depth, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void blockDump(struct Blocks* blocks, size_t depth, FILE* out,
|
||||
const char* name, const char* type) {
|
||||
struct BlockLevel* level = &blocks->levels[depth];
|
||||
struct ValueList* current;
|
||||
static void blockDump(struct Blocks *blocks, size_t depth, FILE *out,
|
||||
const char *name, const char *type) {
|
||||
struct BlockLevel *level = &blocks->levels[depth];
|
||||
struct ValueList *current;
|
||||
size_t i, j, printed = 0;
|
||||
|
||||
fprintf(out, "static const %s %s[] = {\n ", type, name);
|
||||
@@ -120,9 +120,9 @@ static void blockDump(struct Blocks* blocks, size_t depth, FILE* out,
|
||||
fprintf(out, "\n};\n\n");
|
||||
}
|
||||
|
||||
static void blockAccess(struct Blocks* blocks, size_t depth, FILE* out,
|
||||
const char* var, const char* arg, const char* name) {
|
||||
struct BlockLevel* level = &blocks->levels[depth];
|
||||
static void blockAccess(struct Blocks *blocks, size_t depth, FILE *out,
|
||||
const char *var, const char *arg, const char *name) {
|
||||
struct BlockLevel *level = &blocks->levels[depth];
|
||||
long i, bits = 0, offset, mask;
|
||||
|
||||
for (i = depth + 1; i < blocks->depth; i++) {
|
||||
|
||||
@@ -24,18 +24,18 @@ struct CaseInfo {
|
||||
long title[4];
|
||||
long fold[4];
|
||||
} full;
|
||||
struct CaseInfo* prev;
|
||||
struct CaseInfo* next;
|
||||
struct CaseInfo *prev;
|
||||
struct CaseInfo *next;
|
||||
};
|
||||
|
||||
typedef int (*EntryCb)(long rune, int fill, char** fields, size_t size);
|
||||
|
||||
static void entryProcess(FILE* in, EntryCb cb, const char* globStart,
|
||||
const char* globEnd, size_t globField,
|
||||
static void entryProcess(FILE *in, EntryCb cb, const char *globStart,
|
||||
const char *globEnd, size_t globField,
|
||||
size_t codeField, size_t minFields) {
|
||||
long code, startCode, prevCode = -1;
|
||||
char line[MAX_LINE];
|
||||
char* fields[MAX_FIELDS];
|
||||
char *fields[MAX_FIELDS];
|
||||
int emitted = 0;
|
||||
size_t columns;
|
||||
|
||||
@@ -76,9 +76,9 @@ static void entryProcess(FILE* in, EntryCb cb, const char* globStart,
|
||||
emitted = cb(code++, 1, fields, columns);
|
||||
}
|
||||
|
||||
static struct CaseInfo* caseInfoSort(struct CaseInfo* head) {
|
||||
struct CaseInfo* current;
|
||||
struct CaseInfo* next;
|
||||
static struct CaseInfo *caseInfoSort(struct CaseInfo *head) {
|
||||
struct CaseInfo *current;
|
||||
struct CaseInfo *next;
|
||||
int swapped;
|
||||
|
||||
if (!head || !head->next)
|
||||
@@ -112,9 +112,9 @@ static struct CaseInfo* caseInfoSort(struct CaseInfo* head) {
|
||||
return head;
|
||||
}
|
||||
|
||||
static struct CaseInfo* caseInfoGet(struct CaseInfo** head, long rune) {
|
||||
struct CaseInfo* current = *head;
|
||||
struct CaseInfo* node;
|
||||
static struct CaseInfo *caseInfoGet(struct CaseInfo** head, long rune) {
|
||||
struct CaseInfo *current = *head;
|
||||
struct CaseInfo *node;
|
||||
|
||||
while (current != NULL) {
|
||||
if (current->rune == rune)
|
||||
@@ -135,7 +135,7 @@ static struct CaseInfo* caseInfoGet(struct CaseInfo** head, long rune) {
|
||||
return node;
|
||||
}
|
||||
|
||||
static size_t categoryClassify(const char* name) {
|
||||
static size_t categoryClassify(const char *name) {
|
||||
static const char *categories[] = {
|
||||
"Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Pc",
|
||||
"Pd", "Ps", "Pe", "Pi", "Pf", "Po", "Sm", "Sc", "Sk", "So", "Zs", "Zl",
|
||||
@@ -152,15 +152,15 @@ static size_t categoryClassify(const char* name) {
|
||||
return categoryClassify("Cn");
|
||||
}
|
||||
|
||||
FILE* in;
|
||||
FILE* out;
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
|
||||
struct Blocks categoryBlocks;
|
||||
struct CaseInfo* caseInfo = NULL;
|
||||
struct CaseInfo *caseInfo = NULL;
|
||||
|
||||
static int entryUnicodeData(long rune, int fill, char** fields, size_t size) {
|
||||
long lowercase, uppercase, titlecase;
|
||||
struct CaseInfo* node;
|
||||
struct CaseInfo *node;
|
||||
|
||||
if (fill) {
|
||||
return blockInsert(&categoryBlocks, categoryClassify("Cn"), 0);
|
||||
@@ -180,8 +180,8 @@ static int entryUnicodeData(long rune, int fill, char** fields, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
static void arrayParseFromStr(const char* field, long* array) {
|
||||
char* endptr = (char*)field;
|
||||
static void arrayParseFromStr(const char *field, long *array) {
|
||||
char *endptr = (char*)field;
|
||||
size_t written = 0;
|
||||
|
||||
while (1) {
|
||||
@@ -193,7 +193,7 @@ static void arrayParseFromStr(const char* field, long* array) {
|
||||
}
|
||||
|
||||
static int entryCaseFolding(long rune, int fill, char** fields, size_t size) {
|
||||
struct CaseInfo* node;
|
||||
struct CaseInfo *node;
|
||||
|
||||
if (fill || !strcmp("T", fields[1]))
|
||||
return 1;
|
||||
@@ -208,7 +208,7 @@ static int entryCaseFolding(long rune, int fill, char** fields, size_t size) {
|
||||
}
|
||||
|
||||
static int entrySpecialCasing(long rune, int fill, char** fields, size_t size) {
|
||||
struct CaseInfo* node;
|
||||
struct CaseInfo *node;
|
||||
|
||||
if (fill || strcmp("", fields[4]))
|
||||
return 1;
|
||||
@@ -221,13 +221,13 @@ static int entrySpecialCasing(long rune, int fill, char** fields, size_t size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mappingRemoveSingle(long* array) {
|
||||
static void mappingRemoveSingle(long *array) {
|
||||
if (array[0] && !array[1])
|
||||
array[0] = 0;
|
||||
}
|
||||
|
||||
static void caseInfoReduce(void) {
|
||||
struct CaseInfo* current = caseInfo;
|
||||
struct CaseInfo *current = caseInfo;
|
||||
while (current) {
|
||||
if (!current->simple.title && current->simple.upper)
|
||||
current->simple.title = current->simple.upper;
|
||||
@@ -248,7 +248,7 @@ struct Blocks lowerFullBlocks, upperFullBlocks, titleFullBlocks, foldFullBlocks;
|
||||
long longIndexData[1024][4];
|
||||
size_t longIndexSize = 0;
|
||||
|
||||
static long longIndexGet(long* array) {
|
||||
static long longIndexGet(long *array) {
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < longIndexSize; i++) {
|
||||
@@ -261,7 +261,7 @@ static long longIndexGet(long* array) {
|
||||
}
|
||||
|
||||
static void blocksBuild(void) {
|
||||
struct CaseInfo* current = caseInfo;
|
||||
struct CaseInfo *current = caseInfo;
|
||||
int emitted;
|
||||
long last = -1;
|
||||
|
||||
@@ -388,14 +388,14 @@ static void outputCode(void) {
|
||||
} while(0)
|
||||
|
||||
#define EMIT_FULL(FUNC, SIMPLE, FULL_BLOCKS, FULL_BASE, SIMPLE_FUNC) do { \
|
||||
fprintf(out, "size_t CgeRune" #FUNC "Full(uint32_t r, uint32_t* out){\n"); \
|
||||
fprintf(out, "size_t CgeRune" #FUNC "Full(uint32_t r, uint32_t *out){\n"); \
|
||||
fprintf(out, " long t;\n if(r>1114111ul){\n *out=r;\n return 1;\n }\n"); \
|
||||
blockAccess(&FULL_BLOCKS, 0, out, "t", "r", FULL_BASE "1"); \
|
||||
blockAccess(&FULL_BLOCKS, 1, out, "t", "r", FULL_BASE "2"); \
|
||||
blockAccess(&FULL_BLOCKS, 2, out, "t", "r", FULL_BASE "3"); \
|
||||
blockAccess(&FULL_BLOCKS, 3, out, "t", "r", FULL_BASE "4"); \
|
||||
fprintf(out, " if(t>=0){\n"); \
|
||||
fprintf(out, " const int32_t* p=case_data[t];\n"); \
|
||||
fprintf(out, " const int32_t *p=case_data[t];\n"); \
|
||||
fprintf(out, " size_t i=0;\n"); \
|
||||
fprintf(out, " while(p[i] && i<3){out[i]=p[i];i++;}\n"); \
|
||||
fprintf(out, " return i;\n }\n"); \
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#define MAX_FIELDS 16
|
||||
|
||||
static int glob(const char* pattern, const char* text) {
|
||||
const char* star = NULL;
|
||||
const char* restart = text;
|
||||
static int glob(const char *pattern, const char *text) {
|
||||
const char *star = NULL;
|
||||
const char *restart = text;
|
||||
|
||||
while (*text) {
|
||||
if (*pattern == *text || *pattern == '?')
|
||||
@@ -27,13 +27,13 @@ static int glob(const char* pattern, const char* text) {
|
||||
return (*pattern == '\0');
|
||||
}
|
||||
|
||||
static char* trimLeft(char* line) {
|
||||
static char *trimLeft(char *line) {
|
||||
for (; *line && isspace(*line); ++line);
|
||||
return line;
|
||||
}
|
||||
|
||||
static void trimRight(char* line) {
|
||||
char* last = line;
|
||||
static void trimRight(char *line) {
|
||||
char *last = line;
|
||||
|
||||
for (; *line; ++line)
|
||||
if (!isspace(*line))
|
||||
@@ -41,17 +41,17 @@ static void trimRight(char* line) {
|
||||
*last = '\0';
|
||||
}
|
||||
|
||||
static void trimComment(char* line) {
|
||||
char* separator = strchr(line, '#');
|
||||
static void trimComment(char *line) {
|
||||
char *separator = strchr(line, '#');
|
||||
if (separator) *separator = '\0';
|
||||
}
|
||||
|
||||
static char* trim(char* line) {
|
||||
static char *trim(char *line) {
|
||||
trimRight(line);
|
||||
return trimLeft(line);
|
||||
}
|
||||
|
||||
static size_t fieldParse(char* line, char** fields, char separator) {
|
||||
static size_t fieldParse(char *line, char** fields, char separator) {
|
||||
size_t index = 0;
|
||||
|
||||
do {
|
||||
@@ -65,7 +65,7 @@ static size_t fieldParse(char* line, char** fields, char separator) {
|
||||
return index;
|
||||
}
|
||||
|
||||
static int processLine(FILE* in, char* line, size_t size, char** fields) {
|
||||
static int processLine(FILE *in, char *line, size_t size, char** fields) {
|
||||
if (!fgets(line, size, in))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
struct ValueList {
|
||||
long* data;
|
||||
long *data;
|
||||
size_t size;
|
||||
struct ValueList* next;
|
||||
struct ValueList *next;
|
||||
};
|
||||
|
||||
static long valueListFind(struct ValueList* list, long* data, size_t size) {
|
||||
static long valueListFind(struct ValueList *list, long *data, size_t size) {
|
||||
long index = 0;
|
||||
|
||||
while (list) {
|
||||
@@ -22,7 +22,7 @@ static long valueListFind(struct ValueList* list, long* data, size_t size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static long valueListIntern(struct ValueList** list, long* data, size_t size) {
|
||||
static long valueListIntern(struct ValueList** list, long *data, size_t size) {
|
||||
long index = 0;
|
||||
|
||||
while (*list) ++index, list = &(*list)->next;
|
||||
|
||||
Reference in New Issue
Block a user