- Portability changes for ARM
- Allow larger sort memory on 64-bit platforms Submitted by: Oleg Moskalenko <oleg.moskalenko@citrix.com>
This commit is contained in:
parent
252462b3bd
commit
e8da8c744b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242430
@ -69,7 +69,7 @@ initialise_months(void)
|
|||||||
continue;
|
continue;
|
||||||
if (debug_sort)
|
if (debug_sort)
|
||||||
printf("month[%d]=%s\n", i, tmp);
|
printf("month[%d]=%s\n", i, tmp);
|
||||||
len = strlen(tmp);
|
len = strlen((char*)tmp);
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
continue;
|
continue;
|
||||||
while (isblank(*tmp))
|
while (isblank(*tmp))
|
||||||
@ -95,13 +95,13 @@ initialise_months(void)
|
|||||||
continue;
|
continue;
|
||||||
if (debug_sort)
|
if (debug_sort)
|
||||||
printf("month[%d]=%s\n", i, tmp);
|
printf("month[%d]=%s\n", i, tmp);
|
||||||
len = strlen(tmp);
|
len = strlen((char*)tmp);
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
continue;
|
continue;
|
||||||
while (isblank(*tmp))
|
while (isblank(*tmp))
|
||||||
++tmp;
|
++tmp;
|
||||||
m = sort_malloc(SIZEOF_WCHAR_STRING(len + 1));
|
m = sort_malloc(SIZEOF_WCHAR_STRING(len + 1));
|
||||||
if (mbstowcs(m, tmp, len) == ((size_t) -1))
|
if (mbstowcs(m, (char*)tmp, len) == ((size_t) -1))
|
||||||
continue;
|
continue;
|
||||||
m[len] = L'\0';
|
m[len] = L'\0';
|
||||||
for (unsigned int j = 0; j < len; j++)
|
for (unsigned int j = 0; j < len; j++)
|
||||||
@ -421,7 +421,7 @@ bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset,
|
|||||||
* The output is ended either with '\n' (nl == true)
|
* The output is ended either with '\n' (nl == true)
|
||||||
* or '\0' (nl == false).
|
* or '\0' (nl == false).
|
||||||
*/
|
*/
|
||||||
int
|
size_t
|
||||||
bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
|
bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -442,11 +442,11 @@ bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
wchar_t eols;
|
wchar_t eols;
|
||||||
int printed = 0;
|
size_t printed = 0;
|
||||||
|
|
||||||
eols = zero_ended ? btowc('\0') : btowc('\n');
|
eols = zero_ended ? btowc('\0') : btowc('\n');
|
||||||
|
|
||||||
while (printed < (int) BWSLEN(bws)) {
|
while (printed < BWSLEN(bws)) {
|
||||||
const wchar_t *s = bws->data.wstr + printed;
|
const wchar_t *s = bws->data.wstr + printed;
|
||||||
|
|
||||||
if (*s == L'\0') {
|
if (*s == L'\0') {
|
||||||
@ -479,7 +479,7 @@ bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
|
|||||||
struct bwstring *
|
struct bwstring *
|
||||||
bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
||||||
{
|
{
|
||||||
wchar_t eols;
|
wint_t eols;
|
||||||
|
|
||||||
eols = zero_ended ? btowc('\0') : btowc('\n');
|
eols = zero_ended ? btowc('\0') : btowc('\n');
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (*len > 0) {
|
if (*len > 0) {
|
||||||
if (ret[*len - 1] == eols)
|
if (ret[*len - 1] == (wchar_t)eols)
|
||||||
--(*len);
|
--(*len);
|
||||||
}
|
}
|
||||||
return (bwssbdup(ret, *len));
|
return (bwssbdup(ret, *len));
|
||||||
@ -513,11 +513,9 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
|||||||
if (ret[*len - 1] == '\n')
|
if (ret[*len - 1] == '\n')
|
||||||
--(*len);
|
--(*len);
|
||||||
}
|
}
|
||||||
return (bwscsbdup(ret, *len));
|
return (bwscsbdup((unsigned char*)ret, *len));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wchar_t c = 0;
|
|
||||||
|
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
|
||||||
if (feof(f))
|
if (feof(f))
|
||||||
@ -532,6 +530,8 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
|||||||
|
|
||||||
if (MB_CUR_MAX == 1)
|
if (MB_CUR_MAX == 1)
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
|
int c;
|
||||||
|
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
|
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
@ -553,6 +553,8 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
|
wint_t c = 0;
|
||||||
|
|
||||||
c = fgetwc(f);
|
c = fgetwc(f);
|
||||||
|
|
||||||
if (c == WEOF) {
|
if (c == WEOF) {
|
||||||
@ -750,7 +752,7 @@ bwscoll(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset)
|
|||||||
} else if (s2[i] == 0)
|
} else if (s2[i] == 0)
|
||||||
return (+1);
|
return (+1);
|
||||||
|
|
||||||
res = strcoll(s1 + i, s2 + i);
|
res = strcoll((const char*)(s1 + i), (const char*)(s2 + i));
|
||||||
if (res)
|
if (res)
|
||||||
return (res);
|
return (res);
|
||||||
|
|
||||||
@ -872,7 +874,7 @@ bwstod(struct bwstring *s0, bool *empty)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = strtod(s, &ep);
|
ret = strtod((char*)s, &ep);
|
||||||
if ((unsigned char*) ep == s) {
|
if ((unsigned char*) ep == s) {
|
||||||
*empty = true;
|
*empty = true;
|
||||||
return (0);
|
return (0);
|
||||||
@ -923,11 +925,11 @@ bws_month_score(const struct bwstring *s0)
|
|||||||
while (isblank(*s) && s < end)
|
while (isblank(*s) && s < end)
|
||||||
++s;
|
++s;
|
||||||
|
|
||||||
len = strlen(s);
|
len = strlen((const char*)s);
|
||||||
|
|
||||||
for (int i = 11; i >= 0; --i) {
|
for (int i = 11; i >= 0; --i) {
|
||||||
if (cmonths[i] &&
|
if (cmonths[i] &&
|
||||||
(s == (unsigned char*)strstr(s, cmonths[i])))
|
(s == (unsigned char*)strstr((const char*)s, (char*)(cmonths[i]))))
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ struct bwstring *bwsnocpy(struct bwstring *dst, const struct bwstring *src, size
|
|||||||
int bwscmp(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset);
|
int bwscmp(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset);
|
||||||
int bwsncmp(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset, size_t len);
|
int bwsncmp(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset, size_t len);
|
||||||
int bwscoll(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset);
|
int bwscoll(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset);
|
||||||
int bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended);
|
size_t bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended);
|
||||||
struct bwstring *bwsfgetln(FILE *file, size_t *len, bool zero_ended, struct reader_buffer *rb);
|
struct bwstring *bwsfgetln(FILE *file, size_t *len, bool zero_ended, struct reader_buffer *rb);
|
||||||
|
|
||||||
static inline bwstring_iterator
|
static inline bwstring_iterator
|
||||||
|
@ -47,11 +47,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
struct key_specs *keys;
|
struct key_specs *keys;
|
||||||
size_t keys_num = 0;
|
size_t keys_num = 0;
|
||||||
|
|
||||||
wchar_t symbol_decimal_point = L'.';
|
wint_t symbol_decimal_point = L'.';
|
||||||
/* there is no default thousands separator in collate rules: */
|
/* there is no default thousands separator in collate rules: */
|
||||||
wchar_t symbol_thousands_sep = 0;
|
wint_t symbol_thousands_sep = 0;
|
||||||
wchar_t symbol_negative_sign = L'-';
|
wint_t symbol_negative_sign = L'-';
|
||||||
wchar_t symbol_positive_sign = L'+';
|
wint_t symbol_positive_sign = L'+';
|
||||||
|
|
||||||
static int wstrcoll(struct key_value *kv1, struct key_value *kv2, size_t offset);
|
static int wstrcoll(struct key_value *kv1, struct key_value *kv2, size_t offset);
|
||||||
static int gnumcoll(struct key_value*, struct key_value *, size_t offset);
|
static int gnumcoll(struct key_value*, struct key_value *, size_t offset);
|
||||||
@ -260,7 +260,7 @@ skip_fields_to_start(const struct bwstring *s, size_t fields, bool *empty_field)
|
|||||||
while (cpos < BWSLEN(s)) {
|
while (cpos < BWSLEN(s)) {
|
||||||
bool isblank;
|
bool isblank;
|
||||||
|
|
||||||
isblank = iswblank(BWS_GET(s,cpos));
|
isblank = iswblank(BWS_GET(s, cpos));
|
||||||
|
|
||||||
if (isblank && !pb) {
|
if (isblank && !pb) {
|
||||||
--fields;
|
--fields;
|
||||||
@ -277,7 +277,7 @@ skip_fields_to_start(const struct bwstring *s, size_t fields, bool *empty_field)
|
|||||||
size_t cpos = 0;
|
size_t cpos = 0;
|
||||||
|
|
||||||
while (cpos < BWSLEN(s)) {
|
while (cpos < BWSLEN(s)) {
|
||||||
if (BWS_GET(s,cpos) == sort_opts_vals.field_sep) {
|
if (BWS_GET(s,cpos) == (wchar_t)sort_opts_vals.field_sep) {
|
||||||
--fields;
|
--fields;
|
||||||
if (fields <= 1)
|
if (fields <= 1)
|
||||||
return (cpos + 1);
|
return (cpos + 1);
|
||||||
@ -328,7 +328,7 @@ find_field_end(const struct bwstring *s, struct key_specs *ks)
|
|||||||
next_field_start = skip_fields_to_start(s, f2 + 1,
|
next_field_start = skip_fields_to_start(s, f2 + 1,
|
||||||
&empty_field);
|
&empty_field);
|
||||||
if ((next_field_start > 0) && sort_opts_vals.tflag &&
|
if ((next_field_start > 0) && sort_opts_vals.tflag &&
|
||||||
(sort_opts_vals.field_sep == BWS_GET(s,
|
((wchar_t)sort_opts_vals.field_sep == BWS_GET(s,
|
||||||
next_field_start - 1)))
|
next_field_start - 1)))
|
||||||
--next_field_start;
|
--next_field_start;
|
||||||
} else
|
} else
|
||||||
@ -699,7 +699,7 @@ static void setsuffix(wchar_t c, unsigned char *si)
|
|||||||
* point is in sfrac, tail is the pointer to the remainder of the string.
|
* point is in sfrac, tail is the pointer to the remainder of the string.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
read_number(struct bwstring *s0, int *sign, wchar_t *smain, int *main_len, wchar_t *sfrac, int *frac_len, unsigned char *si)
|
read_number(struct bwstring *s0, int *sign, wchar_t *smain, size_t *main_len, wchar_t *sfrac, size_t *frac_len, unsigned char *si)
|
||||||
{
|
{
|
||||||
bwstring_iterator s;
|
bwstring_iterator s;
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ read_number(struct bwstring *s0, int *sign, wchar_t *smain, int *main_len, wchar
|
|||||||
while (iswblank(bws_get_iter_value(s)))
|
while (iswblank(bws_get_iter_value(s)))
|
||||||
s = bws_iterator_inc(s, 1);
|
s = bws_iterator_inc(s, 1);
|
||||||
|
|
||||||
if (bws_get_iter_value(s) == symbol_negative_sign) {
|
if (bws_get_iter_value(s) == (wchar_t)symbol_negative_sign) {
|
||||||
*sign = -1;
|
*sign = -1;
|
||||||
s = bws_iterator_inc(s, 1);
|
s = bws_iterator_inc(s, 1);
|
||||||
}
|
}
|
||||||
@ -727,7 +727,7 @@ read_number(struct bwstring *s0, int *sign, wchar_t *smain, int *main_len, wchar
|
|||||||
s = bws_iterator_inc(s, 1);
|
s = bws_iterator_inc(s, 1);
|
||||||
*main_len += 1;
|
*main_len += 1;
|
||||||
} else if (symbol_thousands_sep &&
|
} else if (symbol_thousands_sep &&
|
||||||
(bws_get_iter_value(s) == symbol_thousands_sep))
|
(bws_get_iter_value(s) == (wchar_t)symbol_thousands_sep))
|
||||||
s = bws_iterator_inc(s, 1);
|
s = bws_iterator_inc(s, 1);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@ -735,7 +735,7 @@ read_number(struct bwstring *s0, int *sign, wchar_t *smain, int *main_len, wchar
|
|||||||
|
|
||||||
smain[*main_len] = 0;
|
smain[*main_len] = 0;
|
||||||
|
|
||||||
if (bws_get_iter_value(s) == symbol_decimal_point) {
|
if (bws_get_iter_value(s) == (wchar_t)symbol_decimal_point) {
|
||||||
s = bws_iterator_inc(s, 1);
|
s = bws_iterator_inc(s, 1);
|
||||||
while (iswdigit(bws_get_iter_value(s)) &&
|
while (iswdigit(bws_get_iter_value(s)) &&
|
||||||
*frac_len < MAX_NUM_SIZE) {
|
*frac_len < MAX_NUM_SIZE) {
|
||||||
@ -798,7 +798,8 @@ numcoll_impl(struct key_value *kv1, struct key_value *kv2,
|
|||||||
struct bwstring *s1, *s2;
|
struct bwstring *s1, *s2;
|
||||||
wchar_t sfrac1[MAX_NUM_SIZE + 1], sfrac2[MAX_NUM_SIZE + 1];
|
wchar_t sfrac1[MAX_NUM_SIZE + 1], sfrac2[MAX_NUM_SIZE + 1];
|
||||||
wchar_t smain1[MAX_NUM_SIZE + 1], smain2[MAX_NUM_SIZE + 1];
|
wchar_t smain1[MAX_NUM_SIZE + 1], smain2[MAX_NUM_SIZE + 1];
|
||||||
int cmp_res, frac1, frac2, main1, main2, sign1, sign2;
|
int cmp_res, sign1, sign2;
|
||||||
|
size_t frac1, frac2, main1, main2;
|
||||||
unsigned char SI1, SI2;
|
unsigned char SI1, SI2;
|
||||||
bool e1, e2, key1_read, key2_read;
|
bool e1, e2, key1_read, key2_read;
|
||||||
|
|
||||||
|
@ -133,12 +133,12 @@ extern struct key_specs *keys;
|
|||||||
extern size_t keys_num;
|
extern size_t keys_num;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main localised symbols
|
* Main localised symbols. These must be wint_t as they may hold WEOF.
|
||||||
*/
|
*/
|
||||||
extern wchar_t symbol_decimal_point;
|
extern wint_t symbol_decimal_point;
|
||||||
extern wchar_t symbol_thousands_sep;
|
extern wint_t symbol_thousands_sep;
|
||||||
extern wchar_t symbol_negative_sign;
|
extern wint_t symbol_negative_sign;
|
||||||
extern wchar_t symbol_positive_sign;
|
extern wint_t symbol_positive_sign;
|
||||||
|
|
||||||
/* funcs */
|
/* funcs */
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ read_file0_line(struct file0_reader *f0r)
|
|||||||
char *
|
char *
|
||||||
new_tmp_file_name(void)
|
new_tmp_file_name(void)
|
||||||
{
|
{
|
||||||
static unsigned int tfcounter = 0;
|
static size_t tfcounter = 0;
|
||||||
static const char *fn = ".bsdsort.";
|
static const char *fn = ".bsdsort.";
|
||||||
char *ret;
|
char *ret;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
@ -237,7 +237,7 @@ new_tmp_file_name(void)
|
|||||||
sz = strlen(tmpdir) + 1 + strlen(fn) + 32 + 1;
|
sz = strlen(tmpdir) + 1 + strlen(fn) + 32 + 1;
|
||||||
ret = sort_malloc(sz);
|
ret = sort_malloc(sz);
|
||||||
|
|
||||||
sprintf(ret, "%s/%s%d.%u", tmpdir, fn, (int) getpid(), tfcounter++);
|
sprintf(ret, "%s/%s%d.%lu", tmpdir, fn, (int) getpid(), (unsigned long)(tfcounter++));
|
||||||
tmp_file_atexit(ret);
|
tmp_file_atexit(ret);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ file_list_clean(struct file_list *fl)
|
|||||||
|
|
||||||
if (fl) {
|
if (fl) {
|
||||||
if (fl->fns) {
|
if (fl->fns) {
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < fl->count; i++) {
|
for (i = 0; i < fl->count; i++) {
|
||||||
if (fl->fns[i]) {
|
if (fl->fns[i]) {
|
||||||
@ -345,7 +345,7 @@ sort_list_add(struct sort_list *l, struct bwstring *str)
|
|||||||
size_t indx = l->count;
|
size_t indx = l->count;
|
||||||
|
|
||||||
if ((l->list == NULL) || (indx >= l->size)) {
|
if ((l->list == NULL) || (indx >= l->size)) {
|
||||||
int newsize = (l->size + 1) + 1024;
|
size_t newsize = (l->size + 1) + 1024;
|
||||||
|
|
||||||
l->list = sort_realloc(l->list,
|
l->list = sort_realloc(l->list,
|
||||||
sizeof(struct sort_list_item*) * newsize);
|
sizeof(struct sort_list_item*) * newsize);
|
||||||
@ -439,7 +439,8 @@ check(const char *fn)
|
|||||||
struct bwstring *s1, *s2, *s1disorder, *s2disorder;
|
struct bwstring *s1, *s2, *s1disorder, *s2disorder;
|
||||||
struct file_reader *fr;
|
struct file_reader *fr;
|
||||||
struct keys_array *ka1, *ka2;
|
struct keys_array *ka1, *ka2;
|
||||||
int res, pos, posdisorder;
|
int res;
|
||||||
|
size_t pos, posdisorder;
|
||||||
|
|
||||||
s1 = s2 = s1disorder = s2disorder = NULL;
|
s1 = s2 = s1disorder = s2disorder = NULL;
|
||||||
ka1 = ka2 = NULL;
|
ka1 = ka2 = NULL;
|
||||||
@ -979,7 +980,7 @@ file_header_close(struct file_header **fh)
|
|||||||
* Swap two array elements
|
* Swap two array elements
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_header_swap(struct file_header **fh, int i1, int i2)
|
file_header_swap(struct file_header **fh, size_t i1, size_t i2)
|
||||||
{
|
{
|
||||||
struct file_header *tmp;
|
struct file_header *tmp;
|
||||||
|
|
||||||
@ -995,11 +996,11 @@ file_header_swap(struct file_header **fh, int i1, int i2)
|
|||||||
* "Raises" last element to its right place
|
* "Raises" last element to its right place
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_header_heap_swim(struct file_header **fh, int indx)
|
file_header_heap_swim(struct file_header **fh, size_t indx)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (indx > 0) {
|
if (indx > 0) {
|
||||||
int parent_index;
|
size_t parent_index;
|
||||||
|
|
||||||
parent_index = (indx - 1) >> 1;
|
parent_index = (indx - 1) >> 1;
|
||||||
|
|
||||||
@ -1015,16 +1016,16 @@ file_header_heap_swim(struct file_header **fh, int indx)
|
|||||||
* Sink the top element to its correct position
|
* Sink the top element to its correct position
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_header_heap_sink(struct file_header **fh, int indx, int size)
|
file_header_heap_sink(struct file_header **fh, size_t indx, size_t size)
|
||||||
{
|
{
|
||||||
int left_child_index;
|
size_t left_child_index;
|
||||||
int right_child_index;
|
size_t right_child_index;
|
||||||
|
|
||||||
left_child_index = indx + indx + 1;
|
left_child_index = indx + indx + 1;
|
||||||
right_child_index = left_child_index + 1;
|
right_child_index = left_child_index + 1;
|
||||||
|
|
||||||
if (left_child_index < size) {
|
if (left_child_index < size) {
|
||||||
int min_child_index;
|
size_t min_child_index;
|
||||||
|
|
||||||
min_child_index = left_child_index;
|
min_child_index = left_child_index;
|
||||||
|
|
||||||
@ -1045,7 +1046,7 @@ file_header_heap_sink(struct file_header **fh, int indx, int size)
|
|||||||
* Adds element to the "left" end
|
* Adds element to the "left" end
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_header_list_rearrange_from_header(struct file_header **fh, int size)
|
file_header_list_rearrange_from_header(struct file_header **fh, size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
file_header_heap_sink(fh, 0, size);
|
file_header_heap_sink(fh, 0, size);
|
||||||
@ -1055,7 +1056,7 @@ file_header_list_rearrange_from_header(struct file_header **fh, int size)
|
|||||||
* Adds element to the "right" end
|
* Adds element to the "right" end
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_header_list_push(struct file_header *f, struct file_header **fh, int size)
|
file_header_list_push(struct file_header *f, struct file_header **fh, size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
fh[size++] = f;
|
fh[size++] = f;
|
||||||
@ -1118,10 +1119,10 @@ file_header_read_next(struct file_header *fh)
|
|||||||
* Merge array of "files headers"
|
* Merge array of "files headers"
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
file_headers_merge(int fnum, struct file_header **fh, FILE *f_out)
|
file_headers_merge(size_t fnum, struct file_header **fh, FILE *f_out)
|
||||||
{
|
{
|
||||||
struct last_printed lp;
|
struct last_printed lp;
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
memset(&lp, 0, sizeof(lp));
|
memset(&lp, 0, sizeof(lp));
|
||||||
|
|
||||||
@ -1149,13 +1150,13 @@ file_headers_merge(int fnum, struct file_header **fh, FILE *f_out)
|
|||||||
* stdout.
|
* stdout.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
merge_files_array(int argc, char **argv, const char *fn_out)
|
merge_files_array(size_t argc, char **argv, const char *fn_out)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (argv && fn_out) {
|
if (argv && fn_out) {
|
||||||
struct file_header **fh;
|
struct file_header **fh;
|
||||||
FILE *f_out;
|
FILE *f_out;
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
f_out = openfile(fn_out, "w");
|
f_out = openfile(fn_out, "w");
|
||||||
|
|
||||||
@ -1189,12 +1190,12 @@ shrink_file_list(struct file_list *fl)
|
|||||||
return (0);
|
return (0);
|
||||||
else {
|
else {
|
||||||
struct file_list new_fl;
|
struct file_list new_fl;
|
||||||
int indx = 0;
|
size_t indx = 0;
|
||||||
|
|
||||||
file_list_init(&new_fl, true);
|
file_list_init(&new_fl, true);
|
||||||
while (indx < fl->count) {
|
while (indx < fl->count) {
|
||||||
char *fnew;
|
char *fnew;
|
||||||
int num;
|
size_t num;
|
||||||
|
|
||||||
num = fl->count - indx;
|
num = fl->count - indx;
|
||||||
fnew = new_tmp_file_name();
|
fnew = new_tmp_file_name();
|
||||||
@ -1203,7 +1204,7 @@ shrink_file_list(struct file_list *fl)
|
|||||||
num = max_open_files - 1;
|
num = max_open_files - 1;
|
||||||
merge_files_array(num, fl->fns + indx, fnew);
|
merge_files_array(num, fl->fns + indx, fnew);
|
||||||
if (fl->tmp) {
|
if (fl->tmp) {
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
unlink(fl->fns[indx + i]);
|
unlink(fl->fns[indx + i]);
|
||||||
@ -1379,7 +1380,7 @@ sub_list_cmp(struct sort_list *l1, struct sort_list *l2)
|
|||||||
* Swap two array elements
|
* Swap two array elements
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
sub_list_swap(struct sort_list **sl, int i1, int i2)
|
sub_list_swap(struct sort_list **sl, size_t i1, size_t i2)
|
||||||
{
|
{
|
||||||
struct sort_list *tmp;
|
struct sort_list *tmp;
|
||||||
|
|
||||||
@ -1395,11 +1396,11 @@ sub_list_swap(struct sort_list **sl, int i1, int i2)
|
|||||||
* "Raises" last element to its right place
|
* "Raises" last element to its right place
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
sub_list_swim(struct sort_list **sl, int indx)
|
sub_list_swim(struct sort_list **sl, size_t indx)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (indx > 0) {
|
if (indx > 0) {
|
||||||
int parent_index;
|
size_t parent_index;
|
||||||
|
|
||||||
parent_index = (indx - 1) >> 1;
|
parent_index = (indx - 1) >> 1;
|
||||||
|
|
||||||
@ -1415,16 +1416,16 @@ sub_list_swim(struct sort_list **sl, int indx)
|
|||||||
* Sink the top element to its correct position
|
* Sink the top element to its correct position
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
sub_list_sink(struct sort_list **sl, int indx, int size)
|
sub_list_sink(struct sort_list **sl, size_t indx, size_t size)
|
||||||
{
|
{
|
||||||
int left_child_index;
|
size_t left_child_index;
|
||||||
int right_child_index;
|
size_t right_child_index;
|
||||||
|
|
||||||
left_child_index = indx + indx + 1;
|
left_child_index = indx + indx + 1;
|
||||||
right_child_index = left_child_index + 1;
|
right_child_index = left_child_index + 1;
|
||||||
|
|
||||||
if (left_child_index < size) {
|
if (left_child_index < size) {
|
||||||
int min_child_index;
|
size_t min_child_index;
|
||||||
|
|
||||||
min_child_index = left_child_index;
|
min_child_index = left_child_index;
|
||||||
|
|
||||||
@ -1445,7 +1446,7 @@ sub_list_sink(struct sort_list **sl, int indx, int size)
|
|||||||
* Adds element to the "right" end
|
* Adds element to the "right" end
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
sub_list_push(struct sort_list *s, struct sort_list **sl, int size)
|
sub_list_push(struct sort_list *s, struct sort_list **sl, size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
sl[size++] = s;
|
sl[size++] = s;
|
||||||
|
@ -65,8 +65,8 @@ struct file_reader;
|
|||||||
struct file_list
|
struct file_list
|
||||||
{
|
{
|
||||||
char **fns;
|
char **fns;
|
||||||
int count;
|
size_t count;
|
||||||
int sz;
|
size_t sz;
|
||||||
bool tmp;
|
bool tmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ pop_ls_mt(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_to_sublevel(struct sort_level *sl, struct sort_list_item *item, int indx)
|
add_to_sublevel(struct sort_level *sl, struct sort_list_item *item, size_t indx)
|
||||||
{
|
{
|
||||||
struct sort_level *ssl;
|
struct sort_level *ssl;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ static bool print_symbols_on_debug;
|
|||||||
/*
|
/*
|
||||||
* Arguments from file (when file0-from option is used:
|
* Arguments from file (when file0-from option is used:
|
||||||
*/
|
*/
|
||||||
static int argc_from_file0 = -1;
|
static size_t argc_from_file0 = (size_t)-1;
|
||||||
static char **argv_from_file0;
|
static char **argv_from_file0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -244,9 +244,9 @@ read_fns_from_file0(const char *fn)
|
|||||||
char *line = read_file0_line(&f0r);
|
char *line = read_file0_line(&f0r);
|
||||||
|
|
||||||
if (line && *line) {
|
if (line && *line) {
|
||||||
|
if (argc_from_file0 == (size_t)-1)
|
||||||
|
argc_from_file0 = 0;
|
||||||
++argc_from_file0;
|
++argc_from_file0;
|
||||||
if (argc_from_file0 < 1)
|
|
||||||
argc_from_file0 = 1;
|
|
||||||
argv_from_file0 = sort_realloc(argv_from_file0,
|
argv_from_file0 = sort_realloc(argv_from_file0,
|
||||||
argc_from_file0 * sizeof(char *));
|
argc_from_file0 * sizeof(char *));
|
||||||
if (argv_from_file0 == NULL)
|
if (argv_from_file0 == NULL)
|
||||||
@ -1221,7 +1221,7 @@ main(int argc, char **argv)
|
|||||||
ks->sm.func = get_sort_func(&(ks->sm));
|
ks->sm.func = get_sort_func(&(ks->sm));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc_from_file0 >= 0) {
|
if (argv_from_file0) {
|
||||||
argc = argc_from_file0;
|
argc = argc_from_file0;
|
||||||
argv = argv_from_file0;
|
argv = argv_from_file0;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ extern MD5_CTX md5_ctx;
|
|||||||
*/
|
*/
|
||||||
struct sort_opts
|
struct sort_opts
|
||||||
{
|
{
|
||||||
wchar_t field_sep;
|
wint_t field_sep;
|
||||||
int sort_method;
|
int sort_method;
|
||||||
bool cflag;
|
bool cflag;
|
||||||
bool csilentflag;
|
bool csilentflag;
|
||||||
|
Loading…
Reference in New Issue
Block a user