mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Put the fix back for wcwidth() failing.
This commit is contained in:
		
							
								
								
									
										23
									
								
								utf8.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								utf8.c
									
									
									
									
									
								
							@@ -244,12 +244,25 @@ utf8_width(struct utf8_data *ud, int *width)
 | 
				
			|||||||
		return (UTF8_ERROR);
 | 
							return (UTF8_ERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	*width = wcwidth(wc);
 | 
						*width = wcwidth(wc);
 | 
				
			||||||
	if (*width < 0 || *width > 0xff) {
 | 
						if (*width >= 0 && *width <= 0xff)
 | 
				
			||||||
		log_debug("UTF-8 %.*s, wcwidth() %d", (int)ud->size, ud->data,
 | 
							return (UTF8_DONE);
 | 
				
			||||||
		    *width);
 | 
						log_debug("UTF-8 %.*s, wcwidth() %d", (int)ud->size, ud->data, *width);
 | 
				
			||||||
		return (UTF8_ERROR);
 | 
					
 | 
				
			||||||
 | 
					#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) {
 | 
				
			||||||
 | 
							*width = 1;
 | 
				
			||||||
 | 
							return (UTF8_DONE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return (UTF8_DONE);
 | 
					#endif
 | 
				
			||||||
 | 
						return (UTF8_ERROR);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user