mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Sync OpenBSD patchset 566:
Rename a variable to something more helpful.
This commit is contained in:
		
							
								
								
									
										42
									
								
								attributes.c
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								attributes.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: attributes.c,v 1.2 2009-06-25 15:25:45 nicm Exp $ */
 | 
			
		||||
/* $Id: attributes.c,v 1.3 2009-11-28 14:46:23 tcunha Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
 | 
			
		||||
@@ -23,29 +23,29 @@
 | 
			
		||||
#include "tmux.h"
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
attributes_tostring(u_char ch)
 | 
			
		||||
attributes_tostring(u_char attr)
 | 
			
		||||
{
 | 
			
		||||
	static char	buf[128];
 | 
			
		||||
 | 
			
		||||
	if (ch == 0)
 | 
			
		||||
	if (attr == 0)
 | 
			
		||||
		return ("default");
 | 
			
		||||
 | 
			
		||||
	buf[0] = '\0';
 | 
			
		||||
	if (ch & GRID_ATTR_BRIGHT)
 | 
			
		||||
	if (attr & GRID_ATTR_BRIGHT)
 | 
			
		||||
		strlcat(buf, "bright,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_DIM)
 | 
			
		||||
	if (attr & GRID_ATTR_DIM)
 | 
			
		||||
		strlcat(buf, "dim,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_UNDERSCORE)
 | 
			
		||||
	if (attr & GRID_ATTR_UNDERSCORE)
 | 
			
		||||
		strlcat(buf, "underscore,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_BLINK)
 | 
			
		||||
	if (attr & GRID_ATTR_BLINK)
 | 
			
		||||
		strlcat(buf, "blink,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_REVERSE)
 | 
			
		||||
	if (attr & GRID_ATTR_REVERSE)
 | 
			
		||||
		strlcat(buf, "reverse,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_HIDDEN)
 | 
			
		||||
	if (attr & GRID_ATTR_HIDDEN)
 | 
			
		||||
		strlcat(buf, "hidden,", sizeof (buf));
 | 
			
		||||
	if (ch & GRID_ATTR_ITALICS)
 | 
			
		||||
	if (attr & GRID_ATTR_ITALICS)
 | 
			
		||||
		strlcat(buf, "italics,", sizeof (buf));
 | 
			
		||||
	if (*buf)
 | 
			
		||||
	if (*buf != '\0')
 | 
			
		||||
		*(strrchr(buf, ',')) = '\0';
 | 
			
		||||
 | 
			
		||||
	return (buf);
 | 
			
		||||
@@ -55,7 +55,7 @@ int
 | 
			
		||||
attributes_fromstring(const char *str)
 | 
			
		||||
{
 | 
			
		||||
	const char	delimiters[] = " ,|";
 | 
			
		||||
	u_char		ch;
 | 
			
		||||
	u_char		attr;
 | 
			
		||||
	size_t		end;
 | 
			
		||||
 | 
			
		||||
	if (*str == '\0' || strcspn(str, delimiters) == 0)
 | 
			
		||||
@@ -66,28 +66,28 @@ attributes_fromstring(const char *str)
 | 
			
		||||
	if (strcasecmp(str, "default") == 0)
 | 
			
		||||
		return (0);
 | 
			
		||||
 | 
			
		||||
	ch = 0;
 | 
			
		||||
	attr = 0;
 | 
			
		||||
	do {
 | 
			
		||||
		end = strcspn(str, delimiters);
 | 
			
		||||
		if ((end == 6 && strncasecmp(str, "bright", end) == 0) ||
 | 
			
		||||
		    (end == 4 && strncasecmp(str, "bold", end) == 0))
 | 
			
		||||
			ch |= GRID_ATTR_BRIGHT;
 | 
			
		||||
			attr |= GRID_ATTR_BRIGHT;
 | 
			
		||||
		else if (end == 3 && strncasecmp(str, "dim", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_DIM;
 | 
			
		||||
			attr |= GRID_ATTR_DIM;
 | 
			
		||||
		else if (end == 10 && strncasecmp(str, "underscore", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_UNDERSCORE;
 | 
			
		||||
			attr |= GRID_ATTR_UNDERSCORE;
 | 
			
		||||
		else if (end == 5 && strncasecmp(str, "blink", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_BLINK;
 | 
			
		||||
			attr |= GRID_ATTR_BLINK;
 | 
			
		||||
		else if (end == 7 && strncasecmp(str, "reverse", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_REVERSE;
 | 
			
		||||
			attr |= GRID_ATTR_REVERSE;
 | 
			
		||||
		else if (end == 6 && strncasecmp(str, "hidden", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_HIDDEN;
 | 
			
		||||
			attr |= GRID_ATTR_HIDDEN;
 | 
			
		||||
		else if (end == 7 && strncasecmp(str, "italics", end) == 0)
 | 
			
		||||
			ch |= GRID_ATTR_ITALICS;
 | 
			
		||||
			attr |= GRID_ATTR_ITALICS;
 | 
			
		||||
		else
 | 
			
		||||
			return (-1);
 | 
			
		||||
		str += end + strspn(str + end, delimiters);
 | 
			
		||||
	} while (*str != '\0');
 | 
			
		||||
 | 
			
		||||
	return (ch);
 | 
			
		||||
	return (attr);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user