From owner-p4-projects@FreeBSD.ORG Sun May 31 02:18:02 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A47701065673; Sun, 31 May 2009 02:18:01 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61FA61065674 for ; Sun, 31 May 2009 02:18:01 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4599C8FC18 for ; Sun, 31 May 2009 02:18:01 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4V2I1lr076071 for ; Sun, 31 May 2009 02:18:01 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4V2I1Ma076069 for perforce@freebsd.org; Sun, 31 May 2009 02:18:01 GMT (envelope-from gabor@freebsd.org) Date: Sun, 31 May 2009 02:18:01 GMT Message-Id: <200905310218.n4V2I1Ma076069@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 163138 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2009 02:18:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=163138 Change 163138 by gabor@gabor_server on 2009/05/31 02:17:48 - Add some GNU compatibility features - Document changes Affected files ... .. //depot/projects/soc2008/gabor_textproc/bc/bc.1#2 edit .. //depot/projects/soc2008/gabor_textproc/bc/bc.y#2 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/bc/bc.1#2 (text+ko) ==== @@ -34,7 +34,7 @@ .\" .\" @(#)bc.1 6.8 (Berkeley) 8/8/91 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: May 31 2009 $ .Dt BC 1 .Sh NAME .Nm bc @@ -54,6 +54,8 @@ Options available: .Bl -tag -width Ds .It Fl c +.It Fl d +.It Fl Fl debug .Nm is actually a preprocessor for .Xr dc 1 , @@ -67,17 +69,25 @@ instead of being interpreted by a running .Xr dc 1 process. -.It Fl e Ar expression +.It Fl e Ar exp +.It Fl Fl expression Ar exp Evaluate .Ar expression . If multiple .Fl e options are specified, they are processed in the order given, separated by newlines. +.It Fl h +.It Fl Fl help +Prints usage information. .It Fl l +.It Fl Fl mathlib Allow specification of an arbitrary precision math library. The definitions in the library are available to command line expressions. +.It Fl v +.It Fl Fl version +Prints version information. .El .Pp The syntax for ==== //depot/projects/soc2008/gabor_textproc/bc/bc.y#2 (text+ko) ==== @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include "extern.h" #include "pathnames.h" +#define BC_VER "1.0-FreeBSD" #define END_NODE ((ssize_t) -1) #define CONST_STRING ((ssize_t) -2) #define ALLOC_STRING ((ssize_t) -3) @@ -121,6 +123,18 @@ #define VAR_BASE (256-4) #define MAX_VARIABLES (VAR_BASE * VAR_BASE) +const struct option long_options[] = +{ + {"debug", no_argument, NULL, 'd'}, + {"expression", required_argument, NULL, 'e'}, + {"help", no_argument, NULL, 'h'}, + {"mathlib", no_argument, NULL, 'l'}, + /* compatibility option */ + {"quiet", no_argument, NULL, 'q'}, + {"version", no_argument, NULL, 'v'}, + {NULL, no_argument, NULL, 0} +}; + %} %start program @@ -996,7 +1010,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s [-cl] [-e expression] [file ...]\n", + fprintf(stderr, "usage: %s [-cdhlqv] [-e expression] [file ...]\n", __progname); exit(1); } @@ -1094,7 +1108,8 @@ if ((cmdexpr = strdup("")) == NULL) err(1, NULL); /* The d debug option is 4.4 BSD bc(1) compatible */ - while ((ch = getopt(argc, argv, "cde:l")) != -1) { + while ((ch = getopt_long(argc, argv, "cde:hlqv", + long_options, NULL)) != -1) { switch (ch) { case 'c': case 'd': @@ -1106,9 +1121,19 @@ err(1, NULL); free(q); break; + case 'h': + usage(); + break; case 'l': sargv[sargc++] = _PATH_LIBB; break; + case 'q': + /* compatibility option */ + break; + case 'v': + fprintf(stderr, "%s (BSD bc) %s\n", __progname, BC_VER); + exit(0); + break; default: usage(); }