Fix code style for pointers

This commit is contained in:
2026-06-21 13:35:05 +03:00
parent 32649b3526
commit 58526b9ee1
10 changed files with 2246 additions and 2246 deletions

View File

@@ -4,15 +4,15 @@
#include <stdint.h> #include <stdint.h>
typedef struct CgeStr { typedef struct CgeStr {
const char* data; const char *data;
size_t size; size_t size;
} CgeStr; } CgeStr;
#define CGE_STR_LIT(s) \ #define CGE_STR_LIT(s) \
{(s), sizeof(s) - 1} {(s), sizeof(s) - 1}
typedef void (*CgeStrIterCb)(uint32_t rune, void* user); typedef void (*CgeStrIterCb)(uint32_t rune, void *user);
typedef void (*CgeStrWriteCb)(const char* data, size_t size, void* user); typedef void (*CgeStrWriteCb)(const char *data, size_t size, void *user);
enum CgeCat { enum CgeCat {
CGE_CAT_LU, CGE_CAT_LL, CGE_CAT_LT, CGE_CAT_LM, CGE_CAT_LO, CGE_CAT_MN, 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 CgeRuneUpper(uint32_t rune);
uint32_t CgeRuneTitle(uint32_t rune); uint32_t CgeRuneTitle(uint32_t rune);
uint32_t CgeRuneFold(uint32_t rune); uint32_t CgeRuneFold(uint32_t rune);
size_t CgeRuneLowerFull(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 CgeRuneUpperFull(uint32_t rune, uint32_t *out);
size_t CgeRuneTitleFull(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 CgeRuneFoldFull(uint32_t rune, uint32_t *out);
int CgeRuneIsControl(uint32_t rune); int CgeRuneIsControl(uint32_t rune);
int CgeRuneIsDigit(uint32_t rune); int CgeRuneIsDigit(uint32_t rune);
@@ -46,33 +46,33 @@ int CgeRuneIsSymbol(uint32_t rune);
int CgeRuneIsTitle(uint32_t rune); int CgeRuneIsTitle(uint32_t rune);
int CgeRuneIsUpper(uint32_t rune); int CgeRuneIsUpper(uint32_t rune);
int CgeUtf8Encode(uint32_t rune, char* data); int CgeUtf8Encode(uint32_t rune, char *data);
int CgeUtf8EncodeLax(uint32_t rune, char* data); int CgeUtf8EncodeLax(uint32_t rune, char *data);
int CgeUtf8Decode(const char* data, size_t size, uint32_t* rune); int CgeUtf8Decode(const char *data, size_t size, uint32_t *rune);
int CgeUtf8DecodeLax(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 CgeUtf16Encode(uint32_t rune, uint16_t *data);
int CgeUtf16EncodeLax(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 CgeUtf16Decode(const uint16_t *data, size_t size, uint32_t *rune);
int CgeUtf16DecodeLax(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 CgeStrIter(const CgeStr *str, CgeStrIterCb cb, void *user);
void CgeStrToLower(const CgeStr* str, CgeStrWriteCb cb, void* user); void CgeStrToLower(const CgeStr *str, CgeStrWriteCb cb, void *user);
void CgeStrToUpper(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); 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);
int CgeStrICmp(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 CgeStrIndexRune(const CgeStr *str, uint32_t rune);
size_t CgeStrLastIndexRune(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 CgeStrIndexRuneLax(const CgeStr *str, uint32_t rune);
size_t CgeStrLastIndexRuneLax(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 CgeStrIndexStr(const CgeStr *str, const CgeStr *substr);
size_t CgeStrLastIndexStr(const CgeStr* str, const CgeStr* substr); size_t CgeStrLastIndexStr(const CgeStr *str, const CgeStr *substr);
int CgeStrHasPrefix(const CgeStr* str, const CgeStr* prefix); int CgeStrHasPrefix(const CgeStr *str, const CgeStr *prefix);
int CgeStrHasSuffix(const CgeStr* str, const CgeStr* suffix); int CgeStrHasSuffix(const CgeStr *str, const CgeStr *suffix);
void CgeStrTrimLeft(const CgeStr* str, CgeStr* out); void CgeStrTrimLeft(const CgeStr *str, CgeStr *out);
void CgeStrTrimRight(const CgeStr* str, CgeStr* out); void CgeStrTrimRight(const CgeStr *str, CgeStr *out);
void CgeStrTrim(const CgeStr* str, CgeStr* out); void CgeStrTrim(const CgeStr *str, CgeStr *out);
void CgeStrSplit(CgeStr* str, CgeStr* prefix, uint32_t delim); void CgeStrSplit(CgeStr *str, CgeStr *prefix, uint32_t delim);
#endif /* CGE_STR_H */ #endif /* CGE_STR_H */

View File

@@ -33,7 +33,7 @@ Builds a static library. No shared library or external dependencies.
#include "CgeStr.h" #include "CgeStr.h"
#include <stdio.h> #include <stdio.h>
void print_rune(uint32_t rune, void* user) { void print_rune(uint32_t rune, void *user) {
printf("U+%04X ", rune); printf("U+%04X ", rune);
} }

64
Str.c
View File

@@ -12,7 +12,7 @@ struct UniStream {
size_t size; 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) if (stream->size >= MAX_UNI_STREAM)
return 0; return 0;
@@ -22,7 +22,7 @@ static int uniStreamPut(struct UniStream* stream, uint32_t rune) {
return 1; return 1;
} }
static int uniStreamGet(struct UniStream* stream, uint32_t* rune) { static int uniStreamGet(struct UniStream *stream, uint32_t *rune) {
if (!stream->size) if (!stream->size)
return 0; return 0;
@@ -32,9 +32,9 @@ static int uniStreamGet(struct UniStream* stream, uint32_t* rune) {
return 1; return 1;
} }
void CgeStrIter(const CgeStr* str, CgeStrIterCb cb, void* user) { void CgeStrIter(const CgeStr *str, CgeStrIterCb cb, void *user) {
const char* current = str->data; const char *current = str->data;
const char* end = str->data + str->size; const char *end = str->data + str->size;
while (current < end) { while (current < end) {
uint32_t rune; 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) { void CgeStrToLower(const CgeStr *str, CgeStrWriteCb cb, void *user) {
const char* current = str->data; const char *current = str->data;
const char* end = str->data + str->size; const char *end = str->data + str->size;
while (current < end) { while (current < end) {
uint32_t rune; 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) { void CgeStrToUpper(const CgeStr *str, CgeStrWriteCb cb, void *user) {
const char* current = str->data; const char *current = str->data;
const char* end = str->data + str->size; const char *end = str->data + str->size;
while (current < end) { while (current < end) {
uint32_t rune; 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) { void CgeStrFold(const CgeStr *str, CgeStrWriteCb cb, void *user) {
const char* current = str->data; const char *current = str->data;
const char* end = str->data + str->size; const char *end = str->data + str->size;
while (current < end) { while (current < end) {
uint32_t rune; 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; size_t leastSize;
int result; int result;
@@ -120,14 +120,14 @@ int CgeStrCmp(const CgeStr* lhs, const CgeStr* rhs) {
return 0; 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 buf1 = {{0}, 0, 0, 0};
struct UniStream buf2 = {{0}, 0, 0, 0}; struct UniStream buf2 = {{0}, 0, 0, 0};
const char* current1 = lhs->data; const char *current1 = lhs->data;
const char* current2 = rhs->data; const char *current2 = rhs->data;
const char* end1 = lhs->data + lhs->size; const char *end1 = lhs->data + lhs->size;
const char* end2 = rhs->data + rhs->size; const char *end2 = rhs->data + rhs->size;
while (1) { while (1) {
uint32_t rune1, rune2; 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]; char scratch[4];
CgeStr tmp; CgeStr tmp;
@@ -179,7 +179,7 @@ size_t CgeStrIndexRune(const CgeStr* str, uint32_t rune) {
return CgeStrIndexStr(str, &tmp); 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]; char scratch[4];
CgeStr tmp; CgeStr tmp;
@@ -190,7 +190,7 @@ size_t CgeStrLastIndexRune(const CgeStr* str, uint32_t rune) {
return CgeStrLastIndexStr(str, &tmp); 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; size_t i = 0;
while (i < str->size) { while (i < str->size) {
uint32_t r; uint32_t r;
@@ -204,7 +204,7 @@ size_t CgeStrIndexRuneLax(const CgeStr* str, uint32_t rune) {
return (size_t)-1; 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; size_t i = str->size;
while (i > 0) { while (i > 0) {
@@ -224,7 +224,7 @@ size_t CgeStrLastIndexRuneLax(const CgeStr* str, uint32_t rune) {
return (size_t)-1; 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; size_t i;
if (!substr->size) if (!substr->size)
@@ -239,7 +239,7 @@ size_t CgeStrIndexStr(const CgeStr* str, const CgeStr* substr) {
return (size_t)-1; 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; size_t i;
if (!substr->size) if (!substr->size)
@@ -254,21 +254,21 @@ size_t CgeStrLastIndexStr(const CgeStr* str, const CgeStr* substr) {
return (size_t)-1; 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) if (prefix->size > str->size)
return 0; return 0;
return !memcmp(str->data, prefix->data, prefix->size); 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) if (suffix->size > str->size)
return 0; return 0;
return !memcmp(str->data + str->size - suffix->size, suffix->data, suffix->size); 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->data = str->data;
out->size = str->size; 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->data = str->data;
out->size = str->size; 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); CgeStrTrimLeft(str, out);
CgeStrTrimRight(out, 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; uint32_t r;
size_t pos; size_t pos;
int count; int count;

16
UCD.c
View File

@@ -2268,7 +2268,7 @@ uint32_t CgeRuneFold(uint32_t r){
return t?t+r:r; return t?t+r:r;
} }
size_t CgeRuneLowerFull(uint32_t r, uint32_t* out){ size_t CgeRuneLowerFull(uint32_t r, uint32_t *out){
long t; long t;
if(r>1114111ul){ if(r>1114111ul){
*out=r; *out=r;
@@ -2279,7 +2279,7 @@ size_t CgeRuneLowerFull(uint32_t r, uint32_t* out){
t = (long)lfx3[(t<<5)+(r&31)]; t = (long)lfx3[(t<<5)+(r&31)];
t = (long)lfx4[t]; t = (long)lfx4[t];
if(t>=0){ if(t>=0){
const int32_t* p=case_data[t]; const int32_t *p=case_data[t];
size_t i=0; size_t i=0;
while(p[i] && i<3){out[i]=p[i];i++;} while(p[i] && i<3){out[i]=p[i];i++;}
return i; return i;
@@ -2288,7 +2288,7 @@ size_t CgeRuneLowerFull(uint32_t r, uint32_t* out){
return 1; return 1;
} }
size_t CgeRuneUpperFull(uint32_t r, uint32_t* out){ size_t CgeRuneUpperFull(uint32_t r, uint32_t *out){
long t; long t;
if(r>1114111ul){ if(r>1114111ul){
*out=r; *out=r;
@@ -2299,7 +2299,7 @@ size_t CgeRuneUpperFull(uint32_t r, uint32_t* out){
t = (long)ufx3[(t<<5)+(r&31)]; t = (long)ufx3[(t<<5)+(r&31)];
t = (long)ufx4[t]; t = (long)ufx4[t];
if(t>=0){ if(t>=0){
const int32_t* p=case_data[t]; const int32_t *p=case_data[t];
size_t i=0; size_t i=0;
while(p[i] && i<3){out[i]=p[i];i++;} while(p[i] && i<3){out[i]=p[i];i++;}
return i; return i;
@@ -2308,7 +2308,7 @@ size_t CgeRuneUpperFull(uint32_t r, uint32_t* out){
return 1; return 1;
} }
size_t CgeRuneTitleFull(uint32_t r, uint32_t* out){ size_t CgeRuneTitleFull(uint32_t r, uint32_t *out){
long t; long t;
if(r>1114111ul){ if(r>1114111ul){
*out=r; *out=r;
@@ -2319,7 +2319,7 @@ size_t CgeRuneTitleFull(uint32_t r, uint32_t* out){
t = (long)tfx3[(t<<5)+(r&31)]; t = (long)tfx3[(t<<5)+(r&31)];
t = (long)tfx4[t]; t = (long)tfx4[t];
if(t>=0){ if(t>=0){
const int32_t* p=case_data[t]; const int32_t *p=case_data[t];
size_t i=0; size_t i=0;
while(p[i] && i<3){out[i]=p[i];i++;} while(p[i] && i<3){out[i]=p[i];i++;}
return i; return i;
@@ -2328,7 +2328,7 @@ size_t CgeRuneTitleFull(uint32_t r, uint32_t* out){
return 1; return 1;
} }
size_t CgeRuneFoldFull(uint32_t r, uint32_t* out){ size_t CgeRuneFoldFull(uint32_t r, uint32_t *out){
long t; long t;
if(r>1114111ul){ if(r>1114111ul){
*out=r; *out=r;
@@ -2339,7 +2339,7 @@ size_t CgeRuneFoldFull(uint32_t r, uint32_t* out){
t = (long)ffx3[(t<<5)+(r&31)]; t = (long)ffx3[(t<<5)+(r&31)];
t = (long)ffx4[t]; t = (long)ffx4[t];
if(t>=0){ if(t>=0){
const int32_t* p=case_data[t]; const int32_t *p=case_data[t];
size_t i=0; size_t i=0;
while(p[i] && i<3){out[i]=p[i];i++;} while(p[i] && i<3){out[i]=p[i];i++;}
return i; return i;

View File

@@ -2,7 +2,7 @@
#define INVALID_RUNE 0xFFFD #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 <= 0xFFFF) {
if (rune >= 0xD800 && rune <= 0xDFFF) if (rune >= 0xD800 && rune <= 0xDFFF)
return -1; return -1;
@@ -18,7 +18,7 @@ int CgeUtf16Encode(uint32_t rune, uint16_t* data) {
return -1; return -1;
} }
int CgeUtf16EncodeLax(uint32_t rune, uint16_t* data) { int CgeUtf16EncodeLax(uint32_t rune, uint16_t *data) {
int result; int result;
result = CgeUtf16Encode(rune, data); result = CgeUtf16Encode(rune, data);
@@ -28,7 +28,7 @@ int CgeUtf16EncodeLax(uint32_t rune, uint16_t* data) {
return result; 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]; uint16_t trail, lead = data[0];
if (size == 0) if (size == 0)
@@ -51,7 +51,7 @@ int CgeUtf16Decode(const uint16_t* data, size_t size, uint32_t* rune) {
return -1; 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; int result;
result = CgeUtf16Decode(data, size, rune); result = CgeUtf16Decode(data, size, rune);

8
Utf8.c
View File

@@ -2,7 +2,7 @@
#define INVALID_RUNE 0xFFFD #define INVALID_RUNE 0xFFFD
int CgeUtf8Encode(uint32_t rune, char* data) { int CgeUtf8Encode(uint32_t rune, char *data) {
if (rune < 0x80) { if (rune < 0x80) {
data[0] = (char)rune; data[0] = (char)rune;
return 1; return 1;
@@ -30,7 +30,7 @@ int CgeUtf8Encode(uint32_t rune, char* data) {
return -1; return -1;
} }
int CgeUtf8EncodeLax(uint32_t rune, char* data) { int CgeUtf8EncodeLax(uint32_t rune, char *data) {
int result; int result;
result = CgeUtf8Encode(rune, data); result = CgeUtf8Encode(rune, data);
@@ -40,7 +40,7 @@ int CgeUtf8EncodeLax(uint32_t rune, char* data) {
return result; 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]; unsigned char byte = (unsigned char)data[0];
int i, n; int i, n;
@@ -88,7 +88,7 @@ int CgeUtf8Decode(const char* data, size_t size, uint32_t* rune) {
return n; 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; int result;
result = CgeUtf8Decode(data, size, rune); result = CgeUtf8Decode(data, size, rune);

View File

@@ -6,14 +6,14 @@
#include "ValueList.h" #include "ValueList.h"
struct BlockLevel { struct BlockLevel {
long* data; long *data;
size_t size; size_t size;
size_t capacity; size_t capacity;
struct ValueList* list; struct ValueList *list;
}; };
struct Blocks { struct Blocks {
struct BlockLevel* levels; struct BlockLevel *levels;
size_t depth; size_t depth;
}; };
@@ -23,8 +23,8 @@ static int ilog2(unsigned long value) {
return result; return result;
} }
static long blockInsert(struct Blocks* blocks, long value, size_t depth) { static long blockInsert(struct Blocks *blocks, long value, size_t depth) {
struct BlockLevel* level = blocks->levels + depth; struct BlockLevel *level = blocks->levels + depth;
if (blocks->depth - 1 != depth) { if (blocks->depth - 1 != depth) {
if ((value = blockInsert(blocks, value, depth + 1)) == -1) 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; return -1;
} }
static long blockFindR(struct Blocks* blocks, long value, long offset, size_t depth) { static long blockFindR(struct Blocks *blocks, long value, long offset, size_t depth) {
struct BlockLevel* level = &blocks->levels[depth]; struct BlockLevel *level = &blocks->levels[depth];
struct ValueList* current; struct ValueList *current;
size_t i, bits = 0; size_t i, bits = 0;
for (i = depth + 1; i < blocks->depth; i++) { 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; return offset;
} }
static long blockFind(struct Blocks* blocks, long value) { static long blockFind(struct Blocks *blocks, long value) {
size_t i, bits = 0; size_t i, bits = 0;
long offset; long offset;
@@ -77,7 +77,7 @@ static long blockFind(struct Blocks* blocks, long value) {
return blockFindR(blocks, value, offset, 0); 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; va_list args;
blocks->depth = 0; blocks->depth = 0;
@@ -87,7 +87,7 @@ static void blockInit(struct Blocks* blocks, size_t depth, ...) {
va_start(args, depth); va_start(args, depth);
while (blocks->depth < depth) { while (blocks->depth < depth) {
struct BlockLevel* level = &blocks->levels[blocks->depth]; struct BlockLevel *level = &blocks->levels[blocks->depth];
level->list = NULL; level->list = NULL;
level->size = 0; level->size = 0;
@@ -100,10 +100,10 @@ static void blockInit(struct Blocks* blocks, size_t depth, ...) {
va_end(args); va_end(args);
} }
static void blockDump(struct Blocks* blocks, size_t depth, FILE* out, static void blockDump(struct Blocks *blocks, size_t depth, FILE *out,
const char* name, const char* type) { const char *name, const char *type) {
struct BlockLevel* level = &blocks->levels[depth]; struct BlockLevel *level = &blocks->levels[depth];
struct ValueList* current; struct ValueList *current;
size_t i, j, printed = 0; size_t i, j, printed = 0;
fprintf(out, "static const %s %s[] = {\n ", type, name); 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"); fprintf(out, "\n};\n\n");
} }
static void blockAccess(struct Blocks* blocks, size_t depth, FILE* out, static void blockAccess(struct Blocks *blocks, size_t depth, FILE *out,
const char* var, const char* arg, const char* name) { const char *var, const char *arg, const char *name) {
struct BlockLevel* level = &blocks->levels[depth]; struct BlockLevel *level = &blocks->levels[depth];
long i, bits = 0, offset, mask; long i, bits = 0, offset, mask;
for (i = depth + 1; i < blocks->depth; i++) { for (i = depth + 1; i < blocks->depth; i++) {

View File

@@ -24,18 +24,18 @@ struct CaseInfo {
long title[4]; long title[4];
long fold[4]; long fold[4];
} full; } full;
struct CaseInfo* prev; struct CaseInfo *prev;
struct CaseInfo* next; struct CaseInfo *next;
}; };
typedef int (*EntryCb)(long rune, int fill, char** fields, size_t size); typedef int (*EntryCb)(long rune, int fill, char** fields, size_t size);
static void entryProcess(FILE* in, EntryCb cb, const char* globStart, static void entryProcess(FILE *in, EntryCb cb, const char *globStart,
const char* globEnd, size_t globField, const char *globEnd, size_t globField,
size_t codeField, size_t minFields) { size_t codeField, size_t minFields) {
long code, startCode, prevCode = -1; long code, startCode, prevCode = -1;
char line[MAX_LINE]; char line[MAX_LINE];
char* fields[MAX_FIELDS]; char *fields[MAX_FIELDS];
int emitted = 0; int emitted = 0;
size_t columns; size_t columns;
@@ -76,9 +76,9 @@ static void entryProcess(FILE* in, EntryCb cb, const char* globStart,
emitted = cb(code++, 1, fields, columns); emitted = cb(code++, 1, fields, columns);
} }
static struct CaseInfo* caseInfoSort(struct CaseInfo* head) { static struct CaseInfo *caseInfoSort(struct CaseInfo *head) {
struct CaseInfo* current; struct CaseInfo *current;
struct CaseInfo* next; struct CaseInfo *next;
int swapped; int swapped;
if (!head || !head->next) if (!head || !head->next)
@@ -112,9 +112,9 @@ static struct CaseInfo* caseInfoSort(struct CaseInfo* head) {
return head; return head;
} }
static struct CaseInfo* caseInfoGet(struct CaseInfo** head, long rune) { static struct CaseInfo *caseInfoGet(struct CaseInfo** head, long rune) {
struct CaseInfo* current = *head; struct CaseInfo *current = *head;
struct CaseInfo* node; struct CaseInfo *node;
while (current != NULL) { while (current != NULL) {
if (current->rune == rune) if (current->rune == rune)
@@ -135,7 +135,7 @@ static struct CaseInfo* caseInfoGet(struct CaseInfo** head, long rune) {
return node; return node;
} }
static size_t categoryClassify(const char* name) { static size_t categoryClassify(const char *name) {
static const char *categories[] = { static const char *categories[] = {
"Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Pc", "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Pc",
"Pd", "Ps", "Pe", "Pi", "Pf", "Po", "Sm", "Sc", "Sk", "So", "Zs", "Zl", "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"); return categoryClassify("Cn");
} }
FILE* in; FILE *in;
FILE* out; FILE *out;
struct Blocks categoryBlocks; struct Blocks categoryBlocks;
struct CaseInfo* caseInfo = NULL; struct CaseInfo *caseInfo = NULL;
static int entryUnicodeData(long rune, int fill, char** fields, size_t size) { static int entryUnicodeData(long rune, int fill, char** fields, size_t size) {
long lowercase, uppercase, titlecase; long lowercase, uppercase, titlecase;
struct CaseInfo* node; struct CaseInfo *node;
if (fill) { if (fill) {
return blockInsert(&categoryBlocks, categoryClassify("Cn"), 0); 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) { static void arrayParseFromStr(const char *field, long *array) {
char* endptr = (char*)field; char *endptr = (char*)field;
size_t written = 0; size_t written = 0;
while (1) { 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) { static int entryCaseFolding(long rune, int fill, char** fields, size_t size) {
struct CaseInfo* node; struct CaseInfo *node;
if (fill || !strcmp("T", fields[1])) if (fill || !strcmp("T", fields[1]))
return 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) { static int entrySpecialCasing(long rune, int fill, char** fields, size_t size) {
struct CaseInfo* node; struct CaseInfo *node;
if (fill || strcmp("", fields[4])) if (fill || strcmp("", fields[4]))
return 1; return 1;
@@ -221,13 +221,13 @@ static int entrySpecialCasing(long rune, int fill, char** fields, size_t size) {
return 1; return 1;
} }
static void mappingRemoveSingle(long* array) { static void mappingRemoveSingle(long *array) {
if (array[0] && !array[1]) if (array[0] && !array[1])
array[0] = 0; array[0] = 0;
} }
static void caseInfoReduce(void) { static void caseInfoReduce(void) {
struct CaseInfo* current = caseInfo; struct CaseInfo *current = caseInfo;
while (current) { while (current) {
if (!current->simple.title && current->simple.upper) if (!current->simple.title && current->simple.upper)
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]; long longIndexData[1024][4];
size_t longIndexSize = 0; size_t longIndexSize = 0;
static long longIndexGet(long* array) { static long longIndexGet(long *array) {
size_t i; size_t i;
for (i = 0; i < longIndexSize; i++) { for (i = 0; i < longIndexSize; i++) {
@@ -261,7 +261,7 @@ static long longIndexGet(long* array) {
} }
static void blocksBuild(void) { static void blocksBuild(void) {
struct CaseInfo* current = caseInfo; struct CaseInfo *current = caseInfo;
int emitted; int emitted;
long last = -1; long last = -1;
@@ -388,14 +388,14 @@ static void outputCode(void) {
} while(0) } while(0)
#define EMIT_FULL(FUNC, SIMPLE, FULL_BLOCKS, FULL_BASE, SIMPLE_FUNC) do { \ #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"); \ 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, 0, out, "t", "r", FULL_BASE "1"); \
blockAccess(&FULL_BLOCKS, 1, out, "t", "r", FULL_BASE "2"); \ blockAccess(&FULL_BLOCKS, 1, out, "t", "r", FULL_BASE "2"); \
blockAccess(&FULL_BLOCKS, 2, out, "t", "r", FULL_BASE "3"); \ blockAccess(&FULL_BLOCKS, 2, out, "t", "r", FULL_BASE "3"); \
blockAccess(&FULL_BLOCKS, 3, out, "t", "r", FULL_BASE "4"); \ blockAccess(&FULL_BLOCKS, 3, out, "t", "r", FULL_BASE "4"); \
fprintf(out, " if(t>=0){\n"); \ 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, " size_t i=0;\n"); \
fprintf(out, " while(p[i] && i<3){out[i]=p[i];i++;}\n"); \ fprintf(out, " while(p[i] && i<3){out[i]=p[i];i++;}\n"); \
fprintf(out, " return i;\n }\n"); \ fprintf(out, " return i;\n }\n"); \

View File

@@ -8,9 +8,9 @@
#define MAX_FIELDS 16 #define MAX_FIELDS 16
static int glob(const char* pattern, const char* text) { static int glob(const char *pattern, const char *text) {
const char* star = NULL; const char *star = NULL;
const char* restart = text; const char *restart = text;
while (*text) { while (*text) {
if (*pattern == *text || *pattern == '?') if (*pattern == *text || *pattern == '?')
@@ -27,13 +27,13 @@ static int glob(const char* pattern, const char* text) {
return (*pattern == '\0'); return (*pattern == '\0');
} }
static char* trimLeft(char* line) { static char *trimLeft(char *line) {
for (; *line && isspace(*line); ++line); for (; *line && isspace(*line); ++line);
return line; return line;
} }
static void trimRight(char* line) { static void trimRight(char *line) {
char* last = line; char *last = line;
for (; *line; ++line) for (; *line; ++line)
if (!isspace(*line)) if (!isspace(*line))
@@ -41,17 +41,17 @@ static void trimRight(char* line) {
*last = '\0'; *last = '\0';
} }
static void trimComment(char* line) { static void trimComment(char *line) {
char* separator = strchr(line, '#'); char *separator = strchr(line, '#');
if (separator) *separator = '\0'; if (separator) *separator = '\0';
} }
static char* trim(char* line) { static char *trim(char *line) {
trimRight(line); trimRight(line);
return trimLeft(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; size_t index = 0;
do { do {
@@ -65,7 +65,7 @@ static size_t fieldParse(char* line, char** fields, char separator) {
return index; 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)) if (!fgets(line, size, in))
return 0; return 0;

View File

@@ -6,12 +6,12 @@
#include <stdlib.h> #include <stdlib.h>
struct ValueList { struct ValueList {
long* data; long *data;
size_t size; 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; long index = 0;
while (list) { while (list) {
@@ -22,7 +22,7 @@ static long valueListFind(struct ValueList* list, long* data, size_t size) {
return -1; 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; long index = 0;
while (*list) ++index, list = &(*list)->next; while (*list) ++index, list = &(*list)->next;