mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Use vis(3) instead of handrolled function.
This commit is contained in:
		@@ -23,6 +23,7 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <vis.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -156,8 +157,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
				    ent->code, ent->name);
 | 
									    ent->code, ent->name);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			case TTYCODE_STRING:
 | 
								case TTYCODE_STRING:
 | 
				
			||||||
				clean_string(
 | 
									strnvis(out, code->value.string, sizeof out,
 | 
				
			||||||
				    code->value.string, out, sizeof out);
 | 
									    VIS_OCTAL|VIS_TAB|VIS_NL);
 | 
				
			||||||
				ctx->print(ctx, "%2u: %s: (string) %s",
 | 
									ctx->print(ctx, "%2u: %s: (string) %s",
 | 
				
			||||||
				    ent->code, ent->name, out);
 | 
									    ent->code, ent->name, out);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								util.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								util.c
									
									
									
									
									
								
							@@ -50,23 +50,3 @@ section_string(char *buf, size_t len, size_t sectoff, size_t sectlen)
 | 
				
			|||||||
	    (int) (last - first), buf + first, last == len ? "" : "...");
 | 
						    (int) (last - first), buf + first, last == len ? "" : "...");
 | 
				
			||||||
	return (s);
 | 
						return (s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Clean string of invisible characters. */
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
clean_string(const char *in, char *buf, size_t len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const u_char	*cp;
 | 
					 | 
				
			||||||
	size_t	 	 off;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	off = 0;
 | 
					 | 
				
			||||||
	for (cp = in; *cp != '\0'; cp++) {
 | 
					 | 
				
			||||||
		if (off >= len)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		if (*cp >= 0x20 && *cp <= 0x7f)
 | 
					 | 
				
			||||||
			buf[off++] = *cp;
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			off += xsnprintf(buf + off, len - off, "\\%03hho", *cp);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (off < len)
 | 
					 | 
				
			||||||
		buf[off] = '\0';
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user