Official patch #1 for calctool v2.1 - please apply it.

Rich Burridge richb at sunaus.oz
Sat Mar 5 14:21:36 AEST 1988


This is the first official patch to Calctool v2.1. Please apply it.

It fixes the following problems.

  * adjustment of text in the online help file for clarity.
  * the Makefile and calctool.h were modified for easier installation.
    (thanks to Ian Donaldson for the code for this).
  * the keyboard function keys are now handled better.
  * trigonometric functions were producing incorrect results.

Feed the following to Larry Wall's patch program. If you don't have
that I suggest you get a copy (not from me please, I'm too far away :-),
or apply these changes by hand.

Note that I initially forgot to include the calctool manual page with
the original distribution. I sent it to comp.sources.misc about ten
days ago, but I haven't seen it returned on the net yet, so I'm including
it again here. Patch may barf if you already have a copy of this.

The following suggestions have also been given to me; they will be
included in a future release. My next intention is to produce a NeWS
version of the calculator, unless any more bugs are found.

  * calculator display window should have a scroll bar attached.
  * right mouse button should bring up the default frame window.
  * calculator should use the users erase and line erase characters.
  * commas should optionally be used as separators in the display in
    decimal mode.
  * ability to resize the window, the the calculator adjusts the button
    sizes accordingly.
  * A variable setting for the number of numeric places, depending upon
    the result.

Thanks everybody for the feedback on bugs and suggestions. It's really
appreciated. Look for the NeWS version in two or three months, real work
permitting.

    Rich.

------CUT HERE------CUT HERE------CUT HERE------

*** original/Makefile	Sun Feb 28 11:53:17 1988
--- Makefile	Sat Mar  5 12:51:21 1988
***************
*** 16,25 ****
  
  BINARIES        = calctool
  BINDIR          = .
! CFLAGS          = -O
  HEADERS         = calctool.h color.h
  OBJS            = calctool.o functions.o sunview.o
! OTHERS          = Makefile README calctool.help patchlevel.h
  SRCS            = calctool.c functions.c sunview.c
  IMAGES          = button.icon calctool.icon help.cursor
  LIBS            = -lm -lsuntool -lsunwindow -lpixrect
--- 16,26 ----
  
  BINARIES        = calctool
  BINDIR          = .
! LIBDIR          = .
! CFLAGS          = -g -DHELPGIVEN -DHELPNAME=\"$(LIBDIR)/calctool.help\"
  HEADERS         = calctool.h color.h
  OBJS            = calctool.o functions.o sunview.o
! OTHERS          = Makefile README calctool.help calctool.1 patchlevel.h
  SRCS            = calctool.c functions.c sunview.c
  IMAGES          = button.icon calctool.icon help.cursor
  LIBS            = -lm -lsuntool -lsunwindow -lpixrect
***************
*** 27,34 ****
  all:            $(BINARIES)
  
  install:        $(BINARIES)
! 		strip $(BINARIES)
! 		-mv $(BINARIES) $(BINDIR)
  
  clean:
  		rm -f *.o core
--- 28,35 ----
  all:            $(BINARIES)
  
  install:        $(BINARIES)
! 		install -s -m 751 calctool $(BINDIR)
! 		install -c -m 644 calctool.help $(LIBDIR)
  
  clean:
  		rm -f *.o core
***************
*** 37,44 ****
  		lint $(SRCS) $(LIBS)
  
  shar:
! 		shar.sh $(SRCS) > archive.1
! 		shar.sh $(HEADERS) $(IMAGES) $(OTHERS) > archive.2
  
  calctool:       $(OBJS)
  		cc -o calctool $(OBJS) $(LIBS)
--- 38,45 ----
  		lint $(SRCS) $(LIBS)
  
  shar:
! 		shar.script $(SRCS) > archive.1
! 		shar.script $(HEADERS) $(IMAGES) $(OTHERS) > archive.2
  
  calctool:       $(OBJS)
  		cc -o calctool $(OBJS) $(LIBS)
*** original/calctool.1	Sat Mar  5 14:55:11 1988
--- calctool.1	Thu Feb 25 10:49:37 1988
***************
*** 0 ****
--- 1,245 ----
+ .\" @(#)calctool.1 2.1 27/01/88 SMI;
+ .TH CALCTOOL 1 "19 February 1988"
+ .SH NAME
+ calctool \- window based calculator.
+ .SH SYNOPSIS
+ .B "calctool
+ [
+ .B -h
+ .I helpfile
+ ]
+ [
+ .B -v
+ ]
+ [
+ .B -?
+ ]
+ .SH DESCRIPTION
+ .I calctool
+ is a window based calculator. It gets its input via the mouse
+ or the keyboard. Each calculator button has two functions associated with it.
+ .LP
+ Arithmetic is done with double precision floating point numbers internally.
+ Numbers are displayed initially to two numeric places in the decimal base.
+ Accuracy can be adjusted from zero to nine numeric places, and the base of
+ operation can be binary,octal,decimal or hexidecimal.
+ .LP
+ The display can be adjusted using the
+ .I SunView
+ .I Put
+ and
+ .I Get
+ function keys. Similarly the previous digit entered can be removed or the
+ whole display cleared.
+ .LP
+ There are ten memory registers and numbers can be retrieved or stored in
+ these locations.
+ .LP
+ As well as the current numerical value, the display window contains the
+ current base and the current trigonometrical units. If an operation needing
+ more than one numerical input is only partly completed, then that operation
+ is symbolically displayed in this window as a reminder.
+ .LP
+ The calculator has arithmetic, logical and trigonometrical functions.
+ These are grouped together and color coded on color workstations.
+ .LP
+ Online help is also provided via a help button. When this is selected, it
+ should be followed by the selection you wish help on.
+ .SH OPTIONS
+ .TP
+ .BI -h " helpfile"
+ Use an alternate helpfile to
+ .I calctool.help
+ in the current directory.
+ .TP
+ .B -v
+ Print the version number of this release of the
+ .I calctool
+ program.
+ .TP
+ .B -?
+ Print the usage line for this program. Note that the
+ .I ?
+ character should be escaped if running from a
+ .I csh
+ .SH CALCULATOR BUTTONS
+ All of the calculators buttons are described below with their keyboard
+ equivalents given in brackets.
+ .SS Numerical Keys.
+ .LP
+ As well as the digits 0-9 which have the same keyboard equivalents, there
+ are the hexidecimal digits A-F whose keyboard equivalents are the lower-case
+ letters a-f.
+ .SS Arithmetical Operations.
+ .LP
+ Addition, subtraction, multiplication and division are denoted by the keys
+ +, \-, x and / respectively. The . is the numeric point and the = key is used
+ for completion of the number entry. The keyboard equivalents are identical.
+ Return can be also used from the keyboard as well for numeric entry, and *
+ and X are synonymous with x for multiplication.
+ .SS Base Changes.
+ .LP
+ .IP "\fBBIN  ( B )\fP" 18
+ Change base to binary. The display value is shown in binary. A maximum of
+ 32 digits are allowed.
+ .IP "\fBOCT  ( O )\fP" 18
+ Change base to octal. The display value is shown in octal. A maximum of 15
+ digits are allowed.
+ .IP "\fBDEC  ( D )\fP" 18
+ Change base to decimal. The display value is shown in decimal. This is the
+ default base. A maximum of 12 digits are allowed.
+ .IP "\fBHEX  ( H )\fP" 18
+ Change base to hexidecimal. The display value is shown in hexidecimal.
+ A maximum of 12 digits are allowed.
+ .SS Trigonometric Unit Changes.
+ .LP
+ .IP "\fBDEG  ( ^d )\fP" 18
+ Change current trigonometrical base to degrees.
+ .IP "\fBRAD  ( ^r )\fP" 18
+ Change the current trigonometrical base to radians.
+ .IP "\fBGRAD ( ^g )\fP" 18
+ Change the current trigonometrical base to gradients.
+ .SS Logical Operations.
+ .LP
+ .IP "\fBAND  ( & )\fP" 18
+ This operation takes the last number and the next number
+ entered, and performs a logical AND operation on them, treating
+ both numbers as unsigned long integers.
+ .IP "\fBNOT  ( ~ )\fP" 18
+ This operation will perform the logical NOT operation of the
+ current value of the calculators display.
+ .IP "\fBOR   ( | )\fP" 18
+ This operation takes the last number and the next number
+ entered, and performs a logical OR operation on them, treating both numbers
+ as unsigned long integers.
+ .IP "\fBXNOR ( n or N )\fP" 18
+ This operation takes the last number and the next number
+ entered, and performs a logical XNOR operation on them, treating
+ both numbers as unsigned long integers.
+ .IP "\fBXOR  ( ^ )\fP" 18
+ This operation takes the last number and the next number
+ entered, and performs a logical XOR operation on them, treating
+ both numbers as unsigned long integers.
+ .SS Trigonometrical Operators.
+ .LP
+ .IP "\fBASIN ( } )\fP" 18
+ Return the trigonometric Arc Sin of the current value, in the
+ current units, degrees, radians or gradients.
+ .IP "\fBSIN  ( { )\fP" 18
+ Return the trigonometric Sin of the current value, in the current
+ units, degrees, radians or gradients.
+ .IP "\fBACOS ( ) )\fP" 18
+ Return the trigonometric Arc Cos of the current value, in the
+ current units, degrees, radians or gradients.
+ .IP "\fBCOS  ( ( )\fP" 18
+ Return the trigonometric Cos of the current value, in the current
+ units, degrees, radians or gradients.
+ .IP "\fBATAN ( T )\fP" 18
+ Return the trigonometric Arc Tan of the current value, in the
+ current units, degrees, radians or gradients.
+ .IP "\fBTAN  ( t )\fP" 18
+ Return the trigonometric Tan of the current value, in the current
+ units, degrees, radians or gradients.
+ .SS Memory Register Operators.
+ .LP
+ .IP "\fBRCL  ( r )\fP" 18
+ Retrieve memory register n.  This must be followed by a digit
+ in the range 0 to 9 to indicate which memory register to retrieve
+ the value from.
+ .IP "\fBSTO  ( s )\fP" 18
+ Store memory register n.  This must be followed by an arithmetic
+ operation (addition, subtraction, multiplication or division),
+ then a digit in the range 0 to 9 to indicate which memory register
+ to store the current display value in. The arithmetic operator is
+ optional in which case the current display is stored in the memory
+ register.
+ .SS Constants.
+ .LP
+ .IP "\fBPI   ( P )\fP" 18
+ Enter the value of pi into the calculator.
+ .IP "\fBe    ( E )\fP" 18
+ Enter the value of e into the calculator.
+ .SS Mathematical Operators.
+ .LP
+ .IP "\fB%    ( % )\fP" 18
+ This calculation takes the last number enter and the next number
+ given, and performs a percentage calculation on them.
+ .IP "\fBe^x  ( # )\fP" 18
+ Return e raised to the power of the current display value.
+ .IP "\fB10^x ( $ )\fP" 18
+ Return 10 raised to the power of the current display value.
+ .IP "\fBy^x  ( Y )\fP" 18
+ The operation takes the last number and raises it to the power
+ of the next number given.
+ .IP "\fBln   ( N )\fP" 18
+ This operation returns the natural logarithm of the current
+ displayed value.
+ .IP "\fBlog  ( G )\fP" 18
+ This operation returns the base 10 logarithm of the current
+ displayed value.
+ .IP "\fBSQRT ( S )\fP" 18
+ This operation will perform a square root operation on the
+ current value of the calculator display.
+ .IP "\fB1/x  ( R )\fP" 18
+ Reciprocal. The will return the current the
+ value of 1 divided by the current display value.
+ .IP "\fBx!   ( ! )\fP" 18
+ This will return the factorial of the current displayed value.
+ .IP "\fBx^2  ( @ )\fP" 18
+ This will reurn the square of the current displayed value.
+ .SS Number Manipulation Operators.
+ .LP
+ .IP "\fB<    ( < )\fP" 18
+ Left shift n places. This must be followed by a digit
+ in the range 0 to 9 to indicate how many places to shift.
+ .IP "\fB>    ( > )\fP" 18
+ Right shift n places. This must be followed by a digit
+ in the range 0 to 9 to indicate how many places to shift.
+ .IP "\fB&32  ( i )\fP" 18
+ Get 32 bit unsigned integer. This is a logical function, that
+ will truncate the given number to return a 32 bit unsigned integer.
+ .IP "\fB&16  ( h )\fP" 18
+ Get 16 bit unsigned intger. This is a logical function, that
+ will truncate the given number to return a 16 bit unsigned integer.
+ .IP "\fBclr  ( Delete )\fP" 18
+ This will clear the value of the calculators display.
+ .IP "\fBbsp  ( BackSpace )\fP" 18
+ The right most character of the current calculator display value
+ is removed, and the value of the display is recalculated. Note,
+ internal accuracy is lost with this operation.
+ .IP "\fBINT  ( I )\fP" 18
+ Return the integer portion of the current displayed value.
+ .IP "\fBFRAC ( F )\fP" 18
+ Return the fractional portion of the current displayed value.
+ .IP "\fBACC  ( A )\fP" 18
+ Accuracy n numeric places. This must be followed by a digit
+ in the range 0 to 9 to indicate how many digits of precision are
+ to be displayed.
+ .IP "\fBCHS  ( C )\fP" 18
+ Change the arithmetic sign of the current displayed value.
+ .IP "\fBABS  ( U )\fP" 18
+ Return the absolute value of the current displayed value.
+ .SS Other keys.
+ .LP
+ .IP "\fBMEM  ( M )\fP" 18
+ Toggle the display of the popup register window, with the
+ values of the ten memory registers given in the current
+ base, to the current accuracy.
+ .IP "\fBKEYS ( K )\fP" 18
+ Toggle the labels on the calctool buttons between the mouse and
+ keyboard equivalents.
+ .IP "\fB?    ( ? )\fP" 18
+ Get help on a particular button. Selection of this key should be
+ followed with the selection of the key you wish help on.
+ .IP "\fBQUIT (q or Q)\fP" 18
+ The calctool program is exited, without user verification.
+ .IP "\fBOFF  ( o )\fP" 18
+ Turn calctool iconic.
+ .SH FILES
+ .ta 1i
+ ~/\&calctool.help
+ .SH BUGS
+ Parsing of the online help file is very primative.
+ .LP
+ Handling of errors generated by the mathematical routines is poorly
+ done.
*** original/calctool.h	Sun Feb 28 11:53:14 1988
--- calctool.h	Sat Mar  5 11:38:39 1988
***************
*** 72,78 ****
--- 72,82 ----
  
  #define  EQUAL          !strcmp          /* For character comparisons. */
  #define  EXTRA          4                /* Extra useful character definitions. */
+ 
+ #ifndef HELPGIVEN
  #define  HELPNAME       "calctool.help"
+ #endif
+ 
  #define  MAX_DIGITS     32               /* Maximum displayable number of digits. */
  #define  MAXLINE        80               /* Length of character strings. */
  #define  MAXREGS        10               /* Maximum number of memory registers. */
*** original/calctool.help	Sun Feb 28 11:53:19 1988
--- calctool.help	Sat Mar  5 12:57:04 1988
***************
*** 67,84 ****
  _?   _
  Calctool Help v2.1.         ( ? ).
  
! All calculations performed as
! doubles. The display can be used
! with the [Get] and [Put] function
! keys with other Sunview windows.
! Equivalent keystrokes can be
! found by selecting the KEYS
! button.
  
  If an error condition occurs, you
  must clear the calculator.
  
! >From now on when you select [?]
  you will get help on the next
  selection you make.
  _&32 _
--- 67,85 ----
  _?   _
  Calctool Help v2.1.         ( ? ).
  
! All calculations are in double
! precision. The display can be
! used with the [Get] and [Put]
! function keys with other Sunview
! windows. For every mouse
! selection, there is an equivalent
! keystroke. These can be found by
! selecting the KEYS button.
  
  If an error condition occurs, you
  must clear the calculator.
  
! From now on when you select [?]
  you will get help on the next
  selection you make.
  _&32 _
*** original/functions.c	Sun Feb 28 11:53:06 1988
--- functions.c	Sat Mar  5 14:16:41 1988
***************
*** 75,80 ****
--- 75,81 ----
    tresults[RAD]  = disp_val ;
    cur_op = current ;
    show_display(tresults[ttype]) ;
+   disp_val = tresults[ttype] ;
  }
  
  
