From MattK@SANDVINE.com  Wed Apr 16 14:31:26 2003
Return-Path: <MattK@SANDVINE.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E749637B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 16 Apr 2003 14:31:26 -0700 (PDT)
Received: from mail.sandvine.com (sandvine.com [199.243.201.138])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2762943FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 16 Apr 2003 14:31:26 -0700 (PDT)
	(envelope-from MattK@SANDVINE.com)
Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19)
	id <HS8WRA51>; Wed, 16 Apr 2003 17:31:25 -0400
Message-Id: <FE045D4D9F7AED4CBFF1B3B813C85337017CC19C@mail.sandvine.com>
Date: Wed, 16 Apr 2003 17:31:16 -0400
From: Matt Koivisto <MattK@SANDVINE.com>
To: "'FreeBSD-gnats-submit@freebsd.org'" <FreeBSD-gnats-submit@freebsd.org>
Subject: add -p option to pom [PATCH]

>Number:         51070
>Category:       bin
>Synopsis:       [patch] add -p option to pom(6)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    emaste
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 16 14:40:06 PDT 2003
>Closed-Date:    Thu Jul 22 01:31:05 UTC 2010
>Last-Modified:  Thu Jul 22 01:40:03 UTC 2010
>Originator:     Matt Koivisto
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
>Description:
	No easy way to use pom from a shell script

E.g. Now you can do
	if [ `pom -p` -gt 50 ]
>How-To-Repeat:
>Fix:

--- /usr/src/games/pom/pom.c	Mon Nov 29 22:49:09 1999
+++ ./pom.c	Wed Apr 16 17:05:39 2003
@@ -54,12 +54,14 @@
  * particular piece of code was adapted from.
  *
  * -- Keith E. Brandt  VIII 1984
+ * -- -p option added by Matt Koivisto 2003 (btw, I was 2 in 1984)
  *
  */
 
 #include <time.h>
 #include <stdio.h>
 #include <math.h>
+#include <unistd.h>
 
 #ifndef	PI
 #define	PI	  3.14159265358979323846
@@ -76,15 +78,32 @@
 static void	adj360 __P((double *));
 static double	dtor __P((double));
 static double	potm __P((double));
+static int parseable = 0;
 
 int
-main()
+main(argc, argv)
+    int argc;
+    char *argv[];
 {
 	time_t tt;
 	struct tm *GMT;
 	double days, today, tomorrow;
 	int cnt;
+	int ch;
 
+	while ((ch = getopt(argc, argv, "p")) != -1)
+	    switch (ch) {
+	    case 'p':
+		parseable = 1;
+		break;
+	    case '?':
+	    default:
+		(void)fprintf(stderr, "Usage: pom [-p]\n");
+		(void)fprintf(stderr, "\tWhere the options are:\n");
+		(void)fprintf(stderr, "\t-p : Return pom as a
percentage\n");
+		break;
+	    }
+    
 	(void) time(&tt);
 	GMT = gmtime(&tt);
 	days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
@@ -92,6 +111,10 @@
 	for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
 		days += isleap(1900 + cnt) ? 366 : 365;
 	today = potm(days) + .5;
+	if ((int)parseable == 1) {
+	    (void)printf("%1.0f\n", today);
+	    return 0;
+	}
 	(void)printf("The Moon is ");
 	if ((int)today == 100)
 		(void)printf("Full\n");
--- /usr/src/games/pom/pom.6	Sun Jul 22 07:32:37 2001
+++ pom.6	Wed Apr 16 17:22:24 2003
@@ -32,15 +32,24 @@
 .\"	@(#)pom.6	8.1 (Berkeley) 5/31/93
 .\" $FreeBSD$
 .\"
-.TH POM 6 "May 31, 1993"
-.UC 7
-.SH NAME
-pom \- display the phase of the moon
-.SH SYNOPSIS
-.B pom
-.SH DESCRIPTION
+.Dd May 31, 1993
+.Dt POM 6
+.Os
+.Sh NAME
+.Nm pom
+.Nd \- display the phase of the moon
+.Sh SYNOPSIS
+.Nm
+.Op Fl p
+.Sh DESCRIPTION
 The
 .I pom
 utility displays the current phase of the moon.
 Useful for selecting software completion target dates and predicting
 managerial behavior.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl p
+print just the phase as a percent, useful within a shell script.
+.El
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->emaste 
Responsible-Changed-By: emaste 
Responsible-Changed-When: Thu Jul 15 00:09:32 UTC 2010 
Responsible-Changed-Why:  
Grab 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51070 
State-Changed-From-To: open->patched 
State-Changed-By: emaste 
State-Changed-When: Thu Jul 15 00:16:59 UTC 2010 
State-Changed-Why:  
Somewhat modified version of patch committed as r210089. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/51070: commit references a PR
Date: Thu, 15 Jul 2010 00:16:59 +0000 (UTC)

 Author: emaste
 Date: Thu Jul 15 00:16:04 2010
 New Revision: 210089
 URL: http://svn.freebsd.org/changeset/base/210089
 
 Log:
   Add -p option to have pom(6) print just the percentage, without extra text.
   
   PR:		bin/51070
   Submitted by:	Matt Koivisto mkoivisto sandvine com
   MFC after:	1 week
 
 Modified:
   head/games/pom/pom.6
   head/games/pom/pom.c
 
 Modified: head/games/pom/pom.6
 ==============================================================================
 --- head/games/pom/pom.6	Thu Jul 15 00:04:14 2010	(r210088)
 +++ head/games/pom/pom.6	Thu Jul 15 00:16:04 2010	(r210089)
 @@ -32,7 +32,7 @@
  .\"	@(#)pom.6	8.1 (Berkeley) 5/31/93
  .\" $FreeBSD$
  .\"
 -.Dd May 31, 1993
 +.Dd July 14, 2010
  .Dt POM 6
  .Os
  .Sh NAME
 @@ -40,6 +40,7 @@
  .Nd display the phase of the moon
  .Sh SYNOPSIS
  .Nm 
 +.Op Fl p
  .Op Fl d Ar yyyy.mm.dd
  .Op Fl t Ar hh:mm:ss
  .Sh DESCRIPTION
 @@ -49,6 +50,10 @@ utility displays the current phase of th
  Useful for selecting software completion target dates and predicting
  managerial behavior.
  .Pp
 +Use the
 +.Fl p
 +option to print just the phase as a percentage.
 +.Pp
  Use the arguments
  .Fl d
  and
 
 Modified: head/games/pom/pom.c
 ==============================================================================
 --- head/games/pom/pom.c	Thu Jul 15 00:04:14 2010	(r210088)
 +++ head/games/pom/pom.c	Thu Jul 15 00:16:04 2010	(r210089)
 @@ -84,14 +84,17 @@ main(int argc, char **argv)
  	time_t tt;
  	struct tm GMT, tmd;
  	double days, today, tomorrow;
 -	int ch, cnt;
 +	int ch, cnt, pflag = 0;
  	char *odate = NULL, *otime = NULL;
  
 -	while ((ch = getopt(argc, argv, "d:t:")) != -1)
 +	while ((ch = getopt(argc, argv, "d:pt:")) != -1)
  		switch (ch) {
  		case 'd':
  			odate = optarg;
  			break;
 +		case 'p':
 +			pflag = 1;
 +			break;
  		case 't':
  			otime = optarg;
  			break;
 @@ -134,6 +137,10 @@ main(int argc, char **argv)
  	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
  		days += isleap(1900 + cnt) ? 366 : 365;
  	today = potm(days) + .5;
 +	if (pflag) {
 +		(void)printf("%1.0f\n", today);
 +		return (0);
 +	}
  	(void)printf("The Moon is ");
  	if ((int)today == 100)
  		(void)printf("Full\n");
 @@ -227,6 +234,7 @@ static void
  usage(char *progname)
  {
  
 -	fprintf(stderr, "Usage: %s [-d yyyy.mm.dd] [-t hh:mm:ss]\n", progname);
 +	fprintf(stderr, "Usage: %s [-p] [-d yyyy.mm.dd] [-t hh:mm:ss]\n",
 +	    progname);
  	exit(EX_USAGE);
  }
 _______________________________________________
 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: patched->closed 
State-Changed-By: emaste 
State-Changed-When: Thu Jul 22 01:26:04 UTC 2010 
State-Changed-Why:  
Merged to 8 now as r210364. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/51070: commit references a PR
Date: Thu, 22 Jul 2010 01:23:54 +0000 (UTC)

 Author: emaste
 Date: Thu Jul 22 01:23:39 2010
 New Revision: 210364
 URL: http://svn.freebsd.org/changeset/base/210364
 
 Log:
   MFC r210089:
   
     Add -p option to have pom(6) print just the percentage, without extra
     text.
   
   PR:           bin/51070
   Submitted by: Matt Koivisto mkoivisto sandvine com
 
 Modified:
   stable/8/games/pom/pom.6
   stable/8/games/pom/pom.c
 Directory Properties:
   stable/8/games/pom/   (props changed)
 
 Modified: stable/8/games/pom/pom.6
 ==============================================================================
 --- stable/8/games/pom/pom.6	Thu Jul 22 01:14:33 2010	(r210363)
 +++ stable/8/games/pom/pom.6	Thu Jul 22 01:23:39 2010	(r210364)
 @@ -32,7 +32,7 @@
  .\"	@(#)pom.6	8.1 (Berkeley) 5/31/93
  .\" $FreeBSD$
  .\"
 -.Dd May 31, 1993
 +.Dd July 14, 2010
  .Dt POM 6
  .UC 7
  .Sh NAME
 @@ -40,6 +40,7 @@
  .Nd display the phase of the moon
  .Sh SYNOPSIS
  .Nm 
 +.Op Fl p
  .Op Fl d Ar yyyy.mm.dd
  .Op Fl t Ar hh:mm:ss
  .Sh DESCRIPTION
 @@ -49,6 +50,10 @@ utility displays the current phase of th
  Useful for selecting software completion target dates and predicting
  managerial behavior.
  .Pp
 +Use the
 +.Fl p
 +option to print just the phase as a percentage.
 +.Pp
  Use the arguments
  .Fl d
  and
 
 Modified: stable/8/games/pom/pom.c
 ==============================================================================
 --- stable/8/games/pom/pom.c	Thu Jul 22 01:14:33 2010	(r210363)
 +++ stable/8/games/pom/pom.c	Thu Jul 22 01:23:39 2010	(r210364)
 @@ -88,14 +88,17 @@ main(int argc, char **argv)
  	time_t tt;
  	struct tm GMT, tmd;
  	double days, today, tomorrow;
 -	int ch, cnt;
 +	int ch, cnt, pflag = 0;
  	char *odate = NULL, *otime = NULL;
  
 -	while ((ch = getopt(argc, argv, "d:t:")) != -1)
 +	while ((ch = getopt(argc, argv, "d:pt:")) != -1)
  		switch (ch) {
  		case 'd':
  			odate = optarg;
  			break;
 +		case 'p':
 +			pflag = 1;
 +			break;
  		case 't':
  			otime = optarg;
  			break;
 @@ -138,6 +141,10 @@ main(int argc, char **argv)
  	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
  		days += isleap(1900 + cnt) ? 366 : 365;
  	today = potm(days) + .5;
 +	if (pflag) {
 +		(void)printf("%1.0f\n", today);
 +		return (0);
 +	}
  	(void)printf("The Moon is ");
  	if ((int)today == 100)
  		(void)printf("Full\n");
 @@ -231,6 +238,7 @@ static void
  usage(char *progname)
  {
  
 -	fprintf(stderr, "Usage: %s [-d yyyy.mm.dd] [-t hh:mm:ss]\n", progname);
 +	fprintf(stderr, "Usage: %s [-p] [-d yyyy.mm.dd] [-t hh:mm:ss]\n",
 +	    progname);
  	exit(EX_USAGE);
  }
 _______________________________________________
 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"
 
>Unformatted:
