loguru icon indicating copy to clipboard operation
loguru copied to clipboard

The usage of "+= snprintf" in print_preamble_header()/print_preamble() is wrong.

Open scturtle opened this issue 7 years ago • 2 comments

https://github.com/emilk/loguru/blob/bead38889d44d9fdb5c52916d1f26c4d6af09e66/loguru.hpp#L2329

Ref: http://www.cplusplus.com/reference/cstdio/snprintf/

  1. The type of argument buf_size is size_t, but out_buff_size - pos may produce negative value.
  2. The return value maybe negative if an encoding error occurs.
  3. If out_buff_size == 0, there is no \0.

scturtle avatar Feb 09 '18 02:02 scturtle

BTW, are g_preamble_* variables used to disable some fields (e.g. YYYYMMDD)? It will be useful

MaskRay avatar Feb 12 '18 04:02 MaskRay

BTW, TERM=tmux does not mean 256 colors or 24-bit colors are not supported. tmux supports colors as long as the underlying terminal supports it.

If TERM=tmux is specified, which likely indicates the user specifies set -g default-terminal "tmux" (as it is not the default), the user may want to use enter_italics_mode, which means the terminal is unlikely monochrome.

				return 0 == strcmp(term, "cygwin")
					|| 0 == strcmp(term, "linux")
					|| 0 == strcmp(term, "rxvt-unicode-256color")
					|| 0 == strcmp(term, "screen")
					|| 0 == strcmp(term, "screen-256color")
					|| 0 == strcmp(term, "tmux-256color")
					|| 0 == strcmp(term, "xterm")
					|| 0 == strcmp(term, "xterm-256color")
					|| 0 == strcmp(term, "xterm-termite")
					|| 0 == strcmp(term, "xterm-color");

% TERM=xterm-termite-24bits tput setf24 65555 | cat -v # Emacs terminal 24-bit color rocks

MaskRay avatar Feb 12 '18 05:02 MaskRay