sort: add -x hex sort feature back
. so unstack works again
This commit is contained in:
parent
f44fb1784b
commit
e286ccc05b
|
@ -82,6 +82,10 @@ static u_char *enterfield(u_char *, const u_char *, struct field *, int);
|
||||||
static u_char *number(u_char *, const u_char *, u_char *, u_char *, int);
|
static u_char *number(u_char *, const u_char *, u_char *, u_char *, int);
|
||||||
static u_char *length(u_char *, const u_char *, u_char *, u_char *, int);
|
static u_char *length(u_char *, const u_char *, u_char *, u_char *, int);
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
static u_char *numhex(u_char *, const u_char *, u_char *, u_char *, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DECIMAL_POINT '.'
|
#define DECIMAL_POINT '.'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -205,6 +209,10 @@ enterfield(u_char *tablepos, const u_char *endkey, struct field *cur_fld,
|
||||||
return length(tablepos, endkey, start, end, flags);
|
return length(tablepos, endkey, start, end, flags);
|
||||||
if (flags & N)
|
if (flags & N)
|
||||||
return number(tablepos, endkey, start, end, flags);
|
return number(tablepos, endkey, start, end, flags);
|
||||||
|
#ifdef __minix
|
||||||
|
if (flags & X)
|
||||||
|
return numhex(tablepos, endkey, start, end, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Bound check space - assuming nothing is skipped */
|
/* Bound check space - assuming nothing is skipped */
|
||||||
if (tablepos + (end - start) + 1 >= endkey)
|
if (tablepos + (end - start) + 1 >= endkey)
|
||||||
|
@ -375,3 +383,18 @@ length(u_char *pos, const u_char *bufend, u_char *line, u_char *lineend,
|
||||||
l = snprintf((char *)buf, sizeof(buf), "%td", lineend - line);
|
l = snprintf((char *)buf, sizeof(buf), "%td", lineend - line);
|
||||||
return number(pos, bufend, buf, buf + l, flag);
|
return number(pos, bufend, buf, buf + l, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
static u_char *
|
||||||
|
numhex(u_char *pos, const u_char *bufend, u_char *line, u_char *lineend,
|
||||||
|
int flag)
|
||||||
|
{
|
||||||
|
u_char buf[32];
|
||||||
|
int64_t n = 0;
|
||||||
|
int l;
|
||||||
|
SKIP_BLANKS(line);
|
||||||
|
sscanf((const char *) pos, "%lx", &n);
|
||||||
|
l = snprintf((char *)buf, sizeof(buf), "%lld", n);
|
||||||
|
return number(pos, bufend, buf, buf + l, flag);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -233,6 +233,9 @@ optval(int desc, int tcolflag)
|
||||||
case 'i': return I;
|
case 'i': return I;
|
||||||
case 'l': return L;
|
case 'l': return L;
|
||||||
case 'n': return N;
|
case 'n': return N;
|
||||||
|
#ifdef __minix
|
||||||
|
case 'x': return X;
|
||||||
|
#endif
|
||||||
case 'r': return R;
|
case 'r': return R;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,9 @@ main(int argc, char *argv[])
|
||||||
debug_flags |= 1 << (optarg[i] & 31);
|
debug_flags |= 1 << (optarg[i] & 31);
|
||||||
break;
|
break;
|
||||||
case 'd': case 'f': case 'i': case 'n': case 'l':
|
case 'd': case 'f': case 'i': case 'n': case 'l':
|
||||||
|
#ifdef __minix
|
||||||
|
case 'x':
|
||||||
|
#endif
|
||||||
fldtab[0].flags |= optval(ch, 0);
|
fldtab[0].flags |= optval(ch, 0);
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
|
|
|
@ -86,6 +86,9 @@
|
||||||
#define BI 0x20 /* ignore blanks in icol */
|
#define BI 0x20 /* ignore blanks in icol */
|
||||||
#define BT 0x40 /* ignore blanks in tcol */
|
#define BT 0x40 /* ignore blanks in tcol */
|
||||||
#define L 0x80 /* Sort by field length */
|
#define L 0x80 /* Sort by field length */
|
||||||
|
#ifdef __minix
|
||||||
|
#define X 0x100 /* Field is a hex number */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* masks for delimiters: blanks, fields, and termination. */
|
/* masks for delimiters: blanks, fields, and termination. */
|
||||||
#define BLANK 1 /* ' ', '\t'; '\n' if -R is invoked */
|
#define BLANK 1 /* ' ', '\t'; '\n' if -R is invoked */
|
||||||
|
|
Loading…
Reference in a new issue