Skip to content

Commit

Permalink
erts: Remove halfword relative printf
Browse files Browse the repository at this point in the history
  • Loading branch information
psyeugenic committed Jun 24, 2015
1 parent 1d76e08 commit 9c2f061
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 29 deletions.
4 changes: 2 additions & 2 deletions erts/emulator/beam/erl_db_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2187,11 +2187,11 @@ static void db_print_hash(int to, void *to_arg, int show, DbTable *tbl)
erts_print(to, to_arg, "*");
if (tb->common.compress) {
Eterm key = GETKEY(tb, list->dbterm.tpl);
erts_print(to, to_arg, "key=%R", key, list->dbterm.tpl);
erts_print(to, to_arg, "key=%T", key);
}
else {
Eterm obj = make_tuple(list->dbterm.tpl);
erts_print(to, to_arg, "%R", obj, list->dbterm.tpl);
erts_print(to, to_arg, "%T", obj);
}
if (list->next != 0)
erts_print(to, to_arg, ",");
Expand Down
7 changes: 3 additions & 4 deletions erts/emulator/beam/erl_db_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ static Sint cmp_partly_bound(Eterm partly_bound_key, Eterm bound_key, Eterm* bk_
erts_fprintf(stderr," > ");
else
erts_fprintf(stderr," == ");
erts_fprintf(stderr,"%R\n", bound_key, bk_base);
erts_fprintf(stderr,"%T\n", bound_key);
#endif
return ret;
}
Expand Down Expand Up @@ -3155,9 +3155,8 @@ static void do_dump_tree2(DbTableTree* tb, int to, void *to_arg, int show,
prefix = "";
term = make_tuple(t->dbterm.tpl);
}
erts_print(to, to_arg, "%*s%s%R (addr = %p, bal = %d)\n",
offset, "", prefix, term, t->dbterm.tpl,
t, t->balance);
erts_print(to, to_arg, "%*s%s%T (addr = %p, bal = %d)\n",
offset, "", prefix, term, t, t->balance);
}
do_dump_tree2(tb, to, to_arg, show, t->left, offset + 4);
}
Expand Down
15 changes: 5 additions & 10 deletions erts/emulator/beam/erl_printf_term.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ do { \
/* return 0 if list is not a non-empty flat list of printable characters */

static int
is_printable_string(Eterm list, Eterm* base)
{
is_printable_string(Eterm list) {
int len = 0;
int c;

Expand Down Expand Up @@ -260,9 +259,7 @@ static char *format_binary(Uint16 x, char *b) {
#endif

static int
print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
Eterm* obj_base)
{
print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount) {
DECLARE_WSTACK(s);
int res;
int i;
Expand Down Expand Up @@ -420,7 +417,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
PRINT_CHAR(res, fn, arg, '>');
break;
case LIST_DEF:
if (is_printable_string(obj, obj_base)) {
if (is_printable_string(obj)) {
int c;
PRINT_CHAR(res, fn, arg, '"');
nobj = list_val(obj);
Expand Down Expand Up @@ -644,13 +641,11 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,


int
erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision,
ErlPfEterm* term_base)
{
erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision) {
int res;
ERTS_CT_ASSERT(sizeof(ErlPfEterm) == sizeof(Eterm));

res = print_term(fn, arg, (Eterm)term, &precision, (Eterm*)term_base);
res = print_term(fn, arg, (Eterm)term, &precision);
if (res < 0)
return res;
if (precision <= 0)
Expand Down
3 changes: 1 addition & 2 deletions erts/emulator/beam/erl_printf_term.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@
#define ERL_PRINTF_TERM_H__

#include "erl_printf_format.h"
int erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision,
ErlPfEterm* term_base);
int erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision);
#endif
2 changes: 1 addition & 1 deletion erts/include/internal/erl_printf_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern int erts_printf_double(fmtfn_t, void *, char, int, int, double);

typedef ErlPfUWord ErlPfEterm;

extern int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long, ErlPfEterm*);
extern int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long);

#endif /* ERL_PRINTF_FORMAT_H__ */

15 changes: 5 additions & 10 deletions erts/lib_src/common/erl_printf_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#endif

#define FMTC_d 0x0000
#define FMTC_R 0x0001
/*empty 0x0001 was RELATIVE */
#define FMTC_o 0x0002
#define FMTC_u 0x0003
#define FMTC_x 0x0004
Expand Down Expand Up @@ -158,7 +158,7 @@ static char heX[] = "0123456789ABCDEF";
#define SIGN(X) ((X) > 0 ? 1 : ((X) < 0 ? -1 : 0))
#define USIGN(X) ((X) == 0 ? 0 : 1)

int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long, ErlPfEterm*) = NULL;
int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long) = NULL;

static int
noop_fn(void *vfp, char* buf, size_t len)
Expand Down Expand Up @@ -637,7 +637,6 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
case 'p': ptr++; fmt |= FMTC_p; break;
case 'n': ptr++; fmt |= FMTC_n; break;
case 'T': ptr++; fmt |= FMTC_T; break;
case 'R': ptr++; fmt |= FMTC_R; break;
case '%':
FMT(fn,arg,ptr,1,count);
ptr++;
Expand Down Expand Up @@ -812,11 +811,9 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
default: *va_arg(ap,int*) = count; break;
}
break;
case FMTC_T: /* Eterm */
case FMTC_R: { /* Eterm, Eterm* base */
case FMTC_T: { /* Eterm */
long prec;
ErlPfEterm eterm;
ErlPfEterm* eterm_base;

if (!erts_printf_eterm_func)
return -EINVAL;
Expand All @@ -827,16 +824,14 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
else
prec = (long) precision;
eterm = va_arg(ap, ErlPfEterm);
eterm_base = ((fmt & FMTC_MASK) == FMTC_R) ?
va_arg(ap, ErlPfEterm*) : NULL;
if (width > 0 && !(fmt & FMTF_adj)) {
res = (*erts_printf_eterm_func)(noop_fn, NULL, eterm, prec, eterm_base);
res = (*erts_printf_eterm_func)(noop_fn, NULL, eterm, prec);
if (res < 0)
return res;
if (width > res)
BLANKS(fn, arg, width - res, count);
}
res = (*erts_printf_eterm_func)(fn, arg, eterm, prec, eterm_base);
res = (*erts_printf_eterm_func)(fn, arg, eterm, prec);
if (res < 0)
return res;
count += res;
Expand Down

0 comments on commit 9c2f061

Please sign in to comment.