***************
*** 106,111 ****
--- 107,118 ----
    if (current != '=' && old_cal_value == '=') cur_op = '?' ;
    switch (cur_op)
      {
+       case ')'    :                                     /* cos-1. */
+       case '}'    :                                     /* sin-1. */
+       case 'T'    :                                     /* tan-1. */
+       case '('    :                                     /* cos. */
+       case '{'    :                                     /* sin. */
+       case 't'    :                                     /* tan. */
        case '?'    : result = disp_val ;                 /* Undefined. */
                      break ;
        case '+'    : result += disp_val ;                /* Addition. */
***************
*** 306,312 ****
                             }
                           else make_text(5,y,"Invalid help file given.") ;
                         }    
!                      make_text(5,y+25,"Hit any button or valid key.") ;
                       pending_op = '?' ;
                       return ;
                     }
--- 313,319 ----
                             }
                           else make_text(5,y,"Invalid help file given.") ;
                         }    
!                      make_text(5,y+25,"Hit the left button or valid key.") ;
                       pending_op = '?' ;
                       return ;
                     }
***************
*** 421,431 ****
                     break ;
          case '{' : tresults[i] = sin(tresults[i]) ;   /* sin. */
                     break ;
!         case 't' : temp = cos(tresults[i]) ;          /* tan. */
!                    tresults[i] = sin(tresults[i]) / temp ;
        }
    cur_op = current ;
    show_display(tresults[ttype]) ;
  }
  
  
