bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Smal bugfixes for GNU bc 1.06


From: Juan Manuel Guerrero
Subject: Smal bugfixes for GNU bc 1.06
Date: Tue, 30 Jan 2001 18:52:24 +0200

I send this suggestions to this mailing list in the hope that the
bc/dc maintainers will find this here because I am not able to locate
<address@hidden> at all.
I would like to present the following three suggestions/bugfixes:

1) It is not possible to compile the sbc binary.
   The reason for this is that the configure script does not
   define the macro BC_VERSION making the compilation of sbc.y
   fail. This can easily be solved by modifying configure.in.
   See patch.
2) GCC always complains when compiling lib/getopt.c about that the
   variable "indfound" may be used uninitialized. This can be easily
   resolved by seting the variable to a sane default. This is probably
   the wrong place to report this, but I do it anyway.
   See patch.
3) Unfortunately in bc.texi, the makeinfo command @var is used
   to highlight certain kind of bc variables like ibase, obase, scale, x
   and math. functions like j(n,x) and s(x), etc. This is very confusing,
   especially for a newbee, because the @var command highlights its argument
   by translating it to uppercase. This is:
   a) syntacticaly wrong. The manual clearly states that all commands
      and variables of the bc language must be written lowercase.
   b) it is a contradiction to the information given by the bc man page
      that clearly shows that variables and math. functions are written
      in lowercase.
   I have reviewed the entire bc.texi file and replaced every use of
   @var{some math. function} with  @math{some math. function}, every use
   of @var{x} or @var{ibase} or whatever variable has been used by @code{x},
   @code{ibase}, etc. Real metasyntactic variables like: "<expression>", etc.
   have been left unchanged. This means that these expressions are still
   highlighted using @var command as it should be. I have also added an
   dircategory and direntry entry similar to the one used in the dc.texi file.
   It should also be noticed that if an user tries to recreate the info
   file as it is using texinfo 4.0 the following warnings will be issued:

Making all in doc
make.exe[2]: Entering directory `j:/bc-1.06/doc'
cd . \
  && makeinfo --no-split `echo bc.texi | sed 's,.*/,,'`
bc.texi:515: warning: unlikely character ( in @var.
bc.texi:515: warning: unlikely character ) in @var.
bc.texi:515: warning: unlikely character [ in @var.
bc.texi:515: warning: unlikely character ] in @var.
bc.texi:522: warning: unlikely character ( in @var.
bc.texi:522: warning: unlikely character ) in @var.
bc.texi:528: warning: unlikely character ( in @var.
bc.texi:528: warning: unlikely character [ in @var.
bc.texi:528: warning: unlikely character ] in @var.
bc.texi:528: warning: unlikely character [ in @var.
bc.texi:528: warning: unlikely character ] in @var.
bc.texi:528: warning: unlikely character [ in @var.
bc.texi:528: warning: unlikely character ] in @var.
bc.texi:528: warning: unlikely character ) in @var.
bc.texi:567: warning: unlikely character ( in @var.
bc.texi:567: warning: unlikely character ) in @var.
bc.texi:700: warning: unlikely character , in @var.
bc.texi:862: warning: unlikely character , in @var.
bc.texi:869: warning: unlikely character , in @var.
bc.texi:869: warning: unlikely character , in @var.
bc.texi:892: warning: unlikely character , in @var.
bc.texi:892: warning: unlikely character , in @var.
bc.texi:892: warning: unlikely character , in @var.
bc.texi:892: warning: unlikely character , in @var.
bc.texi:892: warning: unlikely character , in @var.
cd . \
  && makeinfo --no-split `echo dc.texi | sed 's,.*/,,'`
make.exe[2]: Leaving directory `j:/bc-1.06/doc'

   The reason for this is the use of @var in some places of
   the texi file, especially in those places where tables
   are defined. Of course all this has been fixed in the
   patch.


Although this patch is part of a porting job of GNU bc 1.06 to
MSDOS/DJGPP, the patch is not OS specific at all and I hope it
will be of general interest.
Suggestions, objections, comments, etc are welcome.

Regards,
Guerrero, Juan Manuel


Tue Jan 30 17:00:00 2001  Juan Manuel Guerrero  <address@hidden>
        * configure.in: Added macro: BC_VERSION.
        * lib/getopt.c (_getopt_internal): The variable indfound has been set 
to a
                                           default value. This pacifies gcc 
2.95.2.
        * doc/bc.texi: Added a @direntry and @dircategory command for bc.
                       Math. functions will be highlighted using the @math 
command
                       instead of the @var command.
                       Variables will be highlighted using the @code command
                       instead of the @var command.
        * doc/dc.texi: Added a @dircategory command for dc.

diff -acprNC5 bc-1.06.original/configure.in bc-1.06/configure.in
*** bc-1.06.original/configure.in       Fri Jul  7 23:34:08 2000
--- bc-1.06/configure.in        Tue Jan 30 17:58:00 2001
***************
*** 1,10 ****
--- 1,11 ----
  dnl Process this file with autoconf to produce a configure script.
  AC_INIT(doc/bc.1)
  AM_INIT_AUTOMAKE("bc", "1.06")
  AM_CONFIG_HEADER(config.h)
  
+ AC_DEFINE(BC_VERSION,"1.06")
  AC_DEFINE(DC_VERSION,"1.3")
  AC_DEFINE_UNQUOTED(BC_COPYRIGHT, dnl
   ["Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc."])
  AC_DEFINE_UNQUOTED(DC_COPYRIGHT, dnl
   ["Copyright 1994, 1997, 1998, 2000 Free Software Foundation, Inc."])
diff -acprNC5 bc-1.06.original/doc/bc.texi bc-1.06/doc/bc.texi
*** bc-1.06.original/doc/bc.texi        Thu Sep 28 00:22:24 2000
--- bc-1.06/doc/bc.texi Tue Jan 30 17:55:32 2001
*************** Computer Science Department, address@hidden
*** 56,65 ****
--- 56,72 ----
  Western Washington address@hidden
  Bellingham, WA 98226-9062
  
  @end titlepage
  
+ @ifinfo
+ @dircategory Utilities
+ @direntry
+ * bc: (bc).                   An arbitrary precision calculator language.
+ @end direntry
+ @end ifinfo
+ 
  @node Top, Introduction, (dir), (dir)
  
  @menu
  * Introduction::
  * Basic Elements::
*************** Bellingham, WA 98226-9062
*** 81,91 ****
  @end menu
  
  @node Description, Command Line Options, Introduction, Introduction
  @section Description
  
! @command{bc} [ -hlwsqv ] [long-options] [ @var{ file ...} ]
  
  @command{bc} is a language that supports arbitrary precision numbers
  with interactive execution of statements.  There are some similarities
  in the syntax to the C programming language. 
  A standard math library is available by command line option.
--- 88,98 ----
  @end menu
  
  @node Description, Command Line Options, Introduction, Introduction
  @section Description
  
! bc [ -hlwsqv ] [long-options] [ @var{file ...} ]
  
  @command{bc} is a language that supports arbitrary precision numbers
  with interactive execution of statements.  There are some similarities
  in the syntax to the C programming language. 
  A standard math library is available by command line option.
*************** begin with a letter followed by any numb
*** 168,183 ****
  underscores.  All letters must be lower case.  (Full alphanumeric
  names are an extension. In POSIX @command{bc} all names are a single
  lower case letter.)  The type of variable is clear by the context
  because all array variable names will be followed by brackets ( [ ] ).
  
! There are four special variables, @var{scale}, @var{ibase}, @var{obase}, and
! @var{last}.  @var{scale} defines how some operations use digits after the
! decimal point.  The default value of @var{scale} is 0. @var{ibase}
! and @var{obase} define the conversion base for input and output
  numbers.  The default for both input and output is base 10.
! @var{last} (an extension) is a variable that has the value of the last
  printed number.  These will be discussed in further detail where
  appropriate.  All of these variables may have values assigned to them
  as well as used in expressions.
  
  @node Comments, , Variables, Basic Elements
--- 175,190 ----
  underscores.  All letters must be lower case.  (Full alphanumeric
  names are an extension. In POSIX @command{bc} all names are a single
  lower case letter.)  The type of variable is clear by the context
  because all array variable names will be followed by brackets ( [ ] ).
  
! There are four special variables, @code{scale}, @code{ibase}, @code{obase}, 
and
! @code{last}.  @code{scale} defines how some operations use digits after the
! decimal point.  The default value of @code{scale} is 0. @code{ibase}
! and @code{obase} define the conversion base for input and output
  numbers.  The default for both input and output is base 10.
! @code{last} (an extension) is a variable that has the value of the last
  printed number.  These will be discussed in further detail where
  appropriate.  All of these variables may have values assigned to them
  as well as used in expressions.
  
  @node Comments, , Variables, Basic Elements
