From tobias.rehbein@web.de  Fri Jul  1 21:18:03 2011
Return-Path: <tobias.rehbein@web.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EEEE0106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Jul 2011 21:18:03 +0000 (UTC)
	(envelope-from tobias.rehbein@web.de)
Received: from fmmailgate02.web.de (fmmailgate02.web.de [217.72.192.227])
	by mx1.freebsd.org (Postfix) with ESMTP id 81F1E8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Jul 2011 21:18:03 +0000 (UTC)
Received: from smtp03.web.de  ( [172.20.0.65])
	by fmmailgate02.web.de (Postfix) with ESMTP id 7C7091A40A6CA
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Jul 2011 23:18:02 +0200 (CEST)
Received: from [78.46.73.134] (helo=sushi.pseudo.local)
	by smtp03.web.de with asmtp (TLSv1:AES256-SHA:256)
	(WEB.DE 4.110 #2)
	id 1Qcl6A-00032p-00
	for FreeBSD-gnats-submit@freebsd.org; Fri, 01 Jul 2011 23:18:02 +0200
Received: from sushi.pseudo.local (localhost [127.0.0.1])
	by sushi.pseudo.local (8.14.4/8.14.4) with ESMTP id p61LI0nP029653
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 1 Jul 2011 23:18:01 +0200 (CEST)
	(envelope-from tobi@sushi.pseudo.local)
Received: (from tobi@localhost)
	by sushi.pseudo.local (8.14.4/8.14.4/Submit) id p61LI02m029652;
	Fri, 1 Jul 2011 23:18:00 +0200 (CEST)
	(envelope-from tobi)
Message-Id: <201107012118.p61LI02m029652@sushi.pseudo.local>
Date: Fri, 1 Jul 2011 23:18:00 +0200 (CEST)
From: Tobias Rehbein <tobias.rehbein@web.de>
Sender: tobias.rehbein@web.de
Reply-To: Tobias Rehbein <tobias.rehbein@web.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] Disable ncal(1)s date highlighting if stdout is not a tty
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         158580
>Category:       bin
>Synopsis:       [patch] Disable ncal(1)s date highlighting if stdout is not a tty
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 01 21:20:09 UTC 2011
>Closed-Date:    
>Last-Modified:  Thu Nov 24 16:15:40 UTC 2011
>Originator:     Tobias Rehbein
>Release:        FreeBSD 8.2-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD sushi.pseudo.local 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #4: Thu Jun 2 16:42:39 CEST 2011 tobi@sushi.pseudo.local:/usr/obj/usr/src/sys/SUSHI i386


	
>Description:
	ncal(1) highlights the current date (or a date provided via parameter) even if stdout
	is not a tty. If stdout is not a tty the data is normally processed by other tools and no
	control sequences are expected.

	The attached patch disables the higlighting of dates if stdout is not a tty which seems
	to be "the right thing to do". 

	
>How-To-Repeat:
	
>Fix:

	

--- usr.bin-ncal_conditional-highlight.diff begins here ---
diff -ruN usr.bin/ncal.orig/ncal.1 usr.bin/ncal/ncal.1
--- usr.bin/ncal.orig/ncal.1	2011-07-01 22:37:47.000000000 +0200
+++ usr.bin/ncal/ncal.1	2011-07-01 22:36:58.000000000 +0200
@@ -171,6 +171,8 @@
 will warn about these combinations.
 .Pp
 A year starts on January 1.
+.Pp
+Highlighting of dates is diabled if stdout is not a tty.
 .Sh SEE ALSO
 .Xr calendar 3 ,
 .Xr strftime 3
diff -ruN usr.bin/ncal.orig/ncal.c usr.bin/ncal/ncal.c
--- usr.bin/ncal.orig/ncal.c	2011-07-01 22:37:47.000000000 +0200
+++ usr.bin/ncal/ncal.c	2011-07-01 22:34:26.000000000 +0200
@@ -822,7 +822,7 @@
 					dt.d = j - jan1 + 1;
 				else
 					sdater(j, &dt);
-				if (j == highlightdate && !flag_nohighlight)
+				if (j == highlightdate && !flag_nohighlight && isatty(STDOUT_FILENO))
 					highlight(mlines->lines[i] + k,
 					    ds + dt.d * dw, dw, &l);
 				else
--- usr.bin-ncal_conditional-highlight.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Fri Jul 8 10:07:55 UTC 2011 
Responsible-Changed-Why:  
Hi Edwin, 

could you take a look at this PR? 

Cheers. 
Alex 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158580 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/158580: commit references a PR
Date: Mon, 11 Jul 2011 10:41:23 +0000 (UTC)

 Author: edwin
 Date: Mon Jul 11 10:41:08 2011
 New Revision: 223931
 URL: http://svn.freebsd.org/changeset/base/223931
 
 Log:
   ncal(1) highlights the current date (or a date provided via parameter)
   even if stdout is not a tty. If stdout is not a tty the data is
   normally processed by other tools and no control sequences are
   expected.
   
   PR:		bin/158580
   MFC after:	1 week
 
 Modified:
   head/usr.bin/ncal/ncal.1
   head/usr.bin/ncal/ncal.c
 
 Modified: head/usr.bin/ncal/ncal.1
 ==============================================================================
 --- head/usr.bin/ncal/ncal.1	Mon Jul 11 10:02:27 2011	(r223930)
 +++ head/usr.bin/ncal/ncal.1	Mon Jul 11 10:41:08 2011	(r223931)
 @@ -171,6 +171,8 @@ that, two after that and the whole year.
  will warn about these combinations.
  .Pp
  A year starts on January 1.
 +.P
 +Highlighting of dates is disabled if stdout is not a tty.
  .Sh SEE ALSO
  .Xr calendar 3 ,
  .Xr strftime 3
 
 Modified: head/usr.bin/ncal/ncal.c
 ==============================================================================
 --- head/usr.bin/ncal/ncal.c	Mon Jul 11 10:02:27 2011	(r223930)
 +++ head/usr.bin/ncal/ncal.c	Mon Jul 11 10:41:08 2011	(r223931)
 @@ -822,7 +822,8 @@ mkmonthr(int y, int m, int jd_flag, stru
  					dt.d = j - jan1 + 1;
  				else
  					sdater(j, &dt);
 -				if (j == highlightdate && !flag_nohighlight)
 +				if (j == highlightdate && !flag_nohighlight
 +				 && isatty(STDOUT_FILENO))
  					highlight(mlines->lines[i] + k,
  					    ds + dt.d * dw, dw, &l);
  				else
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Thu Nov 24 16:15:16 UTC 2011 
State-Changed-Why:  
Patched in r223931. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158580 
>Unformatted:
