mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Only assume width 1 when wcwidth() returns -1 on non-OpenBSD platforms.
This commit is contained in:
		
							
								
								
									
										14
									
								
								utf8.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								utf8.c
									
									
									
									
									
								
							@@ -118,6 +118,20 @@ utf8_width(wchar_t wc)
 | 
				
			|||||||
	width = wcwidth(wc);
 | 
						width = wcwidth(wc);
 | 
				
			||||||
	if (width < 0 || width > 0xff) {
 | 
						if (width < 0 || width > 0xff) {
 | 
				
			||||||
		log_debug("Unicode %04x, wcwidth() %d", wc, width);
 | 
							log_debug("Unicode %04x, wcwidth() %d", wc, width);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __OpenBSD__
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							 * Many platforms (particularly and inevitably OS X) have no
 | 
				
			||||||
 | 
							 * width for relatively common characters (wcwidth() returns
 | 
				
			||||||
 | 
							 * -1); assume width 1 in this case. This will be wrong for
 | 
				
			||||||
 | 
							 * genuinely nonprintable characters, but they should be
 | 
				
			||||||
 | 
							 * rare. We may pass through stuff that ideally we would block,
 | 
				
			||||||
 | 
							 * but this is no worse than sending the same to the terminal
 | 
				
			||||||
 | 
							 * without tmux.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (width < 0)
 | 
				
			||||||
 | 
								return (1);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		return (-1);
 | 
							return (-1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return (width);
 | 
						return (width);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user