[F] Fixed compilation errors
This commit is contained in:
parent
a512666698
commit
e88f49d8ff
34
lib/fort.c
34
lib/fort.c
@ -176,7 +176,7 @@ struct conv_context {
|
|||||||
union {
|
union {
|
||||||
char *buf;
|
char *buf;
|
||||||
wchar_t *wbuf;
|
wchar_t *wbuf;
|
||||||
};
|
} u;
|
||||||
size_t raw_avail;
|
size_t raw_avail;
|
||||||
struct fort_context *cntx;
|
struct fort_context *cntx;
|
||||||
enum str_buf_type b_type;
|
enum str_buf_type b_type;
|
||||||
@ -3072,7 +3072,7 @@ const void *ft_to_string_impl(const ft_table_t *table, enum str_buf_type b_type)
|
|||||||
|
|
||||||
conv_context_t cntx;
|
conv_context_t cntx;
|
||||||
cntx.buf_origin = buffer;
|
cntx.buf_origin = buffer;
|
||||||
cntx.buf = buffer;
|
cntx.u.buf = buffer;
|
||||||
cntx.raw_avail = string_buffer_raw_capacity(table->conv_buffer);
|
cntx.raw_avail = string_buffer_raw_capacity(table->conv_buffer);
|
||||||
cntx.cntx = &context;
|
cntx.cntx = &context;
|
||||||
cntx.b_type = b_type;
|
cntx.b_type = b_type;
|
||||||
@ -3635,9 +3635,9 @@ int snprint_n_strings_impl(char *buf, size_t length, size_t n, const char *str)
|
|||||||
static
|
static
|
||||||
int snprint_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
int snprint_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
||||||
{
|
{
|
||||||
int w = snprint_n_strings_impl(cntx->buf, cntx->raw_avail, n, str);
|
int w = snprint_n_strings_impl(cntx->u.buf, cntx->raw_avail, n, str);
|
||||||
if (w >= 0) {
|
if (w >= 0) {
|
||||||
cntx->buf += w;
|
cntx->u.buf += w;
|
||||||
cntx->raw_avail -= w;
|
cntx->raw_avail -= w;
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@ -3665,25 +3665,25 @@ int print_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
|||||||
return snprint_n_strings(cntx, n, str);
|
return snprint_n_strings(cntx, n, str);
|
||||||
#ifdef FT_HAVE_WCHAR
|
#ifdef FT_HAVE_WCHAR
|
||||||
case W_CHAR_BUF:
|
case W_CHAR_BUF:
|
||||||
cod_w = wsnprint_n_string(cntx->wbuf, cntx->raw_avail, n, str);
|
cod_w = wsnprint_n_string(cntx->u.wbuf, cntx->raw_avail, n, str);
|
||||||
if (cod_w < 0)
|
if (cod_w < 0)
|
||||||
return cod_w;
|
return cod_w;
|
||||||
raw_written = sizeof(wchar_t) * cod_w;
|
raw_written = sizeof(wchar_t) * cod_w;
|
||||||
|
|
||||||
cntx->buf += raw_written;
|
cntx->u.buf += raw_written;
|
||||||
cntx->raw_avail -= raw_written;
|
cntx->raw_avail -= raw_written;
|
||||||
return cod_w;
|
return cod_w;
|
||||||
#endif /* FT_HAVE_WCHAR */
|
#endif /* FT_HAVE_WCHAR */
|
||||||
#ifdef FT_HAVE_UTF8
|
#ifdef FT_HAVE_UTF8
|
||||||
case UTF8_BUF:
|
case UTF8_BUF:
|
||||||
/* Everying is very strange and differs with W_CHAR_BUF */
|
/* Everying is very strange and differs with W_CHAR_BUF */
|
||||||
raw_written = u8nprint_n_strings(cntx->buf, cntx->raw_avail, n, str);
|
raw_written = u8nprint_n_strings(cntx->u.buf, cntx->raw_avail, n, str);
|
||||||
if (raw_written < 0) {
|
if (raw_written < 0) {
|
||||||
fprintf(stderr, " raw_written = %d\n", raw_written);
|
fprintf(stderr, " raw_written = %d\n", raw_written);
|
||||||
return raw_written;
|
return raw_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
cntx->buf += raw_written;
|
cntx->u.buf += raw_written;
|
||||||
cntx->raw_avail -= raw_written;
|
cntx->raw_avail -= raw_written;
|
||||||
return utf8len(str) * n;
|
return utf8len(str) * n;
|
||||||
#endif /* FT_HAVE_UTF8 */
|
#endif /* FT_HAVE_UTF8 */
|
||||||
@ -3699,10 +3699,10 @@ int ft_nprint(conv_context_t *cntx, const char *str, size_t strlen)
|
|||||||
if (cntx->raw_avail + 1/* for 0 */ < strlen)
|
if (cntx->raw_avail + 1/* for 0 */ < strlen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(cntx->buf, str, strlen);
|
memcpy(cntx->u.buf, str, strlen);
|
||||||
cntx->buf += strlen;
|
cntx->u.buf += strlen;
|
||||||
cntx->raw_avail -= strlen;
|
cntx->raw_avail -= strlen;
|
||||||
*cntx->buf = '\0'; /* Do we need this ? */
|
*cntx->u.buf = '\0'; /* Do we need this ? */
|
||||||
return strlen;
|
return strlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3714,13 +3714,13 @@ int ft_nwprint(conv_context_t *cntx, const wchar_t *str, size_t strlen)
|
|||||||
|
|
||||||
size_t raw_len = strlen * sizeof(wchar_t);
|
size_t raw_len = strlen * sizeof(wchar_t);
|
||||||
|
|
||||||
memcpy(cntx->buf, str, raw_len);
|
memcpy(cntx->u.buf, str, raw_len);
|
||||||
cntx->buf += raw_len;
|
cntx->u.buf += raw_len;
|
||||||
cntx->raw_avail -= raw_len;
|
cntx->raw_avail -= raw_len;
|
||||||
|
|
||||||
/* Do we need this ? */
|
/* Do we need this ? */
|
||||||
wchar_t end_of_string = L'\0';
|
wchar_t end_of_string = L'\0';
|
||||||
memcpy(cntx->buf, &end_of_string, sizeof(wchar_t));
|
memcpy(cntx->u.buf, &end_of_string, sizeof(wchar_t));
|
||||||
return strlen;
|
return strlen;
|
||||||
}
|
}
|
||||||
#endif /* FT_HAVE_WCHAR */
|
#endif /* FT_HAVE_WCHAR */
|
||||||
@ -3735,10 +3735,10 @@ int ft_nu8print(conv_context_t *cntx, const void *beg, const void *end)
|
|||||||
if (cntx->raw_avail + 1 < raw_len)
|
if (cntx->raw_avail + 1 < raw_len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(cntx->buf, beg, raw_len);
|
memcpy(cntx->u.buf, beg, raw_len);
|
||||||
cntx->buf += raw_len;
|
cntx->u.buf += raw_len;
|
||||||
cntx->raw_avail -= raw_len;
|
cntx->raw_avail -= raw_len;
|
||||||
*(char *)cntx->buf = '\0'; /* Do we need this ? */
|
*(cntx->u.buf) = '\0'; /* Do we need this ? */
|
||||||
return raw_len; /* what return here ? */
|
return raw_len; /* what return here ? */
|
||||||
}
|
}
|
||||||
#endif /* FT_HAVE_UTF8 */
|
#endif /* FT_HAVE_UTF8 */
|
||||||
|
@ -655,7 +655,7 @@ const void *ft_to_string_impl(const ft_table_t *table, enum str_buf_type b_type)
|
|||||||
|
|
||||||
conv_context_t cntx;
|
conv_context_t cntx;
|
||||||
cntx.buf_origin = buffer;
|
cntx.buf_origin = buffer;
|
||||||
cntx.buf = buffer;
|
cntx.u.buf = buffer;
|
||||||
cntx.raw_avail = string_buffer_raw_capacity(table->conv_buffer);
|
cntx.raw_avail = string_buffer_raw_capacity(table->conv_buffer);
|
||||||
cntx.cntx = &context;
|
cntx.cntx = &context;
|
||||||
cntx.b_type = b_type;
|
cntx.b_type = b_type;
|
||||||
|
@ -225,9 +225,9 @@ int snprint_n_strings_impl(char *buf, size_t length, size_t n, const char *str)
|
|||||||
static
|
static
|
||||||
int snprint_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
int snprint_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
||||||
{
|
{
|
||||||
int w = snprint_n_strings_impl(cntx->buf, cntx->raw_avail, n, str);
|
int w = snprint_n_strings_impl(cntx->u.buf, cntx->raw_avail, n, str);
|
||||||
if (w >= 0) {
|
if (w >= 0) {
|
||||||
cntx->buf += w;
|
cntx->u.buf += w;
|
||||||
cntx->raw_avail -= w;
|
cntx->raw_avail -= w;
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@ -255,25 +255,25 @@ int print_n_strings(conv_context_t *cntx, size_t n, const char *str)
|
|||||||
return snprint_n_strings(cntx, n, str);
|
return snprint_n_strings(cntx, n, str);
|
||||||
#ifdef FT_HAVE_WCHAR
|
#ifdef FT_HAVE_WCHAR
|
||||||
case W_CHAR_BUF:
|
case W_CHAR_BUF:
|
||||||
cod_w = wsnprint_n_string(cntx->wbuf, cntx->raw_avail, n, str);
|
cod_w = wsnprint_n_string(cntx->u.wbuf, cntx->raw_avail, n, str);
|
||||||
if (cod_w < 0)
|
if (cod_w < 0)
|
||||||
return cod_w;
|
return cod_w;
|
||||||
raw_written = sizeof(wchar_t) * cod_w;
|
raw_written = sizeof(wchar_t) * cod_w;
|
||||||
|
|
||||||
cntx->buf += raw_written;
|
cntx->u.buf += raw_written;
|
||||||
cntx->raw_avail -= raw_written;
|
cntx->raw_avail -= raw_written;
|
||||||
return cod_w;
|
return cod_w;
|
||||||
#endif /* FT_HAVE_WCHAR */
|
#endif /* FT_HAVE_WCHAR */
|
||||||
#ifdef FT_HAVE_UTF8
|
#ifdef FT_HAVE_UTF8
|
||||||
case UTF8_BUF:
|
case UTF8_BUF:
|
||||||
/* Everying is very strange and differs with W_CHAR_BUF */
|
/* Everying is very strange and differs with W_CHAR_BUF */
|
||||||
raw_written = u8nprint_n_strings(cntx->buf, cntx->raw_avail, n, str);
|
raw_written = u8nprint_n_strings(cntx->u.buf, cntx->raw_avail, n, str);
|
||||||
if (raw_written < 0) {
|
if (raw_written < 0) {
|
||||||
fprintf(stderr, " raw_written = %d\n", raw_written);
|
fprintf(stderr, " raw_written = %d\n", raw_written);
|
||||||
return raw_written;
|
return raw_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
cntx->buf += raw_written;
|
cntx->u.buf += raw_written;
|
||||||
cntx->raw_avail -= raw_written;
|
cntx->raw_avail -= raw_written;
|
||||||
return utf8len(str) * n;
|
return utf8len(str) * n;
|
||||||
#endif /* FT_HAVE_UTF8 */
|
#endif /* FT_HAVE_UTF8 */
|
||||||
@ -289,10 +289,10 @@ int ft_nprint(conv_context_t *cntx, const char *str, size_t strlen)
|
|||||||
if (cntx->raw_avail + 1/* for 0 */ < strlen)
|
if (cntx->raw_avail + 1/* for 0 */ < strlen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(cntx->buf, str, strlen);
|
memcpy(cntx->u.buf, str, strlen);
|
||||||
cntx->buf += strlen;
|
cntx->u.buf += strlen;
|
||||||
cntx->raw_avail -= strlen;
|
cntx->raw_avail -= strlen;
|
||||||
*cntx->buf = '\0'; /* Do we need this ? */
|
*cntx->u.buf = '\0'; /* Do we need this ? */
|
||||||
return strlen;
|
return strlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,13 +304,13 @@ int ft_nwprint(conv_context_t *cntx, const wchar_t *str, size_t strlen)
|
|||||||
|
|
||||||
size_t raw_len = strlen * sizeof(wchar_t);
|
size_t raw_len = strlen * sizeof(wchar_t);
|
||||||
|
|
||||||
memcpy(cntx->buf, str, raw_len);
|
memcpy(cntx->u.buf, str, raw_len);
|
||||||
cntx->buf += raw_len;
|
cntx->u.buf += raw_len;
|
||||||
cntx->raw_avail -= raw_len;
|
cntx->raw_avail -= raw_len;
|
||||||
|
|
||||||
/* Do we need this ? */
|
/* Do we need this ? */
|
||||||
wchar_t end_of_string = L'\0';
|
wchar_t end_of_string = L'\0';
|
||||||
memcpy(cntx->buf, &end_of_string, sizeof(wchar_t));
|
memcpy(cntx->u.buf, &end_of_string, sizeof(wchar_t));
|
||||||
return strlen;
|
return strlen;
|
||||||
}
|
}
|
||||||
#endif /* FT_HAVE_WCHAR */
|
#endif /* FT_HAVE_WCHAR */
|
||||||
@ -325,10 +325,10 @@ int ft_nu8print(conv_context_t *cntx, const void *beg, const void *end)
|
|||||||
if (cntx->raw_avail + 1 < raw_len)
|
if (cntx->raw_avail + 1 < raw_len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(cntx->buf, beg, raw_len);
|
memcpy(cntx->u.buf, beg, raw_len);
|
||||||
cntx->buf += raw_len;
|
cntx->u.buf += raw_len;
|
||||||
cntx->raw_avail -= raw_len;
|
cntx->raw_avail -= raw_len;
|
||||||
*(char *)cntx->buf = '\0'; /* Do we need this ? */
|
*(cntx->u.buf) = '\0'; /* Do we need this ? */
|
||||||
return raw_len; /* what return here ? */
|
return raw_len; /* what return here ? */
|
||||||
}
|
}
|
||||||
#endif /* FT_HAVE_UTF8 */
|
#endif /* FT_HAVE_UTF8 */
|
||||||
|
@ -139,7 +139,7 @@ struct conv_context {
|
|||||||
union {
|
union {
|
||||||
char *buf;
|
char *buf;
|
||||||
wchar_t *wbuf;
|
wchar_t *wbuf;
|
||||||
};
|
} u;
|
||||||
size_t raw_avail;
|
size_t raw_avail;
|
||||||
struct fort_context *cntx;
|
struct fort_context *cntx;
|
||||||
enum str_buf_type b_type;
|
enum str_buf_type b_type;
|
||||||
|
@ -607,24 +607,24 @@ static void test_print_n_strings_(const char *str, size_t n)
|
|||||||
{
|
{
|
||||||
string_buffer_t *buffer = create_string_buffer(200, CHAR_BUF);
|
string_buffer_t *buffer = create_string_buffer(200, CHAR_BUF);
|
||||||
conv_context_t cntx;
|
conv_context_t cntx;
|
||||||
cntx.buf = (char *)buffer_get_data(buffer);
|
cntx.u.buf = (char *)buffer_get_data(buffer);
|
||||||
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
||||||
cntx.raw_avail = 200;
|
cntx.raw_avail = 200;
|
||||||
cntx.b_type = CHAR_BUF;
|
cntx.b_type = CHAR_BUF;
|
||||||
assert_true(print_n_strings(&cntx, n, str) == sz);
|
assert_true(print_n_strings(&cntx, n, str) == sz);
|
||||||
assert_true(cntx.buf - cntx.buf_origin == (ptrdiff_t)sz);
|
assert_true(cntx.u.buf - cntx.buf_origin == (ptrdiff_t)sz);
|
||||||
destroy_string_buffer(buffer);
|
destroy_string_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
string_buffer_t *buffer = create_string_buffer(200, W_CHAR_BUF);
|
string_buffer_t *buffer = create_string_buffer(200, W_CHAR_BUF);
|
||||||
conv_context_t cntx;
|
conv_context_t cntx;
|
||||||
cntx.buf = (char *)buffer_get_data(buffer);
|
cntx.u.buf = (char *)buffer_get_data(buffer);
|
||||||
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
||||||
cntx.raw_avail = 200;
|
cntx.raw_avail = 200;
|
||||||
cntx.b_type = W_CHAR_BUF;
|
cntx.b_type = W_CHAR_BUF;
|
||||||
assert_true(print_n_strings(&cntx, n, str) == /*sizeof(wchar_t) **/ sz);
|
assert_true(print_n_strings(&cntx, n, str) == /*sizeof(wchar_t) **/ sz);
|
||||||
assert_true(cntx.buf - cntx.buf_origin == (ptrdiff_t)sizeof(wchar_t) * sz);
|
assert_true(cntx.u.buf - cntx.buf_origin == (ptrdiff_t)sizeof(wchar_t) * sz);
|
||||||
destroy_string_buffer(buffer);
|
destroy_string_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,12 +632,12 @@ static void test_print_n_strings_(const char *str, size_t n)
|
|||||||
{
|
{
|
||||||
string_buffer_t *buffer = create_string_buffer(200, UTF8_BUF);
|
string_buffer_t *buffer = create_string_buffer(200, UTF8_BUF);
|
||||||
conv_context_t cntx;
|
conv_context_t cntx;
|
||||||
cntx.buf = (char *)buffer_get_data(buffer);
|
cntx.u.buf = (char *)buffer_get_data(buffer);
|
||||||
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
cntx.buf_origin = (char *)buffer_get_data(buffer);
|
||||||
cntx.raw_avail = 200;
|
cntx.raw_avail = 200;
|
||||||
cntx.b_type = UTF8_BUF;
|
cntx.b_type = UTF8_BUF;
|
||||||
assert_true(print_n_strings(&cntx, n, str) == sz);
|
assert_true(print_n_strings(&cntx, n, str) == sz);
|
||||||
assert_true(cntx.buf - cntx.buf_origin == (ptrdiff_t)sz);
|
assert_true(cntx.u.buf - cntx.buf_origin == (ptrdiff_t)sz);
|
||||||
destroy_string_buffer(buffer);
|
destroy_string_buffer(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user