[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: avoid unnecessary 2nd getenv("TERM")
From: |
Jim Meyering |
Subject: |
[PATCH] maint: avoid unnecessary 2nd getenv("TERM") |
Date: |
Thu, 01 Apr 2010 16:18:00 +0200 |
Not necessary, but...
>From 2390067340d41aac6ed32f2faaec8b94d09f03e0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 1 Apr 2010 16:16:10 +0200
Subject: [PATCH] maint: avoid unnecessary 2nd getenv("TERM")
* src/main.c (main): Don't call getenv("TERM") twice -- in the same
expression, even.
---
src/main.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/main.c b/src/main.c
index 0bb4098..1697c80 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2010,13 +2010,15 @@ main (int argc, char **argv)
show_help = 1;
} else
color_option = 2;
- if(color_option == 2) {
- if(isatty(STDOUT_FILENO) && getenv("TERM") &&
- strcmp(getenv("TERM"), "dumb"))
- color_option = 1;
- else
- color_option = 0;
- }
+ if (color_option == 2)
+ {
+ char const *t;
+ if (isatty (STDOUT_FILENO) && (t = getenv ("TERM"))
+ && strcmp (t, "dumb"))
+ color_option = 1;
+ else
+ color_option = 0;
+ }
break;
case EXCLUDE_OPTION:
--
1.7.0.3.513.gc8ed0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] maint: avoid unnecessary 2nd getenv("TERM"),
Jim Meyering <=