*************** are executed as soon as possible.  There
*** 216,242 ****
  code is executed as it is encountered.  (Functions, discussed in
  detail later, are defined when encountered.)
  
  A simple expression is just a constant. @command{bc} converts constants
  into internal decimal numbers using the current input base, specified by
! the variable @var{ibase}. (There is an exception in functions.)  The
! legal values of @var{ibase} are 2 through 16.  Assigning a value outside
! this range to @var{ibase} will result in a value of 2 or 16.  Input
  numbers may contain the characters 0-9 and A-F. (Note: They must be
  capitals.  Lower case letters are variable names.)  Single digit numbers
  always have the value of the digit regardless of the value of
! @var{ibase}. (i.e. A = 10.)  For multi-digit numbers, @command{bc}
! changes all input digits greater or equal to @var{ibase} to the value of
! @var{ibase}-1.  This makes the number @code{FFF} always be the largest
  3 digit number of the input base.
  
  Full expressions are similar to many other high level languages.
  Since there is only one kind of number, there are no rules for mixing
  types.  Instead, there are rules on the scale of expressions.  Every
  expression has a scale.  This is derived from the scale of original
  numbers, the operation performed and in many cases, the value of the
! variable @var{scale}. Legal values of the variable @var{scale} are
  0 to the maximum number representable by a C integer.
  
  @node Basic Expressions, Relational Expressions, About Expressions and 
Special Variables, Expressions
  @section Basic Expressions
  
--- 223,249 ----
  code is executed as it is encountered.  (Functions, discussed in
  detail later, are defined when encountered.)
  
  A simple expression is just a constant. @command{bc} converts constants
  into internal decimal numbers using the current input base, specified by
! the variable @code{ibase}. (There is an exception in functions.)  The
! legal values of @code{ibase} are 2 through 16.  Assigning a value outside
! this range to @code{ibase} will result in a value of 2 or 16.  Input
  numbers may contain the characters 0-9 and A-F. (Note: They must be
  capitals.  Lower case letters are variable names.)  Single digit numbers
  always have the value of the digit regardless of the value of
! @code{ibase}. (i.e. A = 10.)  For multi-digit numbers, @command{bc}
! changes all input digits greater or equal to @code{ibase} to the value of
! @code{ibase}-1.  This makes the number @code{FFF} always be the largest
  3 digit number of the input base.
  
  Full expressions are similar to many other high level languages.
  Since there is only one kind of number, there are no rules for mixing
  types.  Instead, there are rules on the scale of expressions.  Every
  expression has a scale.  This is derived from the scale of original
  numbers, the operation performed and in many cases, the value of the
! variable @code{scale}. Legal values of the variable @code{scale} are
  0 to the maximum number representable by a C integer.
  
  @node Basic Expressions, Relational Expressions, About Expressions and 
Special Variables, Expressions
  @section Basic Expressions
  
*************** character.  The sequence "\<nl>", where 
*** 455,494 ****
  @command{bc} as whitespace instead of a newline.  A statement list is a
  series of statements separated by semicolons and newlines.  The
  following is a list of @command{bc} statements and what they do: (Things
  enclosed in brackets ( [ ] ) are optional parts of the statement.)
  
! @table @var
  @item expression
  This statement does one of two things.  If the expression starts with
  "<variable> <assignment> ...", it is considered to be an assignment
  statement.  If the expression is not an assignment statement, the
  expression is evaluated and printed to the output.  After the number is
  printed, a newline is printed.  For example, "a=1" is an assignment
  statement and "(a=1)" is an expression that has an embedded assignment.
  All numbers that are printed are printed in the base specified by the
! variable @var{obase}. The legal values for @var{obase} are 2 through
  BC_BASE_MAX (@pxref{Environment Variables}).  For bases 2 through 16,
  the usual method of writing numbers is used.  For bases greater than 16,
  @command{bc} uses a multi-character digit method of printing the numbers
  where each higher base digit is printed as a base 10 number.  The
  multi-character digits are separated by spaces.  Each digit contains the
  number of characters required to represent the base ten value of
! "@var{obase} -1".  Since numbers are of arbitrary precision, some
  numbers may not be printable on a single output line.  These long
  numbers will be split across lines using the "\" as the last character
  on a line.  The maximum number of characters printed per line is 70.
  Due to the interactive nature of @command{bc}, printing a number causes
  the side effect of assigning the printed value to the special variable
! @var{last}. This allows the user to recover the last value printed
  without having to retype the expression that printed the number.
! Assigning to @var{last} is legal and will overwrite the last printed
  value with the assigned value.  The newly assigned value will remain
  until the next number is printed or another value is assigned to
! @var{last}.  (Some installations may allow the use of a single period
  (.) which is not part of a number as a short hand notation for for
! @var{last}.)
  
  @item string
  The string is printed to the output.  Strings start with a double quote
  character and contain all characters until the next double quote character.
  All characters are taken literally, including any newline.  No newline
--- 462,501 ----
  @command{bc} as whitespace instead of a newline.  A statement list is a
  series of statements separated by semicolons and newlines.  The
  following is a list of @command{bc} statements and what they do: (Things
  enclosed in brackets ( [ ] ) are optional parts of the statement.)
  
! @table @code
  @item expression
  This statement does one of two things.  If the expression starts with
  "<variable> <assignment> ...", it is considered to be an assignment
  statement.  If the expression is not an assignment statement, the
  expression is evaluated and printed to the output.  After the number is
  printed, a newline is printed.  For example, "a=1" is an assignment
  statement and "(a=1)" is an expression that has an embedded assignment.
  All numbers that are printed are printed in the base specified by the
! variable @code{obase}. The legal values for @code{obase} are 2 through
  BC_BASE_MAX (@pxref{Environment Variables}).  For bases 2 through 16,
  the usual method of writing numbers is used.  For bases greater than 16,
  @command{bc} uses a multi-character digit method of printing the numbers
  where each higher base digit is printed as a base 10 number.  The
  multi-character digits are separated by spaces.  Each digit contains the
  number of characters required to represent the base ten value of
! "@code{obase} -1".  Since numbers are of arbitrary precision, some
  numbers may not be printable on a single output line.  These long
  numbers will be split across lines using the "\" as the last character
  on a line.  The maximum number of characters printed per line is 70.
  Due to the interactive nature of @command{bc}, printing a number causes
  the side effect of assigning the printed value to the special variable
! @code{last}. This allows the user to recover the last value printed
  without having to retype the expression that printed the number.
! Assigning to @code{last} is legal and will overwrite the last printed
  value with the assigned value.  The newly assigned value will remain
  until the next number is printed or another value is assigned to
! @code{last}.  (Some installations may allow the use of a single period
  (.) which is not part of a number as a short hand notation for for
! @code{last}.)
  
  @item string
  The string is printed to the output.  Strings start with a double quote
  character and contain all characters until the next double quote character.
  All characters are taken literally, including any newline.  No newline
*************** the value 0 to the calling expression.  
*** 649,664 ****
  "@code{return} ( @var{expression} )", computes the value of the expression
  and returns that value to the calling expression.  There is an implied
  "@code{return} (0)" at the end of every function.  This allows a function
  to terminate and return 0 without an explicit @code{return} statement.
  
! Functions also change the usage of the variable @var{ibase}.  All
  constants in the function body will be converted using the value of
! @var{ibase} at the time of the function call.  Changes of @var{ibase}
  will be ignored during the execution of the function except for the
  standard function @code{read}, which will always use the current value
! of @var{ibase} for conversion of numbers.
  
  As an extension, the format of the definition has been slightly relaxed.
  The standard requires the opening brace be on the same line as the 
  @code{define} keyword and all other parts must be on following lines.
  This version of @command{bc} will allow any number of newlines before and
--- 656,671 ----
  "@code{return} ( @var{expression} )", computes the value of the expression
  and returns that value to the calling expression.  There is an implied
  "@code{return} (0)" at the end of every function.  This allows a function
  to terminate and return 0 without an explicit @code{return} statement.
  
! Functions also change the usage of the variable @code{ibase}.  All
  constants in the function body will be converted using the value of
! @code{ibase} at the time of the function call.  Changes of @code{ibase}
  will be ignored during the execution of the function except for the
  standard function @code{read}, which will always use the current value
! of @code{ibase} for conversion of numbers.
  
  As an extension, the format of the definition has been slightly relaxed.
  The standard requires the opening brace be on the same line as the 
  @code{define} keyword and all other parts must be on following lines.
  This version of @command{bc} will allow any number of newlines before and
*************** definitions are legal.
*** 674,712 ****
  
  @node Math Library Functions, , Functions, Functions
  @section Math Library Functions
  
  If @command{bc} is invoked with the @code{-l} option, a math library is
