mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 09:44:29 +00:00 
			
		
		
		
	Misc: Most text functions also treat "%.*s" (along with "%s") specially to avoid formatting. (#3466, #6846)
This commit is contained in:
		@@ -93,6 +93,7 @@ Other changes:
 | 
			
		||||
- MenuBar: Fixed an issue where layouting an item in the menu-bar would erroneously
 | 
			
		||||
  register contents size in a way that would affect the scrolling layer.
 | 
			
		||||
  Was most often noticable when using an horizontal scrollbar. (#6789)
 | 
			
		||||
- Misc: Most text functions also treat "%.*s" (along with "%s") specially to avoid formatting. (#3466, #6846)
 | 
			
		||||
- IO: Setting io.WantSetMousePos ignores incoming MousePos events. (#6837, #228) [@bertaye]
 | 
			
		||||
- ImDrawList: Added AddEllipse(), AddEllipseFilled(), PathEllipticalArcTo(). (#2743) [@Doohl]
 | 
			
		||||
- ImVector: Added find_index() helper.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -1918,21 +1918,9 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
 | 
			
		||||
 | 
			
		||||
void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, const char* fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    va_list args;
 | 
			
		||||
    va_start(args, fmt);
 | 
			
		||||
    if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
 | 
			
		||||
    {
 | 
			
		||||
        const char* buf = va_arg(args, const char*); // Skip formatting when using "%s"
 | 
			
		||||
        *out_buf = buf;
 | 
			
		||||
        if (out_buf_end) { *out_buf_end = buf + strlen(buf); }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
 | 
			
		||||
        *out_buf = g.TempBuffer.Data;
 | 
			
		||||
        if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
 | 
			
		||||
    }
 | 
			
		||||
    ImFormatStringToTempBufferV(out_buf, out_buf_end, fmt, args);
 | 
			
		||||
    va_end(args);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1945,6 +1933,13 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
 | 
			
		||||
        *out_buf = buf;
 | 
			
		||||
        if (out_buf_end) { *out_buf_end = buf + strlen(buf); }
 | 
			
		||||
    }
 | 
			
		||||
    else if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '*' && fmt[3] == 's' && fmt[4] == 0)
 | 
			
		||||
    {
 | 
			
		||||
        int buf_len = va_arg(args, int); // Skip formatting when using "%.*s"
 | 
			
		||||
        const char* buf = va_arg(args, const char*);
 | 
			
		||||
        *out_buf = buf;
 | 
			
		||||
        *out_buf_end = buf + buf_len; // Disallow not passing 'out_buf_end' here. User is expected to use it.
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user