[PATCH 1/8] ul.c: convert definition to function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/ul.c |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/text-utils/ul.c b/text-utils/ul.c
index dc0550c..2638939 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -80,6 +80,7 @@ void setmode(int newmode);
 static void setcol(int newcol);
 static void needcol(int col);
 static void sig_handler(int signo);
+static void print_line(char *line);
 
 #define	IESC	'\033'
 #define	SO	'\016'
@@ -115,8 +116,6 @@ int	halfpos;
 int	upln;
 int	iflag;
 
-#define	PRINT(s)	if (s == NULL) /* void */; else putwp(s)
-
 int main(int argc, char **argv)
 {
 	int c, ret;
@@ -327,7 +326,7 @@ void flushln(void)
 		}
 		if (obuf[i].c_char == '\0') {
 			if (upln) {
-				PRINT(CURS_RIGHT);
+				print_line(CURS_RIGHT);
 			} else
 				outc(' ', 1);
 		} else
@@ -452,8 +451,8 @@ void reverse(void)
 {
 	upln++;
 	fwd();
-	PRINT(CURS_UP);
-	PRINT(CURS_UP);
+	print_line(CURS_UP);
+	print_line(CURS_UP);
 	upln++;
 }
 
@@ -510,9 +509,9 @@ outc(wint_t c, int width) {
 	putwchar(c);
 	if (must_use_uc && (curmode&UNDERL)) {
 		for (i=0; i<width; i++)
-			PRINT(CURS_LEFT);
+			print_line(CURS_LEFT);
 		for (i=0; i<width; i++)
-			PRINT(UNDER_CHAR);
+			print_line(UNDER_CHAR);
 	}
 }
 
@@ -527,40 +526,40 @@ void setmode(int newmode)
 			case NORMAL:
 				break;
 			case UNDERL:
-				PRINT(EXIT_UNDERLINE);
+				print_line(EXIT_UNDERLINE);
 				break;
 			default:
 				/* This includes standout */
-				PRINT(EXIT_ATTRIBUTES);
+				print_line(EXIT_ATTRIBUTES);
 				break;
 			}
 			break;
 		case ALTSET:
-			PRINT(ENTER_REVERSE);
+			print_line(ENTER_REVERSE);
 			break;
 		case SUPERSC:
 			/*
 			 * This only works on a few terminals.
 			 * It should be fixed.
 			 */
-			PRINT(ENTER_UNDERLINE);
-			PRINT(ENTER_DIM);
+			print_line(ENTER_UNDERLINE);
+			print_line(ENTER_DIM);
 			break;
 		case SUBSC:
-			PRINT(ENTER_DIM);
+			print_line(ENTER_DIM);
 			break;
 		case UNDERL:
-			PRINT(ENTER_UNDERLINE);
+			print_line(ENTER_UNDERLINE);
 			break;
 		case BOLD:
-			PRINT(ENTER_BOLD);
+			print_line(ENTER_BOLD);
 			break;
 		default:
 			/*
 			 * We should have some provision here for multiple modes
 			 * on at once.  This will have to come later.
 			 */
-			PRINT(ENTER_STANDOUT);
+			print_line(ENTER_STANDOUT);
 			break;
 		}
 	}
@@ -602,3 +601,11 @@ static void sig_handler(int signo)
 	_exit(EXIT_SUCCESS);
 }
 
+static void print_line(char *line)
+{
+	if (line == NULL)
+		return;
+	else
+		putwp(line);
+	return;
+}
-- 
1.7.5

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux