Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 2010 01:23:39 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r210364 - stable/8/games/pom
Message-ID:  <201007220123.o6M1NdVu095555@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007220123.o6M1NdVu095555>