* util.c (ruby_qsort): the result of cmp must be signed, so get

rid of reuse of a variable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-14 04:53:13 +00:00
Родитель b82b4e6e48
Коммит 1f17d739ce
2 изменённых файлов: 24 добавлений и 18 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat Mar 14 13:53:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* util.c (ruby_qsort): the result of cmp must be signed, so ge
rid of reuse of a variable.
Sat Mar 14 10:56:13 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (init_funcname_len, dln_find_exe_r, dln_find_file_r): use

37
util.c
Просмотреть файл

@ -370,7 +370,7 @@ valid_filename(const char *s)
#define mmarg mmkind, size, high, low
static void mmswap_(register char *a, register char *b, int mmkind, int size, int high, int low)
static void mmswap_(register char *a, register char *b, int mmkind, size_t size, size_t high, size_t low)
{
register int s;
if (a == b) return;
@ -395,7 +395,7 @@ static void mmswap_(register char *a, register char *b, int mmkind, int size, in
}
#define mmswap(a,b) mmswap_((a),(b),mmarg)
static void mmrot3_(register char *a, register char *b, register char *c, int mmkind, int size, int high, int low)
static void mmrot3_(register char *a, register char *b, register char *c, int mmkind, size_t size, size_t high, size_t low)
{
register int s;
if (mmkind >= 0) {
@ -441,12 +441,13 @@ ruby_qsort(void* base, const size_t nel, const size_t size,
int (*cmp)(const void*, const void*, void*), void *d)
{
register char *l, *r, *m; /* l,r:left,right group m:median point */
register size_t t, eq_l, eq_r; /* eq_l: all items in left group are equal to S */
register int t, eq_l, eq_r; /* eq_l: all items in left group are equal to S */
char *L = base; /* left end of curren region */
char *R = (char*)base + size*(nel-1); /* right end of current region */
int chklim = 63; /* threshold of ordering element check */
stack_node stack[32], *top = stack; /* 32 is enough for 32bit CPU */
int mmkind, high, low;
int mmkind;
size_t high, low, n;
if (nel <= 1) return; /* need not to sort */
mmprepare(base, size);
@ -463,29 +464,29 @@ ruby_qsort(void* base, const size_t nel, const size_t size,
}
l = L; r = R;
t = (r - l + size) / size; /* number of elements */
m = l + size * (t >> 1); /* calculate median value */
n = (r - l + size) / size; /* number of elements */
m = l + size * (n >> 1); /* calculate median value */
if (t >= 60) {
if (n >= 60) {
register char *m1;
register char *m3;
if (t >= 200) {
t = size*(t>>3); /* number of bytes in splitting 8 */
if (n >= 200) {
n = size*(n>>3); /* number of bytes in splitting 8 */
{
register char *p1 = l + t;
register char *p2 = p1 + t;
register char *p3 = p2 + t;
register char *p1 = l + n;
register char *p2 = p1 + n;
register char *p3 = p2 + n;
m1 = med3(p1, p2, p3);
p1 = m + t;
p2 = p1 + t;
p3 = p2 + t;
p1 = m + n;
p2 = p1 + n;
p3 = p2 + n;
m3 = med3(p1, p2, p3);
}
}
else {
t = size*(t>>2); /* number of bytes in splitting 4 */
m1 = l + t;
m3 = m + t;
n = size*(n>>2); /* number of bytes in splitting 4 */
m1 = l + n;
m3 = m + n;
}
m = med3(m1, m, m3);
}