! preloaded and the default @var{scale} is set to 20.  The math functions will
  calculate their results to the scale set at the time of their call.  The
  math library defines the following functions:
  
  @table @code
! @item s (@var{x})
! The sine of @var{x}, @var{x} is in radians.
  
! @item c (@var{x})
! The cosine of @var{x}, @var{x} is in radians.
  
! @item a (@var{x})
! The arctangent of @var{x}, arctangent returns radians.
  
! @item l (@var{x})
! The natural logarithm of @var{x}.
  
! @item @var{e} (@var{x})
! The exponential function of raising @var{e} to the value @var{x}.
  
! @item @var{j} (@var{n,x})
! The bessel function of integer order @var{n} of @var{x}.
  @end table
  
  @node Examples, Readline and Libedit Options, Functions, Top
  @chapter Examples
  
  In /bin/sh,  the following will assign the value of "pi" to the shell
! variable @var{pi}.
  @example
  
  pi=$(echo "scale=10; 4*a(1)" | bc -l)
  
  @end example
--- 681,719 ----
  
  @node Math Library Functions, , Functions, Functions
  @section Math Library Functions
  
  If @command{bc} is invoked with the @code{-l} option, a math library is
! preloaded and the default @code{scale} is set to 20.  The math functions will
  calculate their results to the scale set at the time of their call.  The
  math library defines the following functions:
  
  @table @code
! @item @math{s (x)}
! The sine of @code{x}, @code{x} is in radians.
  
! @item @math{c (x)}
! The cosine of @code{x}, @code{x} is in radians.
  
! @item @math{a (x)}
! The arctangent of @code{x}, arctangent returns radians.
  
! @item @math{l (x)}
! The natural logarithm of @code{x}.
  
! @item @math{e (x)}
! The exponential function of raising @code{e} to the value @code{x}.
  
! @item @math{j (n,x)}
! The bessel function of integer order @code{n} of @code{x}.
  @end table
  
  @node Examples, Readline and Libedit Options, Functions, Top
  @chapter Examples
  
  In /bin/sh,  the following will assign the value of "pi" to the shell
! variable @code{pi}.
  @example
  
  pi=$(echo "scale=10; 4*a(1)" | bc -l)
  
  @end example
*************** for debugging the parser and preparing t
*** 829,841 ****
  
  A major source of differences is extensions, where a feature is extended
  to add more functionality and additions, where new features are added.
  The following is the list of differences and extensions.
  
! @table @var
  
! @item LANG environment
  This version does not conform to the POSIX standard in the processing
  of the LANG environment variable and all environment variables starting
  with LC_.
  
  @item names
--- 836,848 ----
  
  A major source of differences is extensions, where a feature is extended
  to add more functionality and additions, where new features are added.
  The following is the list of differences and extensions.
  
! @table @code
  
! @item environment
  This version does not conform to the POSIX standard in the processing
  of the LANG environment variable and all environment variables starting
  with LC_.
  
  @item names
diff -acprNC5 bc-1.06.original/doc/dc.texi bc-1.06/doc/dc.texi
*** bc-1.06.original/doc/dc.texi        Thu Aug 31 15:57:42 2000
--- bc-1.06/doc/dc.texi Tue Jan 30 17:55:32 2001
***************
*** 19,28 ****
--- 19,29 ----
  @syncodeindex ky fn
  @syncodeindex pg fn
  @syncodeindex tp fn
  
  @ifinfo
+ @dircategory Utilities
  @direntry
  * dc: (dc).                   Arbritrary precision RPN ``Desktop Calculator''.
  @end direntry
  This file documents @sc{dc}, an arbitrary precision calculator.
  
diff -acprNC5 bc-1.06.original/lib/getopt.c bc-1.06/lib/getopt.c
*** bc-1.06.original/lib/getopt.c       Fri Jul  7 23:34:08 2000
--- bc-1.06/lib/getopt.c        Tue Jan 30 17:55:32 2001
*************** _getopt_internal (argc, argv, optstring,
*** 474,484 ****
        char *nameend;
        const struct option *p;
        const struct option *pfound = NULL;
        int exact = 0;
        int ambig = 0;
!       int indfound;
        int option_index;
  
        for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
        /* Do nothing.  */ ;
  
--- 474,484 ----
        char *nameend;
        const struct option *p;
        const struct option *pfound = NULL;
        int exact = 0;
        int ambig = 0;
!       int indfound = -1;  /* Pacify gcc 2.95.2. */
        int option_index;
  
        for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
        /* Do nothing.  */ ;
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]