diff options
author | Mike Pall <mike> | 2013-08-31 19:38:20 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2013-08-31 19:38:20 +0200 |
commit | 19c2dd17dbaf66f1341efe2a71a26f0b5724f9e1 (patch) | |
tree | 4bb1f9bed90610f20b75855b431561bf1145bbbd | |
parent | 517500ba48a290699d5a2ec7465bf76a5109c49f (diff) | |
download | luajit-19c2dd17dbaf66f1341efe2a71a26f0b5724f9e1.tar.gz luajit-19c2dd17dbaf66f1341efe2a71a26f0b5724f9e1.tar.bz2 luajit-19c2dd17dbaf66f1341efe2a71a26f0b5724f9e1.zip |
Add common helper for pointer to string formatting.
-rw-r--r-- | src/lib_string.c | 3 | ||||
-rw-r--r-- | src/lj_strfmt.c | 9 | ||||
-rw-r--r-- | src/lj_strfmt.h | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/lib_string.c b/src/lib_string.c index 204f6975..0529cff3 100644 --- a/src/lib_string.c +++ b/src/lib_string.c | |||
@@ -714,8 +714,7 @@ again: | |||
714 | lj_strfmt_putfchar(sb, sf, lj_lib_checkint(L, arg)); | 714 | lj_strfmt_putfchar(sb, sf, lj_lib_checkint(L, arg)); |
715 | break; | 715 | break; |
716 | case STRFMT_PTR: /* No formatting. */ | 716 | case STRFMT_PTR: /* No formatting. */ |
717 | setsbufP(sb, lj_strfmt_wptr(lj_buf_more(sb, STRFMT_MAXBUF_PTR), | 717 | lj_strfmt_putptr(sb, lj_obj_ptr(L->base+arg-1)); |
718 | lj_obj_ptr(L->base+arg-1))); | ||
719 | break; | 718 | break; |
720 | default: | 719 | default: |
721 | lua_assert(0); | 720 | lua_assert(0); |
diff --git a/src/lj_strfmt.c b/src/lj_strfmt.c index 0003de70..614bd4ef 100644 --- a/src/lj_strfmt.c +++ b/src/lj_strfmt.c | |||
@@ -203,6 +203,12 @@ SBuf * LJ_FASTCALL lj_strfmt_putnum(SBuf *sb, cTValue *o) | |||
203 | } | 203 | } |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | SBuf * LJ_FASTCALL lj_strfmt_putptr(SBuf *sb, const void *v) | ||
207 | { | ||
208 | setsbufP(sb, lj_strfmt_wptr(lj_buf_more(sb, STRFMT_MAXBUF_PTR), v)); | ||
209 | return sb; | ||
210 | } | ||
211 | |||
206 | /* Add quoted string to buffer. */ | 212 | /* Add quoted string to buffer. */ |
207 | SBuf * LJ_FASTCALL lj_strfmt_putquoted(SBuf *sb, GCstr *str) | 213 | SBuf * LJ_FASTCALL lj_strfmt_putquoted(SBuf *sb, GCstr *str) |
208 | { | 214 | { |
@@ -520,8 +526,7 @@ const char *lj_strfmt_pushvf(lua_State *L, const char *fmt, va_list argp) | |||
520 | lj_buf_putb(sb, va_arg(argp, int)); | 526 | lj_buf_putb(sb, va_arg(argp, int)); |
521 | break; | 527 | break; |
522 | case STRFMT_PTR: | 528 | case STRFMT_PTR: |
523 | setsbufP(sb, lj_strfmt_wptr(lj_buf_more(sb, STRFMT_MAXBUF_PTR), | 529 | lj_strfmt_putptr(sb, va_arg(argp, void *)); |
524 | va_arg(argp, void *))); | ||
525 | break; | 530 | break; |
526 | case STRFMT_ERR: | 531 | case STRFMT_ERR: |
527 | default: | 532 | default: |
diff --git a/src/lj_strfmt.h b/src/lj_strfmt.h index 5454336f..4bbdd4a7 100644 --- a/src/lj_strfmt.h +++ b/src/lj_strfmt.h | |||
@@ -93,6 +93,7 @@ LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putint(SBuf *sb, int32_t k); | |||
93 | #if LJ_HASJIT | 93 | #if LJ_HASJIT |
94 | LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putnum(SBuf *sb, cTValue *o); | 94 | LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putnum(SBuf *sb, cTValue *o); |
95 | #endif | 95 | #endif |
96 | LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putptr(SBuf *sb, const void *v); | ||
96 | LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putquoted(SBuf *sb, GCstr *str); | 97 | LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putquoted(SBuf *sb, GCstr *str); |
97 | 98 | ||
98 | /* Formatted conversions to buffer. */ | 99 | /* Formatted conversions to buffer. */ |