diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib_string.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib_string.c b/src/lib_string.c index 09010b15..eb2ae226 100644 --- a/src/lib_string.c +++ b/src/lib_string.c | |||
@@ -881,14 +881,10 @@ LJLIB_CF(string_format) | |||
881 | tv.n = lj_lib_checknum(L, arg); | 881 | tv.n = lj_lib_checknum(L, arg); |
882 | if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { | 882 | if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { |
883 | /* Canonicalize output of non-finite values. */ | 883 | /* Canonicalize output of non-finite values. */ |
884 | char *p, nbuf[LJ_STR_NUMBUF]; | 884 | char nbuf[LJ_STR_NUMBUF]; |
885 | MSize n = lj_str_bufnum(nbuf, &tv); | 885 | char *p = lj_str_bufnum(nbuf, &tv); |
886 | if (fmt[-1] < 'a') { | 886 | if (fmt[-1] < 'a') { *(p-3) -= 0x20; *(p-2) -= 0x20; *(p-1) -= 0x20; } |
887 | nbuf[n-3] = nbuf[n-3] - 0x20; | 887 | *p = '\0'; |
888 | nbuf[n-2] = nbuf[n-2] - 0x20; | ||
889 | nbuf[n-1] = nbuf[n-1] - 0x20; | ||
890 | } | ||
891 | nbuf[n] = '\0'; | ||
892 | for (p = spec; *p < 'A' && *p != '.'; p++) ; | 888 | for (p = spec; *p < 'A' && *p != '.'; p++) ; |
893 | *p++ = 's'; *p = '\0'; | 889 | *p++ = 's'; *p = '\0'; |
894 | len = (MSize)sprintf(buf, spec, nbuf); | 890 | len = (MSize)sprintf(buf, spec, nbuf); |
@@ -901,8 +897,9 @@ LJLIB_CF(string_format) | |||
901 | string_fmt_quoted(sb, lj_lib_checkstr(L, arg)); | 897 | string_fmt_quoted(sb, lj_lib_checkstr(L, arg)); |
902 | continue; | 898 | continue; |
903 | case 'p': | 899 | case 'p': |
904 | len = lj_str_bufptr(buf, lua_topointer(L, arg)); | 900 | setsbufP(sb, lj_str_bufptr(lj_buf_more(sb, LJ_STR_PTRBUF), |
905 | break; | 901 | lua_topointer(L, arg))); |
902 | continue; | ||
906 | case 's': { | 903 | case 's': { |
907 | GCstr *str = string_fmt_tostring(L, arg); | 904 | GCstr *str = string_fmt_tostring(L, arg); |
908 | if (!strchr(spec, '.') && str->len >= 100) { /* Format overflow? */ | 905 | if (!strchr(spec, '.') && str->len >= 100) { /* Format overflow? */ |