--- 428,441 ----
                     break ;
          case '{' : tresults[i] = sin(tresults[i]) ;   /* sin. */
                     break ;
! /*        case 't' : temp = cos(tresults[i]) ;   */       /* tan. */
! /*                   tresults[i] = sin(tresults[i]) / temp ; */
! 
!         case 't' : tresults[i] = tan(tresults[i]) ;          /* tan. */
        }
    cur_op = current ;
    show_display(tresults[ttype]) ;
+   disp_val = tresults[ttype] ;
  }
  
  
*** original/patchlevel.h	Sun Feb 28 11:53:20 1988
--- patchlevel.h	Sat Mar  5 11:36:48 1988
***************
*** 18,21 ****
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  0
--- 18,21 ----
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  1
*** original/sunview.c	Sun Feb 28 11:53:07 1988
--- sunview.c	Sat Mar  5 14:57:50 1988
***************
*** 155,162 ****
        down = 0 ;
        return ;
      }
!   else return ;
!      
    process_item(n) ;
  }        
           
--- 155,162 ----
        down = 0 ;
        return ;
      }
!   else window_default_event_proc(win,event,arg) ;
!  
    process_item(n) ;
  }        
           
***************
*** 426,432 ****
                           WIN_EVENT_PROC,canvas_proc,
                           0) ;
    WINDOW_SET(canvas,WIN_CONSUME_KBD_EVENT,WIN_ASCII_EVENTS,0) ;
!   WINDOW_SET(canvas,WIN_IGNORE_KBD_EVENTS,WIN_LEFT_KEYS,WIN_TOP_KEYS,WIN_RIGHT_KEYS,0) ;
  }
  
  
--- 426,433 ----
                           WIN_EVENT_PROC,canvas_proc,
                           0) ;
    WINDOW_SET(canvas,WIN_CONSUME_KBD_EVENT,WIN_ASCII_EVENTS,0) ;
!   WINDOW_SET(canvas,WIN_CONSUME_KBD_EVENTS,WIN_LEFT_KEYS,WIN_TOP_KEYS,WIN_RIGHT_KEYS,0) ;
!   WINDOW_SET(canvas,WIN_IGNORE_PICK_EVENT,LOC_MOVE,0) ;
  }
  
  



More information about the Comp.sources.bugs mailing list