diff --git a/BUGS b/BUGS index fc52714..f0fdd98 100644 --- a/BUGS +++ b/BUGS @@ -75,7 +75,7 @@ not currently a member of the calc-tester mailing list. Known bugs: - * Calc does not support the #! exec method. For example of the + * Calc does not support the #! exec method. For example of the following is placed in an executable file (assume the path to calc is correct) called /tmp/xyzzy: @@ -127,7 +127,7 @@ Other items of note: fails because it puts a space inside the concatenated hex. Calc has code that is affected by this bug. This bug has been reported - to Compaq and may be fixed in the future. A work-a-round is to + to Compaq and may be fixed in the future. A work-a-round is to compile with cc -std0 or to use a later version of their compiler. * On a Digital UNIX V4.0F (Rev. 1229) on a 500 Mhz 21264, make check @@ -148,7 +148,7 @@ Other items of note: it finally hangs at test 2000. The work-a-round is to compile calc without the optimizer. If this - happens to you, try compiling without -O and without -O2. I.e., in + happens to you, try compiling without -O and without -O2. I.e., in the Makefile, set: DEBUG= -g diff --git a/CHANGES b/CHANGES index ee1045f..c438108 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,10 @@ -Following is the change from calc version 2.11.0t8.9.1 to date: +The following are the changes from calc version 2.11.0t10 to date: + + Misc code cleanup. Removed dead code. Removed trailing whitespace. + Fixed whitespace to make the best use of 8 character tabs. + + +The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5: The config("verbose_quit") will control the printing of the message: @@ -52,7 +58,7 @@ Following is the change from calc version 2.11.0t8.9.1 to date: print "Good bye"; Comments entered at input terminal level may be spread over several - lines. For example: + lines. For example: /* * Assume that this calc script is called: comment.cal @@ -135,19 +141,19 @@ Following is the change from calc version 2.11.0t8.9.1 to date: Fixed the make depend code in the custom and sample Makefiles. - Fixed how the help/builtin file is formed. The help/Makefile is + Fixed how the help/builtin file is formed. The help/Makefile is now given the name of the native C compiler by the top level Makefile. The include files are installed under INCDIRCALC (a new Makefile variable) - which by default is ${INCDIR}/calc. The INCDIR (also a new Makefile var) + which by default is ${INCDIR}/calc. The INCDIR (also a new Makefile var) by default is /usr/local/include. Include files previously installed directly under ${LIBDIR} will be removed. Added the piforever() funcion to lib/pi.cal. It was written by Klaus Alexander Seistrup and was inspired by - an algorithm conceived by Lambert Meertens. (See also the ABC + an algorithm conceived by Lambert Meertens. (See also the ABC Programmer's Handbook, by Geurts, Meertens & Pemberton, published - by Prentice-Hall (UK) Ltd., 1990.) The piforever() funcion prints + by Prentice-Hall (UK) Ltd., 1990.) The piforever() funcion prints digits of pi for as long as your memory and system uptime allows. :-) Fixed the URLs found thruout the source and documentation which did @@ -173,7 +179,7 @@ Following is the change from calc version 2.11.0t8.9.1 to date: will now require something like: - mat A[2], mat B[3] or A = mat[2], B = mat[3] + mat A[2], mat B[3] or A = mat[2], B = mat[3] For example, if obj point and obj pair are known types, the following is now allowed: @@ -207,8 +213,8 @@ Following is the change from calc version 2.11.0t8.9.1 to date: othewise if "%lld" is required, l_format will be < 0. Added HAVE_STRDUP Makefile variable as well as the have_strdup.c - program that forms the have_strdup.h file. The have_strdup.h file - will define HAVE_STRDUP is the system has strdup(). If HAVE_STRDUP + program that forms the have_strdup.h file. The have_strdup.h file + will define HAVE_STRDUP is the system has strdup(). If HAVE_STRDUP is not defined, then calc will use calc_strdup() to simulate the real strdup() function. @@ -219,8 +225,9 @@ Following is the change from calc version 2.11.0t8.9.1 to date: 10000 will be considered calc errors instead. The Makefile symbol ERRNO_DECL has gone away as well as calc_errno.c and calc_errno.h. - On system errors are are not known to to the libc strerror() function, - strerror() will now print something such as: + System errors that are are not known to to the libc strerror() + function, will now print (via the strerror() calc builtin function) + something such as: Unknown error 9999 @@ -235,10 +242,10 @@ Following is the change from calc version 2.11.0t8.9.1 to date: stay under the radar of spammers as much as one can do so. -Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: +The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9: Moved 'wishlist' enhancements from the help/todo file to a new - help/wishlist file. Ordered, by priority, help/todo items into + help/wishlist file. Ordered, by priority, help/todo items into Very High, High and Medium priority items. The BUGS file now has a 'bugs' section as well as a 'mis-features' @@ -317,21 +324,21 @@ Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: the way config("calc_debug"). Now the lower 4 bits of the config("calc_debug") parameter have the following meaning: - n Meaning of bit n of config("calc_debug") + n Meaning of bit n of config("calc_debug") 0 Outputs shell commands prior to execution. 1 Outputs currently active functions when a quit instruction - is executed. + is executed. 2 Some details of shs, shs1 and md5 hash states are included - in the output when these are printed. + in the output when these are printed. 3 When a function constructs a block value, tests are - made that the result has the properties required for use of - that block, e.g. that the pointer to the start of the - block is not NULL, and that its "length" is not negative. - A failure will result in a runtime error. + made that the result has the properties required for use of + that block, e.g. that the pointer to the start of the + block is not NULL, and that its "length" is not negative. + A failure will result in a runtime error. Changed the meaning of (config("calc_debug") & 1) from only printing the shell commands (and pausing) while displaying help files into @@ -339,13 +346,13 @@ Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: Documented the meaning of config("lib_debug"): - n Meaning of bit n of config("lib_debug") + n Meaning of bit n of config("lib_debug") - 0 When a function is defined, redefined or undefined at + 0 When a function is defined, redefined or undefined at interactive level, a message saying what has been done is displayed. - 1 When a function is defined, redefined or undefined during + 1 When a function is defined, redefined or undefined during the reading of a file, a message saying what has been done is displayed. @@ -357,7 +364,7 @@ Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: of a file. Changed the calc lib files to reflect the new config("lib_debug") - bit field meaning. Calc lib files that need to print extra information + bit field meaning. Calc lib files that need to print extra information should now do something such as: if (config("lib_debug") & 3) { @@ -391,12 +398,12 @@ Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: Fixed misc compiler warnings. -Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: +The following are the changes from calc version 2.11.0t7 to 2.11.0t7.5: Calc has some new command line flags / command line meaning: (Thanks goes to Ernest Bowen ) - -i Go into interactive mode if possible. + -i Go into interactive mode if possible. -c Continue reading command lines even after an execution error has caused the abandonment of a line @@ -450,7 +457,7 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: mat A[1] = {2,3}; print "end";' - will print both ``start'' and ``end''. C-shell users can do: + will print both ``start'' and ``end''. C-shell users can do: calc -c 'print "start"; \ mat A[1] = {2,3}; \ @@ -468,7 +475,7 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Added another command line flag to calc: - -d Disable display of the opening title and config("lib_debug",0) + -d Disable display of the opening title and config("lib_debug",0) The command: @@ -515,9 +522,9 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Added the Makefile variable ${LCC} to invoke the local c compiler. By default, ${CC} also run the ${LCC} compiler. The distinction is - useful when using something such as purify. In the case of ${LCC}, + useful when using something such as purify. In the case of ${LCC}, only the local C compiler is invoked. In the case of ${CC} a purify - compile is invoked. Only the source that must be compiled and run + compile is invoked. Only the source that must be compiled and run on the local machine use ${LCC}; everything else uses ${CC}. Fixed memory buffer ovreread problem in eatstring() in token.c. @@ -528,7 +535,7 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Fixed compilation warnings and problems on BSDI. - Removed ${CCMAIN} as a variable from the Makefile. Now files + Removed ${CCMAIN} as a variable from the Makefile. Now files use either ${CFLAGS} for general C source and ${ICFLAGS} for intermediate C source (e.g., special code for building hsrc files). @@ -539,14 +546,14 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Misc calc man page fixes. -Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: +The following are the changes from calc version 2.11.0t1 to 2.11.0t6.3: Removed the makefile symbol MAIN. Now forcing all functions to correctly be declared main. To satisfy some old broken compilers, a return 0; (instead of an exit(0);) is used at the end of main(). A few of files that were added to calc used 4 character indentation - whereas most of calc uses 8 character indentation. These imported + whereas most of calc uses 8 character indentation. These imported sources have been changed to conform better with the calc style. Added the program calc_errno.c and the Makefile symbol ERRNO_DECL. @@ -562,7 +569,7 @@ Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: Changed check.awk to be more 'old awk' friendly. - Made some of the source a little more ++ friendly. We are NOT + Made some of the source a little more ++ friendly. We are NOT porting calc to C++! We will NOT support C++ compilation of calc. Calc will written ANSI C. We just compiled with a suggestion from Love-Jensen, John to make calc's version @@ -612,11 +619,11 @@ Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: Ernest Bowen . Added FORCE_STDC symbol. When defined it will force __STDC__ like - conditions. Thus for compilers with as the Solaris cc compiler + conditions. Thus for compilers with as the Solaris cc compiler that are ANSI-like but still define __STDC__ as 0, one can use -DFORCE_STDC and make use of ANSI-like features. - Removed the CCSHS symbol from the Makefile. The shs.c and shs1.c + Removed the CCSHS symbol from the Makefile. The shs.c and shs1.c files are now compiled with full ${CFLAGS}. The custom.c file is now compiled with full ${CFLAGS}. @@ -691,7 +698,7 @@ Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: Removed if (config("lib_debug") >= 0) { ... } the ends of most of the calc library scripts because it was redundant with the - new config("lib_debug") >= 0 functionality. Some of the calc + new config("lib_debug") >= 0 functionality. Some of the calc library still has a partial section because some useful additional information was being printed: @@ -731,12 +738,12 @@ Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: Fixed misc compile warnings and notices. -Following is the change from calc version 2.10.3t5.38 to 2.11.0t0: +The following are the changes from calc version 2.10.3t5.38 to 2.11.0t0: Fixed a few compile problems found under Red Hat 6.0 Linux. -Following is the change from calc version 2.10.3t5.38 to 2.11.3t5.46: +The following are the changes from calc version 2.10.3t5.38 to 2.11.3t5.46: Fixed a bug discovered by Ernest Bowen related to matrix-to-matrix copies. @@ -759,7 +766,7 @@ Following is the change from calc version 2.10.3t5.38 to 2.11.3t5.46: Fixed previously reported bug in popcnt() in relation to . values. Calc man page changes per suggestion from Martin Buck - . The calc man page is + . The calc man page is edited with a few more parameters from the Makefile. Misc Makefile changes per Martin Buck . @@ -770,7 +777,7 @@ Following is the change from calc version 2.10.3t5.38 to 2.11.3t5.46: Fixed the regress.cal dependency list. Make chk and check will exit with an error if check.awk detects - a problem in the regression output. (Martin Buck) + a problem in the regression output. (Martin Buck) Fixed print line for test #4404. @@ -793,7 +800,7 @@ Following is the change from calc version 2.10.3t5.38 to 2.11.3t5.46: into a single section. -Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: +The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37: Per request from David I Bell, the README line: @@ -808,7 +815,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: address agd arrow dereference free freeglobals freeredc freestatics gd isptr mattrace oldvalue saveval & * -> and . - Fixed blkcpy() and copy() arg order and processing. Now: + Fixed blkcpy() and copy() arg order and processing. Now: A = blk() = {1,2,3,4} B = blk() @@ -819,12 +826,12 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: Since "make chk" pipes the regression output to awk, we cannot assume that stdout and stderr are ttys. Tests #5985 and #5986 - have been removed for this reason. (thanks to Martin Buck + have been removed for this reason. (thanks to Martin Buck for this report) Fixed the order of prints in regress.cal. By convention, a print of a test line happens after the test. This is because function - parsed messages occur after the function is parsed. Also the + parsed messages occur after the function is parsed. Also the boolean tesrt of vrfy happens before any print statement. Therefore a non-test line is tested and printed as follows: @@ -838,7 +845,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: Moved string.c into libcalc.a. - The NUMBER union was converted back into a flat structure. Changes + The NUMBER union was converted back into a flat structure. Changes where 'num' and 'next' symbols were changed to avoid #define conflicts were reverse since the #define's needed to support the union went away. @@ -852,7 +859,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: A = B = strcat("abc", "def"); would store "abc" and "def" as literal strings never to be freed, and - store "abcdef" once each for both A and B. Now the "abc" and "bcd" + store "abcdef" once each for both A and B. Now the "abc" and "bcd" are freed immediately after they are concatenated and "abcdef" is stored only once, just as the number 47 would be stored only once for @@ -877,17 +884,17 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: distinction between a string-octet and a block-octet. The same operations and functions can be used for both, and as before, an octet is in some respects a number in [0,256) and in others a one-character - string. For example, for A = "abc\0def" one will have both A[0] == "a" - and A[0] == 97. Assignments to octets can be used to change + string. For example, for A = "abc\0def" one will have both A[0] == "a" + and A[0] == 97. Assignments to octets can be used to change characters in the string, e.g. A[0] = "A", A[1] = 0, A[2] -= 32, A[3] = " " will change the above A to "A\0C def". (3) "show strings" now displays the indices, links, length, and some or all of the early and late characters in all unfreed strings which are values of lvalues or occur as "constants" in function definitions, - using "\n", "\t", "\0", "\252", etc. when appropriate. For example, + using "\n", "\t", "\0", "\252", etc. when appropriate. For example, the string A in (1) would be displayed as in the definition there. - Only one line is used for each string. I've also changed the + Only one line is used for each string. I've also changed the analogous "show numbers" so that only some digits of numbers that would require more than one line are displayed. @@ -896,7 +903,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: literal strings as in A = "abc". There is a major difference between strings and numbers in that there are operations by which characters in any string may be changed. For example, after A = "abc", - A[0] = "X" changes A to "Xbc". It follows that if a literal string + A[0] = "X" changes A to "Xbc". It follows that if a literal string is to be constant in the sense of never changing, such a character- changing operation should never be applied to that string. @@ -905,7 +912,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: A = B results in A referring to exactly the same string as B rather than to - a copy of what is in B. Thie is like the use of character-pointers in + a copy of what is in B. Thie is like the use of character-pointers in C, as in char *s1, *s2; @@ -971,7 +978,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: k * A and A * k - for any real number k and any string A. In the case of k == 1, these + for any real number k and any string A. In the case of k == 1, these return a new string rather than A itself. (This differs from "" + A and A + "" which return A.) @@ -1000,7 +1007,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: S1 & S2 having the size of the smaller of S1 and S2. By using, say, 4-character strings, one can simulate a C integral type so far as the | and & operations are concerned. It then seemed appropriate to - use the operator ~ for a "bitwise complement" as in C. Thus I have + use the operator ~ for a "bitwise complement" as in C. Thus I have defined ~s for a string s to be the string of the same size as s with each character being complemented by the C ~ operation. @@ -1009,9 +1016,9 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: would be confusing when this is used elsewhere for powers, so I decided to use ~. For setminus, I adopted the commonly used '\'. Strings of fixed size n can now be used for a boolean algebra - structure with 8 * n elements. The zero element is n * char(0), + structure with 8 * n elements. The zero element is n * char(0), the unity is n * char(-1), and one have all of the usual laws like - A & (B | C) == A & B | A * C, A \ B = A & ~B, etc. + A & (B | C) == A & B | A * C, A \ B = A & ~B, etc. (13) Having extended the bitwise operations for strings, it was appropriate to do the same for integers. Definitions of the binary ~ and \ @@ -1024,7 +1031,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: 2^i_1 + 2^i_2 + ... - For ~N for non-integer real N, I have simply used -N. There is some + For ~N for non-integer real N, I have simply used -N. There is some logic in this and it is certainly better than an error value. I have not defined the binary operations |, &, ~, \ for non-integral arguments. @@ -1034,7 +1041,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: To resolve this, my preference would be to replace the printing of "~" as a prefix by a trailing ellipsis "...", the rounding always being towards zero. E.g. with config("display", 5), 1/7 would print - as ".14285..." rather than "~.14285". The config("outround") + as ".14285..." rather than "~.14285". The config("outround") parameter would determine the type of rounding only for the equivalent of config("tilde", 0). @@ -1045,7 +1052,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: (15) For the obviously useful feature corresponding to cardinality of a set, I have defined #S for a string S to be the number of nonzero bits - in S. For a degree of consistency, it was then appropriate to + in S. For a degree of consistency, it was then appropriate to define #N for a nonnegative integer N to be the number of nonzero bits in the binary representation of N. I've extended this to arbitrary real N by using in effect #(abs(num(N))). I feel it is better to make @@ -1059,7 +1066,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: use for a binary operation. For real numbers x and y I have defined x # y to be abs(x - y). (This is often symbolized by x ~ y, but it would be confusing to have x ~ y meaning xor(x,y) for strings and - abs(x-y) for numbers.) Because '#' is commonly called the hash symbol, + abs(x-y) for numbers.) Because '#' is commonly called the hash symbol, I have used xx_hashop to permit definition of x # y for xx-objects. (17) For a similar reason I've added one line of code to codegen.c so that @@ -1080,7 +1087,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: (20) For octets o1, o2, I've defined o1 | o2, o1 & o2, o1 ~ o2, ~o1 so - that they return 1-character strings. #o for an octet o returns the + that they return 1-character strings. #o for an octet o returns the number of nonzero bits in o. (21) For substrings I've left substr() essentially as before, but @@ -1099,7 +1106,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: segment(A, n) now returns the one-character string with its character being that with - index n in A. (I've made a corresponding modification to the segment + index n in A. (I've made a corresponding modification to the segment function for lists.) Some examples, if A = "abcdef", segment(A,2,4) = "cde", @@ -1134,7 +1141,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: of the indices. (24) A string A of length N determines in obvious ways arrays of M = 8 * N - bits. If the characters in increasing index order are c_0, c_1, ... + bits. If the characters in increasing index order are c_0, c_1, ... and the bits in increasing order in c_i are b_j, b_j+1, ..., b_j+7 where j = 8 * i, I've taken the array of bits determined by A to be @@ -1168,21 +1175,21 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: (27) To achieve much the same as the C strcpy and strncpy functions for null-terminated strings, strcpy(S1, S2) and strncpy(S1, S2, n) have - been defined. Unlike the blkcpy() and copy() functions, the copying + been defined. Unlike the blkcpy() and copy() functions, the copying for these is only from the beginning of the strings. Also, unlike C, no memory overflow can occur as the copying ceases when size(S1) is reached. Note that these overwrite the content of S1 (which affects all strings linked to it) as well as returning S1. Examples: - S = strcpy(6 * "x", "abc") <=> S = "abc\0xx" + S = strcpy(6 * "x", "abc") <=> S = "abc\0xx" - S = strcpy(3 * "x", "abcdef") <=> S = "abc" + S = strcpy(3 * "x", "abcdef") <=> S = "abc" - S = strncpy(6 * "x", "abcd", 2) <=> S = "ab\0xxx" + S = strncpy(6 * "x", "abcd", 2) <=> S = "ab\0xxx" - S = strncpy(6 * "x", "ab", 4) <=> S = "ab\0\0xx" + S = strncpy(6 * "x", "ab", 4) <=> S = "ab\0\0xx" - S = strncpy(6 * "x", "ab", 20) <=> S = "ab\0\0\0\0" + S = strncpy(6 * "x", "ab", 20) <=> S = "ab\0\0\0\0" If a new string S not linked to S1 is to be created, this can be achieved by using str(S1) in place of S1. For example, the strcpy in @@ -1209,7 +1216,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: A = "abcdefg"; copy(A, A, , , 2); - will result in A == "abababa". If the overwriting that occurs here + will result in A == "abababa". If the overwriting that occurs here is not wanted, one may use A = "abcdefg"; @@ -1242,7 +1249,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: There may be one or two other changes resulting from the way I have rewritten the optimization code in addop.c. I think there was a bug - that assumed that PTR_SIZE would be the same as sizeof(long). By + that assumed that PTR_SIZE would be the same as sizeof(long). By the way, the new OP_STRING is now of index rather than pointer type. It follows that pointers are now used in opcodes only for global variables. By introducing a table of addresses of global variables @@ -1255,7 +1262,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: stack, etc. Maybe more detail should be added to math_error(), but to achieve the freeing of memory for a quit statement and at the same time give more information about its occurrence I have changed the - way opcodes.c handles OP_QUIT. Now it should free the local variables + way opcodes.c handles OP_QUIT. Now it should free the local variables and whatever is on the stack, and display the name and line-number, for each of the functions currently being evaluated. The last function listed should be the "top-level" one with name "*". @@ -1312,7 +1319,7 @@ Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37: user-specified bound. -Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: +The following are the changes from calc version 2.10.3t5.28 to 2.10.3t5.33: Added hnrmod(v, h, n, r) builtin to compute: @@ -1371,7 +1378,7 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: To allow & to be used as a C-like address operator, use of it has been dropped in calls to user-defined functions. For the - time being I have replaced it by the back-quote `. For example: + time being I have replaced it by the back-quote `. For example: > global a > define f(a,b) = a = b @@ -1451,7 +1458,7 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: if q->links = 0. The old "num" is #defined to "nu->n_num". The prior method calc has used for handling "constants" amounted - to leakage. After: + to leakage. After: > define f(x) = 27 + x; > a = 27; @@ -1463,7 +1470,7 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: > a = 45; There seems little point in retaining 27 as a constant and - therefore using up memory. If this example seems trivial, + therefore using up memory. If this example seems trivial, replace 27 with a few larger numbers like 2e12345, or better, -2e12345, for which calc needs memory for both 2e12345 and -2e12345! @@ -1547,7 +1554,7 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: > . 4 - can now be treated as an unnamed variable. For example: + can now be treated as an unnamed variable. For example: > mat x[3,3]={1,2,3,4,5,6,7,8,9} > x @@ -1620,7 +1627,7 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: LONG_BITS > BASEB, len = 1 and nf = 0, since it then reduces to the value of (nf != q->num.v[1]) in which q->num.v[1] is not part of the size-1 array of HALFs for - q->num. At present this is used only for changing opcodes + q->num. At present this is used only for changing opcodes for ^2 and ^4 from sequences involving OP_POWER to sequences using OP_SQUARE, which has no effect on the results of calculations. @@ -1668,17 +1675,17 @@ Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33: is now 10000 cycles. SGI Mips r10k compile set is speced for IRIX6.5 with v7.2 - compilers. A note for pre-IRIX6.5 and/or pre-v7.2 compilers + compilers. A note for pre-IRIX6.5 and/or pre-v7.2 compilers is given in the compile set. Added regression tests related to saveval(), dot and pointers. -Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: +The following are the changes from calc version 2.10.3t5.11 to 2.10.3t5.27: The todo help file as been updated with the in-progress items: - XXX - block print function is not written yet ... + xxx - block print function is not written yet ... Expanded the role of blk() to produce unnamed blocks as in: @@ -1708,13 +1715,13 @@ Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: The builtin function blkfree(val) will free memory allocated to block. If val is a named block, or the name of a named block, or the identifying index for a named block, blkfree(val) frees the - memory block allocated to this named block. The block remains + memory block allocated to this named block. The block remains in existence with the same name, identifying index, and chunksize, but its size and maxsize becomes zero and the pointer for the start of its data block null. The builtin function blocks() returns the number of blocks that - have been created but not freed by the blkfree() function. When called + have been created but not freed by the blkfree() function. When called as blocks(id) and the argument id less than the number of named blocks that have been created, blocks(id) returns the named block with identifying index id. @@ -1729,7 +1736,7 @@ Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: Added isobjtype() to determine the type of an object. The isatty(v) builtin will return 1 if v is a file that associated - with a tty (terminal, xterm, etc.) and 0 otherwise. The isatty(v) + with a tty (terminal, xterm, etc.) and 0 otherwise. The isatty(v) builtin will no longer return an error if v is not a file or is a closed file. @@ -1788,15 +1795,15 @@ Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: Resolved a number of missing symbols for libcalc users. Added lib_util.{c,h} to the calc source to support users of - libcalc.a. These utility routines are not directly used by + libcalc.a. These utility routines are not directly used by calc but are otherwise have utility to those programmers who directly use libcalc.a instead. - Added sample sub-directory. This sub-directory contains a few - sample programs that use libcalc.a. These sample programs are + Added sample sub-directory. This sub-directory contains a few + sample programs that use libcalc.a. These sample programs are built via the all rule because they will help check to see that libcalc.a library does not contain external references that - cannot be resolved. At the current time none of these sample + cannot be resolved. At the current time none of these sample programs are installed. Added a libcalc_call_me_last() call to return storage created @@ -1807,7 +1814,7 @@ Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: Fixed fseek() file operations for SunOS. - Fixed convz2hex() fencepost error. It also removes leading 0's. + Fixed convz2hex() fencepost error. It also removes leading 0's. Plugged a memory leak relating to pmod. The following calculation: @@ -1816,7 +1823,7 @@ Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27: where x was not 2^n-1 would leak memory. This has been fixed. -Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: +The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10: Misc printf warning bug fixes. @@ -1831,7 +1838,7 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: P = {A, B} - has the effect of P.x = A; P.y = B. Sometimes one might want these in + has the effect of P.x = A; P.y = B. Sometimes one might want these in the reverse order: P.y = B; P.x = A. This is achieved by: P = { , B} = {A} @@ -1842,20 +1849,20 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: which results in Q having Q.x.x = 1, Q.x.y = 2, etc. - The role of the comma in has been changed. Expressions such as: + The role of the comma in has been changed. Expressions such as: - mat A[2], B[3] + mat A[2], B[3] are equivalent to: - (mat A[2]), (mat B[3]) + (mat A[2]), (mat B[3]) Now, expr1, expr2 returns type of expr2 rather than EXPR_RVALUE. This permits expressions such as: (a = 2, b) = 3 - Also, expr1 ? expr2 : expr3 returns type(expr2) | type(expr3). + Also, expr1 ? expr2 : expr3 returns type(expr2) | type(expr3). This will make the result an lvalue (i.e. EXPR_RVALUE bit not set) For example, if both expr2 and expr3 are lvalues. Then: @@ -1870,7 +1877,7 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: which does d = b if a is "nonzero", otherwise d = c. And now, expr1 || expr2 and expr1 && expr2 each return - htype(expr1)| type(expr2). So for example: + htype(expr1)| type(expr2). So for example: a || b = c @@ -1920,7 +1927,7 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: Now 's' will print '10' instead of '5'. - Added more regression tests to regress.cal. Changed the error + Added more regression tests to regress.cal. Changed the error counter from 'err' to 'prob'. The errmax() is set very high and the expected value of errcount() is kept in ecnt. @@ -1933,7 +1940,7 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: The blkalloc() builtin has been renamed blk(). - Only a "fixed" type of BLOCK will be used. Other types of + Only a "fixed" type of BLOCK will be used. Other types of blocks in the future will be different VALUE types. Introduced an undefine command so that @@ -1956,12 +1963,12 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: a USB8 in B. xx_assign added to object functions to permit the possibility of - specifying what A = B will do if A is an xx-object. Normal + specifying what A = B will do if A is an xx-object. Normal assignment use of = is restored by the command: undefine xx_assign. For error-value err, errno(err) returns the error-code for err and - stores this in calc_errno; error(err) returns err as if + stores this in calc_errno; error(err) returns err as if error(errno(err)) were called. Anticipating probable future use, names have been introduced for @@ -1983,7 +1990,7 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: In most cases, CALC_ENV= CALCPATH=./lib is sufficent. Added ${CALC_LIBS} to list the libaraies created and used to - build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a + build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a is standard for everyone. Improved how 'make calc' and 'make all' rules work with respect @@ -2017,10 +2024,10 @@ Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10: regression tests for memsize(), sizeof() and size(). -Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: +The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0: The calc source now comes with a custom sub-directory which - contains the custom interface code. The main Makefile now + contains the custom interface code. The main Makefile now drives the building and installing of this code in a similar way that it drives the lib and help sub-directories. (see below) @@ -2115,7 +2122,7 @@ Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: Added the custom() builtin function. The custom() builtin interface is designed to make it easier for local custom modification to be added to calc. Custom functions are - non-standard or non-portable code. For these reasons, one must can + non-standard or non-portable code. For these reasons, one must can only execute custom() code by way of an explicit action. By default, custom() returns an error. A new calc command line @@ -2139,7 +2146,7 @@ Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: of calling config("all", "newstd") at startup time. Added -e as a calc command line option to ignore all environment - varialbes at startup time. The getenv() builtin function will + varialbes at startup time. The getenv() builtin function will still return values, however. Added -i as a calc command line option. This has the effect @@ -2156,7 +2163,7 @@ Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: The 'make check' rule now uses the -i calc command line flag so that regress.cal can continue beyond when errcount exceeds errmax. In regress.cal, vrfy() reports when errcount exceeds - errmax and resets errmax to match errcount. This check + errmax and resets errmax to match errcount. This check and report is independent of the test success of failure. Fixed missing or out of order tests in regress.cal. @@ -2171,9 +2178,9 @@ Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: The help command will search ${LIBDIR}/custhelp if it fails to find a file in ${LIBDIR}. This allows the help command to also print - help for a custom function. However if a standard help file and a + help for a custom function. However if a standard help file and a custom help file share the same name, help will only print the - standard help file. One can skip the standard help file and print + standard help file. One can skip the standard help file and print the custom help file by: help custhelp/name @@ -2209,7 +2216,7 @@ Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0: The max(), min() builtins work for lists. -Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: +The following are the changes from calc version 2.10.3t3 to 2.10.3t4.15: The priority of unary + and - to that of binary + and - when they are applied to a first or only term. Thus: @@ -2257,7 +2264,7 @@ Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: and randrun.cal a55 tests. Improved hash.c interface to lower level hash functions. The hash - interface does not yet have a func.c interface ... it is still + interface does not yet have a func.c interface ... it is still under test. Added randombitrun.cal to test the Blum-Blum-Shub generator. @@ -2267,7 +2274,7 @@ Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: In the original version, each call to newerror(str) created a new error-value. Now a new value will be created only if str has not - been used in a previous call to newerror(). In effect, the string + been used in a previous call to newerror(). In effect, the string serves to identify the error-value; for example: return newerror("Non-integer argument"); @@ -2317,11 +2324,11 @@ Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: Added "blkmaxprint" config value, which limits the octets to print for a block. A "blkmaxprint" of 0 means to print all octets of a - block, regardless of size. The default is to print only the first + block, regardless of size. The default is to print only the first 256 octets. The "blkverbose" determines if all lines, including duplicates - should be printed. If TRUE, then all lines are printed. If false, + should be printed. If TRUE, then all lines are printed. If false, duplicate lines are skipped and only a "*" is printed in a sytle similar to od. This config value has not meaning if "blkfmt" is "str". The default value for "blkverbose" is FALSE: duplicate @@ -2330,39 +2337,39 @@ Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: The "blkbase" determines the base in which octets of a block are printed. Possible values are: - "hexadecimal" Octets printed in 2 digit hex - "hex" + "hexadecimal" Octets printed in 2 digit hex + "hex" - "octal" Octets printed in 3 digit octal - "oct" + "octal" Octets printed in 3 digit octal + "oct" - "character" Octets printed as chars with non-printing - "char" chars as \123 or \n, \t, \r + "character" Octets printed as chars with non-printing + "char" chars as \123 or \n, \t, \r - "binary" Octets printed as 0 or 1 chars - "bin" + "binary" Octets printed as 0 or 1 chars + "bin" - "raw" Octets printed as is, i.e. raw binary - "none" + "raw" Octets printed as is, i.e. raw binary + "none" The default "blkbase" is "hex". The "blkfmt" determines for format of how block are printed: - "line" print in lines of up to 79 chars + newline - "lines" + "line" print in lines of up to 79 chars + newline + "lines" - "str" print as one long string - "string" - "strings" + "str" print as one long string + "string" + "strings" - "od" print in od-like format, with leading offset, - "odstyle" followed by octets in the given base - "od_style" + "od" print in od-like format, with leading offset, + "odstyle" followed by octets in the given base + "od_style" - "hd" print in hex dump format, with leading offset, - "hdstyle" followed by octets in the given base, followed - "hd_style" by chars or '.' if no-printable or blank + "hd" print in hex dump format, with leading offset, + "hdstyle" followed by octets in the given base, followed + "hd_style" by chars or '.' if no-printable or blank The default "blkfmt" is "hd". @@ -2385,7 +2392,7 @@ Following is the change from calc version 2.10.3t3 to 2.10.3t4.15: Fixed error in using cmdbuf(""). -Following is the change from calc version 2.10.3t0 to 2.10.3t2: +The following are the changes from calc version 2.10.3t0 to 2.10.3t2: Bumped to version 2.10.3 due to the amount of changes. @@ -2394,7 +2401,7 @@ Following is the change from calc version 2.10.3t0 to 2.10.3t2: Fixed a casting problem in label.c. A lot of work was performed on the code generation by Ernest Bowen - . Declarations no longer need to precese code: + . Declarations no longer need to precese code: define f(x) { local i = x^2; @@ -2464,7 +2471,7 @@ Following is the change from calc version 2.10.3t0 to 2.10.3t2: } Fixed some faults in the handling of syntax errors for the matrix - and object creation operators mat and obj. In previous versions of calc: + and object creation operators mat and obj. In previous versions of calc: mat; <- Bad dimension 0 for matrix mat A; <- Bad dimension 0 for matrix @@ -2513,7 +2520,7 @@ Following is the change from calc version 2.10.3t0 to 2.10.3t2: 5200 regress test and lib/test5200.cal for details. Optimized opcode generator so that functions defined using '=' do not - have two unreached opcodes. I.e.,: + have two unreached opcodes. I.e.,: define f(x) = x^2 show opcodes f @@ -2534,7 +2541,7 @@ Following is the change from calc version 2.10.3t0 to 2.10.3t2: The LONG_BITS make variable, if set, will force the size of a long as well as forcing the USB8, SB8, USB16, SB16, USB32, SB32, - HAVE_B64, USB64, SB64, U(x) and L(x) types. If the longbits + HAVE_B64, USB64, SB64, U(x) and L(x) types. If the longbits program is given an arg (of 32 or 64), then it will output based on a generic 32 or 64 bit machine where the long is the same size as the wordsize. @@ -2547,7 +2554,7 @@ Following is the change from calc version 2.10.3t0 to 2.10.3t2: SGI 6.2 and later uses -xansi. -Following is the change from calc version 2.10.2t33 to 2.10.2t34: +The following are the changes from calc version 2.10.2t33 to 2.10.2t34: Fixed a bug related to fact(). @@ -2593,27 +2600,27 @@ Following is the change from calc version 2.10.2t33 to 2.10.2t34: essentially "start" as before, but for rsearch() is better for c and d to be the same as for search(). For a non-file case, if: - 0 <= c < d <= size(a), + 0 <= c < d <= size(a), the index-interval over which the search is to take place is: - c <= i < d. + c <= i < d. If the user has defined a function accept(v,b), this is used rather than the test v == b to decide for matrix, list, or association searches when a "match" of v = a[[i]] with b occurs. E.g. after: - define accept(v,b) = (v >= b); + define accept(v,b) = (v >= b); then calling: - search(a, 5, 100, 200) + search(a, 5, 100, 200) will return, if it exists, the smallest index i for which 100 <= i < 200 and a[[i]] >= 5. To restore the effect of the original "match" function, one would then have to: - define accept(v,b) == (v == b). + define accept(v,b) == (v == b). Renamed the calc symbol BYTE_ORDER to CALC_BYTE_ORDER in order to avoid conflict. @@ -2624,10 +2631,10 @@ Following is the change from calc version 2.10.2t33 to 2.10.2t34: http://www.latech.edu/~acm/HelloWorld.shtml -Following is the change from calc version 2.10.2t25 to 2.10.2t32: +The following are the changes from calc version 2.10.2t25 to 2.10.2t32: Eliminated use of VARARG and . Calc supports only - . The VARARGS Makefile variable has been eliminated. + . The VARARGS Makefile variable has been eliminated. Source is converted to ANSI C. In particular, functions will now have ANSI C style args. Any comments from old K&R @@ -2692,12 +2699,12 @@ Following is the change from calc version 2.10.2t25 to 2.10.2t32: "static a" in the second line; the second "a" remains active until its scope ends with the ending of the definition of f(). Thus one ends with g(x) = 10 + x and on successive calls to - f(), f(x) returns 20 + x, 21 + x, etc. With successive "static + f(), f(x) returns 20 + x, 21 + x, etc. With successive "static a" declarations at the same level, the active one at any stage is the most recent; if the instructions are being read from a file, the scope of the last "static a" ends at the end-of-file. - Here I have assumed that no "global a" is encountered. As + Here I have assumed that no "global a" is encountered. As there can be only one global variable with name "a", it seems to me that its use must end the scope of any static "a". Thus the changes I introduce are such that after: @@ -2712,7 +2719,7 @@ Following is the change from calc version 2.10.2t25 to 2.10.2t32: g(x) will always return 20 + x, and until h(x) has been called, f(x) and i(x) will return 10 + x; when h(x) is called, it returns 30 + x and any later call to f(x) or i(x) will return - 30 + x. It is the reading of "global a" in the definition of + 30 + x. It is the reading of "global a" in the definition of h() that terminates the scope of the static a = 20, so that the "a" for the last line is the global variable defined in the first line. The "a = 30" is executed only when h() is called. @@ -2723,7 +2730,7 @@ Following is the change from calc version 2.10.2t25 to 2.10.2t32: The other changes produced by the patch are more straightforward, but some tricky programming was needed to get the possibility of multiple assignments and what seems to be the appropriate order - of executions and assignments. For example, the order for the + of executions and assignments. For example, the order for the declaration: global a, b = expr1, c, d = expr2, e, f @@ -2740,7 +2747,7 @@ Following is the change from calc version 2.10.2t25 to 2.10.2t32: a = 0; b = expr1; c = 0; d = expr2; e = 0; f = 0; The order is important when the same name is used for different - variables in the same context. E.g. one may have: + variables in the same context. E.g. one may have: define f(x) { global a = 10; @@ -2808,7 +2815,7 @@ Following is the change from calc version 2.10.2t25 to 2.10.2t32: and file system permits. -Following is the change from calc version 2.10.2t4 to 2.10.2t24: +The following are the changes from calc version 2.10.2t4 to 2.10.2t24: Added makefile debugging rules: @@ -2858,7 +2865,7 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: > demo() Added a new trace option for display of links to real and complex - numbers. This is activated by config("trace", 4). The printing + numbers. This is activated by config("trace", 4). The printing of a real number is immediately followed by "#" and the number of links to that number; complex numbers are printed in the same except for having "##" instead of "#". @@ -2877,7 +2884,7 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: file to indicate where recent versions of calc are available. The regression test suite output has been changed so that it will - output the same information regardless of CPU performance. In + output the same information regardless of CPU performance. In particular, cpu times of certain tests are not printed. This allows one to compare the regression output of two different systems easier. @@ -2908,7 +2915,7 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: Missing arguments are considered as "no change" rather than "assign null values". As in recent versions of calc, the default value assigned to matrix elements is zero and the default for object - elements is a null value). Thus: + elements is a null value). Thus: mat A[2] = {1,2}; A = { , 3}; @@ -2940,7 +2947,7 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: B == A[i] implies A[i][j] = B[j] There is requirement in the use of A[i][j] that the matrices A[i] - for i = 0, 1, ... all be of the same size. Thus: + for i = 0, 1, ... all be of the same size. Thus: mat A[3] = {(mat[2]), (mat[3]), (mat[2])}; @@ -3042,29 +3049,29 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: Statements such as: - mat A[2][3]; + mat A[2][3]; now to the same as: - mat M[3]; - mat A[2] = {M, M}; + mat M[3]; + mat A[2] = {M, M}; To initialize such an A one can use a statement like - A = {{1,2,3}, {4,5,6}}; + A = {{1,2,3}, {4,5,6}}; or combine initialization with creation by: - mat A[2][3] = {{1,2,3}, {4,5,6}}; + mat A[2][3] = {{1,2,3}, {4,5,6}}; One would then have, for example, A[1][0] = 4. Also, the inner braces cannot be removed from the initialization for A: - mat A[2][3] = {1,2}; + mat A[2][3] = {1,2}; results in exactly the same as: - mat A[2] = {1,2}; + mat A[2] = {1,2}; Added rm("file") builtin to remove a file. @@ -3089,11 +3096,11 @@ Following is the change from calc version 2.10.2t4 to 2.10.2t24: for more tests. Fixed all out of sequence test numbers. Fixed some malformatted regression reports. - Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to + Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to SWAP_HALF_IN_OFF_T. -Following is the change from calc version 2.10.2t1 to 2.10.2t3: +The following are the changes from calc version 2.10.2t1 to 2.10.2t3: Fixed bug in the regression suite that made test3400 and test4100 fail on correct computations. @@ -3222,7 +3229,7 @@ Following is the change from calc version 2.10.2t1 to 2.10.2t3: E.g. expressions like 2e4i+7/8 are acceptable. The builtin size(x) now returns the size of x if x is an open file - or -1 if x is a file but not open. If s is a string, size(s) returns + or -1 if x is a file but not open. If s is a string, size(s) returns characters in s. Added buildin access("foo", "w") returns the null value if a file @@ -3237,14 +3244,14 @@ Following is the change from calc version 2.10.2t1 to 2.10.2t3: Calc error codes are now as follows: - <0 invalid + <0 invalid 0 .. sys_nerr-1 system error ala C's errno values sys_nerr .. E__BASE-1 reserved for future system errors E__BASE .. E__HIGHEST calc internal errors E__HIGHEST+1 .. E_USERDEF-1 invalid E_USERDEF .. user defined errors - Currently, E__BASE == 10000 and E_USERDEF == 20000. Of course, + Currently, E__BASE == 10000 and E_USERDEF == 20000. Of course, sys_nerr is system defined however is likely to be < E__BASE. Renamed CONST_TYPE (as defined in have_const.h) to just CONST. @@ -3252,14 +3259,14 @@ Following is the change from calc version 2.10.2t1 to 2.10.2t3: on if your compiler understands const. CONST is beginning to be used with read-only tables and some - function arguments. This allows certain compilers to better + function arguments. This allows certain compilers to better optimize the code as well as alerts one to when some value is being changed inappropriately. Use of CONST as in: int foo(CONST int curds, char *CONST whey) while legal C is not as useful because the caller is protected - by the fact that args are passed by value. However, the + by the fact that args are passed by value. However, the in the following: int bar(CONST char *fizbin, CONST HALF *data) @@ -3269,7 +3276,7 @@ Following is the change from calc version 2.10.2t1 to 2.10.2t3: treated as read-only. -Following is the change from calc version 2.10.1t21 to 2.10.2t0: +The following are the changes from calc version 2.10.1t21 to 2.10.2t0: Bumped patch level 2.10.2t0 in honor of having help files for all builtin functions. Beta release will happen at the end of @@ -3277,7 +3284,7 @@ Following is the change from calc version 2.10.1t21 to 2.10.2t0: Fewer items listed in BUGS due to a number of bug fixes. - Less todo in the help/todo file because more has already been done. :-) + Less todo in the help/todo file because more has already been done. :-) All builtin functions have help files! While a number need cleanup and some of the LIMITS, LIBRARY and SEE ALSO sections need fixing @@ -3351,7 +3358,7 @@ Following is the change from calc version 2.10.1t21 to 2.10.2t0: mat D[] = { } -Following is the change from calc version 2.10.1t20 to 2.10.1t20: +The following are the changes from calc version 2.10.1t20 to 2.10.1t20: Changes made in preparation for Blum Blum Shub random number generator. @@ -3364,7 +3371,7 @@ Following is the change from calc version 2.10.1t20 to 2.10.1t20: sometimes lost rather than added to the appropriate carry. A new function zredcmodinv(ZVALUE z, ZVALUE *res) has been defined for - evaluating rp->inv in zredcalloc(). + evaluating rp->inv in zredcalloc(). New functions zmod5(ZVALUE *zp) and zmod6(ZVALUE z, ZVALUE *res) have been defined to give O(N^1.585)-runtime evaluation of z % m for @@ -3415,20 +3422,20 @@ Following is the change from calc version 2.10.1t20 to 2.10.1t20: Changed zprimetest() so that skip in ptest(n, count, skip) determines the way bases for the tests are selected. Neg values of - n are treated differently. When considering factorization, + n are treated differently. When considering factorization, primeness, etc. one is concerned with equivalence classes which for the rational integers are {0}, {-1, 1}, {-2, 2}, etc. To refer to an equivalence class users may use any of its elements but when returning a value for a factor the computer normally gives the non-negative member. The same sort of thing happens with integers modulo an integer, with fractions, etc., etc. E.g. users may refer - to 3/4 as 6/8 or 9/12, etc. A simple summary of the way negative n + to 3/4 as 6/8 or 9/12, etc. A simple summary of the way negative n is treated is "the sign is ignored". E.g. isprime(-97) and nextprime(-97) now return the same as isprime(97) and nextprime(97). -Following is the change from calc version 2.10.1t11 to 2.10.1t19: +The following are the changes from calc version 2.10.1t11 to 2.10.1t19: Added many more regression tests to lib/regress.cal. Some due to . @@ -3436,7 +3443,7 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: Added many help files, most due to . Fixed exp() and ln() so that when they return a complex value with a - zero imaginary component, isreal() is true. + zero imaginary component, isreal() is true. Fixed cast problem in byteswap.c. @@ -3462,7 +3469,7 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: Added the CONFIG type; a structure containing all of the configuration values under the control of config(). Added V_CONFIG data type. - The call config("all") returns a V_CONFIG. One may now save/restore + The call config("all") returns a V_CONFIG. One may now save/restore the configuration state as follows: x = config("all") @@ -3508,7 +3515,7 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: display 10 epsilon 1e-10 quo 0 - outround 24 + outround 24 leadzero 1 fullzero 1 prompt "; " (allows full line cut/paste) @@ -3560,9 +3567,9 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: } The ploy() function can take a list of coefficients. See - the help/poly file. Added poly.c. + the help/poly file. Added poly.c. - Fixes and performance improvemtns to det(). + Fixes and performance improvemtns to det(). Renamed atoq() and atoz() to str2q() and str2z() to avoid conflicts with libc function names. @@ -3573,9 +3580,9 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: long long or with LONGLONG_BITS=0. Added error() and iserror() to generate a value of a given error type. - See help/error for details. + See help/error for details. - Added singular forms of help files. For example one can now get + Added singular forms of help files. For example one can now get help for binding, bug, change, errorcode and type. The builtin mmin(x, md) has been changed to return the same as @@ -3585,10 +3592,10 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: The builtin avg(x_1, x_2, ...) has been changed to accept list-valued - arguments: a list x_i contributes its elements to the list of items to + arguments: a list x_i contributes its elements to the list of items to be averaged. E.g. avg(list(1,2,list(3,4)),5) is treated as if it were avg(1,2,3,4,5). If an error value is encountered in the items to be - averaged, the first such value is returned. If the number of items to be + averaged, the first such value is returned. If the number of items to be averaged is zero, the null value is returned. The builtin hmean(x_1, x_2, ...) has been changed to admit types @@ -3605,7 +3612,7 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: Calc used to accept with no warning or error message, gcdrem(0,2) or generally gcdrem(0,y) for any y with abs(y) > 1, but then went into an infinite loop. This has been fixed by never calling zfacrem() with zero x. - Both frem(x,y) and gcdrem(x,y) now reject y = -1, 0 or 1 as errors. For + Both frem(x,y) and gcdrem(x,y) now reject y = -1, 0 or 1 as errors. For nonzero x, and y == -1 or 1, defining frem(x,y) and gcdrem(x,y) to equal abs(x) is almost as natural as defining x^0 to be 1. Similarly, if x is not zero then gcdrem(x,0) == 1. @@ -3628,7 +3635,7 @@ Following is the change from calc version 2.10.1t11 to 2.10.1t19: Ha Lam -Following is the change from calc version 2.10.0t13 to 2.10.1t10: +The following are the changes from calc version 2.10.0t13 to 2.10.1t10: Added SB8, USB8, SB16, USB16, SB32, USB32 typedefs, determined by longbits and declared in longbits.h, to deal with 8, 16 and 32 bit @@ -3650,7 +3657,7 @@ Following is the change from calc version 2.10.0t13 to 2.10.1t10: and if HAVE_LONGLONG, in longbits.h if it is needed. The only place were a long long constant might be used is in longlong.c. Any long long constants, if HAVE_LONGLONG, are hidden under the U(x) and - L(x) macros on longbits.h. And of course, if you don't have long long, + L(x) macros on longbits.h. And of course, if you don't have long long, then HAVE_LONGLONG will NOT be defined and long long's will not be used. The longlong.h file is no longer directly used by the main calc source. @@ -3675,7 +3682,7 @@ Following is the change from calc version 2.10.0t13 to 2.10.1t10: the nonprincipal root rather than the principal value. If commands are given on the command line, leading tabs are not - printed in output. Giving a command on the command line implies + printed in output. Giving a command on the command line implies that config("tab",0) was given. Pipe processing is enabled by use of -p. For example: @@ -3745,7 +3752,8 @@ Following is the change from calc version 2.10.0t13 to 2.10.1t10: digits or bits rather than places, e.g. round(.00238, 2, 32) returns .0023, round(.00238, 2, 56) returns .0024. -Following is the change from calc version 2.9.3t11 to 2.10.0t12: + +The following are the changes from calc version 2.9.3t11 to 2.10.0t12: The default ${LIBDIR}/bindings CALCBINDINGS uses ^D for editing. The alternate CALCBINDINGS ${LIBDIR}/altbind uses ^D for EOF. @@ -3782,11 +3790,11 @@ Following is the change from calc version 2.9.3t11 to 2.10.0t12: stderr is re-directed to a non-file by some test suite. Changed how , or simulate stdarg is determined. - Changed how vsprintf() vs sprintf() is determined. The args.h file + Changed how vsprintf() vs sprintf() is determined. The args.h file is created by Makefile to test which combination works. Setting VARARG and/or HAVE_VSPRINTF in the Makefile will alter these tests and direct a specific combination to be used. Removed have_vs.c, - std_arg.h and try_stdarg.c. Added have_stdvs.c and have_varvs.c. + std_arg.h and try_stdarg.c. Added have_stdvs.c and have_varvs.c. Added 3rd optional arg to round(), bround(), appr() to specify the type of rounding to be used. @@ -3799,7 +3807,8 @@ Following is the change from calc version 2.9.3t11 to 2.10.0t12: to provide a more extensive test suite for some builtin numeric functions. -Following is the change from calc version 2.9.3t9.2+ to 2.9.3t10: + +The following are the changes from calc version 2.9.3t9.2+ to 2.9.3t10: Added many help files for builtin functions and some symbols. More help files are needed, see help/todo. @@ -3828,8 +3837,8 @@ Following is the change from calc version 2.9.3t9.2+ to 2.9.3t10: Fixed bug that caused: - global a,b,c (newline with no semicolon) - read test.cal + global a,b,c (newline with no semicolon) + read test.cal the read command to not be recognized. @@ -3902,7 +3911,8 @@ Following is the change from calc version 2.9.3t9.2+ to 2.9.3t10: { } -Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: + +The following are the changes from calc version 2.9.3t8 to 2.9.3t9.2: Use of the macro zisleone(z) has been clarified. The zisleone(z) macro tests if z <= 1. The macro zisabsleone(z) tests of z is 1, 0 or -1. @@ -3931,14 +3941,14 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: The second ptest() argument, which is now optional, defaults to 1. This ptest(x) is the same as ptest(x,1). - Added an optional 3rd argument to ptest(). The 3rd arg tells how many + Added an optional 3rd argument to ptest(). The 3rd arg tells how many tests to skip. Thus ptest(a,10) performs the same probabilistic tests as ptest(a,3) and ptest(a,7,3). The ptest() builtin by default will determine if a value is divisible - by a trivial prime. Thus, ptest(a,0) will only perform a quick trivial + by a trivial prime. Thus, ptest(a,0) will only perform a quick trivial factor check. If the test count is < 0, then this trivial factor check - is omitted. Thus ptest(a,10) performs the same amount of work as + is omitted. Thus ptest(a,10) performs the same amount of work as ptest(a,3) and ptest(a,-7,3) and the same amount of work as ptest(a,-3) and ptest(a,7,3). @@ -3949,7 +3959,7 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Added nextprime(x) and and prevprime(x) return the next and previous primes with respect to x respectively. As of this - release, x must be < 2^32. With one argument, they will return + release, x must be < 2^32. With one argument, they will return an error if x is out of range. With two arguments, they will not generate an error but instead will return y. @@ -3981,17 +3991,17 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: instead will return y. Added pix(x) to return the number of primes <= x. As of this - release, x must be < 2^32. With one argument, pix(x) will + release, x must be < 2^32. With one argument, pix(x) will return an error if x is out of range. With two arguments, pix(x,y) will not generate an error but instead will return y. - Fixed the way *.h files are formed. Each file guards against + Fixed the way *.h files are formed. Each file guards against multiple inclusion. Fixed numeric I/O on 64 bit systems. Previously the print and constant conversion routines assumed a base of 2^16. - Added support for 'long long' type. If the Makefile is setup + Added support for 'long long' type. If the Makefile is setup with 'LONGLONG_BITS=', then it will attempt to detect support for the 'long long' type. If the Makefile is setup with 'LONGLONG_BITS=64', then a 64 bit 'long long' is assumed. @@ -4007,7 +4017,7 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Fixed btrunc() limit. The ord("string") function can now take a string of multiple - characters. However it still will only operate on the first + characters. However it still will only operate on the first character. Renamed stdarg.h to std_arg.h and endian.h endian_calc.h to @@ -4017,15 +4027,15 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Added additive 55 shuffle generator functions rand(), randbits() and its seed function srand(). Calling rand(a,b) produces a random value over the open half interval [a,b). With one arg, - rand(a) is equivalent to rand(0,a). Calling rand() produces + rand(a) is equivalent to rand(0,a). Calling rand() produces 64 random bits and is equivalent to rand(0,2^64). Calling randbit(x>0) produces x random bits. Calling randbit(skip<0) skips -skip bits and returns -skip. - The srand() function will return the current state. The call - srand(0) returns the initial state. Calling srand(x), where - x > 0 will seed the generator to a different state. Calling + The srand() function will return the current state. The call + srand(0) returns the initial state. Calling srand(x), where + x > 0 will seed the generator to a different state. Calling srand(mat55) (mat55 is a matrix of integers at least 55 elements long) will seed the internal table with the matrix elements mod 2^64. Finally calling srand(state) where state is a generator state @@ -4077,7 +4087,7 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: a = 3 ++(b = a) (a == 3, b == 4) ++++a (a == 5) - (++a)++ == 6 (a == 7) + (++a)++ == 6 (a == 7) (++a) *= b (a == 32, b == 4) Fixed a bug related to calling epsilon(variable) thanks to ernie. @@ -4086,21 +4096,21 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Some compilers do not support the const type. The file have_const.h, which is built from have_const.c will determine if we can or should - use const. See the Makefile for details. + use const. See the Makefile for details. Some systems do not have uid_t. The file have_uid_t.h, which is built from have_uid_t.c will determine if we can or should depend - on uid_t being typefed by the system include files. See the Makefile + on uid_t being typefed by the system include files. See the Makefile for details. Some systems do not have memcpy(), memset() and strchr(). The file have_newstr.h, which is built from have_newstr.c will determine if we can or should depend libc providing these - functions. See the Makefile for details. + functions. See the Makefile for details. The Makefile symbol DONT_HAVE_VSPRINTF is now called HAVE_VSPRINTF. The file have_vs.h, which is built from have_vs.c will determine if - we can or should depend libc providing vsprintf(). See the Makefile + we can or should depend libc providing vsprintf(). See the Makefile for details. Removed UID_T and OLD_BSD symbols from the Makefile. @@ -4110,7 +4120,8 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Fixed bug where reserved keyword used as symbol name caused a core dump. -Following is the change from calc version 2.9.3t7 to 2.9.3t7: + +The following are the changes from calc version 2.9.3t7 to 2.9.3t7: The 'show' command by itself will issue an error message that will remind one of the possible show arguments. @@ -4143,7 +4154,7 @@ Following is the change from calc version 2.9.3t7 to 2.9.3t7: digit, ), matrix operations (size, index, creation), scaling, shifting, rounding and computing a Fibonacci number is 2^31. For example, one cannot raise a number by a power >= 2^31. - One cannot test for a bit position >= 2^31. One cannot round + One cannot test for a bit position >= 2^31. One cannot round a value to 2^31 decimal digit places. One cannot compute the Fibonacci number F(2^31). @@ -4157,12 +4168,13 @@ Following is the change from calc version 2.9.3t7 to 2.9.3t7: Added utoz(), ztou() to zmath.c, and utoq(), qtou() to qmath.c in preparation for 2.9.3t9 mods. -Following is the change from calc version 2.9.2 to 2.9.3t7: + +The following are the changes from calc version 2.9.2 to 2.9.3t7: Calc can now compile on OSF/1, SGI and IBM RS6000 systems. A number of systems that have both and do - not correctly implement both types. On some System V, MIPS and DEC + not correctly implement both types. On some System V, MIPS and DEC systems, vsprintf() and do not mix. While calc will pass the regression test, use of undefined variables will cause problems. The Makefile has been modified to look for this problem @@ -4175,20 +4187,20 @@ Following is the change from calc version 2.9.2 to 2.9.3t7: The library script nextprim.cal is now a link to nextprime.cal. The lib/Makefile will take care of this link and install. - The show command now takes singular forms. For example, the + The show command now takes singular forms. For example, the command 'show builtin' does the same as 'show builtins'. This allows show to match the historic singular names used in the help system. Synced 'show builtin' output with 'help builtin' output. - Fixed the ilog2() builtin. Previously ilog2(2^-20) returned + Fixed the ilog2() builtin. Previously ilog2(2^-20) returned -21 instead of -20. - The internal function qprecision() has been fixed. The changes + The internal function qprecision() has been fixed. The changes ensure that for any e for which 0 < e <= 1: - 1/4 < sup(abs(appr(x,e) - x))/e <= 1/2. + 1/4 < sup(abs(appr(x,e) - x))/e <= 1/2. Here 'sup' denotes the supremum or least upper bound over values of x. Previousld calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1. @@ -4226,7 +4238,7 @@ Following is the change from calc version 2.9.2 to 2.9.3t7: work-a-rounds involved initializing or making static, certain local variables. - The cryrand.cal library has been improved. Due to the way + The cryrand.cal library has been improved. Due to the way the initial quadratic residues are selected, the random numbers produced differ from previous versions. @@ -4245,7 +4257,7 @@ Following is the change from calc version 2.9.2 to 2.9.3t7: The value atan2(0,0) now returns 0 value in conformance with the 4.3BSD ANSI/IEEE 754-1985 math library. - For all values of x, x^0 yields 1. The major change here is + For all values of x, x^0 yields 1. The major change here is that 0^0 yields 1 instead of an error. Fixed gcd() bug that caused gcd(2,3,1/2) to ignore the 1/2 arg. @@ -4275,10 +4287,11 @@ Following is the change from calc version 2.9.2 to 2.9.3t7: The regression test code is now more extensive. - Updated the help/todo list. A BUGS file was added. Volunteers are + Updated the help/todo list. A BUGS file was added. Volunteers are welcome to send in patches! -Following is the change from calc version 2.9.1 to 2.9.1: + +The following are the changes from calc version 2.9.1 to 2.9.1: Fixed floor() for values -1 < x < 0. @@ -4292,12 +4305,14 @@ Following is the change from calc version 2.9.1 to 2.9.1: Added more regression test code. -Following is the change from calc version 2.9.0 to 2.9.0: + +The following are the changes from calc version 2.9.0 to 2.9.0: A major bug was fixed in subtracting two numbers when the first number was zero. The problem caused wrong answers and core dumps. -Following is a list of visible changes to calc from version 1.27.0 to 2.8.0: + +The following are the changes from calc version 1.27.0 to 2.8.0: Full prototypes have been provided for all C functions, and are used if calc is compiled with an ANSI compiler. @@ -4337,7 +4352,7 @@ Following is a list of visible changes to calc from version 1.27.0 to 2.8.0: statement, to immediately define a variable as an object. Object definitions can be repeated as long as they are exactly the same - as the previous definition. This allows the rereading of files which + as the previous definition. This allows the rereading of files which happen to define objects. The integer, rational, and complex routines have been made into a @@ -4369,15 +4384,15 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1: There is a new emacs-like command line editing and edit history feature. The old history mechanism has been removed. The key bindings for the new editing commands are slightly configurable - since they are read in from an initialization file. This file is + since they are read in from an initialization file. This file is usually called /usr/lib/calc/bindings, but can be changed by the - CALCBINDINGS environment variable. All editing code is + CALCBINDINGS environment variable. All editing code is self-contained in the new files hist.c and hist.h, which can be easily extracted and used in other programs. Two new library files have been added: chrem.cal and cryrand.cal. The first of these solves the chinese remainder problem for a set - of modulos and remainders. The second of these implements several + of modulos and remainders. The second of these implements several very good random number generators for large numbers. A small bug which allowed division by zero was fixed. diff --git a/HOWTO.INSTALL b/HOWTO.INSTALL index e9d8234..377e02d 100644 --- a/HOWTO.INSTALL +++ b/HOWTO.INSTALL @@ -21,7 +21,7 @@ Installing calc in 4 easy steps: The CALCBINDINGS is matter of personal taste. As shipped the Makefile assumes a default quasi-emacs-like command - line editor. Changing CALCBINDINGS= altbind will cause ^D + line editor. Changing CALCBINDINGS= altbind will cause ^D to end calc in a fashion similar to that of the bc(1) command. Set TOPDIR to be the place under which help files, calc, diff --git a/LIBRARY b/LIBRARY index 076b1c5..61718db 100644 --- a/LIBRARY +++ b/LIBRARY @@ -43,7 +43,7 @@ to use more than one type of arithmetic, since qmath.h automatically includes zmath.h, and cmath.h automatically includes qmath.h. The prototypes for the available routines are listed in the above include -files. Some of these routines are meant for internal use, and so aren't +files. Some of these routines are meant for internal use, and so aren't convenient for outside use. So you should read the source for a routine to see if it really does what you think it does. I won't guarantee that obscure internal routines won't change or disappear in future releases! @@ -60,7 +60,7 @@ External programs may want to compile with: ERROR HANDLING -------------- -Your program MUST provide a function called math_error. This is called by +Your program MUST provide a function called math_error. This is called by the math routines on an error condition, such as malloc failures or a division by zero. The routine is called in the manner of printf, with a format string and optional arguments. (However, none of the low level math @@ -142,7 +142,7 @@ output strings with space filling, output formatted strings like printf, and flush the output. Output from these routines is diverted as described above. You can change the default output mode by calling math_setmode, and you can -change the default number of digits printed by calling math_setdigits. These +change the default number of digits printed by calling math_setdigits. These routines return the previous values. The possible modes are described in zmath.h. @@ -154,7 +154,7 @@ The arbitrary precision integer routines define a structure called a ZVALUE. This is defined in zmath.h. A ZVALUE contains a pointer to an array of integers, the length of the array, and a sign flag. The array is allocated using malloc, so you need to free this array when you are done with a -ZVALUE. To do this, you should call zfree with the ZVALUE as an argument +ZVALUE. To do this, you should call zfree with the ZVALUE as an argument (or call freeh with the pointer as an argument) and never try to free the array yourself using free. The reason for this is that sometimes the pointer points to one of two statically allocated arrays which should NOT be freed. @@ -248,7 +248,7 @@ If the value is too large for ztofull(), ztoulong() or ztolong(), only the low order bits converted. There are two types of comparisons you can make on ZVALUEs. This is whether -or not they are equal, or the ordering on size of the numbers. The zcmp +or not they are equal, or the ordering on size of the numbers. The zcmp function tests whether two ZVALUEs are equal, returning TRUE if they differ. The zrel function tests the relative sizes of two ZVALUEs, returning -1 if the first one is smaller, 0 if they are the same, and 1 if the first one @@ -267,7 +267,7 @@ is always positive. If the NUMBER is an integer, the denominator has the value 1. Unlike ZVALUEs, NUMBERs are passed using pointers, and pointers to them are -returned by functions. So the basic type for using fractions is not really +returned by functions. So the basic type for using fractions is not really (NUMBER), but is (NUMBER *). NUMBERs are allocated using the qalloc routine. This returns a pointer to a number which has the value 1. Because of the special property of a ZVALUE of 1, the numerator and denominator of this @@ -283,7 +283,7 @@ A better way to create NUMBERs with particular values is to use the itoq, iitoq, or atoq functions. Using itoq makes a long value into a NUMBER, using iitoq makes a pair of longs into the numerator and denominator of a NUMBER (reducing them first if needed), and atoq converts a string representing -a number into the corresponding NUMBER. The atoq function accepts input in +a number into the corresponding NUMBER. The atoq function accepts input in integral, fractional, real, or exponential formats. Examples of allocating numbers are: @@ -294,7 +294,7 @@ numbers are: q3 = atoq("456.78"); Also unlike ZVALUEs, NUMBERs are quickly copied. This is because they contain -a link count, which is the number of pointers there are to the NUMBER. The +a link count, which is the number of pointers there are to the NUMBER. The qlink macro is used to copy a pointer to a NUMBER, and simply increments the link count and returns the same pointer. Since it is a macro, the argument should not be a function call, but a real pointer variable. The @@ -329,11 +329,11 @@ denominator, qint to return the integer part of, qfrac to return the fractional part of, and qinv to invert a fraction. There are some transcendental functions in the library, such as sin and cos. -These cannot be evaluated exactly as fractions. Therefore, they accept -another argument which tells how accurate you want the result. This is an +These cannot be evaluated exactly as fractions. Therefore, they accept +another argument which tells how accurate you want the result. This is an "epsilon" value, and the returned value will be within that quantity of the correct value. This is usually an absolute difference, but for some -functions (such as exp), this is a relative difference. For example, to +functions (such as exp), this is a relative difference. For example, to calculate sin(0.5) to 100 decimal places, you could do: NUMBER *q, *ans, *epsilon; @@ -363,7 +363,7 @@ macros are: The comparisons for NUMBERs are similar to the ones for ZVALUEs. You use the qcmp and qrel functions. -There are four predefined values for fractions. You should qlink them when +There are four predefined values for fractions. You should qlink them when you want to use them. These are _qzero_, _qone_, _qnegone_, and _qonehalf_. These have the values 0, 1, -1, and 1/2. An example of using them is: @@ -377,7 +377,7 @@ USING COMPLEX NUMBERS --------------------- The arbitrary precision complex arithmetic routines define a structure -called COMPLEX. This is defined in cmath.h. This contains two NUMBERs +called COMPLEX. This is defined in cmath.h. This contains two NUMBERs for the real and imaginary parts of a complex number, and a count of the number of links there are to this COMPLEX number. @@ -410,7 +410,7 @@ There is no direct routine to convert a string value into a COMPLEX value. But you can do this yourself by converting two strings into two NUMBERS, and then using the qqtoc routine. -COMPLEX values are always returned from these routines. To split out the +COMPLEX values are always returned from these routines. To split out the real and imaginary parts into normal NUMBERs, you can simply qlink the two components, as shown in the following example: @@ -423,7 +423,7 @@ two components, as shown in the following example: There are many macros for checking quick things about complex numbers, similar to the ZVALUE and NUMBER macros. In addition, there are some -only used for complex numbers. Examples of macros are: +only used for complex numbers. Examples of macros are: cisreal(c) (number is real) cisimag(c) (number is pure imaginary) @@ -441,8 +441,8 @@ only used for complex numbers. Examples of macros are: There is only one comparison you can make for COMPLEX values, and that is for equality. The ccmp function returns TRUE if two complex numbers differ. -There are three predefined values for complex numbers. You should clink -them when you want to use them. They are _czero_, _cone_, and _conei_. +There are three predefined values for complex numbers. You should clink +them when you want to use them. They are _czero_, _cone_, and _conei_. These have the values 0, 1, and i. ---------------- diff --git a/Makefile b/Makefile index 5d4759b..e825838 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,12 @@ # Determine the type of terminal controls that you want to use # -# value meaning +# value meaning # -------- ------- # (nothing) let the makefile guess at what you need # -DUSE_TERMIOS use struct termios from -# -DUSE_TERMIO use struct termios from -# -DUSE_SGTTY use struct sgttyb from +# -DUSE_TERMIO use struct termios from +# -DUSE_SGTTY use struct sgttyb from # # If in doubt, leave TERMCONTROL empty. # @@ -41,7 +41,7 @@ TERMCONTROL= # for the best. # # If HAVE_VSPRINTF is empty, this makefile will run the have_stdvs.c and/or -# have_varvs.c program to determine if vsprintf() is supported. If +# have_varvs.c program to determine if vsprintf() is supported. If # HAVE_VSPRINTF is set to -DDONT_HAVE_VSPRINTF then calc will hope that # sprintf() will work. # @@ -55,12 +55,12 @@ HAVE_VSPRINTF= # Big Endian: Amdahl, 68k, Pyramid, Mips, Sparc, ... # Little Endian: Vax, 32k, Spim (Dec Mips), i386, i486, ... # -# If in doubt, leave BYTE_ORDER empty. This makefile will attempt to +# If in doubt, leave BYTE_ORDER empty. This makefile will attempt to # use BYTE_ORDER in or it will attempt to run # the endian program. If you get syntax errors when you compile, # try forcing the value to be BIG_ENDIAN and run the calc regression -# tests. (see the README file) If the calc regression tests fail, do -# a make clobber and try LITTLE_ENDIAN. If that fails, ask a wizard +# tests. (see the README file) If the calc regression tests fail, do +# a make clobber and try LITTLE_ENDIAN. If that fails, ask a wizard # for help. # BYTE_ORDER= @@ -112,7 +112,7 @@ HAVE_FPOS= #HAVE_FPOS= -DHAVE_NO_FPOS # Determine if we have an off_t which one can perform arithmetic operations, -# assignments and comparisons. On some systems off_t is some sort of union +# assignments and comparisons. On some systems off_t is some sort of union # or struct. # # If HAVE_OFFSCL is empty, this makefile will run the have_offscl program @@ -126,7 +126,7 @@ HAVE_OFFSCL= #HAVE_OFFSCL= -DOFF_T_NON_SCALAR # Determine if we have an fpos_t which one can perform arithmetic operations, -# assignments and comparisons. On some systems fpos_t is some sort of union +# assignments and comparisons. On some systems fpos_t is some sort of union # or struct. Some systems do not have an fpos_t and long is as a file # offset instead. # @@ -192,7 +192,7 @@ HAVE_MEMMOVE= # Determine if we have ustat() # # If HAVE_USTAT is empty, this makefile will run the have_memmv program -# to determine if ustat() is supported. If HAVE_USTAT is set to +# to determine if ustat() is supported. If HAVE_USTAT is set to # -DHAVE_NO_USTAT, then calc will use internal functions to simulate # the memory move function that does correct overlapping memory modes. # @@ -228,7 +228,7 @@ HAVE_GETPGID= # Determine if we have clock_gettime() # # If HAVE_GETTIME is empty, this makefile will run the have_memmv program -# to determine if clock_gettime() is supported. If HAVE_GETTIME is set to +# to determine if clock_gettime() is supported. If HAVE_GETTIME is set to # -DHAVE_NO_GETTIME, then calc will use internal functions to simulate # the memory move function that does correct overlapping memory modes. # @@ -289,7 +289,7 @@ HAVE_STRDUP= # that are not alligned on a 32 bit boundary. # # The Dec Alpha running OSF/1 will produce alignment error messages when -# align32.c tries to figure out if alignment is needed. Use the +# align32.c tries to figure out if alignment is needed. Use the # ALIGN32= -DMUST_ALIGN32 to force alignment and avoid such error messages. # # ALIGN32= let align32.c figure out if alignment is needed @@ -426,8 +426,8 @@ CALCBINDINGS= bindings # and history libs # READLINE_INCLUDE Where the readline include files reside # -# NOTE: The GNU-readline code is not shipped with calc. You must have -# the appropriate headers and libs installed on your system in +# NOTE: The GNU-readline code is not shipped with calc. You must have +# the appropriate headers and libs installed on your system in # order to use it. # # If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing. @@ -483,7 +483,7 @@ DEBUG= -O2 -g3 # BSD NO_SHARED= # SYSV NO_SHARED= -dn # IRIX NO_SHARED= -non_shared -# disable NO_SHARED= +# disable NO_SHARED= # # If in doubt, use NO_SHARED= # @@ -494,11 +494,11 @@ NO_SHARED= # On some systems where you are disabling dynamic shared libs, you may # need to pass a special flag to ${CC} and ${LCC} during linking stage. # -# System type NO_SHARED recommendation +# System type NO_SHARED recommendation # # IRIX with NO_SHARED= -non_shared LD_NO_SHARED= -Wl,-rdata_shared # IRIX with NO_SHARED= LD_NO_SHARED= -# others LD_NO_SHARED= +# others LD_NO_SHARED= # # If in doubt, use LD_NO_SHARED= # @@ -520,7 +520,7 @@ RANLIB=ranlib # # BSD ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -Ccalc # SYSV ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -o calc -# disable : +# disable : # # If in doubt and you don't care about lint, use LINTLIB= : # @@ -529,10 +529,10 @@ RANLIB=ranlib LINTLIB= : # The lint flags vary from system to system. Some systems have the -# opposite meaning for the flags below. Other systems change flag +# opposite meaning for the flags below. Other systems change flag # meaning altogether. # -# System LINTFLAGS recommendation +# System LINTFLAGS recommendation # # SunOs -a -h -v -z # @@ -542,7 +542,7 @@ LINTLIB= : LINTFLAGS= # Normally certain files depend on the Makefile. If the Makefile is -# changed, then certain steps should be redone. If MAKE_FILE is +# changed, then certain steps should be redone. If MAKE_FILE is # set to Makefile, then these files will depend on Makefile. If # MAKE_FILE is empty, they they wont. # @@ -593,7 +593,7 @@ CALC_ENV= CALCPATH=./lib # By default, custom builtin functions may only be executed if calc # is given the -C option. This is because custom builtin functions -# may invoke non-standard or non-portable code. One may completely +# may invoke non-standard or non-portable code. One may completely # disable custom builtin functions by not compiling any of code # # ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given @@ -1079,7 +1079,7 @@ TARGETS= ${CALC_LIBS} custom/.all calc sample/sample \ ### # -# The reason for this Makefile :-) +# The reason for this Makefile :-) # ### @@ -1286,9 +1286,9 @@ have_malloc.h: ${MAKE_FILE} ${Q}echo '' >> have_malloc.h ${Q}echo '/* do we have /usr/include/malloc.h? */' >> have_malloc.h -${Q}if [ -f /usr/include/malloc.h ]; then \ - echo '#define HAVE_MALLOC_H /* yes */' >> have_malloc.h; \ + echo '#define HAVE_MALLOC_H /* yes */' >> have_malloc.h; \ else \ - echo '#undef HAVE_MALLOC_H /* no */' >> have_malloc.h; \ + echo '#undef HAVE_MALLOC_H /* no */' >> have_malloc.h; \ fi ${Q}echo '' >> have_malloc.h ${Q}echo '' >> have_malloc.h @@ -1318,7 +1318,7 @@ have_times.h: ${MAKE_FILE} ${Q}echo '' >> have_times.h ${Q}echo '/* do we have /usr/include/times.h? */' >> have_times.h -${Q}if [ -f /usr/include/times.h ]; then \ - echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ + echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ else \ echo '#undef HAVE_TIMES_H /* no */' >> have_times.h; \ fi @@ -1365,9 +1365,9 @@ have_stdlib.h: ${MAKE_FILE} ${Q}echo '' >> have_stdlib.h ${Q}echo '/* do we have /usr/include/stdlib.h? */' >> have_stdlib.h -${Q}if [ -f /usr/include/stdlib.h ]; then \ - echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ + echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ else \ - echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ + echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ fi ${Q}echo '' >> have_stdlib.h ${Q}echo '' >> have_stdlib.h @@ -1397,9 +1397,9 @@ have_unistd.h: ${MAKE_FILE} ${Q}echo '' >> have_unistd.h ${Q}echo '/* do we have /usr/include/unistd.h? */' >> have_unistd.h -${Q}if [ -f /usr/include/unistd.h ]; then \ - echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ + echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ else \ - echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ + echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ fi ${Q}echo '' >> have_unistd.h ${Q}echo '' >> have_unistd.h @@ -1429,9 +1429,9 @@ have_string.h: ${MAKE_FILE} ${Q}echo '' >> have_string.h ${Q}echo '/* do we have /usr/include/string.h? */' >> have_string.h -${Q}if [ -f /usr/include/string.h ]; then \ - echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ + echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ else \ - echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ + echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ fi ${Q}echo '' >> have_string.h ${Q}echo '' >> have_string.h @@ -2102,7 +2102,7 @@ have_urandom.h: ${MAKE_FILE} -${Q}if [ -c /dev/urandom ]; then \ echo '#define HAVE_URANDOM_H /* yes */' >> have_urandom.h; \ else \ - echo '#undef HAVE_URANDOM_H /* no */' >> have_urandom.h; \ + echo '#undef HAVE_URANDOM_H /* no */' >> have_urandom.h; \ fi ${Q}echo '' >> have_urandom.h ${Q}echo '' >> have_urandom.h @@ -2428,7 +2428,7 @@ sample/all: ## # # The BSDI cdrom makefile expects certain files to be pre-built in a sub-dir -# called gen_h. This rule creats this sub-directory so that the release can +# called gen_h. This rule creats this sub-directory so that the release can # be shipped off to BSDI. You can ignore this rule. # ## @@ -2498,7 +2498,7 @@ depend: hsrc -${Q}rm -rf skel ${Q}mkdir skel -${Q}for i in ${C_SRC} ${BUILD_C_SRC}; do \ - ${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" > "skel/$$i"; \ + ${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" > "skel/$$i"; \ done ${Q}mkdir skel/custom -${Q}for i in ${H_SRC} ${BUILD_H_SRC} custom.h; do \ diff --git a/README b/README index d01e01d..93ead49 100644 --- a/README +++ b/README @@ -27,7 +27,7 @@ If you run into problems, see the BUGS file. Calc is distributed with an extensive collection of help files that are accessible from the command line. The following assume that you are running calc from the distribution directory or that you have -installed calc. In these examples, the ">" is the calc prompt, not +installed calc. In these examples, the ">" is the calc prompt, not something that you type in. For list of help topics: @@ -52,7 +52,7 @@ C programmers should note some unexpected differences in the calc syntax: > help unexpected -Calc is shipped with a library of calc scripts. For a list see: +Calc is shipped with a library of calc scripts. For a list see: > help stdlib diff --git a/addop.c b/addop.c index 61af125..2549d8d 100644 --- a/addop.c +++ b/addop.c @@ -16,8 +16,8 @@ #include "symbol.h" -#define FUNCALLOCSIZE 20 /* reallocate size for functions */ -#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */ +#define FUNCALLOCSIZE 20 /* reallocate size for functions */ +#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */ static long maxopcodes; /* number of opcodes available */ @@ -168,7 +168,7 @@ endfunc(void) if ((inputisterminal() && conf->lib_debug & LIBDBG_STDIN_FUNC) || (!inputisterminal() && conf->lib_debug & LIBDBG_FILE_FUNC)) { printf("%s(", fp->f_name); - for (index = 0; index < fp->f_paramcount; index++) { + for (index = 0; index < fp->f_paramcount; index++) { if (index) putchar(','); printf("%s", paramname(index)); @@ -291,12 +291,12 @@ rmalluserfunc(void) long getuserfunc(char *name) { - long index; + long index; - index = findstr(&funcnames, name); - if (index >= 0 && functions[index] != NULL) - return index; - return -1L; + index = findstr(&funcnames, name); + if (index >= 0 && functions[index] != NULL) + return index; + return -1L; } @@ -535,8 +535,7 @@ addop(long op) qfree(q); fp->f_opcodes[count - 2] = OP_ZERO; fp->f_opcodecount--; - } - else if (qisone(q)) { + } else if (qisone(q)) { qfree(q); fp->f_opcodes[count - 2] = OP_ONE; fp->f_opcodecount--; @@ -639,5 +638,3 @@ addoplabel(long op, LABEL *label) addop(op); uselabel(label); } - -/* END CODE */ diff --git a/align32.c b/align32.c index 20616cc..e48b392 100644 --- a/align32.c +++ b/align32.c @@ -12,11 +12,11 @@ * copyright this code. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -70,7 +70,7 @@ main(void) * buserr - catch an alignment error * * given: - * arg to keep ANSI C happy + * arg to keep ANSI C happy */ /*ARGSUSED*/ static void diff --git a/assocfunc.c b/assocfunc.c index 380567c..b58b10d 100644 --- a/assocfunc.c +++ b/assocfunc.c @@ -14,10 +14,10 @@ #include "value.h" -#define MINHASHSIZE 31 /* minimum size of hash tables */ -#define GROWHASHSIZE 50 /* approximate growth for hash tables */ -#define CHAINLENGTH 10 /* desired number of elements on a hash chain */ -#define ELEMSIZE(n) (sizeof(ASSOCELEM) + (sizeof(VALUE) * ((n) - 1))) +#define MINHASHSIZE 31 /* minimum size of hash tables */ +#define GROWHASHSIZE 50 /* approximate growth for hash tables */ +#define CHAINLENGTH 10 /* desired number of elements on a hash chain */ +#define ELEMSIZE(n) (sizeof(ASSOCELEM) + (sizeof(VALUE) * ((n) - 1))) static ASSOCELEM *elemindex(ASSOC *ap, long index); @@ -245,8 +245,7 @@ assoccmp(ASSOC *ap1, ASSOC *ap2) hash = ep1->e_hash; dim = ep1->e_dim; for (ep2 = ap2->a_table[hash % size2]; ; - ep2 = ep2->e_next) - { + ep2 = ep2->e_next) { if (ep2 == NULL) return TRUE; if (ep2->e_hash != hash) @@ -283,8 +282,7 @@ assoccopy(ASSOC *oldap) for (oldhi = 0; oldhi < oldap->a_size; oldhi++) { for (oldep = oldap->a_table[oldhi]; oldep; - oldep = oldep->e_next) - { + oldep = oldep->e_next) { ep = (ASSOCELEM *) malloc(ELEMSIZE(oldep->e_dim)); if (ep == NULL) { math_error("Cannot allocate association element"); @@ -449,8 +447,7 @@ assocprint(ASSOC *ap, long max_print) ((ap->a_count == 1) ? "" : "s")); for (index = 0; ((index < max_print) && (index < ap->a_count)); - index++) - { + index++) { ep = elemindex(ap, index); if (ep == NULL) continue; @@ -491,5 +488,3 @@ compareindices(VALUE *v1, VALUE *v2, long dim) return TRUE; } - -/* END CODE */ diff --git a/blkcpy.c b/blkcpy.c index 283932b..8005af6 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -547,7 +547,7 @@ copylist2list(LIST *slp, long ssi, long num, LIST *dlp, long dsi) int copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) { - FILEIO *fiop; + FILEIO *fiop; FILE *fp; unsigned int numw; @@ -563,7 +563,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) return E_COPYF1; fp = fiop->fp; if (id == 1 || id == 2) { - numw = idfputstr(id, (char *)sblk->data + ssi); /* XXX */ + numw = idfputstr(id, (char *)sblk->data + ssi); /* XXX */ return 0; } if (dsi >= 0) { @@ -584,7 +584,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) int copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc) { - FILEIO *fiop; + FILEIO *fiop; FILE *fp; unsigned int numw; ZVALUE fsize; @@ -672,7 +672,7 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi) return E_COPYF1; fp = fiop->fp; if (id == 1 || id == 2) { - numw = idfputstr(id, str->s_str + ssi); /* XXX */ + numw = idfputstr(id, str->s_str + ssi); /* XXX */ return 0; } if (dsi >= 0) { @@ -830,7 +830,7 @@ int copyostr2str(char *sstr, long ssi, long num, STRING *dstr, long dsi) { long len; - char *c, *c1; + char *c, *c1; len = (long)strlen(sstr); @@ -898,8 +898,8 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc) * Copying between objects that overlap will take place correctly. * * given: - * s1 destination - * s2 source + * s1 destination + * s2 source * n octet count * * returns: @@ -959,7 +959,7 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi, BOOL norelo long newsize; USB8 *newdata; #if CALC_BYTE_ORDER == BIG_ENDIAN - ZVALUE *swnum; /* byte swapped numerator */ + ZVALUE *swnum; /* byte swapped numerator */ #endif if (ssi > snum->num.len) diff --git a/blkcpy.h b/blkcpy.h index 6443732..6f4acab 100644 --- a/blkcpy.h +++ b/blkcpy.h @@ -8,7 +8,7 @@ #if !defined(__BLKCPY_H__) -#define __BLKCPY_H__ +#define __BLKCPY_H__ /* * the main copy gateway function diff --git a/block.c b/block.c index 1742614..010b487 100644 --- a/block.c +++ b/block.c @@ -23,7 +23,7 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -141,7 +141,7 @@ blk_free(BLOCK *blk) /* * blkchk - check the sanity of a block * - * These checks should never fail if calc is working correctly. During + * These checks should never fail if calc is working correctly. During * debug time, we plan to call this function often. Once we are satisfied, * we will normally call this code only in a few places. * @@ -205,13 +205,13 @@ blkchk(BLOCK *blk) * * Reallocation of a block can change several aspects of a block. * - * It can change the much data it holds or can hold. + * It can change the much data it holds or can hold. * - * It can change the memory footprint (in terms of - * how much storage is malloced for current or future use). + * It can change the memory footprint (in terms of + * how much storage is malloced for current or future use). * * It can change the chunk size used to grow malloced size - * as the data size grows. + * as the data size grows. * * Each of the len and chunksize may be kept the same. * @@ -329,7 +329,7 @@ blkrealloc(BLOCK *blk, int newlen, int newchunk) /* * blktrunc - truncate a BLOCK down to a minimal fixed block * - * NOTE: THIS IS NOT THE INTERNAL CALC FREE FUNCTION!! This + * NOTE: THIS IS NOT THE INTERNAL CALC FREE FUNCTION!! This * is what blktrunc() builtin calls to reduce storage of a block * down to an absolute minimum. * @@ -479,7 +479,7 @@ blk_print(BLOCK *blk) BOOL havetail; USB8 *ptr; - /* XXX - use the config parameters for better print control */ + /* XXX - should use the config parameters for better print control */ printf("chunksize = %d, maxsize = %d, datalen = %d\n\t", (int)blk->blkchunk, (int)blk->maxsize, (int)blk->datalen); @@ -512,9 +512,9 @@ nblock_print(NBLOCK *nblk) printf("chunksize = %d, maxsize = %d, datalen = %d\n\t", (int)blk->blkchunk, (int)blk->maxsize, (int)blk->datalen); printf("NULL"); - } - else + } else { blk_print(blk); + } } @@ -556,8 +556,7 @@ reallocnblock(int id, int len, int chunk) math_error("Allocation failed"); /*NOTREACHED*/ } - } - else if (newsize != oldsize) { + } else if (newsize != oldsize) { newdata = realloc(blk->data, newsize); if (newdata == NULL) { math_error("Reallocation failed"); @@ -719,7 +718,7 @@ findnblock(int id) /* * Create a new block with specified newlen and new chunksize and copy - * min(newlen, oldlen) octets to the new block. The old block is + * min(newlen, oldlen) octets to the new block. The old block is * not changed. */ BLOCK * @@ -730,7 +729,7 @@ copyrealloc(BLOCK *blk, int newlen, int newchunk) oldlen = blk->datalen; - if (newlen < 0) /* retain length */ + if (newlen < 0) /* retain length */ newlen = oldlen; if (newchunk < 0) /* retain chunksize */ diff --git a/block.h b/block.h index 94febb3..b5dcc7f 100644 --- a/block.h +++ b/block.h @@ -23,7 +23,7 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -35,7 +35,7 @@ #if !defined(__BLOCK_H__) -#define __BLOCK_H__ +#define __BLOCK_H__ /* @@ -139,8 +139,8 @@ * style of output = { * "line", lines in blkbase with no spaces between octets * "string", as one long line with no spaces between octets - * "od_style", position, spaces between octets - * "hd_style"} position, spaces between octets, chars on end + * "od_style", position, spaces between octets + * "hd_style"} position, spaces between octets, chars on end */ struct block { LEN blkchunk; /* allocation chunk size */ diff --git a/byteswap.c b/byteswap.c index 25888fb..011ee30 100644 --- a/byteswap.c +++ b/byteswap.c @@ -28,9 +28,9 @@ * swap_b8_in_HALFs - swap 8 and if needed, 16 bits in an array of HALFs * * given: - * dest - pointer to where the swapped src wil be put or + * dest - pointer to where the swapped src wil be put or * NULL to allocate the storage - * src - pointer to a HALF array to swap + * src - pointer to a HALF array to swap * len - length of the src HALF array * * returns: @@ -263,9 +263,9 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) * swap_b16_in_HALFs - swap 16 bits in an array of HALFs * * given: - * dest - pointer to where the swapped src wil be put or + * dest - pointer to where the swapped src wil be put or * NULL to allocate the storage - * src - pointer to a HALF array to swap + * src - pointer to a HALF array to swap * len - length of the src HALF array * * returns: diff --git a/calc.c b/calc.c index 33b8aac..debf7a4 100644 --- a/calc.c +++ b/calc.c @@ -394,7 +394,7 @@ main(int argc, char **argv) printf("DEBUG: run_state from %s to %s\n", run_state_name(run_state), run_state_name(RUN_EXIT_WITH_ERROR)); - run_state = RUN_EXIT_WITH_ERROR; + run_state = RUN_EXIT_WITH_ERROR; } } } diff --git a/calc.h b/calc.h index 5a76c0c..2e419ae 100644 --- a/calc.h +++ b/calc.h @@ -8,7 +8,7 @@ #if !defined(__CALC_H__) -#define __CALC_H__ +#define __CALC_H__ #include @@ -20,42 +20,42 @@ /* * Configuration definitions */ -#define CALCPATH "CALCPATH" /* environment variable for files */ -#define CALCRC "CALCRC" /* environment variable for startup */ -#define CALCBINDINGS "CALCBINDINGS" /* environment variable for hist bindings */ -#define HOME "HOME" /* environment variable for home dir */ -#define PAGER "PAGER" /* environment variable for help */ -#define SHELL "SHELL" /* environment variable for shell */ -#define DEFAULTCALCHELP "help" /* help file that -h prints */ +#define CALCPATH "CALCPATH" /* environment variable for files */ +#define CALCRC "CALCRC" /* environment variable for startup */ +#define CALCBINDINGS "CALCBINDINGS" /* environment variable for hist bindings */ +#define HOME "HOME" /* environment variable for home dir */ +#define PAGER "PAGER" /* environment variable for help */ +#define SHELL "SHELL" /* environment variable for shell */ +#define DEFAULTCALCHELP "help" /* help file that -h prints */ #define DEFAULTSHELL "sh" /* default shell to use */ -#define CALCEXT ".cal" /* extension for files read in */ -#define MAX_CALCRC 1024 /* maximum length of $CALCRC */ -#define HOMECHAR '~' /* char which indicates home directory */ +#define CALCEXT ".cal" /* extension for files read in */ +#define MAX_CALCRC 1024 /* maximum length of $CALCRC */ +#define HOMECHAR '~' /* char which indicates home directory */ #define DOTCHAR '.' /* char which indicates current directory */ -#define PATHCHAR '/' /* char which separates path components */ -#define LISTCHAR ':' /* char which separates paths in a list */ -#define MAXCMD 16384 /* maximum length of command invocation */ -#define MAXERROR 512 /* maximum length of error message string */ +#define PATHCHAR '/' /* char which separates path components */ +#define LISTCHAR ':' /* char which separates paths in a list */ +#define MAXCMD 16384 /* maximum length of command invocation */ +#define MAXERROR 512 /* maximum length of error message string */ -#define SYMBOLSIZE 256 /* maximum symbol name size */ -#define MAXINDICES 20 /* maximum number of indices for objects */ -#define MAXLABELS 100 /* maximum number of user labels in function */ -#define MAXSTRING 1024 /* maximum size of string constant */ -#define MAXSTACK 1000 /* maximum depth of evaluation stack */ -#define MAXFILES 20 /* maximum number of opened files */ +#define SYMBOLSIZE 256 /* maximum symbol name size */ +#define MAXINDICES 20 /* maximum number of indices for objects */ +#define MAXLABELS 100 /* maximum number of user labels in function */ +#define MAXSTRING 1024 /* maximum size of string constant */ +#define MAXSTACK 1000 /* maximum depth of evaluation stack */ +#define MAXFILES 20 /* maximum number of opened files */ #define PROMPT1 "> " /* default normal prompt*/ #define PROMPT2 ">> " /* default prompt inside multi-line input */ -#define TRACE_NORMAL 0x00 /* normal trace flags */ -#define TRACE_OPCODES 0x01 /* trace every opcode */ -#define TRACE_NODEBUG 0x02 /* suppress debugging opcodes */ +#define TRACE_NORMAL 0x00 /* normal trace flags */ +#define TRACE_OPCODES 0x01 /* trace every opcode */ +#define TRACE_NODEBUG 0x02 /* suppress debugging opcodes */ #define TRACE_LINKS 0x04 /* display links for real and complex numbers */ #define TRACE_FNCODES 0x08 /* display code for newly defined function */ -#define TRACE_MAX 0x0f /* maximum value for trace flag */ +#define TRACE_MAX 0x0f /* maximum value for trace flag */ #define ABORT_NONE 0 /* abort not needed yet */ -#define ABORT_STATEMENT 1 /* abort on statement boundary */ +#define ABORT_STATEMENT 1 /* abort on statement boundary */ #define ABORT_OPCODE 2 /* abort on any opcode boundary */ #define ABORT_MATH 3 /* abort on any math operation */ #define ABORT_NOW 4 /* abort right away */ @@ -65,10 +65,10 @@ /* * File ids corresponding to standard in, out, error, and when not in use. */ -#define FILEID_STDIN ((FILEID) 0) -#define FILEID_STDOUT ((FILEID) 1) -#define FILEID_STDERR ((FILEID) 2) -#define FILEID_NONE ((FILEID) -1) +#define FILEID_STDIN ((FILEID) 0) +#define FILEID_STDOUT ((FILEID) 1) +#define FILEID_STDERR ((FILEID) 2) +#define FILEID_NONE ((FILEID) -1) /* * File I/O routines. @@ -192,7 +192,7 @@ extern int errmax; /* if >= 0, error when errcount exceeds errmax */ extern int new_std; /* TRUE (-n) => use newstd configuration */ extern int allow_read; /* FALSE => may not open any files for reading */ -extern int allow_write; /* FALSE => may not open any files for writing */ +extern int allow_write; /* FALSE => may not open any files for writing */ extern int allow_exec; /* FALSE => may not execute any commands */ /* diff --git a/calc.man b/calc.man index 1c3124f..ee62e75 100644 --- a/calc.man +++ b/calc.man @@ -340,7 +340,7 @@ Normally on startup, attempts to execute a collection of library scripts. The environment variable $CALCRC (if non-existent -then a compiled in value) contains a : separated list of startup +then a compiled in value) contains a : separated list of startup library scripts. No error conditions are produced if these startup library scripts are not found. @@ -589,7 +589,7 @@ Ernest also supplied the original text for many of the help files. .sp Portions of this program are derived from an earlier set of public domain arbitrarily precision routines which was posted -to the net around 1984. By now, there is almost no recognizable +to the net around 1984. By now, there is almost no recognizable code left from that original source. .sp Most of this source and binary has one of the following copyrights: @@ -632,7 +632,7 @@ calc-bugs at postofc dot corp dot sgi dot com .sp See the .I BUGS -source file or use the +source file or use the .I calc command: .sp diff --git a/calcerr_c.awk b/calcerr_c.awk index 331acf8..c2e5490 100644 --- a/calcerr_c.awk +++ b/calcerr_c.awk @@ -6,12 +6,12 @@ BEGIN { printf(" * names of calc error values\n"); printf(" */\n"); printf("CONST char *error_table[E__COUNT+2] = {\n"); - printf(" \"No error\",\n"); + printf(" \"No error\",\n"); } { print $0; } END { - printf(" NULL\n"); + printf(" NULL\n"); printf("};\n"); } diff --git a/check.awk b/check.awk index 1b5512b..1fc42bf 100644 --- a/check.awk +++ b/check.awk @@ -1,5 +1,5 @@ # This awk script will print 3 lines before and after any non-blank line that -# does not begin with a number. This allows the 'make debug' rule to remove +# does not begin with a number. This allows the 'make debug' rule to remove # all non-interest lines the the 'make check' regression output while providing # 3 lines of context around unexpected output. # diff --git a/cmath.h b/cmath.h index f4ffebe..5fe9afb 100644 --- a/cmath.h +++ b/cmath.h @@ -8,7 +8,7 @@ #if !defined(__CMATH_H__) -#define __CMATH_H__ +#define __CMATH_H__ #include "qmath.h" @@ -114,7 +114,7 @@ extern COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all); #define cisnegone(c) (cisreal(c) && qisnegone((c)->real)) #define cisrunit(c) (cisreal(c) && qisunit((c)->real)) #define cisiunit(c) (qiszero((c)->real) && qisunit((c)->imag)) -#define cisunit(c) (cisrunit(c) || cisiunit(c)) +#define cisunit(c) (cisrunit(c) || cisiunit(c)) #define cistwo(c) (cisreal(c) && qistwo((c)->real)) #define cisint(c) (qisint((c)->real) && qisint((c)->imag)) #define ciseven(c) (qiseven((c)->real) && qiseven((c)->imag)) diff --git a/codegen.c b/codegen.c index 60e7ae8..e880081 100644 --- a/codegen.c +++ b/codegen.c @@ -180,8 +180,8 @@ getcommands(BOOL toplevel) /* * Evaluate a line of statements. * This is done by treating the current line as a function body, - * compiling it, and then executing it. Returns TRUE if the line - * successfully compiled and executed. The last expression result + * compiling it, and then executing it. Returns TRUE if the line + * successfully compiled and executed. The last expression result * is saved in the f_savedvalue element of the current function. * The nestflag variable should be FALSE for the outermost evaluation * level, and TRUE for all other calls (such as the 'eval' function). @@ -956,7 +956,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d /* * Read in an object declaration. * This is of the following form: - * OBJ type [ '{' id [ ',' id ] ... '}' ] [ objlist ]. + * OBJ type [ '{' id [ ',' id ] ... '}' ] [ objlist ]. * The OBJ keyword has already been read. Symtype is SYM_UNDEFINED if this * is an OBJ statement, otherwise this is part of a declaration which will * define new symbols with the specified type. @@ -1305,7 +1305,7 @@ getcondition(void) /* * Get an expression list consisting of one or more expressions, - * separated by commas. The value of the list is that of the final expression. + * separated by commas. The value of the list is that of the final expression. * This is the top level routine for parsing expressions. * Returns flags describing the type of the last assignment or expression found. * exprlist = assignment [ ',' assignment ] ... @@ -1359,8 +1359,8 @@ getopassignment(void) case T_MODEQUALS: op = OP_MOD; break; case T_ANDEQUALS: op = OP_AND; break; case T_OREQUALS: op = OP_OR; break; - case T_LSHIFTEQUALS: op = OP_LEFTSHIFT; break; - case T_RSHIFTEQUALS: op = OP_RIGHTSHIFT; break; + case T_LSHIFTEQUALS: op = OP_LEFTSHIFT; break; + case T_RSHIFTEQUALS: op = OP_RIGHTSHIFT; break; case T_POWEREQUALS: op = OP_POWER; break; case T_HASHEQUALS: op = OP_HASHOP; break; case T_TILDEEQUALS: op = OP_XOR; break; @@ -1400,8 +1400,8 @@ getopassignment(void) case T_MODEQUALS: op = OP_MOD; break; case T_ANDEQUALS: op = OP_AND; break; case T_OREQUALS: op = OP_OR; break; - case T_LSHIFTEQUALS: op = OP_LEFTSHIFT; break; - case T_RSHIFTEQUALS: op = OP_RIGHTSHIFT; break; + case T_LSHIFTEQUALS: op = OP_LEFTSHIFT; break; + case T_RSHIFTEQUALS: op = OP_RIGHTSHIFT; break; case T_POWEREQUALS: op = OP_POWER; break; case T_HASHEQUALS: op = OP_HASHOP; break; case T_TILDEEQUALS: op = OP_XOR; break; @@ -1746,7 +1746,7 @@ getshiftexpr(void) case T_NOT: op = OP_NOT; break; case T_DIV: op = OP_INVERT; break; case T_BACKSLASH: op = OP_BACKSLASH; break; - case T_TILDE: op = OP_COMP; break; + case T_TILDE: op = OP_COMP; break; case T_HASH: op = OP_CONTENT; break; } if (op) { @@ -1759,7 +1759,7 @@ getshiftexpr(void) switch (gettoken()) { case T_POWER: op = OP_POWER; break; case T_LEFTSHIFT: op = OP_LEFTSHIFT; break; - case T_RIGHTSHIFT: op = OP_RIGHTSHIFT; break; + case T_RIGHTSHIFT: op = OP_RIGHTSHIFT; break; default: rescantoken(); return type; @@ -2187,7 +2187,7 @@ getmatargs(void) /* * Normal indexing with the indexes separated by commas. * Initialize the flag in the opcode to assume that the array - * element will only be referenced for reading. If the parser + * element will only be referenced for reading. If the parser * finds that the element will be referenced for writing, then * it will call writeindexop to change the flag in the opcode. */ diff --git a/comfunc.c b/comfunc.c index eca902b..fa951aa 100644 --- a/comfunc.c +++ b/comfunc.c @@ -138,38 +138,6 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R) up1 = up2 = 0; sign = (R & 64) != 0; -#if 0 - if (qiszero(epsilon)) { - aes = qsquare(c->real); - bes = qsquare(c->imag); - v = qqadd(aes, bes); - qfree(aes); - qfree(bes); - u = qsqrt(v, epsilon, 0); - qfree(v); - if (qiszero(u)) { - qfree(u); - return clink(&_czero_); - } - aes = qqadd(u, c->real); - qfree(u); - bes = qscale(aes, -1); - qfree(aes); - u = qsqrt(bes, epsilon, R); - qfree(bes); - if (qiszero(u)) { - qfree(u); - return clink(&_czero_); - } - aes = qscale(c->imag, -1); - v = qqdiv(aes, u); - qfree(aes); - r = comalloc(); - r->real = u; - r->imag = v; - return r; - } -#endif imsign = c->imag->num.sign; es = qsquare(epsilon); aes = qqdiv(c->real, es); @@ -255,8 +223,7 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R) up2 = -1; zfree(tmp1); zfree(aa); - } - else { + } else { s1 = zsqrt(tmp3, &cc, 0); zfree(tmp3); zadd(cc, a, &tmp1); @@ -333,9 +300,9 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R) zfree(mul2); mul2 = tmp2; } - if (ziszero(mul1)) + if (ziszero(mul1)) { u = qlink(&_qzero_); - else { + } else { mul1.sign = sign ^ epsilon->num.sign; u = qalloc(); zreduce(mul1, epsilon->den, &tmp2, &u->den); @@ -343,9 +310,9 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R) zfree(tmp2); } zfree(mul1); - if (ziszero(mul2)) + if (ziszero(mul2)) { v = qlink(&_qzero_); - else { + } else { mul2.sign = imsign ^ sign ^ epsilon->num.sign; v = qalloc(); zreduce(mul2, epsilon->den, &tmp2, &v->den); @@ -1147,5 +1114,3 @@ cprintfr(COMPLEX *c) zprintval(i->den, 0L, 0L); } } - -/* END CODE */ diff --git a/commath.c b/commath.c index 65f57ea..0e6adfb 100644 --- a/commath.c +++ b/commath.c @@ -69,7 +69,7 @@ csub(COMPLEX *c1, COMPLEX *c2) /* * Multiply two complex numbers. * This saves one multiplication over the obvious algorithm by - * trading it for several extra additions, as follows. Let + * trading it for several extra additions, as follows. Let * q1 = (a + b) * (c + d) * q2 = a * c * q3 = b * d diff --git a/config.c b/config.c index 5d1981d..125b738 100644 --- a/config.c +++ b/config.c @@ -48,7 +48,7 @@ NAMETYPE configs[] = { {"maxerr", CONFIG_MAXSCAN}, /* old name for maxscan */ {"prompt", CONFIG_PROMPT}, {"more", CONFIG_MORE}, - {"blkmaxprint", CONFIG_BLKMAXPRINT}, + {"blkmaxprint", CONFIG_BLKMAXPRINT}, {"blkverbose", CONFIG_BLKVERBOSE}, {"blkbase", CONFIG_BLKBASE}, {"blkfmt", CONFIG_BLKFMT}, @@ -96,7 +96,7 @@ CONFIG oldstd = { /* backward compatible standard configuration */ BLK_FMT_HD_STYLE, /* block output format */ 0, /* internal calc debug level */ 3, /* calc library debug level */ - 0, /* user defined debug level */ + 0, /* user defined debug level */ TRUE /* print Quit or abort executed messages */ }; CONFIG newstd = { /* new non-backward compatible configuration */ @@ -132,7 +132,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */ BLK_FMT_HD_STYLE, /* block output format */ 0, /* internal calc debug level */ 3, /* calc library debug level */ - 0, /* user defined debug level */ + 0, /* user defined debug level */ TRUE /* print Quit or abort executed messages */ }; CONFIG *conf = NULL; /* loaded in at startup - current configuration */ @@ -148,7 +148,7 @@ static NAMETYPE modes[] = { {"int", MODE_INT}, {"real", MODE_REAL}, {"exp", MODE_EXP}, - {"hexadecimal", MODE_HEX}, + {"hexadecimal", MODE_HEX}, {"hex", MODE_HEX}, {"octal", MODE_OCTAL}, {"oct", MODE_OCTAL}, @@ -184,7 +184,7 @@ static NAMETYPE truth[] = { * Possible block base output modes */ static NAMETYPE blk_base[] = { - {"hexadecimal", BLK_BASE_HEX}, + {"hexadecimal", BLK_BASE_HEX}, {"hex", BLK_BASE_HEX}, {"octal", BLK_BASE_OCT}, {"oct", BLK_BASE_OCT}, @@ -361,7 +361,7 @@ setconfig(int type, VALUE *vp) switch (type) { case CONFIG_ALL: - newconf = NULL; /* firewall */ + newconf = NULL; /* firewall */ if (vp->v_type == V_STR) { if (strcmp(vp->v_str->s_str, "oldstd") == 0) { newconf = &oldstd; diff --git a/config.h b/config.h index d14081c..690cb5c 100644 --- a/config.h +++ b/config.h @@ -20,16 +20,16 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ @@ -52,11 +52,11 @@ #define CONFIG_EPSILON 3 #define CONFIG_EPSILONPREC 3 /* not a real type -- tied to CONFIG_EPSILON */ #define CONFIG_TRACE 4 -#define CONFIG_MAXPRINT 5 -#define CONFIG_MUL2 6 -#define CONFIG_SQ2 7 -#define CONFIG_POW2 8 -#define CONFIG_REDC2 9 +#define CONFIG_MAXPRINT 5 +#define CONFIG_MUL2 6 +#define CONFIG_SQ2 7 +#define CONFIG_POW2 8 +#define CONFIG_REDC2 9 #define CONFIG_TILDE 10 #define CONFIG_TAB 11 #define CONFIG_QUOMOD 12 @@ -66,10 +66,10 @@ #define CONFIG_APPR 16 #define CONFIG_CFAPPR 17 #define CONFIG_CFSIM 18 -#define CONFIG_OUTROUND 19 +#define CONFIG_OUTROUND 19 #define CONFIG_ROUND 20 -#define CONFIG_LEADZERO 21 -#define CONFIG_FULLZERO 22 +#define CONFIG_LEADZERO 21 +#define CONFIG_FULLZERO 22 #define CONFIG_MAXSCAN 23 #define CONFIG_PROMPT 24 #define CONFIG_MORE 25 @@ -87,7 +87,7 @@ * config default symbols */ #define DISPLAY_DEFAULT 20 /* default digits for float display */ -#define EPSILON_DEFAULT "1e-20" /* allowed error for float calculations */ +#define EPSILON_DEFAULT "1e-20" /* allowed error for float calculations */ #define EPSILONPREC_DEFAULT 67 /* 67 ==> 2^-67 <= EPSILON_DEFAULT < 2^-66 */ #define NEW_EPSILON_DEFAULT "1e-10" /* newstd EPSILON_DEFAULT */ #define NEW_EPSILONPREC_DEFAULT 34 /* 34 ==> 2^-34 <= 1e-10 < 2^-33 */ @@ -140,7 +140,7 @@ struct config { long user_debug; /* user defined debug value: 0 default */ BOOL verbose_quit; /* TRUE => print Quit or abort executed msg */ }; -typedef struct config CONFIG; +typedef struct config CONFIG; /* diff --git a/custom.c b/custom.c index ece0ae2..49b51d3 100644 --- a/custom.c +++ b/custom.c @@ -20,7 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -117,7 +117,7 @@ showcustom(void) { #if defined(CUSTOM) - CONST struct custom *p; /* current function */ + CONST struct custom *p; /* current function */ /* * disable custom functions unless -C was given diff --git a/custom.h b/custom.h index 08ac0b2..b76173c 100644 --- a/custom.h +++ b/custom.h @@ -20,16 +20,16 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ diff --git a/custom/HOW_TO_ADD b/custom/HOW_TO_ADD index f561529..2781f58 100644 --- a/custom/HOW_TO_ADD +++ b/custom/HOW_TO_ADD @@ -6,7 +6,7 @@ Step 0: Determine if is should it be done? multi-precision calculations in a C-like environment. You should consider implementing algorithms in the calc language as a first choice. Sometimes an algorithm requires use of special hardware, a - non-portable OS or pre-compiled C library. In these cases a custom + non-portable OS or pre-compiled C library. In these cases a custom interface may be needed. The custom function interface is intended to make is easy for @@ -184,7 +184,7 @@ Step 5: Write your custom function The 3 args are passed in by the custom interface and have the following meaning: - name The name of the custom function that + name The name of the custom function that was called. In particular, this is the first string arg that was given to the custom() builtin. This is the equivalent of argv[0] for @@ -215,11 +215,11 @@ Step 5: Write your custom function custom("curds", a, b, c) - would cause vals to point to the following array: + would cause vals to point to the following array: - vals[0] points to a - vals[1] points to b - vals[2] points to c + vals[0] points to a + vals[1] points to b + vals[2] points to c c) The return value is the function must be a VALUE. @@ -247,7 +247,7 @@ Step 5: Write your custom function The VALUE is a union of major value types found inside calc. The v_type VALUE element determines which union element is - being used. Assume that we have: + being used. Assume that we have: VALUE *vp; @@ -427,12 +427,12 @@ Step 6: Register the function in the custom interface table level Makefile, one does not have unsatisfied symbols. The brief description should be brief so that 'show custom' looks well - formatted. If the brief description cannot fit on the same line as + formatted. If the brief description cannot fit on the same line as the name without wrapping on a 80 col window, the description is probably too long and will not look nice in the show custom output. The minargs places a lower bound on the number of args that - must be supplied to the interface. This does NOT count + must be supplied to the interface. This does NOT count the name argument given to custom(). So if minargs is 2: custom("curds") /* call blocked at high level interface */ diff --git a/custom/Makefile b/custom/Makefile index e8143cd..04ae883 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -22,7 +22,7 @@ # PERFORMANCE OF THIS SOFTWARE. # # Comments, suggestions, bug fixes and questions about these routines -# are welcome. Send EMail to the address given below. +# are welcome. Send EMail to the address given below. # # Happy bit twiddling, # @@ -146,7 +146,7 @@ DEBUG= -O # BSD NO_SHARED= # SYSV NO_SHARED= -dn # IRIX NO_SHARED= -non_shared -# disable NO_SHARED= +# disable NO_SHARED= # # If in doubt, use NO_SHARED= # @@ -168,7 +168,7 @@ RANLIB=: # a default here just in case you want to build from this directory. # # Normally certain files depend on the Makefile. If the Makefile is -# changed, then certain steps should be redone. If MAKE_FILE is +# changed, then certain steps should be redone. If MAKE_FILE is # set to Makefile, then these files will depend on Makefile. If # MAKE_FILE is empty, they they wont. # @@ -192,7 +192,7 @@ MAKE_FILE= Makefile # # By default, custom builtin functions may only be executed if calc # is given the -C option. This is because custom builtin functions -# may invoke non-standard or non-portable code. One may completely +# may invoke non-standard or non-portable code. One may completely # disable custom builtin functions by not compiling any of code # # ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given @@ -333,14 +333,14 @@ c_sysinfo.o: c_sysinfo.c ${MAKE_FILE} ## # -# File list generation. You can ignore this section. +# File list generation. You can ignore this section. # # # We will form the names of source files as if they were in a # sub-directory called calc/lib. # # NOTE: Due to bogus shells found on one common system we must have -# an non-emoty else clause for every if condition. *sigh* +# an non-emoty else clause for every if condition. *sigh* # ## @@ -376,7 +376,7 @@ depend: ${Q}mkdir skel ${Q}mkdir skel/custom -${Q}for i in ${C_SRC}; do \ - ${SED} -n '/^#[ ]*include[ ]*"/p' \ + ${SED} -n '/^#[ ]*include[ ]*"/p' \ "$$i" > "skel/custom/$$i"; \ done -${Q}for i in /dev/null ${H_SRC}; do \ diff --git a/custom/argv b/custom/argv index b2c18c8..677cfb0 100644 --- a/custom/argv +++ b/custom/argv @@ -23,11 +23,11 @@ DESCRIPTION EXAMPLE > foo=5^713; bar=17; baz=list(2,3,4); > custom("argv", foo, bar, baz, 3+4.5i, pi()) - arg[0] rational_value size=1 sizeof=272 - arg[1] rational_value size=1 sizeof=68 - arg[2] list size=3 sizeof=256 - arg[3] complex_value size=1 sizeof=140 - arg[4] rational_value size=1 sizeof=84 + arg[0] rational_value size=1 sizeof=272 + arg[1] rational_value size=1 sizeof=68 + arg[2] list size=3 sizeof=256 + arg[3] complex_value size=1 sizeof=140 + arg[4] rational_value size=1 sizeof=84 5 LIMITS diff --git a/custom/c_argv.c b/custom/c_argv.c index 8e9e843..754c73d 100644 --- a/custom/c_argv.c +++ b/custom/c_argv.c @@ -11,12 +11,12 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ @@ -98,13 +98,13 @@ c_argv(char *name, int count, VALUE **vals) case V_FILE: /* opened file id */ type = "file"; break; - case V_RAND: /* address of additive 55 random state */ + case V_RAND: /* address of additive 55 random state */ type = "rand_state"; break; - case V_RANDOM: /* address of Blum random state */ + case V_RANDOM: /* address of Blum random state */ type = "random_state"; break; - case V_CONFIG: /* configuration state */ + case V_CONFIG: /* configuration state */ type = "config_state"; break; case V_HASH: /* hash state */ @@ -115,7 +115,7 @@ c_argv(char *name, int count, VALUE **vals) break; #if 0 /* XXX - V_OCTET is subject to change */ - case V_OCTET: /* octet (unsigned char) */ + case V_OCTET: /* octet (unsigned char) */ type = "octet"; break; #endif diff --git a/custom/c_devnull.c b/custom/c_devnull.c index 24ba013..22188b8 100644 --- a/custom/c_devnull.c +++ b/custom/c_devnull.c @@ -11,12 +11,12 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ diff --git a/custom/c_help.c b/custom/c_help.c index dae643f..094ec72 100644 --- a/custom/c_help.c +++ b/custom/c_help.c @@ -11,12 +11,12 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index d9410d3..29c9eba 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.c @@ -2,7 +2,7 @@ * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted. * - * Ernest Bowen, following Landon Curt Noll + * Ernest Bowen, following Landon Curt Noll */ #if defined(CUSTOM) @@ -20,7 +20,7 @@ * * given: * count = 1; - * vals[0] real number; + * vals[0] real number; * * returns: * null @@ -29,7 +29,7 @@ VALUE c_pzasusb8(char *name, int count, VALUE **vals) { - VALUE result; /* what we will return */ + VALUE result; /* what we will return */ ZVALUE z; /* numerator of the value */ long half_cnt; /* number of HALFs in the numerator */ USB8 *h; /* octet pointer */ diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index ce87255..ec39512 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.c @@ -11,12 +11,12 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ diff --git a/custom/custtbl.c b/custom/custtbl.c index 5bea277..ff878d2 100644 --- a/custom/custtbl.c +++ b/custom/custtbl.c @@ -20,12 +20,12 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * * chongo /\../\ */ @@ -37,7 +37,7 @@ /* * NOTE: See the file CUSTOM for instructions on how to add - * custom functions. + * custom functions. */ diff --git a/custom/devnull b/custom/devnull index 4d97e54..e18eb47 100644 --- a/custom/devnull +++ b/custom/devnull @@ -10,7 +10,7 @@ TYPES return null DESCRIPTION - This custom function does nothing. It is intented for testing + This custom function does nothing. It is intented for testing of the general custom interface. EXAMPLE diff --git a/custom/pzasusb8 b/custom/pzasusb8 index dc2350a..f1f4565 100644 --- a/custom/pzasusb8 +++ b/custom/pzasusb8 @@ -11,7 +11,7 @@ TYPES DESCRIPTION This custom function prints out the numerator of a real value - in octets. Each HALF value is printed in a separate line. + in octets. Each HALF value is printed in a separate line. NOTE: The output will vary depending on the size of a HALF and the byte order of the system. See: @@ -26,15 +26,15 @@ DESCRIPTION EXAMPLE > custom("pzasusb8", 0x01020304050607080910111213141516); - 0: 13141516 - 1: 09101112 - 2: 05060708 - 3: 01020304 + 0: 13141516 + 1: 09101112 + 2: 05060708 + 3: 01020304 > custom("pzasusb8", 10^25) - 0: 4a000000 - 1: 16140148 - 2: 00084595 + 0: 4a000000 + 1: 16140148 + 2: 00084595 > printf("%x\n", 10^25); 0x84595161401484a000000 diff --git a/file.c b/file.c index c60fa90..d78f364 100644 --- a/file.c +++ b/file.c @@ -19,7 +19,7 @@ #include "file.h" #include "calcerr.h" -#define READSIZE 1024 /* buffer size for reading */ +#define READSIZE 1024 /* buffer size for reading */ /* * external STDIO functions @@ -34,7 +34,7 @@ extern FILE *f_open(char *name, char *mode); * and cannot be closed. Their file ids are always 0, 1, and 2. */ static FILEIO files[MAXFILES] = { - {FILEID_STDIN, NULL, (dev_t)0, (ino_t)0, + {FILEID_STDIN, NULL, (dev_t)0, (ino_t)0, "(stdin)", TRUE, FALSE, 'r', "r"}, {FILEID_STDOUT, NULL, (dev_t)0, (ino_t)0, "(stdout)", FALSE, TRUE, 'w', "w"}, @@ -43,7 +43,7 @@ static FILEIO files[MAXFILES] = { }; -static int ioindex[MAXFILES] = {0,1,2}; /* Indices for FILEIO table */ +static int ioindex[MAXFILES] = {0,1,2}; /* Indices for FILEIO table */ static FILEID lastid = FILEID_STDERR; /* Last allocated file id */ static int idnum = 3; /* Number of allocated file ids */ @@ -398,7 +398,7 @@ indexid(long index) /* - * Close the specified file id. Returns TRUE if there was an error. + * Close the specified file id. Returns TRUE if there was an error. * Closing of stdin, stdout, or stderr is illegal, but closing of already * closed files is allowed. */ @@ -536,7 +536,7 @@ flushall(void) * * bit 0: at newline * bit 1: at null character - * bit 2: at white space (also skips leading white space) + * bit 2: at white space (also skips leading white space) * * If neither '\n' nor '\0' is encountered reading continues until EOF. * If bit 3 is set the stop character is removed. @@ -725,7 +725,7 @@ printid(FILEID id, int flags) /* - * Print a formatted string similar to printf. Various formats of output + * Print a formatted string similar to printf. Various formats of output * are possible, depending on the format string AND the actual types of the * values. Mismatches do not cause errors, instead something reasonable is * printed instead. The output goes to the file with the specified id. @@ -1294,7 +1294,7 @@ getloc(FILEID id, ZVALUE *res) */ fiop = findid(id, 0); if (fiop == NULL) { - /* file not open */ + /* file not open */ return -1; } fp = fiop->fp; @@ -1467,7 +1467,7 @@ setloc(FILEID id, ZVALUE zpos) */ fiop = findid(id, 0); if (fiop == NULL) { - /* file not open */ + /* file not open */ return -1; } fp = fiop->fp; @@ -1635,7 +1635,7 @@ getsize(FILEID id, ZVALUE *res) */ fiop = findid(id, 0); if (fiop == NULL) { - /* file not open */ + /* file not open */ return 1; } fp = fiop->fp; @@ -1671,7 +1671,7 @@ get_device(FILEID id, ZVALUE *dev) */ fiop = findid(id, 0); if (fiop == NULL) { - /* file not open */ + /* file not open */ return -1; } @@ -1704,7 +1704,7 @@ get_inode(FILEID id, ZVALUE *inode) */ fiop = findid(id, 0); if (fiop == NULL) { - /* file not open */ + /* file not open */ return -1; } @@ -2144,7 +2144,7 @@ scanfstr(char *str, char *fmt, int count, VALUE **vals) /* - * Read a number in floating-point format from a file. The first dot, + * Read a number in floating-point format from a file. The first dot, * if any, is considered as the decimal point; later dots are ignored. * For example, -23.45..67. is interpreted as -23.4567 * An optional 'e' or 'E' indicates multiplication by a power or 10, @@ -2394,7 +2394,7 @@ isattyid(FILEID id) * zero if string found, position stored at res * * XXX - This search is a translation of the original search that did not - * work with large files. The search algorithm used is slow and + * work with large files. The search algorithm used is slow and * should be spead up much more. */ int @@ -2513,7 +2513,7 @@ fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res) * zero if string found, position stored at res * * XXX - This search is a translation of the original search that did not - * work with large files. The search algorithm used is so slow + * work with large files. The search algorithm used is so slow * as to be painful to the user and needs to be sped up much more. */ int diff --git a/file.h b/file.h index 796f580..79e3c10 100644 --- a/file.h +++ b/file.h @@ -42,7 +42,7 @@ typedef struct { * We assume that if your system does not have fgetpos/fsetpos, * then it will have a FILEPOS that is a scalar type (e.g., long). * Some obscure systems without fgetpos/fsetpos may not have a simple - * scalar type. In these cases the f_tell macro below will fail. + * scalar type. In these cases the f_tell macro below will fail. */ #if defined(HAVE_FPOS) @@ -51,7 +51,7 @@ typedef struct { #else -#define f_seek_set(stream, loc) \ +#define f_seek_set(stream, loc) \ fseek((FILE*)(stream), *(FILEPOS*)(loc), SEEK_SET) #define f_tell(stream, loc) (*((FILEPOS*)(loc)) = ftell((FILE*)(stream))) diff --git a/fposval.c b/fposval.c index dff42df..c6ea292 100644 --- a/fposval.c +++ b/fposval.c @@ -12,7 +12,7 @@ * * We will #define of 8 symbols: * - * FILEPOS_BITS length in bits of the type FILEPOS + * FILEPOS_BITS length in bits of the type FILEPOS * SWAP_HALF_IN_FILEPOS will copy/swap FILEPOS into an HALF array * OFF_T_BITS length in bits of the st_size stat element * SWAP_HALF_IN_OFF_T will copy/swap st_size into an HALF array diff --git a/func.c b/func.c index d84067b..2de27eb 100644 --- a/func.c +++ b/func.c @@ -133,8 +133,8 @@ static STRINGHEAD newerrorstr; * arg count definitons */ #define IN 100 /* maximum number of arguments */ -#define FE 0x01 /* flag to indicate default epsilon argument */ -#define FA 0x02 /* preserve addresses of variables */ +#define FE 0x01 /* flag to indicate default epsilon argument */ +#define FA 0x02 /* preserve addresses of variables */ /* @@ -146,7 +146,7 @@ struct builtin { short b_maxargs; /* maximum number of arguments */ short b_flags; /* special handling flags */ short b_opcode; /* opcode which makes the call quick */ - NUMBER *(*b_numfunc)(); /* routine to calculate numeric function */ + NUMBER *(*b_numfunc)(); /* routine to calculate numeric function */ VALUE (*b_valfunc)(); /* routine to calculate general values */ char *b_desc; /* description of function */ }; @@ -566,7 +566,7 @@ f_factor(int count, NUMBER **vals) NUMBER *err; /* error return, NULL => use math_error */ ZVALUE limit; /* highest prime factor in search */ ZVALUE n; /* number to factor */ - NUMBER *factor; /* the prime factor found */ + NUMBER *factor; /* the prime factor found */ int res; /* -1 => error, 0 => not found, 1 => factor found */ /* @@ -966,7 +966,7 @@ f_srand(int count, VALUE **vals) if (!qisint(vals[0]->v_num)) { math_error( "srand number seed must be an integer"); - /*NOTREACHED*/ + /*NOTREACHED*/ } result.v_rand = zsrand(&vals[0]->v_num->num, NULL); break; @@ -1117,7 +1117,7 @@ f_srandom(int count, VALUE **vals) if (!qisint(vals[0]->v_num)) { math_error( "srandom number seed must be an integer"); - /*NOTREACHED*/ + /*NOTREACHED*/ } result.v_random = zsrandom1(vals[0]->v_num->num, TRUE); break; @@ -1476,9 +1476,9 @@ f_min(int count, VALUE **vals) if (qisneg(rel.v_num)) { freevalue(&min); min = term; - } - else + } else { freevalue(&term); + } freevalue(&rel); } return min; @@ -1532,9 +1532,9 @@ f_max(int count, VALUE **vals) if (qisneg(rel.v_num)) { freevalue(&max); max = term; - } - else + } else { freevalue(&term); + } freevalue(&rel); } return max; @@ -3370,9 +3370,9 @@ f_root(int count, VALUE **vals) err.v_subtype = V_NOSUBTYPE; result.v_subtype = V_NOSUBTYPE; - if (count > 2) + if (count > 2) { vp = vals[2]; - else { + } else { err.v_num = conf->epsilon; err.v_type = V_NUM; vp = &err; @@ -3391,9 +3391,9 @@ f_power(int count, VALUE **vals) err.v_subtype = V_NOSUBTYPE; result.v_subtype = V_NOSUBTYPE; - if (count > 2) + if (count > 2) { vp = vals[2]; - else { + } else { err.v_num = conf->epsilon; err.v_type = V_NUM; vp = &err; @@ -3413,9 +3413,9 @@ f_polar(int count, VALUE **vals) err.v_subtype = V_NOSUBTYPE; result.v_subtype = V_NOSUBTYPE; - if (count > 2) + if (count > 2) { vp = vals[2]; - else { + } else { err.v_num = conf->epsilon; err.v_type = V_NUM; vp = &err; @@ -4138,9 +4138,9 @@ f_search(int count, VALUE **vals) qfree(start); start = qlink(&_qzero_); } - } - else + } else { start = qlink(start); + } } if (end) { if (!qispos(end)) { @@ -4388,8 +4388,7 @@ f_rsearch(int count, VALUE **vals) else end = qlink(size); start = qlink(&_qzero_); - } - else { + } else { if (start == NULL) start = qlink(&_qzero_); if (end == NULL) @@ -4726,9 +4725,9 @@ f_freopen(int count, VALUE **vals) return error_value(E_FREOPEN2); } errno = 0; - if (count == 2) + if (count == 2) { id = reopenid(vals[0]->v_file, mode, NULL); - else { + } else { if (vals[2]->v_type != V_STR) return error_value(E_FREOPEN3); id = reopenid(vals[0]->v_file, mode, @@ -4963,9 +4962,9 @@ f_newerror(int count, VALUE **vals) if (nexterrnum == E_USERDEF) initstr(&newerrorstr); index = findstr(&newerrorstr, str); - if (index >= 0) + if (index >= 0) { errnum = E_USERDEF + index; - else { + } else { if (nexterrnum == 32767) math_error("Too many new error values"); errnum = nexterrnum++; @@ -5092,9 +5091,9 @@ f_fflush(int count, VALUE **vals) i = 0; errno = 0; - if (count == 0) + if (count == 0) { i = flushall(); - else { + } else { for (n = 0; n < count; n++) { if (vals[n]->v_type != V_FILE) return error_value(E_FFLUSH); @@ -5130,9 +5129,9 @@ f_error(int count, VALUE **vals) r = E_ERROR2; } } - } - else + } else { r = set_errno(-1); + } return error_value(r); } @@ -5192,9 +5191,9 @@ f_fseek(int count, VALUE **vals) return error_value(E_FSEEK1); if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) return error_value(E_FSEEK2); - if (count == 2) + if (count == 2) { whence = 0; - else { + } else { if (vals[2]->v_type != V_NUM || qisfrac(vals[2]->v_num) || qisneg(vals[2]->v_num)) return error_value(E_FSEEK2); @@ -5248,10 +5247,10 @@ f_rewind(int count, VALUE **vals) /* initialize VALUE */ result.v_subtype = V_NOSUBTYPE; - if (count == 0) + if (count == 0) { rewindall(); - else { + } else { for (n = 0; n < count; n++) { if (vals[n]->v_type != V_FILE) return error_value(E_REWIND1); @@ -5337,7 +5336,7 @@ static int filescan(FILEID id, int count, VALUE **vals) { char *str; - int i; + int i; int n = 0; VALUE val; VALUE result; @@ -6331,10 +6330,10 @@ static VALUE f_cmdbuf(void) { VALUE result; - char *newcp; + char *newcp; /* initialize VALUE */ - result.v_type = V_STR; + result.v_type = V_STR; result.v_subtype = V_NOSUBTYPE; newcp = (char *)malloc(strlen(cmdbuf) + 1); @@ -6357,7 +6356,7 @@ f_getenv(VALUE *v1) math_error("Non-string argument for getenv"); /*NOTREACHED*/ } - result.v_type = V_STR; + result.v_type = V_STR; str = getenv(v1->v_str->s_str); if (str == NULL) result.v_type = V_NULL; @@ -6468,7 +6467,7 @@ static VALUE f_putenv(int count, VALUE **vals) { VALUE result; - char *putenv_str; + char *putenv_str; /* initialize VALUE */ result.v_type = V_NUM; @@ -6530,8 +6529,8 @@ static VALUE f_strpos(VALUE *haystack, VALUE *needle) { VALUE result; - char *cpointer; - int cindex; + char *cpointer; + int cindex; /* initialize VALUE */ result.v_type = V_NUM; @@ -6541,11 +6540,11 @@ f_strpos(VALUE *haystack, VALUE *needle) math_error("Non-string argument for index"); /*NOTREACHED*/ } - cpointer = strstr(haystack->v_str->s_str, + cpointer = strstr(haystack->v_str->s_str, needle->v_str->s_str); - if (cpointer == NULL) + if (cpointer == NULL) cindex = 0; - else + else cindex = cpointer - haystack->v_str->s_str + 1; result.v_num = itoq((long) cindex); return result; @@ -6584,7 +6583,7 @@ static NUMBER * f_base(int count, NUMBER **vals) { long base; /* output base/mode */ - long oldbase=0; /* output base/mode */ + long oldbase=0; /* output base/mode */ /* deal with just a query */ if (count != 1) { @@ -6886,9 +6885,9 @@ f_blocks(int count, VALUE **vals) nblk = findnblock(id); - if (nblk == NULL) + if (nblk == NULL) { return error_value(E_BLOCKS2); - else { + } else { result.v_type = V_NBLOCK; result.v_nblock = nblk; } @@ -7311,14 +7310,14 @@ f_md5(int count, VALUE **vals) * * For nice output, when the description of function (b_desc) * gets too long (extends into col 79) you should chop the - * line and add "\n\t\t ", thats newline, 2 tabs a 4 spaces. + * line and add "\n\t\t ", thats newline, 2 tabs a 4 spaces. * For example the description: * * ... very long description that goes beyond col 79 * * should be written as: * - * "... very long description that\n\t\t goes beyond col 79"}, + * "... very long description that\n\t\t goes beyond col 79"}, * * fields: * b_name name of built-in function @@ -7394,7 +7393,7 @@ static CONST struct builtin builtins[] = { {"ceil", 1, 1, 0, OP_NOP, 0, f_ceil, "smallest integer greater than or equal to number"}, {"cfappr", 1, 3, 0, OP_NOP, f_cfappr, 0, - "approximate a within accuracy b using\n\t\t continued fractions"}, + "approximate a within accuracy b using\n\t\t continued fractions"}, {"cfsim", 1, 2, 0, OP_NOP, f_cfsim, 0, "simplify number using continued fractions"}, {"char", 1, 1, 0, OP_NOP, 0, f_char, @@ -7626,7 +7625,7 @@ static CONST struct builtin builtins[] = { {"istype", 2, 2, 0, OP_ISTYPE, 0, 0, "whether the type of a is same as the type of b"}, {"jacobi", 2, 2, 0, OP_NOP, qjacobi, 0, - "-1 => a is not quadratic residue mod b\n\t\t 1 => b is composite, or a is quad residue of b"}, + "-1 => a is not quadratic residue mod b\n\t\t 1 => b is composite, or a is quad residue of b"}, {"join", 1, IN, 0, OP_NOP, 0, f_join, "join one or more lists into one list"}, {"lcm", 1, IN, 0, OP_NOP, f_lcm, 0, @@ -7700,7 +7699,7 @@ static CONST struct builtin builtins[] = { {"ord", 1, 1, 0, OP_NOP, 0, f_ord, "integer corresponding to character value"}, {"param", 1, 1, 0, OP_ARGVALUE, 0, 0, - "value of parameter n (or parameter count if n\n\t\t is zero)"}, + "value of parameter n (or parameter count if n\n\t\t is zero)"}, {"perm", 2, 2, 0, OP_NOP, qperm, 0, "permutation number a!/(a-b)!"}, {"prevcand", 1, 5, 0, OP_NOP, f_prevcand, 0, diff --git a/func.h b/func.h index 188f122..b06403a 100644 --- a/func.h +++ b/func.h @@ -6,7 +6,7 @@ #if !defined(__FUNC_H__) -#define __FUNC_H__ +#define __FUNC_H__ #include "calc.h" diff --git a/hash.c b/hash.c index a045c59..9d3c630 100644 --- a/hash.c +++ b/hash.c @@ -248,14 +248,14 @@ hash_final(HASH *state) * * given: * type - hash type (see hash.h) - * longval - a long value + * longval - a long value * state - the state to hash * * returns: - * the new state + * the new state * * This function will hash a long value as if it were a 64 bit value. - * The input is a long. If a long is smaller than 64 bits, we will + * The input is a long. If a long is smaller than 64 bits, we will * hash a final 32 bits of zeros. */ HASH * diff --git a/hash.h b/hash.h index b5c877e..0ca4ae3 100644 --- a/hash.h +++ b/hash.h @@ -52,8 +52,8 @@ */ typedef struct hashstate HASH; struct hashstate { - int hashtype; /* XYZ_HASH_TYPE debug value */ - BOOL bytes; /* TRUE => reading bytes rather than words */ + int hashtype; /* XYZ_HASH_TYPE debug value */ + BOOL bytes; /* TRUE => reading bytes rather than words */ void (*update)(HASH*, USB8*, USB32); /* update arbitrary length */ void (*chkpt)(HASH*); /* checkpoint a state */ void (*note)(int, HASH*); /* note a special value */ diff --git a/have_offscl.c b/have_offscl.c index e668349..4b665a2 100644 --- a/have_offscl.c +++ b/have_offscl.c @@ -5,7 +5,7 @@ * have_offscl * * On some systems, off_t is a scalar value on which one can perform - * arithmetic operations, assignments and comparisons. On some systems + * arithmetic operations, assignments and comparisons. On some systems * off_t is some sort of union or struct which must be converted into * a ZVALUE in order to perform arithmetic operations, assignments and * comparisons. diff --git a/have_posscl.c b/have_posscl.c index 6e732e1..38ada31 100644 --- a/have_posscl.c +++ b/have_posscl.c @@ -5,7 +5,7 @@ * have_posscl * * On some systems, FILEPOS is a scalar value on which one can perform - * arithmetic operations, assignments and comparisons. On some systems + * arithmetic operations, assignments and comparisons. On some systems * FILEPOS is some sort of union or struct which must be converted into * a ZVALUE in order to perform arithmetic operations, assignments and * comparisons. @@ -51,7 +51,7 @@ main(void) { #if !defined(FILEPOS_NON_SCALAR) FILEPOS value; /* an FILEPOS to perform arithmatic on */ - FILEPOS value2; /* an FILEPOS to perform arithmatic on */ + FILEPOS value2; /* an FILEPOS to perform arithmatic on */ /* * do some math opts on an FILEPOS diff --git a/have_stdvs.c b/have_stdvs.c index a29bab5..def9e1d 100644 --- a/have_stdvs.c +++ b/have_stdvs.c @@ -9,7 +9,7 @@ * as if it were vsprintf() and hope for the best. * * This program will output #defines and exits 0 if vsprintf() (or sprintf()) - * produces the results that we expect. This program exits 1 if vsprintf() + * produces the results that we expect. This program exits 1 if vsprintf() * (or sprintf()) produces unexpected results while using the * include file. */ @@ -109,14 +109,14 @@ main(void) puts(" * SIMULATE_STDARG"); puts(" *"); puts(" * WARNING: This type of stdarg makes assumptions about the stack"); - puts(" * that may not be true on your system. You may want to"); + puts(" * that may not be true on your system. You may want to"); puts(" * define STDARG (if using ANSI C) or VARARGS."); puts(" */"); puts("typedef char *va_list;"); puts("#define va_start(ap,parmn) (void)((ap) = (char*)(&(parmn) + 1))"); puts("#define va_end(ap) (void)((ap) = 0)"); puts("#define va_arg(ap, type) \\"); - puts(" (((type*)((ap) = ((ap) + sizeof(type))))[-1])"); + puts(" (((type*)((ap) = ((ap) + sizeof(type))))[-1])"); puts("#define SIMULATE_STDARG /* use std_arg.h to simulate */"); #else puts("#define STDARG /* use */"); diff --git a/have_ustat.c b/have_ustat.c index c361601..0750749 100644 --- a/have_ustat.c +++ b/have_ustat.c @@ -50,8 +50,8 @@ main(void) #else /* HAVE_NO_USTAT */ - struct stat stat_dot; /* stat of "." */ - struct ustat ustat_dot; /* usage stat of "." */ + struct stat stat_dot; /* stat of "." */ + struct ustat ustat_dot; /* usage stat of "." */ (void) stat(".", &stat_dot); (void) ustat(stat_dot.st_dev, &ustat_dot); diff --git a/have_varvs.c b/have_varvs.c index 2b13202..6dcfea3 100644 --- a/have_varvs.c +++ b/have_varvs.c @@ -6,7 +6,7 @@ * and hope for the best. * * This program will output #defines and exits 0 if vsprintf() (or sprintf()) - * produces the results that we expect. This program exits 1 if vsprintf() + * produces the results that we expect. This program exits 1 if vsprintf() * (or sprintf()) produces unexpected results while using the * include file. */ diff --git a/help/Makefile b/help/Makefile index 9326e87..8eb2662 100644 --- a/help/Makefile +++ b/help/Makefile @@ -153,7 +153,7 @@ all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \ # used by the upper level Makefile to determine of we have done all # # NOTE: Due to bogus shells found on one common system we must have -# an non-emoty else clause for every if condition. *sigh* +# an non-emoty else clause for every if condition. *sigh* # .all: rm -f .all @@ -341,7 +341,7 @@ ${SINGULAR_FILES}: ${PLURAL_FILES} # Form the builtin file # # We ave a "chicken-and-egg" problem. We want the builtn help file to -# accurately reflect the function list. It would be nice if we could +# accurately reflect the function list. It would be nice if we could # just execute calc show builtin, but calc may not have been built or # buildable at this point. The hack-a-round used is to convert ../func.c # into a standalone program that generates a suitable function list @@ -379,7 +379,7 @@ builtin: builtin.top builtin.end ../func.c funclist.sed ## # -# File list generation. You can ignore this section. +# File list generation. You can ignore this section. # # # We will form the names of source files as if they were in a diff --git a/help/acosh b/help/acosh index e723758..2d51694 100644 --- a/help/acosh +++ b/help/acosh @@ -17,7 +17,7 @@ DESCRIPTION acosh(x) is the nonnegative real number v for which cosh(v) = x. It is given by - acosh(x) = ln(x + sqrt(x^2 - 1)) + acosh(x) = ln(x + sqrt(x^2 - 1)) EXAMPLE > print acosh(2, 1e-5), acosh(2, 1e-10), acosh(2, 1e-15), acosh(2, 1e-20) diff --git a/help/acoth b/help/acoth index 5b2d39c..3657858 100644 --- a/help/acoth +++ b/help/acoth @@ -16,7 +16,7 @@ DESCRIPTION acoth(x) is the real number v for which coth(v) = x. It is given by - acoth(x) = ln((x + 1)/(x - 1))/2 + acoth(x) = ln((x + 1)/(x - 1))/2 EXAMPLE > print acoth(2, 1e-5), acoth(2, 1e-10), acoth(2, 1e-15), acoth(2, 1e-20) diff --git a/help/acsch b/help/acsch index b81e1f9..0e8f0d3 100644 --- a/help/acsch +++ b/help/acsch @@ -16,7 +16,7 @@ DESCRIPTION acsch(x) is the real number v for which csch(v) = x. It is given by - acsch(x) = ln((1 + sqrt(1 + x^2))/x) + acsch(x) = ln((1 + sqrt(1 + x^2))/x) EXAMPLE diff --git a/help/address b/help/address index 7da6b6b..90539fe 100644 --- a/help/address +++ b/help/address @@ -20,7 +20,7 @@ DESCRIPTION otherwise accessing, such a vacated address may be catastrophic. An octet is normally expressed by B[i] where B is a block and - 0 <= i < sizeof(B). &B[i] then returns the address at which this + 0 <= i < sizeof(B). &B[i] then returns the address at which this octet is located until the block is freed or relocated. Freeing of an unnamed block B occurs when a new value is assigned to B or when B ceases to exist; a named block B is freed by blkfree(B(). @@ -96,7 +96,7 @@ DESCRIPTION > define f(a) = 27 + a; the three occurrences of 27 have the same address which may be displayed - by any of &27, &*x, &*y and &f(0). If x and y are assigned + by any of &27, &*x, &*y and &f(0). If x and y are assigned other values and f is redefined or undefined and the 27 has not been stored elsewhere (e.g. as the "old value" or in another function definition or as an element in an association), the address assigned at @@ -105,7 +105,7 @@ DESCRIPTION When a function returns a number value, that number value is usually placed at a newly allocated address, even if an equal number is stored - elsewhere. For example calls to f(a), as defined above, with the same + elsewhere. For example calls to f(a), as defined above, with the same non-zero value for a will be assigned to different addresses as can be seen from printing &*A, &*B, &*C after diff --git a/help/appr b/help/appr index 6116096..232b1aa 100644 --- a/help/appr +++ b/help/appr @@ -84,7 +84,7 @@ DESCRIPTION Complex x: - Returns appr(re(x), y, z) + appr(im(x), y, z) * 1i + Returns appr(re(x), y, z) + appr(im(x), y, z) * 1i PROPERTIES If appr(x,y,z) != x, then abs(x - appr(x,y,z)) < abs(y). diff --git a/help/asech b/help/asech index 186ad5d..143b73a 100644 --- a/help/asech +++ b/help/asech @@ -16,7 +16,7 @@ DESCRIPTION asech(x) is the real number v for which sech(v) = x. It is given by - asech(x) = ln((1 + sqrt(1 - x^2))/x) + asech(x) = ln((1 + sqrt(1 - x^2))/x) EXAMPLE > print asech(.5,1e-5), asech(.5,1e-10), asech(.5,1e-15), asech(.5,1e-20) diff --git a/help/asinh b/help/asinh index 48351b1..4c28b60 100644 --- a/help/asinh +++ b/help/asinh @@ -16,7 +16,7 @@ DESCRIPTION asinh(x) is the real number v for which sinh(v) = x. It is given by - asinh(x) = ln(x + sqrt(1 + x^2)) + asinh(x) = ln(x + sqrt(1 + x^2)) EXAMPLE > print asinh(2, 1e-5), asinh(2, 1e-10), asinh(2, 1e-15), asinh(2, 1e-20) diff --git a/help/assign b/help/assign index 7e8a236..6bc5d49 100644 --- a/help/assign +++ b/help/assign @@ -44,7 +44,7 @@ DESCRIPTION In simple assignments, = associates from right to left so that, for example, - a = b = c + a = b = c has the effect of a = (b = c) and results in assigning the value of c to both a and b. The expression (a = b) = c is acceptable, but has the @@ -66,7 +66,7 @@ DESCRIPTION that of A[0] = A[1]. If, in execution of a = b, a is changed by the evaluation of b, the - value of b may be stored in an unintended or inaccessible location. For + value of b may be stored in an unintended or inaccessible location. For example, mat A[2]= {1,2}; A[0] = (A = 3); diff --git a/help/assoc b/help/assoc index 8066859..0971765 100644 --- a/help/assoc +++ b/help/assoc @@ -14,7 +14,7 @@ DESCRIPTION assignments of the forms A[a_1] = v_1 - A[a_1, a_2] = v_2 + A[a_1, a_2] = v_2 A[a_1, a_2, a_3] = v_3 A[a_1, a_2, a_3, a_4] = v_4 @@ -53,7 +53,7 @@ DESCRIPTION a sequential scan through the elements difficult. The search and rsearch functions can search for an element in an - association which has the specified value. They return the index + association which has the specified value. They return the index of the found element, or a NULL value if the value was not found. Associations can be copied by an assignment, and can be compared diff --git a/help/base b/help/base index fbefd60..685eeaa 100644 --- a/help/base +++ b/help/base @@ -18,8 +18,8 @@ DESCRIPTION The following convention is used to declare modes: - base config - value string + base config + value string 2 "binary" binary fractions 8 "octal" octal fractions diff --git a/help/bit b/help/bit index f84db40..b1b5fb1 100644 --- a/help/bit +++ b/help/bit @@ -11,7 +11,7 @@ TYPES return int DESCRIPTION - Determine if the binary bit y is set in x. If: + Determine if the binary bit y is set in x. If: x int(---) mod 2 == 1 diff --git a/help/blk b/help/blk index c19b76b..7b83eb8 100644 --- a/help/blk +++ b/help/blk @@ -26,7 +26,7 @@ DESCRIPTION ... , B[len-1], these all initially having zero value. The octets B[i] for i >= len always have zero value. If B[i] with - some i >= len is referenced, len is increased by 1. For example: + some i >= len is referenced, len is increased by 1. For example: B[i] = x @@ -70,7 +70,7 @@ DESCRIPTION If a block value B created by B = blk(len, chunk) is assigned to another variable by C = B, a new block of the same structure as B is created to become the value of C, and the octets in B are copied - to this new block. A block with possibly different length or + to this new block. A block with possibly different length or chunksize is created by C = blk(B, newlen, newchunk), only the first min(len, newlen) octets being copied from B; later octets are assigned zero value. If omitted, newlen and newchunk default to @@ -120,14 +120,14 @@ DESCRIPTION last two avoid printing of the new value for A. Named blocks are assigned index numbers 0, 1, 2, ..., in the order - of their creation. The block with index id is returned by blocks(id). + of their creation. The block with index id is returned by blocks(id). With no argument, blocks() returns the number of current unfreed named blocks. A named block may be used The memory allocated to a named block is freed by the blkfree() function with argument the named block, its name, or its id number. The block remains in existence but with a null data pointer, - its length and size being reduced to zero. A new block of memory + its length and size being reduced to zero. A new block of memory may be allocated to it, with possibly new length and chunksize by: blk(val [, len, chunk]) diff --git a/help/blkcpy b/help/blkcpy index d08f134..f94c002 100644 --- a/help/blkcpy +++ b/help/blkcpy @@ -90,7 +90,7 @@ DESCRIPTION so that num can be at most size(B) - ssi. For copying to a block B (named or unnamed), reallocation will be - required if dsi + num > sizeof(B). (This will not be permitted if + required if dsi + num > sizeof(B). (This will not be permitted if protect(B) has bit 4 set.) For copying from a file stream fs, num can be at most size(fs) - ssi. diff --git a/help/blkfree b/help/blkfree index c2ece31..7dfcf47 100644 --- a/help/blkfree +++ b/help/blkfree @@ -12,7 +12,7 @@ TYPES DESCRIPTION If val is a named block, or the name of a named block, or the identifying index for a named block, blkfree(val) frees the - memory block allocated to this named block. The block remains + memory block allocated to this named block. The block remains in existence with the same name, identifying index, and chunksize, but its size and maxsize becomes zero and the pointer for the start of its data block null. @@ -26,16 +26,16 @@ EXAMPLE > B1 = blk("foo") > B2 = blk("Second block") show blocks - id name + id name ---- ----- - 0 foo - 1 Second block + 0 foo + 1 Second block > blkfree(B1) > show blocks - id name + id name ---- ----- - 1 Second block + 1 Second block > B1 block 0: foo diff --git a/help/bround b/help/bround index 61ae7aa..06cdc08 100644 --- a/help/bround +++ b/help/bround @@ -12,7 +12,7 @@ TYPES Otherwise, if x is an object of type tt, or if x is not an object or number but y is an object of type tt, and the function tt_bround has to be defined; the types for x, plcs, rnd, and the returned value, - if any, are as required for specified in tt_bround. For the object + if any, are as required for specified in tt_bround. For the object case, plcs and rnd default to the null value. For other cases: @@ -31,7 +31,7 @@ DESCRIPTION If the number of binary places is n and eps = 10^-n, the result is the same as for appr(x, eps, rnd). This will be exactly x if x is a multiple of eps; otherwise rounding occurs - to one of the nearest multiples of eps on either side of x. Which + to one of the nearest multiples of eps on either side of x. Which of these multiples is returned is determined by z = rnd & 31, i.e. the five low order bits of rnd, as follows: diff --git a/help/builtin.end b/help/builtin.end index a3db868..9cff0ab 100644 --- a/help/builtin.end +++ b/help/builtin.end @@ -4,25 +4,25 @@ to be set or read. If only one argument is given, then the current value of the named parameter is returned. If two arguments are given, then the named parameter is set to the value of the second argument, - and the old value of the parameter is returned. Therefore you can + and the old value of the parameter is returned. Therefore you can change a parameter and restore its old value later. The possible parameters are explained in the next section. The scale function multiplies or divides a number by a power of 2. This is used for fractional calculations, unlike the << and >> - operators, which are only defined for integers. For example, + operators, which are only defined for integers. For example, scale(6, -3) is 3/4. The quomod function is used to obtain both the quotient and remainder - of a division in one operation. The first two arguments a and b are + of a division in one operation. The first two arguments a and b are the numbers to be divided. The last two arguments c and d are two variables which will be assigned the quotient and remainder. For nonnegative arguments, the results are equivalent to computing a//b and a%b. If a is negative and the remainder is nonzero, then the quotient will be one less than a//b. This makes the following three - properties always hold: The quotient c is always an integer. The + properties always hold: The quotient c is always an integer. The remainder d is always 0 <= d < b. The equation a = b * c + d always - holds. This function returns 0 if there is no remainder, and 1 if + holds. This function returns 0 if there is no remainder, and 1 if there is a remainder. For examples, quomod(10, 3, x, y) sets x to 3, y to 1, and returns the value 1, and quomod(-4, 3.14159, x, y) sets x to -2, y to 2.28318, and returns the value 1. @@ -37,8 +37,8 @@ The digit and bit functions return individual digits of a number, either in base 10 or in base 2, where the lowest digit of a number - is at digit position 0. For example, digit(5678, 3) is 5, and - bit(0b1000100, 2) is 1. Negative digit positions indicate places + is at digit position 0. For example, digit(5678, 3) is 5, and + bit(0b1000100, 2) is 1. Negative digit positions indicate places to the right of the decimal or binary point, so that for example, digit(3.456, -1) is 4. @@ -139,11 +139,11 @@ The functions rcin, rcmul, rcout, rcpow, and rcsq are used to perform modular arithmetic calculations for large odd numbers - faster than the usual methods. To do this, you first use the + faster than the usual methods. To do this, you first use the rcin function to convert all input values into numbers which are - in a format called REDC format. Then you use rcmul, rcsq, and + in a format called REDC format. Then you use rcmul, rcsq, and rcpow to multiply such numbers together to produce results also - in REDC format. Finally, you use rcout to convert a number in + in REDC format. Finally, you use rcout to convert a number in REDC format back to a normal number. The addition, subtraction, negation, and equality comparison between REDC numbers are done using the normal modular methods. For example, to calculate the @@ -185,8 +185,8 @@ The following convention is used to declare modes: - base config - value string + base config + value string 2 "binary" binary fractions 8 "octal" octal fractions diff --git a/help/builtin.top b/help/builtin.top index 6fc4a5e..d4ec0c5 100644 --- a/help/builtin.top +++ b/help/builtin.top @@ -1,8 +1,8 @@ Builtin functions - There is a large number of built-in functions. Many of the + There is a large number of built-in functions. Many of the functions work on several types of arguments, whereas some only - work for the correct types (e.g., numbers or strings). In the + work for the correct types (e.g., numbers or strings). In the following description, this is indicated by whether or not the description refers to values or numbers. This display is generated by the 'show builtin' command. diff --git a/help/calclevel b/help/calclevel index d9c8f4d..82641d8 100644 --- a/help/calclevel +++ b/help/calclevel @@ -10,7 +10,7 @@ TYPES DESCRIPTION This function returns the calculation level at which it is called. When a command is being read from a terminal or from a file, - calc is at calculation level zero. The level is increased + calc is at calculation level zero. The level is increased by 1 each time calculation starts of a user-defined function or of eval(S) for some expression S which evaluates to a string. It decreases to zero if an error occurs or a quit or abort statement diff --git a/help/cfappr b/help/cfappr index 3f7a645..262f6a7 100644 --- a/help/cfappr +++ b/help/cfappr @@ -6,7 +6,7 @@ SYNOPSIS TYPES x real - eps real with abs(eps) < 1, defaults to epsilon() + eps real with abs(eps) < 1, defaults to epsilon() n real with n >= 1 rnd integer, defaults to config("cfappr") @@ -21,7 +21,7 @@ DESCRIPTION If n >= 1 and den(x) > n, cfappr(x, n) returns the nearest above, nearest below, or nearest, approximation to x with denominator less - than or equal to n. If den(x) <= n, cfappr(x,n) returns x. + than or equal to n. If den(x) <= n, cfappr(x,n) returns x. In either case when the result v is not x, how v relates to x is determined by bits 0, 1, 2 and 4 of the argument rnd in the same way as diff --git a/help/cfsim b/help/cfsim index 7e0fc27..4a405ae 100644 --- a/help/cfsim +++ b/help/cfsim @@ -30,7 +30,7 @@ DESCRIPTION This corresponds to the use of rnd for functions like round(x, n, rnd). If bit 3 or 4 of rnd is set, the lower order bits are ignored; bit 3 - is ignored if bit 4 is set. Thusi, for rnd > 3, it sufficient to + is ignored if bit 4 is set. Thusi, for rnd > 3, it sufficient to consider the two cases rnd = 8 and rnd = 16. If den(x) > 2, cfsim(x, 8) returns the value of the penultimate simple @@ -55,7 +55,7 @@ DESCRIPTION rnd integer x half-integer x den(x) > 2 - 8 0 x - sgn(x)/2 approximant + 8 0 x - sgn(x)/2 approximant 16 x - sgn(x) x + sgn(x)/2 nearest From either cfsim(x, 0) and cfsim(x, 1), the other is easily @@ -72,7 +72,7 @@ DESCRIPTION Iteration of cfsim(x,8) until an integer is obtained gives a sequence of "good" approximations to x with decreasing denominators and correspondingly decreasing accuracy; each denominator is less than half - the preceding denominator. (Unlike the "forward" sequence of + the preceding denominator. (Unlike the "forward" sequence of continued-fraction approximants these are not necessarily alternately greater than and less than x.) diff --git a/help/cmp b/help/cmp index 4c9fe4e..2a3f3a4 100644 --- a/help/cmp +++ b/help/cmp @@ -17,7 +17,7 @@ TYPES return if x and y are both real: -1, 0, or 1 if x and y are both numbers but not both real: - -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i, or 1-1i + -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i, or 1-1i if x and y are both strings: -1, 0, or 1 all other cases: the null value @@ -47,7 +47,7 @@ DESCRIPTION obj point {x,y}; if points with real components are to be partially ordered by their - euclidean distance from the origin, an appropriate point_rel + euclidean distance from the origin, an appropriate point_rel function may be that given by define point_rel(a,b) = sgn(a.x^2 + a.y^2 - b.x^2 - b.y^2); diff --git a/help/command b/help/command index 0ac0d3e..de2760a 100644 --- a/help/command +++ b/help/command @@ -3,7 +3,7 @@ Command sequence This is a sequence of any the following command formats, where each command is terminated by a semicolon or newline. Long command lines can be extended by using a back-slash followed by a newline - character. When this is done, the prompt shows a double angle + character. When this is done, the prompt shows a double angle bracket to indicate that the line is still in progress. Certain cases will automatically prompt for more input in a similar manner, even without the back-slash. The most common case for this is when @@ -25,7 +25,7 @@ Command sequence The second form defines a simple function which calculates the specified expression value from the specified parameters. The expression cannot be a statement. However, the comma - and question mark operators can be useful. Examples of + and question mark operators can be useful. Examples of simple functions are: define sumcubes(a, b) = a^3 + b^3 @@ -45,7 +45,7 @@ Command sequence read filename read -once filename This reads definitions from the specified filename. - The name can be quoted if desired. The calculator + The name can be quoted if desired. The calculator uses the CALCPATH environment variable to search through the specified directories for the filename, similarly to the use of the PATH environment variable. @@ -54,7 +54,7 @@ Command sequence directory followed by a general calc library directory). The ".cal" extension is defaulted for input files, so that if "filename" is not found, then "filename.cal" is - then searched for. The contents of the filename are + then searched for. The contents of the filename are command sequences which can consist of expressions to evaluate or functions to define, just like at the top level command level. @@ -82,7 +82,7 @@ Command sequence later read in order to recreate the variable values. For speed reasons, values are written as hex fractions. This command currently only saves simple types, so that - matrices, lists, and objects are not saved. Function + matrices, lists, and objects are not saved. Function definitions are also not saved. If the -m mode disallows opening of files for writing, @@ -247,7 +247,7 @@ Command sequence > <==== calc interactive prompt because the '-i' calc causes ABORT to drop into an - interactive prompt. However typing a QUIT or ABORT + interactive prompt. However typing a QUIT or ABORT at the interactive prompt level will always calc to exit, even when calc is invoked with '-i'. @@ -304,5 +304,5 @@ Command sequence Also see the help topic: - statement flow control and declaration statements + statement flow control and declaration statements usage how to invoke the calc command and calc -options diff --git a/help/config b/help/config index f692876..e08f3a6 100644 --- a/help/config +++ b/help/config @@ -1,10 +1,10 @@ Configuration parameters Configuration parameters affect how the calculator performs certain - operations. Among features that are controlled by these parameters + operations. Among features that are controlled by these parameters are the accuracy of some calculations, the displayed format of results, the choice from possible alternative algorithms, and whether or not - debugging information is displayed. The parameters are + debugging information is displayed. The parameters are read or set using the "config" built-in function; they remain in effect until their values are changed by a config or equivalent instruction. The following parameters can be specified: @@ -65,7 +65,7 @@ Configuration parameters It allows functions to control their configuration without impacting the calling function. - There are two configuration state aliases that may be set. To + There are two configuration state aliases that may be set. To set the backward compatible standard configuration: config("all", "oldstd") @@ -105,7 +105,7 @@ Configuration parameters the decimal point to be printed in real or exponential mode in normal unformatted printing (print, strprint, fprint) or in formatted printing (printf, strprintf, fprintf) when precision is not - specified. The initial value for oldstd is 20, for newstd 10. + specified. The initial value for oldstd is 20, for newstd 10. The parameter may be changed to the value d by either config("display", d) or by display (d). This parameter does not change the stored value of a number. Where rounding is necessary to @@ -116,7 +116,7 @@ Configuration parameters calculation of functions for which exact values are not possible or not desired. For most functions, the - remainder = exact value - calculated value + remainder = exact value - calculated value has absolute value less than epsilon, but, except when the sign of the remainder is controlled by an appropriate parameter, the @@ -133,7 +133,7 @@ Configuration parameters The "mode" parameter is a string specifying the mode for printing of numbers by the unformatted print functions, and the default ("%d" specifier) for formatted print functions. The initial mode - is "real". The available modes are: + is "real". The available modes are: "frac" decimal fractions "int" decimal integer @@ -152,10 +152,10 @@ Configuration parameters runs in a time of O(N^2). The second method is a recursive and complicated method which runs in a time of O(N^1.585). The argument for these parameters is the number of binary words at which the - second algorithm begins to be used. The minimum value is 2, and + second algorithm begins to be used. The minimum value is 2, and the maximum value is very large. If 2 is used, then the recursive algorithm is used all the way down to single digits, which becomes - slow since the recursion overhead is high. If a number such as + slow since the recursion overhead is high. If a number such as 1000000 is used, then the recursive algorithm is never used, causing calculations for large numbers to slow down. For a typical example on a 386, the two algorithms are about equal in speed for a value @@ -174,9 +174,9 @@ Configuration parameters Redc2 specifies the sizes of numbers at which calc switches from its first to its second algorithm when using the REDC algorithm. The first algorithm performs a multiply and a modular reduction - together in one loop which runs in O(N^2). The second algorithm + together in one loop which runs in O(N^2). The second algorithm does the REDC calculation using three multiplies, and runs in - O(N^1.585). The argument for redc2 is the size of the modulus at + O(N^1.585). The argument for redc2 is the size of the modulus at which the second algorithm begins to be used. Config("tilde") controls whether or not a leading tilde ('~') is @@ -185,7 +185,7 @@ Configuration parameters specified maximum number. The initial "tilde" value is 1. Config ("tab") controls the printing of a tab before results - automatically displayed when working interactively. It does not + automatically displayed when working interactively. It does not affect the printing by the functions print, printf, etc. The initial "tab" value is 1. @@ -271,7 +271,7 @@ Configuration parameters The default is to print only the first 256 octets. The "blkverbose" determines if all lines, including duplicates - should be printed. If TRUE, then all lines are printed. If false, + should be printed. If TRUE, then all lines are printed. If false, duplicate lines are skipped and only a "*" is printed in a style similar to od. This config value has not meaning if "blkfmt" is "str". @@ -319,7 +319,7 @@ Configuration parameters The "calc_debug" is intended for controlling internal calc routines that test its operation, or collect or display information that - might be useful for debug purposes. Much of the output from these + might be useful for debug purposes. Much of the output from these will make sense only to calc wizards. Zero value (the default for both oldstd and newstd) of config("lib_calc") corresponds to switching off all these routines. For nonzero value, particular bits @@ -401,16 +401,16 @@ Configuration parameters The following are synonyms for true: - "on" "yes" "y" "true" "t" "1" any non-zero number + "on" "yes" "y" "true" "t" "1" any non-zero number The following are synonyms for false: - "off" "no" "n" "false" "f" "0" the number zero (0) + "off" "no" "n" "false" "f" "0" the number zero (0) Examples of setting some parameters are: config("mode", "exp"); exponential output config("display", 50); 50 digits of output epsilon(epsilon() / 8); 3 bits more accuracy - config("tilde", 0) disable roundoff tilde printing + config("tilde", 0) disable roundoff tilde printing config("tab", "off") disable leading tab printing diff --git a/help/contrib b/help/contrib index 50dd8f8..5c20b26 100644 --- a/help/contrib +++ b/help/contrib @@ -40,7 +40,7 @@ You should send submissions to: [[ Replace 'at' with @, 'dot' is with . and remove the spaces ]] -Thanks for considering submitting code to calc. Calc is a collective +Thanks for considering submitting code to calc. Calc is a collective work by a number of people. It would not be what it is today without your efforts and submissions! diff --git a/help/credit b/help/credit index e213b1a..d3483a3 100644 --- a/help/credit +++ b/help/credit @@ -15,7 +15,7 @@ Credits hist.c which is used to do the command line editing. Thanks to Ernest W. Bowen for supplying many improvements in - accuracy and generality for some numeric functions. Much of + accuracy and generality for some numeric functions. Much of this was in terms of actual code which I gratefully accepted. Ernest also supplied the original text for many of the help files. diff --git a/help/custom b/help/custom index d53968b..98e02c2 100644 --- a/help/custom +++ b/help/custom @@ -28,7 +28,7 @@ DESCRIPTION calc -C In other words, explicit action must be taken in order to - enable the use of custom functions. By default (no -C arg) + enable the use of custom functions. By default (no -C arg) custom functions are compiled in but disabled so that only portable calc scripts may be used. @@ -36,7 +36,7 @@ DESCRIPTION multi-precision calculations in a C-like environment. You should consider implementing algorithms in the calc language as a first choice. Sometimes an algorithm requires use of special hardware, a - non-portable OS or pre-compiled C library. In these cases a custom + non-portable OS or pre-compiled C library. In these cases a custom interface may be needed. The custom function interface is intended to make is easy for diff --git a/help/define b/help/define index 7ef2ee3..06883fd 100644 --- a/help/define +++ b/help/define @@ -9,7 +9,7 @@ Function definitions by a return statement, and the function definition is ended with a right brace. - There are some subtle differences, however. The types of parameters + There are some subtle differences, however. The types of parameters and variables are not defined at compile time, and may vary during execution and be different in different calls to the function. For example, a two-argument function add may be defined by diff --git a/help/den b/help/den index 0d5bb6d..413b1b4 100644 --- a/help/den +++ b/help/den @@ -11,7 +11,7 @@ TYPES DESCRIPTION For real x, den(x) returns the denominator of x when x is expressed - in lowest terms with positive denominator. In calc, + in lowest terms with positive denominator. In calc, real values are actually rational values. Each calc real value can be uniquely expressed as: diff --git a/help/environment b/help/environment index 7ba0b7c..c60369e 100644 --- a/help/environment +++ b/help/environment @@ -14,7 +14,7 @@ Environment variables /usr/local/lib/calc - This value is used by the READ command. It is an error + This value is used by the READ command. It is an error if no such readable file is found. The CALCBINDINGS file searches the CALCPATH as well. diff --git a/help/errorcodes.sed b/help/errorcodes.sed index 5a6dabd..79fca55 100644 --- a/help/errorcodes.sed +++ b/help/errorcodes.sed @@ -1 +1 @@ -/^#define E_[^_].*[ ][1-9][0-9]*[ ]\/\* .* \*\//s/#define E_.*[ ]\([1-9][0-9]*\)[ ]*\/\* \(.*\)[ ][ ]*\*\// \1 \2/p +/^#define E_[^_].*[ ][1-9][0-9]*[ ]\/\* .* \*\//s/#define E_.*[ ]\([1-9][0-9]*\)[ ]*\/\* \(.*\)[ ][ ]*\*\// \1 \2/p diff --git a/help/eval b/help/eval index f585e43..28135cf 100644 --- a/help/eval +++ b/help/eval @@ -11,7 +11,7 @@ TYPES DESCRIPTION For eval(str), the value of str is to be a string that could be the body - of the definition of a function f(). This string may declare local + of the definition of a function f(). This string may declare local variables and include keywords (while, for, ...) other than the reserved keywords (define, show, help, read, write, show, cd) intended for interactive use or for reading from a file. diff --git a/help/exp b/help/exp index 5931f2b..3b11e63 100644 --- a/help/exp +++ b/help/exp @@ -1,5 +1,5 @@ NAME - exp - exponential function + exp - exponential function SYNOPSIS exp(x [,eps]) diff --git a/help/factor b/help/factor index 30aff53..9f83677 100644 --- a/help/factor +++ b/help/factor @@ -14,7 +14,7 @@ TYPES DESCRIPTION If n >= 0 and n has a prime factor less than or equal to limit, - factor(n, limit) returns the smallest such factor. If n >= 0 + factor(n, limit) returns the smallest such factor. If n >= 0 and the smallest prime factor of n exceeds limit, 1 is returned. In particular, if n >= 0 and limit <= 1, factor(n, limit) always returns 1; factor(n,2) returns 2 if and only if n is even. diff --git a/help/fclose b/help/fclose index ebadb08..5379660 100644 --- a/help/fclose +++ b/help/fclose @@ -13,7 +13,7 @@ DESCRIPTION This function closes the open file associated with the descriptor fd. When this is done, the file value associated with the file remains a file value, but appears 'closed', and cannot be used in further - file-related calls (except fclose) without causing errors. This same + file-related calls (except fclose) without causing errors. This same action occurs to all copies of the file value. You do not need to explicitly close all the copies of a file value. @@ -26,7 +26,7 @@ DESCRIPTION there had been an error using the file, or the null value if there was no error. - Closing a closed file is permitted. Fclose returns null in + Closing a closed file is permitted. Fclose returns null in this case. EXAMPLE diff --git a/help/feof b/help/feof index 37f3b2f..8d5893d 100644 --- a/help/feof +++ b/help/feof @@ -14,7 +14,7 @@ DESCRIPTION is set or clear. The end-of-file flag for the stream fd is set if reading at the - end-of-file position is attempted. The flag is cleared by + end-of-file position is attempted. The flag is cleared by positioning operations (fseek, rewind, fsetpos) and by freopen. EXAMPLE @@ -23,14 +23,14 @@ EXAMPLE > fflush(fd1) > fd2 = fopen("/tmp/newfile", "r") > feof(fd2) - 0 + 0 > fgetline(fd2) "Chongo was here" > feof(fd2) - 0 + 0 > fgetline(fd2) > feof(fd2) - 1 + 1 LIMITS none diff --git a/help/ferror b/help/ferror index de1b6cb..bcb792a 100644 --- a/help/ferror +++ b/help/ferror @@ -20,7 +20,7 @@ DESCRIPTION EXAMPLE > fd = fopen("/etc/motd", "r") > ferror(fd) - 0 + 0 LIMITS fd must be associaed with an open file diff --git a/help/fgetc b/help/fgetc index 4b45ee1..89c2276 100644 --- a/help/fgetc +++ b/help/fgetc @@ -14,7 +14,7 @@ DESCRIPTION associated with fd. If there is a next character, this function returns a 1 - character string containing that character. In the case + character string containing that character. In the case of EOF or error, nil is returned. EXAMPLE diff --git a/help/fgetfield b/help/fgetfield index d41fb73..e7aa4df 100644 --- a/help/fgetfield +++ b/help/fgetfield @@ -16,7 +16,7 @@ DESCRIPTION characters are skipped. If the reading reaches end-of-file, the null value is returned. If non-whitespace is encountered, formation of a string begins, continuing until whitespace of '\0' or end-of-file - is reached. The returned value is this string (terminated as usual + is reached. The returned value is this string (terminated as usual by a null character). After the operation, the file position will be immediately after the first whitespace character of '\0' or at end-of-file. diff --git a/help/fgetline b/help/fgetline index 99c0163..28cad8c 100644 --- a/help/fgetline +++ b/help/fgetline @@ -14,7 +14,7 @@ DESCRIPTION the open file associated with fd. Unlike fgets, the trailing newline is removed from the return string. - Empty lines return the null string. When the end of file is reached, + Empty lines return the null string. When the end of file is reached, fgetline returns the null value. (Note the distinction between a null string and a null value.) diff --git a/help/file b/help/file index d4aec0c..c555159 100644 --- a/help/file +++ b/help/file @@ -6,7 +6,7 @@ Using files Some differences do occur, as will be explained here. Names of files are subject to ~ expansion just like the C or - Korn shell. For example, the file name: + Korn shell. For example, the file name: ~/.rc.cal @@ -19,8 +19,8 @@ Using files A file can be opened for either reading, writing, or appending. To do this, the 'fopen' function is used, which accepts a filename - and an open mode, both as strings. You use 'r' for reading, 'w' - for writing, and 'a' for appending. For example, to open the file + and an open mode, both as strings. You use 'r' for reading, 'w' + for writing, and 'a' for appending. For example, to open the file 'foo' for reading, the following could be used: fd = fopen('foo', 'r'); @@ -53,7 +53,7 @@ Using files The 'fclose' function is used to close a file which had been opened. When this is done, the file value associated with the file remains a file value, but appears 'closed', and cannot be used in further - file-related calls (except fclose) without causing errors. This same + file-related calls (except fclose) without causing errors. This same action occurs to all copies of the file value. You do not need to explicitly close all the copies of a file value. The 'fclose' function returns the numeric value of errno if there had been an @@ -67,7 +67,7 @@ Using files print "error #" : badfile : ":", errno(badfile); } - File values can be printed. When this is done, the filename of the + File values can be printed. When this is done, the filename of the opened file is printed inside of quote marks. If the file value had been closed, then the null string is printed. If a file value is the result of a top-level expression, then in addition to the filename, @@ -75,7 +75,7 @@ Using files status is also displayed. File values can be used inside of 'if' tests. When this is done, - an opened file is TRUE, and a closed file is FALSE. As an example + an opened file is TRUE, and a closed file is FALSE. As an example of this, the following loop will print the names of all the currently opened non-standard files with their indexes, and then close them: @@ -89,9 +89,9 @@ Using files The functions to read from files are 'fgetline' and 'fgetc'. The 'fgetline' function accepts a file value, and returns the next input line from a file. The line is returned as a string value, and - does not contain the end of line character. Empty lines return the + does not contain the end of line character. Empty lines return the null string. When the end of file is reached, fgetline returns the - null value. (Note the distinction between a null string and a null + null value. (Note the distinction between a null string and a null value.) If the line contained a numeric value, then the 'eval' function can then be used to convert the string to a numeric value. Care should be used when doing this, however, since eval will @@ -103,7 +103,7 @@ Using files The 'printf' and 'fprintf' functions are used to print results to a file (which could be stdout or stderr). The 'fprintf' function accepts a file variable, whereas the 'printf' function assumes the - use of 'files(1)' (stdout). They both require a format string, which + use of 'files(1)' (stdout). They both require a format string, which is used in almost the same way as in normal C. The differences come in the interpretation of values to be printed for various formats. Unlike in C, where an unmatched format type and value will cause diff --git a/help/files b/help/files index a626c7e..bda5270 100644 --- a/help/files +++ b/help/files @@ -25,7 +25,7 @@ DESCRIPTION files are already open by the calculator and cannot be closed. When calc starts up, it scans for open file descriptors above - stderr (2) and below MAXFILES (20). Any open descriptor found + stderr (2) and below MAXFILES (20). Any open descriptor found is assumed to be an open file opened in an unknown mode. Calc will try to read and write to this file when directed. diff --git a/help/fopen b/help/fopen index 2880f58..698d115 100644 --- a/help/fopen +++ b/help/fopen @@ -20,7 +20,7 @@ DESCRIPTION "a" appending Names of files are subject to ~ expansion just like the C or - Korn shell. For example, the file name: + Korn shell. For example, the file name: ~/lib/gleet diff --git a/help/fputstr b/help/fputstr index 1356b6b..4110d9f 100644 --- a/help/fputstr +++ b/help/fputstr @@ -6,7 +6,7 @@ SYNOPSIS TYPES fs file stream open for writing - s_1, ... string + s_1, ... string return null or error value @@ -22,9 +22,9 @@ EXAMPLE > fputstr(f, "Alpha", "Beta") > freopen(f, "r") > fgetstr(f) - "Alpha" + "Alpha" > fgetstr(f) - "Beta" + "Beta" > fgetstr(f) > > fputstr(f, "Gamma") diff --git a/help/free b/help/free index b09a045..2038edb 100644 --- a/help/free +++ b/help/free @@ -5,14 +5,14 @@ SYNOPSIS free(a, b, ...) TYPES - a, b, ... any + a, b, ... any return null value DESCRIPTION Those of the arguments a, b, ... that specify lvalues are assigned the null value, effectively freeing whatever memory is used to - store their current values. Other arguments are ignored. + store their current values. Other arguments are ignored. free(.) frees the current "old value". diff --git a/help/freeglobals b/help/freeglobals index 51ed4e4..871e515 100644 --- a/help/freeglobals +++ b/help/freeglobals @@ -19,10 +19,10 @@ EXAMPLE Name Level Type ---- ----- ----- - a 1 real = 2 - a 0 real = 1 - b 0 list - c 0 matrix + a 1 real = 2 + a 0 real = 1 + b 0 list + c 0 matrix Number: 4 > freeglobals() @@ -30,10 +30,10 @@ EXAMPLE Name Level Type ---- ----- ----- - a 1 null - a 0 null - b 0 null - c 0 null + a 1 null + a 0 null + b 0 null + c 0 null Number: 4 diff --git a/help/freeredc b/help/freeredc index e6ea9bf..ba51ccb 100644 --- a/help/freeredc +++ b/help/freeredc @@ -15,8 +15,8 @@ EXAMPLE > a = rcin(10,27) > b = rcin(10,15) > show redc - 0 1 27 - 1 2 15 + 0 1 27 + 1 2 15 > freeredc() > show redc > diff --git a/help/freestatics b/help/freestatics index 8d86343..3f8dd34 100644 --- a/help/freestatics +++ b/help/freestatics @@ -26,7 +26,7 @@ EXAMPLE Name Scopes Type ---- ------ ----- - a 1 0 real = 6 + a 1 0 real = 6 Number: 1 > freestatics() diff --git a/help/frem b/help/frem index d6b6764..23585f8 100644 --- a/help/frem +++ b/help/frem @@ -14,7 +14,7 @@ DESCRIPTION If x and y are not zero and n is the largest non-negative integer for which y^n is a divisor of x, frem(x,y) returns abs(x/y^n). In particular, abs(x) is returned if x is not divisible by - y or if abs(y) = 1. If abs(y) > 1, frem(x,y) is the greatest + y or if abs(y) = 1. If abs(y) > 1, frem(x,y) is the greatest divisor of x not divisible by y. For all x, frem(x,0) is defined to equal abs(x). diff --git a/help/freopen b/help/freopen index 2269a7b..b4b7953 100644 --- a/help/freopen +++ b/help/freopen @@ -18,7 +18,7 @@ DESCRIPTION With three arguments, fs, if open, is closed, and an attempt is made to open the file with the specified name and assign it to the stream - fs. A non-null value is returned only if the attempt fails. + fs. A non-null value is returned only if the attempt fails. EXAMPLE diff --git a/help/fscanf b/help/fscanf index 5b0f197..e96024e 100644 --- a/help/fscanf +++ b/help/fscanf @@ -31,7 +31,7 @@ DESCRIPTION '%'. A single '%' read from fmt is taken to indicate the beginning of a conversion specification field consisting in succession of: - an optional '*', + an optional '*', optional decimal digits, one of 'c', 's', 'n', 'f', 'e', 'i' or a scanset specifier. @@ -40,7 +40,7 @@ DESCRIPTION other sequence of characters follows the '%', characters before the first exceptional character (which could be the terminating null character of the fmt string) are ignored, e.g. the sequence " %*3d " does - the same as " d ". If there is no '*' at the beginning of the specifier, + the same as " d ". If there is no '*' at the beginning of the specifier, and the list x_1, x_2, ... has not been exhausted, a value will be assigned to the next lvalue in the list; if no lvalue remains, the reading of fs stops and the function returns the number @@ -68,7 +68,7 @@ DESCRIPTION The cases 'f', 'e', 'r', 'i' may be considered to indicate expectation of floating-point, exponential, ratio, or integer representation of the - number to be read. For example, 'i' + number to be read. For example, 'i' might be taken to suggest a number like +2345; 'r' might suggest a representation like -27/49; 'e' might suggest a representation like 1.24e-7; 'f' might suggest a representation like 27.145. However, there @@ -82,7 +82,7 @@ DESCRIPTION 2+3/4*7i+3.15e7 - would be interpreted as for an ordinary evaluation. A decimal fraction + would be interpreted as for an ordinary evaluation. A decimal fraction may have more than one dot: dots after the first, which is taken to be the decimal point, are ignored. Thus "12.3..45e6.7" is interpreted as if it were "12.345e67". diff --git a/help/gcd b/help/gcd index c09cdcc..0499158 100644 --- a/help/gcd +++ b/help/gcd @@ -5,7 +5,7 @@ SYNOPSIS gcd(x1, x2, ...) TYPES - x1, x2, ... rational number + x1, x2, ... rational number return rational number diff --git a/help/hash b/help/hash index ca9d255..a3b5537 100644 --- a/help/hash +++ b/help/hash @@ -15,12 +15,12 @@ DESCRIPTION The basis of this hash algorithm was taken from an idea sent as reviewer comments to the IEEE POSIX P1003.2 committee by: - Phong Vo (http://www.research.att.com/info/kpv/) - Glenn Fowler (http://www.research.att.com/~gsf/) + Phong Vo (http://www.research.att.com/info/kpv/) + Glenn Fowler (http://www.research.att.com/~gsf/) In a subsequent ballot round: - Landon Curt Noll (http://reality.sgi.com/chongo/) + Landon Curt Noll (http://reality.sgi.com/chongo/) improved on their algorithm. Some people tried this hash and found that it worked rather well. In an EMail message @@ -30,7 +30,7 @@ DESCRIPTION collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate. See: - http://reality.sgi.com/chongo/tech/comp/fnv/ + http://reality.sgi.com/chongo/tech/comp/fnv/ for more details as well as other forms of the FNV hash. diff --git a/help/help b/help/help index 5a64f9b..a304202 100644 --- a/help/help +++ b/help/help @@ -60,7 +60,7 @@ For example: help usage -will print the calc command usage information. One can obtain calc help +will print the calc command usage information. One can obtain calc help without invoking any startup code by running calc as follows: calc -q help topic @@ -76,7 +76,7 @@ for details of the -m mode. The help command is able to display installed help files for custom builtin functions. However, if the custom name is the same as a standard help -file, the standard help file will be displayed instead. The custom help +file, the standard help file will be displayed instead. The custom help builtin should be used to directly access the custom help file. For example, the custom help builtin has the same name as the standard diff --git a/help/highbit b/help/highbit index 1e3aa17..b1e4bb5 100644 --- a/help/highbit +++ b/help/highbit @@ -11,7 +11,7 @@ TYPES DESCRIPTION If x is a nonzero integer, highbit(x) returns the index of the - highest bit in the binary representation of abs(x). Equivalently, + highest bit in the binary representation of abs(x). Equivalently, highbit(x) = n if 2^n <= abs(x) < 2^(n + 1); the binary representation of x then has n + 1 digits. diff --git a/help/history b/help/history index f57e9d4..292f056 100644 --- a/help/history +++ b/help/history @@ -11,7 +11,7 @@ Command history for future recall. Before the return key is typed, the current line can be edited - using emacs-like editing commands. As examples, ^A moves to + using emacs-like editing commands. As examples, ^A moves to the beginning of the line, ^F moves forwards through the line, backspace removes characters from the line, and ^K kills the rest of the line. @@ -24,7 +24,7 @@ Command history Typing h lists all of the commands in the command history and numbers the lines. The most recently executed line is always - number 1, the next most recent number 2, and so on. The numbering + number 1, the next most recent number 2, and so on. The numbering for a particular command therefore changes as lines are entered. Typing a number at the beginning of a line followed by g @@ -51,11 +51,11 @@ Command history The actual keys used for editing are defined in a bindings file, usually called /usr/local/lib/calc/bindings. Changing the entries - in this file will change the key bindings used for editing. If the + in this file will change the key bindings used for editing. If the file is not readable, then a message will be output and command line editing is disabled. In this case you can only edit each line as provided by the terminal driver in the operating system. A shell command can be executed by typing '!cmd', where cmd - is the command to execute. If cmd is not given, then a shell + is the command to execute. If cmd is not given, then a shell command level is started. diff --git a/help/inputlevel b/help/inputlevel index e67d5de..d940ca4 100644 --- a/help/inputlevel +++ b/help/inputlevel @@ -11,10 +11,10 @@ DESCRIPTION This function returns the input level at which it is called. When calc starts, it is at level zero. The level is increased by 1 each time execution starts of a read file command or a call to - eval(S) for some expression S which evaluates to a string. It + eval(S) for some expression S which evaluates to a string. It decreases by 1 when a file being read reaches EOF or a string being eval-ed reaches '\0', or earlier if a quit statement is - encountered at top calculation-level in the flle or string. It + encountered at top calculation-level in the flle or string. It decreases to zero if an abort statement is encountered at any function-level in the file or string. If a quit or abort statement is encountered at top calculation-level at top input-level, diff --git a/help/interrupt b/help/interrupt index 55dc7a4..67f129b 100644 --- a/help/interrupt +++ b/help/interrupt @@ -9,13 +9,13 @@ Interrupts You can generate the SIGINT signal multiple times if necessary, and each time the calculator will abort the calculation at a more - risky place within the calculation. Each new interrupt prints a + risky place within the calculation. Each new interrupt prints a message of the form: [Abort level n] - where n ranges from 1 to 3. For n equal to 1, the calculator will - abort calculations at the next statement boundary. For n equal to 2, + where n ranges from 1 to 3. For n equal to 1, the calculator will + abort calculations at the next statement boundary. For n equal to 2, the calculator will abort calculations at the next opcode boundary. For n equal to 3, the calculator will abort calculations at the next lowest level arithmetic operation boundary. diff --git a/help/intro b/help/intro index a80d6d9..0bdac59 100644 --- a/help/intro +++ b/help/intro @@ -2,12 +2,12 @@ Quick introduction This is an interactive calculator which provides for easy large numeric calculations, but which also can be easily programmed - for difficult or long calculations. It can accept a command line + for difficult or long calculations. It can accept a command line argument, in which case it executes that single command and exits. Otherwise, it enters interactive mode. In this mode, it accepts commands one at a time, processes them, and displays the answers. In the simplest case, commands are simply expressions which are - evaluated. For example, the following line can be input: + evaluated. For example, the following line can be input: 3 * (4 + 1) diff --git a/help/isblk b/help/isblk index 7d265f4..a22206d 100644 --- a/help/isblk +++ b/help/isblk @@ -14,7 +14,7 @@ DESCRIPTION named block, 0 otherwise. Note that a named block B retains its name after its data block is - freed by rmblk(B). That a named block B has null data block may be + freed by rmblk(B). That a named block B has null data block may be tested using sizeof(B); this returns 0 if and only if the memory has been freed. diff --git a/help/iseven b/help/iseven index dc8d02b..f939d18 100644 --- a/help/iseven +++ b/help/iseven @@ -10,7 +10,7 @@ TYPES return int DESCRIPTION - Determine if x is an even integer. This function will return 1 if x is + Determine if x is an even integer. This function will return 1 if x is even integer, 0 otherwise. EXAMPLE diff --git a/help/ismat b/help/ismat index ee1dc76..f369345 100644 --- a/help/ismat +++ b/help/ismat @@ -10,7 +10,7 @@ TYPES return int DESCRIPTION - Determine if x is a matrix. This function will return 1 if x is + Determine if x is a matrix. This function will return 1 if x is a matrix, 0 otherwise. EXAMPLE diff --git a/help/isnum b/help/isnum index d036559..fd24a1b 100644 --- a/help/isnum +++ b/help/isnum @@ -10,7 +10,7 @@ TYPES return int DESCRIPTION - Determine if x is a numeric value. This function will return 1 if x + Determine if x is a numeric value. This function will return 1 if x is a a numeric value, 0 otherwise. EXAMPLE diff --git a/help/isprime b/help/isprime index 7f1a505..f4ee5ea 100644 --- a/help/isprime +++ b/help/isprime @@ -11,7 +11,7 @@ TYPES return int DESCRIPTION - Determine if x is is a small prime. This function will return + Determine if x is is a small prime. This function will return 1 if x is a small prime. If x is even, this function will return 0. If x is negative or a small composite (non-prime), 0 will be returned. @@ -39,7 +39,7 @@ EXAMPLE -1 2 0 LIMITS - err not given and (y is even or y < 2^32) + err not given and (y is even or y < 2^32) LIBRARY FLAG zisprime(ZVALUE x) (return 1 if prime, 0 not prime, -1 if >= 2^32) diff --git a/help/isrel b/help/isrel index df6cd57..9ba5a46 100644 --- a/help/isrel +++ b/help/isrel @@ -11,7 +11,7 @@ TYPES return int DESCRIPTION - Determine if x and y are relatively prime. If gcd(x,y) == 1, then + Determine if x and y are relatively prime. If gcd(x,y) == 1, then return 1, otherwise return 0. EXAMPLE diff --git a/help/issq b/help/issq index fa6748f..7cb689b 100644 --- a/help/issq +++ b/help/issq @@ -10,7 +10,7 @@ TYPES return int DESCRIPTION - Determine if x is a square. If there exists integers a, b such that: + Determine if x is a square. If there exists integers a, b such that: x == a^2 / b^2 (b != 0) diff --git a/help/isstr b/help/isstr index fc210f5..0121e4c 100644 --- a/help/isstr +++ b/help/isstr @@ -10,7 +10,7 @@ TYPES return int DESCRIPTION - Determine if x is a string. This function will return 1 if x is + Determine if x is a string. This function will return 1 if x is a string, 0 otherwise. EXAMPLE diff --git a/help/jacobi b/help/jacobi index 3c1d378..daee482 100644 --- a/help/jacobi +++ b/help/jacobi @@ -29,7 +29,7 @@ DESCRIPTION where the p_i are primes, not necessarily distinct, the jacobi symbol function is given by - jacobi(x,y) = (x/p_1) * (x/p_2) * ... * (x/p_k). + jacobi(x,y) = (x/p_1) * (x/p_2) * ... * (x/p_k). where the functions on the right are Legendre symbol functions. diff --git a/help/join b/help/join index 93be7d9..466e52b 100644 --- a/help/join +++ b/help/join @@ -23,11 +23,11 @@ EXAMPLE > join(A, B) list (5 elements, 5 nonzero): - [[0]] = 1 - [[1]] = 2 - [[2]] = 3 - [[3]] = 4 - [[4]] = 5 + [[0]] = 1 + [[1]] = 2 + [[2]] = 3 + [[3]] = 4 + [[4]] = 5 LIMITS none diff --git a/help/lcm b/help/lcm index 6ef3ba3..7fc8fb9 100644 --- a/help/lcm +++ b/help/lcm @@ -5,7 +5,7 @@ SYNOPSIS lcm(x1, x2, ...) TYPES - x1, x2, ... rational number + x1, x2, ... rational number return rational number diff --git a/help/list b/help/list index c6dfa04..c38860f 100644 --- a/help/list +++ b/help/list @@ -24,12 +24,12 @@ DESCRIPTION 4, 6, and 7. The 'push' and 'pop' functions insert or remove an element from - the beginning of the list. The 'append' and 'remove' functions + the beginning of the list. The 'append' and 'remove' functions insert or remove an element from the end of the list. The 'insert' and 'delete' functions insert or delete an element from the middle (or ends) of a list. The functions which insert elements return the null value, but the functions which remove an element return - the element as their value. The 'size' function returns the number + the element as their value. The 'size' function returns the number of elements in the list. Note that these functions manipulate the actual list argument, @@ -43,11 +43,11 @@ DESCRIPTION An arbitrary element of a linked list can be accessed by using the double-bracket operator. The beginning of the list has index 0. Thus in the new list x above, the expression x[[0]] returns the - value of the first element of the list, which is 9. Note that this + value of the first element of the list, which is 9. Note that this indexing does not remove elements from the list. Since lists are doubly linked in memory, random access to arbitrary - elements can be slow if the list is large. However, for each list + elements can be slow if the list is large. However, for each list a pointer is kept to the latest indexed element, thus relatively sequential accesses to the elements in a list will not be slow. diff --git a/help/lowbit b/help/lowbit index 8e98e91..da90818 100644 --- a/help/lowbit +++ b/help/lowbit @@ -11,7 +11,7 @@ TYPES DESCRIPTION If x is a nonzero integer, lowbit(x) returns the index of the - lowest nonzero bit in the binary representation of abs(x). Equivalently, + lowest nonzero bit in the binary representation of abs(x). Equivalently, lowbit(x) is the greatest integer for which x/2^n is an integer; the binary representation of x then ends with n zero bits. diff --git a/help/mat b/help/mat index ea50a68..414c538 100644 --- a/help/mat +++ b/help/mat @@ -18,14 +18,14 @@ Using matrices x = name[3,5]; The double-square bracket operator can be used on any matrix to - make references to the elements easy and efficient. This operator + make references to the elements easy and efficient. This operator bypasses the normal indexing mechanism, and treats the array as if it was one-dimensional and with a lower bound of zero. In this indexing mode, elements correspond to the normal indexing mode where the rightmost index increases most frequently. For example, when using double-square bracket indexing on a two-dimensional matrix, increasing indexes will reference the matrix elements left to right, - row by row. Thus in the following example, 'x' and 'y' are copied + row by row. Thus in the following example, 'x' and 'y' are copied from the same matrix element: mat m[1:2, 1:3]; diff --git a/help/max b/help/max index 5867974..38ab847 100644 --- a/help/max +++ b/help/max @@ -34,9 +34,9 @@ DESCRIPTION and returns a real-number value for any comparison that has to be made, max(x_1, x_2, ...) returns the value determined by max(x_1) = x_1, and succesively for later arguments, by the use of the equivalent of - max(a,b) = (a < b) ? b : a. If the ordering determined by < is total, + max(a,b) = (a < b) ? b : a. If the ordering determined by < is total, max(x_1, ...) will be the maximum value among the arguments. For a - preorder relation it may be one of several maximal values. For + preorder relation it may be one of several maximal values. For other relations, it may be difficult to predict the result. EXAMPLE diff --git a/help/md5 b/help/md5 index a5dc06e..2346703 100644 --- a/help/md5 +++ b/help/md5 @@ -24,7 +24,7 @@ DESCRIPTION The new arg1 HASH state is returned. If arg1 is not a a HASH state, then the initial HASH is - used and modifed by arg1 and any val args supplied. The + used and modifed by arg1 and any val args supplied. The return value is the new HASH state. The following table gives a summary of actions and return values. diff --git a/help/memsize b/help/memsize index e5b841a..450af6f 100644 --- a/help/memsize +++ b/help/memsize @@ -10,7 +10,7 @@ TYPES return integer DESCRIPTION - This is analogous to the C operator sizeof. It attempts to assess + This is analogous to the C operator sizeof. It attempts to assess the number of bytes in memory used to store a value and all its components plus all of the related structue overhead. Unlike sizeof(x), this builtin includes overhead. @@ -19,7 +19,7 @@ DESCRIPTION end of strings. Unlike sizeof(x), this builtin includes the size demonitor for integers - and the imaginary part for complex values. Storage for holding + and the imaginary part for complex values. Storage for holding 0, 1 and -1 values are also included. The number returned by memsize(x) may be less than the actual number diff --git a/help/min b/help/min index 57d0419..653b25f 100644 --- a/help/min +++ b/help/min @@ -34,9 +34,9 @@ DESCRIPTION and returns a real-number value for any comparison that has to be made, min(x_1, x_2, ...) returns the value determined by min(x_1) = x_1, and succesively for later arguments, by the use of the equivalent of - min(a,b) = (a < b) ? a : b. If the ordering determined by < is total, + min(a,b) = (a < b) ? a : b. If the ordering determined by < is total, min(x_1, ...) will be the minimum value among the arguments. For a - preorder relation it may be one of several minimal values. For other + preorder relation it may be one of several minimal values. For other relations, it may be difficult to predict the result. EXAMPLE diff --git a/help/minv b/help/minv index e5abe82..8a62393 100644 --- a/help/minv +++ b/help/minv @@ -6,7 +6,7 @@ SYNOPSIS TYPES x integer - md integer + md integer return integer @@ -22,11 +22,11 @@ DESCRIPTION 0 0 < v < md md < v < 0 1 -md < v < 0 0 < v < -md 4 0 < v < md 0 < v < -md - 5 -md < v < 0 md < v < 0 - 16 -md/2 < v <= md/2 md/2 <= v < -md/2 - 17 -md/2 <= v < md/2 md/2 < v <= -md/2 - 20 -md/2 < v <= md/2 md/2 < v <= -md/2 - 21 -md/2 <= v < md/2 md/2 <= v < -md/2 + 5 -md < v < 0 md < v < 0 + 16 -md/2 < v <= md/2 md/2 <= v < -md/2 + 17 -md/2 <= v < md/2 md/2 < v <= -md/2 + 20 -md/2 < v <= md/2 md/2 < v <= -md/2 + 21 -md/2 <= v < md/2 md/2 <= v < -md/2 EXAMPLE > c = config("mod", 0) diff --git a/help/mmin b/help/mmin index 609b4bf..6447dbf 100644 --- a/help/mmin +++ b/help/mmin @@ -6,7 +6,7 @@ SYNOPSIS TYPES x number (real or complex), matrix, list, object - md real + md real return real diff --git a/help/mod b/help/mod index 807b467..a8d22e8 100644 --- a/help/mod +++ b/help/mod @@ -44,10 +44,10 @@ DESCRIPTION (Blank entries indicate that the description would be complicated and probably not of much interest.) - rnd & 15 sign of r parity of q + rnd & 15 sign of r parity of q 0 sgn(y) - 1 -sgn(y) + 1 -sgn(y) 2 sgn(x) 3 -sgn(x) 4 + @@ -55,7 +55,7 @@ DESCRIPTION 6 sgn(x/y) 7 -sgn(x/y) 8 even - 9 odd + 9 odd 10 even if x/y > 0, otherwise odd 11 odd if x/y > 0, otherwise even 12 even if y > 0, otherwise odd diff --git a/help/nextcand b/help/nextcand index 8bc9aa0..94b10be 100644 --- a/help/nextcand +++ b/help/nextcand @@ -43,7 +43,7 @@ DESCRIPTION RUNTIME The runtime for v = nextcand(n, ...) will depend strongly on the - number and nature of the integers between n and v. If this number + number and nature of the integers between n and v. If this number is reasonably large the size of count is largely irrelevant as the compositeness of the numbers between n and v will usually be determined by the test for small prime factors or one pseudoprime diff --git a/help/norm b/help/norm index 2060d4f..f82d2a8 100644 --- a/help/norm +++ b/help/norm @@ -17,7 +17,7 @@ TYPES DESCRIPTION For real x, norm(x) returns: - x^2. + x^2. For complex x, norm(x) returns: diff --git a/help/null b/help/null index 9727457..ee9fb63 100644 --- a/help/null +++ b/help/null @@ -5,7 +5,7 @@ SYNOPSIS null([v_1, v_2,...]) TYPES - v_1, v_2,... any + v_1, v_2,... any return null DESCRIPTION diff --git a/help/obj.file b/help/obj.file index 05f99c2..17c2402 100644 --- a/help/obj.file +++ b/help/obj.file @@ -15,7 +15,7 @@ Using objects where D is a fixed integer, and 'a' and 'b' are arbitrary rational numbers. Addition, subtraction, multiplication, and division can be performed on such numbers, and the result can be put unambiguously - into the same form. (Complex numbers are an example of surds, where + into the same form. (Complex numbers are an example of surds, where D is -1.) The "obj" statement defines either an object type or an actual @@ -53,8 +53,8 @@ Using objects called. The user function is called with the necessary arguments for that - operation. For example, for "surd_mul", there are two arguments, - which are the two numbers. The order of the arguments is always + operation. For example, for "surd_mul", there are two arguments, + which are the two numbers. The order of the arguments is always the order of the binary operands. If only one of the operands to a binary operator is an object, then the user function for that object type is still called. If the two operands are of different @@ -64,7 +64,7 @@ Using objects The above rules mean that for full generality, user functions should detect that one of their arguments is not of its own object type by using the 'istype' function, and then handle these cases - specially. In this way, users can mix normal numbers with object + specially. In this way, users can mix normal numbers with object types. (Functions which only have one operand don't have to worry about this.) The following example of "surd_mul" demonstrates how to handle regular numbers when used together with surds: @@ -88,13 +88,13 @@ Using objects x.b = a.a * b.b + a.b * b.a; } if (x.b == 0) - return x.a; /* normal number */ + return x.a; /* normal number */ return x; /* return surd */ } In order to print the value of an object nicely, a user defined routine can be provided. For small amounts of output, the print - routine should not print a newline. Also, it is most convenient + routine should not print a newline. Also, it is most convenient if the printed object looks like the call to the creation routine. For output to be correctly collected within nested output calls, output should only go to stdout. This means use the 'print' @@ -121,50 +121,50 @@ Using objects in order to make object calls quicker in general. The double-bracket operator can be used to reference the elements - of any object in a generic manner. When this is done, index 0 + of any object in a generic manner. When this is done, index 0 corresponds to the first element name, index 1 to the second name, - and so on. The 'size' function will return the number of elements + and so on. The 'size' function will return the number of elements in an object. The following is a list of the operations possible for objects. The 'xx' in each function name is replaced with the actual object - type name. This table is displayed by the 'show objfuncs' command. + type name. This table is displayed by the 'show objfuncs' command. Name Args Comments - xx_print 1 print value, default prints elements - xx_one 1 multiplicative identity, default is 1 - xx_test 1 logical test (false,true => 0,1), + xx_print 1 print value, default prints elements + xx_one 1 multiplicative identity, default is 1 + xx_test 1 logical test (false,true => 0,1), default tests elements - xx_add 2 - xx_sub 2 subtraction, default adds negative - xx_neg 1 negative - xx_mul 2 - xx_div 2 non-integral division, default multiplies + xx_add 2 + xx_sub 2 subtraction, default adds negative + xx_neg 1 negative + xx_mul 2 + xx_div 2 non-integral division, default multiplies by inverse - xx_inv 1 multiplicative inverse - xx_abs 2 absolute value within given error - xx_norm 1 square of absolute value - xx_conj 1 conjugate - xx_pow 2 integer power, default does multiply, + xx_inv 1 multiplicative inverse + xx_abs 2 absolute value within given error + xx_norm 1 square of absolute value + xx_conj 1 conjugate + xx_pow 2 integer power, default does multiply, square, inverse - xx_sgn 1 sign of value (-1, 0, 1) - xx_cmp 2 equality (equal,non-equal => 0,1), + xx_sgn 1 sign of value (-1, 0, 1) + xx_cmp 2 equality (equal,non-equal => 0,1), default tests elements - xx_rel 2 inequality (less,equal,greater => -1,0,1) - xx_quo 2 integer quotient - xx_mod 2 remainder of division - xx_int 1 integer part - xx_frac 1 fractional part - xx_inc 1 increment, default adds 1 - xx_dec 1 decrement, default subtracts 1 - xx_square 1 default multiplies by itself - xx_scale 2 multiply by power of 2 - xx_shift 2 shift left by n bits (right if negative) - xx_round 2 round to given number of decimal places - xx_bround 2 round to given number of binary places - xx_root 3 root of value within given error - xx_sqrt 2 square root within given error + xx_rel 2 inequality (less,equal,greater => -1,0,1) + xx_quo 2 integer quotient + xx_mod 2 remainder of division + xx_int 1 integer part + xx_frac 1 fractional part + xx_inc 1 increment, default adds 1 + xx_dec 1 decrement, default subtracts 1 + xx_square 1 default multiplies by itself + xx_scale 2 multiply by power of 2 + xx_shift 2 shift left by n bits (right if negative) + xx_round 2 round to given number of decimal places + xx_bround 2 round to given number of binary places + xx_root 3 root of value within given error + xx_sqrt 2 square root within given error xx_or 2 boolean or xx_and 2 boolean and xx_not 1 boolean not diff --git a/help/oldvalue b/help/oldvalue index e3fe4da..f917a49 100644 --- a/help/oldvalue +++ b/help/oldvalue @@ -12,7 +12,7 @@ DESCRIPTION which at top level when directly from a file or keyboard is automatically assigned the saved value for a line of statements when evaluation of that line is completed and this saved - value is not null. A line of statements is normally completed by a + value is not null. A line of statements is normally completed by a '\n' not within a block bounded by braces or an expression bounded by parentheses. diff --git a/help/operator b/help/operator index 5fc3518..7d6ee73 100644 --- a/help/operator +++ b/help/operator @@ -1,7 +1,7 @@ operators The operators are similar to C, but there are some differences in - the associativity and precedence rules for some operators. In + the associativity and precedence rules for some operators. In addition, there are several operators not in C, and some C operators are missing. A more detailed discussion of situations that may be unexpected for the C programmer may be found in @@ -64,7 +64,7 @@ operators E.g., if A is a matrix, A[(a, b), c] evaluates a, b, and c, and returns the value of A[b, c]. - += -= *= /= %= //= &= |= <<= >>= ^= **= + += -= *= /= %= //= &= |= <<= >>= ^= **= Operator-with-assignments. These associate from left to right, e.g. a += b *= c has the effect of a = (a + b) * c, where only a is required to be an @@ -76,7 +76,7 @@ operators e.g. a = b = c has the effect of a = (b = c). Here both a and b are to be lvalues. - ? : Conditional value. + ? : Conditional value. a ? b : c returns b if a tests as true (i.e. nonzero if a is a number), c otherwise. Thus it is equivalent to: if (a) return b; else return c;. @@ -99,7 +99,7 @@ operators true, b is returned, otherwise a. The effect in a test like "if (a && b) ... " is the same as in C. - == != <= >= < > + == != <= >= < > Relations. + - @@ -134,7 +134,7 @@ operators For the shift operators both arguments are to be integers, or if the first is complex, it is to have - integral real and imaginary parts. Changing the + integral real and imaginary parts. Changing the sign of the second argument reverses the shift, e.g. a >> -b = a << b. The result has the same sign as the first argument except that a nonzero value is @@ -143,8 +143,8 @@ operators e.g. a << b ^ c = a << (b ^ c). + - ! - Plus (+) and minus (-) have their usual meanings as unary - prefix operators at this level of precedence when applied to + Plus (+) and minus (-) have their usual meanings as unary + prefix operators at this level of precedence when applied to other than a first or only term. As a prefix operator, '!' is the logical NOT: !a returns 0 if @@ -156,13 +156,13 @@ operators As a postfix operator ! gives the factorial function, i.e. a! = fact(a). - ++ -- + ++ -- Pre or post incrementing or decrementing. These are applicable only to variables. - [ ] [[ ]] . ( ) + [ ] [[ ]] . ( ) Indexing, double-bracket indexing, element references, - and function calls. Indexing can only be applied to matrices, + and function calls. Indexing can only be applied to matrices, element references can only be applied to objects, but double-bracket indexing can be applied to matrices, objects, or lists. @@ -199,7 +199,7 @@ operators | & Both both arguments must be integers. - << >> + << >> The shift amount must be an integer. The value being shifted must be an integer or a complex number with integral real and imaginary parts. diff --git a/help/overview b/help/overview index 6dfd40c..0f775e0 100644 --- a/help/overview +++ b/help/overview @@ -6,13 +6,13 @@ All numbers are represented as fractions with arbitrarily large numerators and denominators which are always reduced to lowest terms. Real or exponential format numbers can be input and are converted - to the equivalent fraction. Hex, binary, or octal numbers can be + to the equivalent fraction. Hex, binary, or octal numbers can be input by using numbers with leading '0x', '0b' or '0' characters. Complex numbers can be input using a trailing 'i', as in '2+3i'. Strings and characters are input by using single or double quotes. Commands are statements in a C-like language, where each input - line is treated as the body of a procedure. Thus the command + line is treated as the body of a procedure. Thus the command line can contain variable declarations, expressions, labels, conditional tests, and loops. Assignments to any variable name will automatically define that name as a global variable. The @@ -20,7 +20,7 @@ which are evaluated are automatically printed. Thus, you can evaluate an expression's value by simply typing it in. - Many useful built-in mathematical functions are available. Use + Many useful built-in mathematical functions are available. Use the 'show builtins' command to list them. You can also define your own functions by using the 'define' keyword, followed by a function declaration very similar to C. Functions which only @@ -29,7 +29,7 @@ Variables in functions can be defined as either 'global', 'local', or 'static'. Global variables are common to all functions and the command line, whereas local variables are unique to each function - level, and are destroyed when the function returns. Static variables + level, and are destroyed when the function returns. Static variables are scoped within single input files, or within functions, and are never destroyed. Variables are not typed at definition time, but dynamically change as they are used. So you must supply the correct @@ -80,7 +80,7 @@ help full By default, arguments to functions are passed by value (even - matrices). For speed, you can put an ampersand before any + matrices). For speed, you can put an ampersand before any variable argument in a function call, and that variable will be passed by reference instead. However, if the function changes its argument, the variable will change. Arguments to built-in @@ -117,17 +117,17 @@ example 'x.real'. All user-defined routines have names composed of the object type and the action to perform separated by an underscore, as in the example 'complex_add'. The command 'show - objfuncs' lists all the definable routines. Object routines + objfuncs' lists all the definable routines. Object routines which accept two arguments should be prepared to handle cases in which either one of the arguments is not of the expected object type. These are the differences between the normal C operators and - the ones defined by the calculator. The '/' operator divides + the ones defined by the calculator. The '/' operator divides fractions, so that '7 / 2' evaluates to 7/2. The '//' operator is an integer divide, so that '7 // 2' evaluates to 3. The '^' operator is a integral power function, so that 3^4 evaluates to - 81. Matrices of any dimension can be treated as a zero based + 81. Matrices of any dimension can be treated as a zero based linear array using double square brackets, as in 'foo[[3]]'. Matrices can be indexed by using commas between the indices, as in foo[3,4]. Object and list elements can be referenced by @@ -144,10 +144,10 @@ affect calculations or the display of values. For example, the output display mode can be set using 'config(\"mode\", type)', where 'type' is one of 'frac', 'int', 'real', 'exp', 'hex', - 'oct', or 'bin'. The default output mode is real. For the + 'oct', or 'bin'. The default output mode is real. For the integer, real, or exponential formats, a leading '~' indicates that the number was truncated to the number of decimal places - specified by the default precision. If the '~' does not + specified by the default precision. If the '~' does not appear, then the displayed number is the exact value. The number of decimal places printed is set by using diff --git a/help/pmod b/help/pmod index 739e10f..1133fbb 100644 --- a/help/pmod +++ b/help/pmod @@ -25,11 +25,11 @@ DESCRIPTION 0 0 < v < md md < v < 0 1 -md < v < 0 0 < v < -md 4 0 < v < md 0 < v < -md - 5 -md < v < 0 md < v < 0 - 16 -md/2 < v <= md/2 md/2 <= v < -md/2 - 17 -md/2 <= v < md/2 md/2 < v <= -md/2 - 20 -md/2 < v <= md/2 md/2 < v <= -md/2 - 21 -md/2 <= v < md/2 md/2 <= v < -md/2 + 5 -md < v < 0 md < v < 0 + 16 -md/2 < v <= md/2 md/2 <= v < -md/2 + 17 -md/2 <= v < md/2 md/2 < v <= -md/2 + 20 -md/2 < v <= md/2 md/2 < v <= -md/2 + 21 -md/2 <= v < md/2 md/2 <= v < -md/2 EXAMPLE > c = config("mod",0) diff --git a/help/polar b/help/polar index a435213..85bb4fa 100644 --- a/help/polar +++ b/help/polar @@ -6,7 +6,7 @@ SYNOPSIS TYPES r real - t real + t real eps nonzero real, defaults to epsilon() return number (real or complex) diff --git a/help/poly b/help/poly index 1f6a087..b0dc962 100644 --- a/help/poly +++ b/help/poly @@ -24,7 +24,7 @@ TYPES Here an arithmetic type is one for which the required + and * operations are defined, e.g. real or complex numbers or square - matrices of the same size. A coefficient is either of arithmetic + matrices of the same size. A coefficient is either of arithmetic type or a list of coefficients. DESCRIPTION @@ -48,11 +48,11 @@ DESCRIPTION In particular: - poly(a, x) returns the value of a. + poly(a, x) returns the value of a. - poly(a, b, x) returns the value of b + a * x + poly(a, b, x) returns the value of b + a * x - poly(a, b, c, x) returns the value of c + (b + a * x) * x + poly(a, b, c, x) returns the value of c + (b + a * x) * x If the first argument is a list as if defined by: @@ -90,7 +90,7 @@ DESCRIPTION returns the same as poly(list(1,2,3), x). If the number of arguments is less than greatest depth of lists in clist, the - "missing" arguments are deemed to be zero. E.g.: + "missing" arguments are deemed to be zero. E.g.: poly(list(list(1,2), list(3,4), 5), x) diff --git a/help/prevcand b/help/prevcand index be55759..fc7a7eb 100644 --- a/help/prevcand +++ b/help/prevcand @@ -45,7 +45,7 @@ DESCRIPTION RUNTIME The runtime for v = prevcand(n, ...) will depend strongly on the - number and nature of the integers between n and v. If this number + number and nature of the integers between n and v. If this number is reasonably large the size of count is largely irrelevant as the compositeness of the numbers between n and v will usually be determined by the test for small prime factors or one pseudoprime diff --git a/help/printf b/help/printf index de09a77..0f41217 100644 --- a/help/printf +++ b/help/printf @@ -60,14 +60,14 @@ DESCRIPTION number of format specifiers in fmt, the "missing" arguments may be taken to be null values - these contribute nothing to the output; if a positive width w has been specified, the effect is - to produce w spaces, e.g. printf("abc%6dxyz") prints "abc xyz". + to produce w spaces, e.g. printf("abc%6dxyz") prints "abc xyz". If i <= the number of specifiers in fmt, the value of argument x_i is printed in the format specified by the i-th specifier. If a positive width w has been specified and normal printing of x_i does not include a '\n' character, what is printed will if necessary be padded with spaces so that the length of the printed output - is at least the w. Note that control + is at least the w. Note that control characters like '\t', '\b' each count as one character. If the 'right-pad' flag has been set, the padding is on the right; otherwise it is on the left. @@ -79,13 +79,13 @@ DESCRIPTION If the i-th specifier is of numerical type, any numbers in the printing of x_i will be printed in the specified format, unless - this is modified by the printing procedure for x_i's type. Any + this is modified by the printing procedure for x_i's type. Any specified precision will be ignored except for floating-point mode. In the case of floating-point (f) format the precision determines the maximum number of decimal places to be - displayed. Other aspects of this printing may be affected by the + displayed. Other aspects of this printing may be affected by the configuration parameters "outround", "tilde", "fullzero", "leadzero". EXAMPLE diff --git a/help/prompt b/help/prompt index 8cb6074..cb5de4c 100644 --- a/help/prompt +++ b/help/prompt @@ -19,13 +19,13 @@ EXAMPLE > x = prompt("? "); ? 273 > x - "273" + "273" > for (;;) {s = prompt("? "); if (s=="end") break; print "\t":eval(s)^2;} ? 3 - 9 + 9 ? 2 + 3 - 25 + 25 ? end > diff --git a/help/protect b/help/protect index 38da6eb..628c980 100644 --- a/help/protect +++ b/help/protect @@ -17,7 +17,7 @@ DESCRIPTION protection status for var or nblk. With two arguments, protect(var, sts) or protect(nblk, sts) sets the - protection status for var or nblk to the value sts. Each nonzero bit + protection status for var or nblk to the value sts. Each nonzero bit of sts corresponds to one kind of protection as follows: sts protection @@ -42,7 +42,7 @@ DESCRIPTION protect(A, 1); - an error state is established if A = expr is attempted. It does + an error state is established if A = expr is attempted. It does not imply constancy if, for example, the current value of A is a list or matrix; such a value may be changed by assignments to the elements of A, or by push or copy commands. @@ -169,7 +169,7 @@ EXAMPLE mat [2] (2 elements, 1 nonzero): [0] = 0 - [1] = 4 + [1] = 4 > A = blk("alpha") = {1,2,3,4} > protect(A, 0) diff --git a/help/ptest b/help/ptest index f021fa4..9466aff 100644 --- a/help/ptest +++ b/help/ptest @@ -55,7 +55,7 @@ DESCRIPTION For the random case (skip = 0), the probability that any one test with random base b will return 1 if n is composite is always less than 1/4, so with count = k, the probability is less - than 1/4^k. For most values of n the probability is much + than 1/4^k. For most values of n the probability is much smaller, possible zero. RUNTIME @@ -77,7 +77,7 @@ RUNTIME If the word-count for n is less than conf("redc2"), REDC algorithms are used in evaluating ptest(n, count, skip) when small-factor - cases have been eliminated. For small word-counts (say < 10) + cases have been eliminated. For small word-counts (say < 10) this may more than double the speed of evaluation compared with the standard algorithms. @@ -114,7 +114,7 @@ EXAMPLE These results show that a is a strong pseudoprime for all 11 prime bases less than or equal to 31, and for all positive integer bases - less than or equal to 21, but not for the bases 37 and 22. The + less than or equal to 21, but not for the bases 37 and 22. The probability that ptest(a,-1,0) (or ptest(a,1,0)) will return 1 is about 0.19. diff --git a/help/quo b/help/quo index eb13182..92bcc5f 100644 --- a/help/quo +++ b/help/quo @@ -35,10 +35,10 @@ DESCRIPTION one of the two integers v for which abs(x/y - v) < 1. Which integer is returned is controlled by rnd as follows: - rnd sign of x/y - v Description of rounding + rnd sign of x/y - v Description of rounding - 0 + down, towards minus infinity - 1 - up, towards infinity + 0 + down, towards minus infinity + 1 - up, towards infinity 2 sgn(x/y) towards zero 3 -sgn(x/y) from zero 4 sgn(y) diff --git a/help/quomod b/help/quomod index 290fada..14e3cc2 100644 --- a/help/quomod +++ b/help/quomod @@ -14,7 +14,7 @@ TYPES DESCRIPTION Returns 0 or 1 according as x is or is not a multiple of y. - Let x = q * y + r where q is an integer and 0 <= r < y + Let x = q * y + r where q is an integer and 0 <= r < y This function assigns the values q and r to the variables Q and R. If x >= 0, the results for Q and R are the same as those given by Q = x // y, R = x % y. @@ -39,4 +39,4 @@ LIBRARY BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod) SEE ALSO - //, % + //, % diff --git a/help/rand b/help/rand index 98a8ba3..779e507 100644 --- a/help/rand +++ b/help/rand @@ -19,7 +19,7 @@ DESCRIPTION pseudo-random generator. If you need a fast generator and do not need a cryptographically strong one, this generator is likely to do the job. Casual direct use of the shuffle generator may be - acceptable. For a much higher quality cryptographically strong + acceptable. For a much higher quality cryptographically strong (but slower) generator use the Blum-Blum-Shub generator (see the random help page). @@ -55,9 +55,9 @@ DESCRIPTION by Knuth, Vol 2, 2nd edition (1981), Section 3.2.2, page 32, Algorithm B. - The rand generator has a good period, and is fast. It is reasonable as + The rand generator has a good period, and is fast. It is reasonable as generators go, though there are better ones available. The shuffle - method has a very good period, and is fast. It is fairly good as + method has a very good period, and is fast. It is fairly good as generators go, particularly when it is feed reasonably random numbers. Because of this, we use feed values from the additive 55 method into the shuffle method. @@ -120,7 +120,7 @@ DESCRIPTION perceptions that are noted above. It should be noted that the purpose of randreseed64 is to scramble a - seed ONLY. We do not care if these generators produce good random + seed ONLY. We do not care if these generators produce good random numbers. We only want to help eliminate the human factors & perceptions noted above. @@ -144,8 +144,8 @@ DESCRIPTION We will select the randreseed64 multiplier 'a' such that: - a mod 8 == 5 (based on note iii) - 0.01*m < a < 0.99*m (based on note iv) + a mod 8 == 5 (based on note iii) + 0.01*m < a < 0.99*m (based on note iv) 0.01*2^64 < a < 0.99*2^64 a is prime (help keep the generators independent) @@ -159,10 +159,10 @@ DESCRIPTION gcd(a, c) == 1 (adders & multipliers will be more independent) The values 'a' and 'c for randreseed64 are taken from the Rand book - of numbers. Because m=2^64 is 20 decimal digits long, we will + of numbers. Because m=2^64 is 20 decimal digits long, we will search the Rand book of numbers 20 at a time. We will skip any of the 55 values that were used to initialize the additive 55 - generators. The values obtained from the Rand book are: + generators. The values obtained from the Rand book are: a = 6316878969928993981 c = 1363042948800878693 @@ -180,12 +180,12 @@ DESCRIPTION One might object to the complexity of the seed scramble/mapping via the randreseed64 process. But Calling srand(0) with the randreseed64 process would be the same as calling srand(10239951819489363767) - without it. No extra security is gained or reduced by using the + without it. No extra security is gained or reduced by using the randreseed64 process. The meaning of seeds are exchanged, but not lost or favored (used by more than one input seed). The randreseed64 process does not reduce the security of the rand - generator. Every seed is converted into a different unique seed. + generator. Every seed is converted into a different unique seed. No seed is ignored or favored. The truly paranoid might suggest that my claims in the MAGIC NUMBERS diff --git a/help/randbit b/help/randbit index de87f92..eb09ce3 100644 --- a/help/randbit +++ b/help/randbit @@ -11,7 +11,7 @@ TYPES DESCRIPTION If x > 0, randbit(x) returns a pseudo-random integer in [0, 2^x), - i.e. the same as rand(2^x). If the integer returned is + i.e. the same as rand(2^x). If the integer returned is b_1 * 2^(x-1) + b_2 * 2^(x-2) + ... + b_n, diff --git a/help/random b/help/random index 6c97f2f..5eb8fb1 100644 --- a/help/random +++ b/help/random @@ -25,7 +25,7 @@ DESCRIPTION random() Same as rand(0, 2^64) random(max) Same as rand(0, max) - The random generator generates the highest order bit first. Thus: + The random generator generates the highest order bit first. Thus: random(256) @@ -37,7 +37,7 @@ DESCRIPTION The basic idea behind the Blum-Blum-Shub generator is to use the low bit bits of quadratic residues modulo a product of - two 3 mod 4 primes. The lowest int(log2(log2(p*q))) bits are used + two 3 mod 4 primes. The lowest int(log2(log2(p*q))) bits are used where log2() is log base 2 and p,q are two primes 3 mod 4. The Blum-Blum-Shub generator is described in the papers: @@ -52,7 +52,7 @@ DESCRIPTION U. V. Vazirani and V. V. Vazirani, "Trapdoor Pseudo-Random Number Generators with Applications to Protocol Design", - Proceedings of the 24th IEEE Symposium on the Foundations + Proceedings of the 24th IEEE Symposium on the Foundations of Computer Science, 1983, pp. 23-30. U. V. Vazirani and V. V. Vazirani, "Efficient and Secure @@ -71,7 +71,7 @@ DESCRIPTION 1st edition (1994), pp 365-366. This generator is considered 'strong' in that it passes all - polynomial-time statistical tests. The sequences produced are + polynomial-time statistical tests. The sequences produced are random in an absolutely precise way. There is absolutely no better way to predict the sequence than by tossing a coin (as with TRULY random numbers) EVEN IF YOU KNOW THE MODULUS! Furthermore, having @@ -86,7 +86,7 @@ DESCRIPTION To compromise the generator, an adversary must either factor the modulus or perform an exhaustive search just to determine the next - (or previous) bit. If we make the modulus hard to factor (such as + (or previous) bit. If we make the modulus hard to factor (such as the product of two large well chosen primes) breaking the sequence could be intractable for todays computers and methods. @@ -130,7 +130,7 @@ DESCRIPTION is given in the source. While this does not reduce the quality of the generator, knowing the factors of the Blum modulus would help someone determine the next or previous bit when they did - not know the seed. If this bothers you, feel free to use one + not know the seed. If this bothers you, feel free to use one of the other compiled in Blum moduli or provide your own. See the srandom help page for details. diff --git a/help/randombit b/help/randombit index 9edf994..024ed5b 100644 --- a/help/randombit +++ b/help/randombit @@ -11,7 +11,7 @@ TYPES DESCRIPTION If x > 0, randombit(x) returns a pseudo-random integer in [0, 2^x), - i.e. the same as rand(2^x). If the integer returned is + i.e. the same as rand(2^x). If the integer returned is b_1 * 2^(x-1) + b_2 * 2^(x-2) + ... + b_n, diff --git a/help/rcin b/help/rcin index 56172f8..0aee90a 100644 --- a/help/rcin +++ b/help/rcin @@ -13,7 +13,7 @@ TYPES DESCRIPTION Let B be the base calc uses for representing integers internally (B = 2^16 for 32-bit machines, 2^32 for 64-bit machines) and N the - number of words (base-B digits) in the representation of m. Then + number of words (base-B digits) in the representation of m. Then rcin(x,m) returns the value of B^N * x % m, where the modulus operator % here gives the least nonnegative residue. @@ -29,7 +29,7 @@ DESCRIPTION rcin(x^k, m) = rcpow(rcin(x,m), k, m). - Here k is any nonnegative integer. Using these formulae may be + Here k is any nonnegative integer. Using these formulae may be faster than direct evaluation of x * y % m, x^2 % m, x^k % m. Some encoding and decoding may be bypassed by formulae like: diff --git a/help/rcmul b/help/rcmul index e119c77..3a593d6 100644 --- a/help/rcmul +++ b/help/rcmul @@ -33,7 +33,7 @@ RUNTIME in a REDC function, the information required for the REDC algorithms is calculated and stored for future use, possibly replacing an already stored valued, in a table covering up to 5 - (i.e. MAXREDC) values of m. The runtime required for this is about + (i.e. MAXREDC) values of m. The runtime required for this is about two times that required for multiplying two N-word integers. Two algorithms are available for evaluating rcmul(x,y,m), the one diff --git a/help/rcout b/help/rcout index fcd9e10..eb9f538 100644 --- a/help/rcout +++ b/help/rcout @@ -13,10 +13,10 @@ TYPES DESCRIPTION Let B be the base calc uses for representing integers internally (B = 2^16 for 32-bit machines, 2^32 for 64-bit machines) and N the - number of words (base-B digits) in the representation of m. Then + number of words (base-B digits) in the representation of m. Then rcout(x,m) returns the value of B^-N * x % m, where the inverse implicit in B^-N is modulo m and the modulus operator % gives the - least non-negative residue. The functions rcin() and rcout() are + least non-negative residue. The functions rcin() and rcout() are inverses of each other for all x: rcout(rcin(x,m), m) = rcin(rcout(x,m),m) = x % m. diff --git a/help/rcpow b/help/rcpow index 53e7e4b..1364c05 100644 --- a/help/rcpow +++ b/help/rcpow @@ -14,7 +14,7 @@ TYPES DESCRIPTION Let B be the base calc uses for representing integers internally (B = 2^16 for 32-bit machines, 2^32 for 64-bit machines) and N the - number of words (base-B digits) in the representation of m. Then + number of words (base-B digits) in the representation of m. Then rcpow(x,k,m) returns the value of B^-N * (B^N * x)^k % m, w here the inverse implicit in B^-N is modulo m and the modulus operator % gives the least nonnegative residue. Note that rcpow(x,0,m) = @@ -43,7 +43,7 @@ RUNTIME in a REDC function, the information required for the REDC algorithms is calculated and stored for future use, possibly replacing an already stored valued, in a table covering up to 5 - (i.e. MAXREDC) values of m. The runtime required for this is about + (i.e. MAXREDC) values of m. The runtime required for this is about two times that required for multiplying two N-word integers. Two algorithms are available for evaluating rcpow(x,k,m), the one diff --git a/help/reverse b/help/reverse index 3883474..77180a4 100644 --- a/help/reverse +++ b/help/reverse @@ -11,7 +11,7 @@ TYPES DESCRIPTION For a list or matrix x, reverse(x) returns a list or matrix in - which the order of the elements has been reversed. The original + which the order of the elements has been reversed. The original list or matrix x is unchanged. In the case of matrix x, the returned value is a matrix with @@ -23,11 +23,11 @@ EXAMPLE > print reverse(A) list (5 elements, 5 nonzero): - [[0]] = 2 - [[1]] = 4 - [[2]] = 2 - [[3]] = 7 - [[4]] = 1 + [[0]] = 2 + [[1]] = 4 + [[2]] = 2 + [[3]] = 7 + [[4]] = 1 > mat B[2,3] = {1,2,3,4,5,6} > print reverse(B) diff --git a/help/rm b/help/rm index 7a19f1e..55da461 100644 --- a/help/rm +++ b/help/rm @@ -10,7 +10,7 @@ TYPES return nil DESCRIPTION - Removes one or more files. If the first arg is "-f", then a forced + Removes one or more files. If the first arg is "-f", then a forced removal is performed and "no such file" errors are ignored. EXAMPLE diff --git a/help/round b/help/round index 4f39200..3c55c75 100644 --- a/help/round +++ b/help/round @@ -31,7 +31,7 @@ DESCRIPTION If the number of decimal places is n and eps = 10^-n, the result is the same as for appr(x, eps, rnd). This will be exactly x if x is a multiple of eps; otherwise rounding occurs - to one of the nearest multiples of eps on either side of x. Which + to one of the nearest multiples of eps on either side of x. Which of these multiples is returned is determined by z = rnd & 31, i.e. the five low order bits of rnd, as follows: diff --git a/help/rsearch b/help/rsearch index 6ba2fea..ff177cd 100644 --- a/help/rsearch +++ b/help/rsearch @@ -38,7 +38,7 @@ Four argument case: For non-file a, the search is for a[[i]] == b, except that if the function accept() as been defined, it is for i such that - accept(a[[i]], b) tests as nonzero. Since the addresses (rather than + accept(a[[i]], b) tests as nonzero. Since the addresses (rather than values) of a[[i]] and b are passed to accept(), the values of one or both of a[[i]] and b may be changed during a call to rsearch(). diff --git a/help/runtime b/help/runtime index ed3ebca..44afae3 100644 --- a/help/runtime +++ b/help/runtime @@ -14,7 +14,7 @@ EXAMPLE The result for this example will depend on the speed and number of of clock-ticks per second for the computer being used. The result is a multiple of 1/CLK_TCK, where CLK_TCK is - usually 60. The following is for a XXX machine. + usually 60. The following is for a XXX machine. > t = runtime(); > pi = pi(1e-1000); diff --git a/help/scan b/help/scan index ed07822..48ba3e8 100644 --- a/help/scan +++ b/help/scan @@ -11,7 +11,7 @@ TYPES DESCRIPTION When input is from a terminal, execution is halted and input is read - until a newline is entered. Strings of non-whitespace characters + until a newline is entered. Strings of non-whitespace characters are evaluated in succession and if the corresponding x_i is an lvalue, the resulting value is assigned to x_i. If the number of strings read exceeds n, only the first n strings are evaluated. If the number @@ -20,7 +20,7 @@ DESCRIPTION EXAMPLE > global a, b, c, d; > scan(a, 0, c, d) - > 2+3 b=a^2 3+4i 3+"a" + > 2+3 b=a^2 3+4i 3+"a" > print a,b,c,d 5 25 3+4i Error 3 diff --git a/help/search b/help/search index bd55556..80800f9 100644 --- a/help/search +++ b/help/search @@ -7,7 +7,7 @@ SYNOPSIS TYPES a matrix, list, association or file b string if a is a file, otherwise any - c integer, defaults to zero or current file-position + c integer, defaults to zero or current file-position d integer, defaults to size(a) or current file-position return nonnegative integer or null value @@ -24,7 +24,7 @@ DESCRIPTION For a matrix, list, or association a, search(a, b, c, d) returns, if it exists, the least index i for which - c <= i < d, 0 <= i < size(a), and, if accept() has not been defined, + c <= i < d, 0 <= i < size(a), and, if accept() has not been defined, a[[i]] == b, or if accept() has been defined, accept(a[[i]], b) tests as nonzero. The null value is returned if there is no such i. @@ -93,7 +93,7 @@ EXAMPLE > search(f, "ha") 10 > ftell(f) - 12 + 12 > search(f, "ha") 18 > search(f, "ha") diff --git a/help/seed b/help/seed index 82e85c3..c175666 100644 --- a/help/seed +++ b/help/seed @@ -19,7 +19,7 @@ DESCRIPTION is almost certainly non-chaotic. This function is likely not suitable for applications (such as cryptographic applications) where the unpredictability of seeds is critical. For such critical - applications, lavarand should be used. See the URL: + applications, lavarand should be used. See the URL: http://lavarand.sgi.com/index.html diff --git a/help/segment b/help/segment index 035e638..8653d37 100644 --- a/help/segment +++ b/help/segment @@ -13,7 +13,7 @@ TYPES DESCRIPTION For 0 <= y < size(x) and 0 <= z < size(x), segment(x, y, z) returns a list for which the values of the elements are those - of the segment of x from x[[y]] to x[[z]]. If y < z, the + of the segment of x from x[[y]] to x[[z]]. If y < z, the new list is in the same order as x; if y > z, the order is reversed. diff --git a/help/select b/help/select index 97156f2..855fe43 100644 --- a/help/select +++ b/help/select @@ -14,7 +14,7 @@ DESCRIPTION If y is to be the name of a user-defined function, select(x, y) returns a list whose members are the values z of elements of x for which the function at z tests as nonzero. - The list x is not changed. The order of the returned list is + The list x is not changed. The order of the returned list is the same as in x. diff --git a/help/sgn b/help/sgn index 383efdb..80c1a3d 100644 --- a/help/sgn +++ b/help/sgn @@ -8,7 +8,7 @@ TYPES x real or complex return -1, 0, 1 (real) - -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i (complex) + -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i (complex) DESCRIPTION Return the value of cmp(a,0). diff --git a/help/sha b/help/sha index 5583198..c88da55 100644 --- a/help/sha +++ b/help/sha @@ -25,7 +25,7 @@ DESCRIPTION The new arg1 HASH state is returned. If arg1 is not a a HASH state, then the initial HASH is - used and modifed by arg1 and any val args supplied. The + used and modifed by arg1 and any val args supplied. The return value is the new HASH state. The following table gives a summary of actions and return values. diff --git a/help/sha1 b/help/sha1 index 3f26a85..6535a89 100644 --- a/help/sha1 +++ b/help/sha1 @@ -25,7 +25,7 @@ DESCRIPTION The new arg1 HASH state is returned. If arg1 is not a a HASH state, then the initial HASH is - used and modifed by arg1 and any val args supplied. The + used and modifed by arg1 and any val args supplied. The return value is the new HASH state. The following table gives a summary of actions and return values. diff --git a/help/sizeof b/help/sizeof index d377c6c..6c61cea 100644 --- a/help/sizeof +++ b/help/sizeof @@ -12,14 +12,14 @@ TYPES DESCRIPTION This is analogous to the C operator sizeof for the value only. It attempts to assess the number of bytes in memory used to store - a value and all of its components. Unlike memsize(x), this + a value and all of its components. Unlike memsize(x), this builtin does not include the size of the overhead. Unlike size(x), this builtin incldues the trailing \0 byte on the end of strings. For numeric values, sizeof(x) ignores the demoninator if 'x' is - an integer. For complex values, sizeof(x) ignores the imaginary + an integer. For complex values, sizeof(x) ignores the imaginary part if 'x' is real. Because the 0, 1 and -1 numeric values are shared static values, sizeof(x) reports such values as having 0 bytes of storage. diff --git a/help/sort b/help/sort index 514271f..0eb69f1 100644 --- a/help/sort +++ b/help/sort @@ -23,7 +23,7 @@ DESCRIPTION If x is a matrix, the matrix returned by sort(x) has the same dimension and index limits as x, but for the sorting, x is treated as a one-dimensional array indexed only by the double- bracket - notation. Then for both lists and matrices, if x has size n, it + notation. Then for both lists and matrices, if x has size n, it may be identified with the array: (x[[0]], x[[1]], ..., x[[n-1]]) @@ -49,7 +49,7 @@ DESCRIPTION with earlier values b using the integer-valued function precedes(); if precedes(a,b) is nonzero, which we may consider as "true", a is "moved" to just before b; if precedes(a,b) is zero, i.e. "false", - a remains after b. Until the sorting is completed, other similar + a remains after b. Until the sorting is completed, other similar pairs (a,b) are compared and if and only if precedes(a,b) is true, a is moved to before b or b is moved to after a. We may say that the intention of precedes(a,b) being nonzero is that a should @@ -59,13 +59,13 @@ DESCRIPTION but to guarantee fulfilment of the intentions just described, precedes() should satisfy the conditions: - (1) For all a, b, c, precedes(a,b) implies precedes(a,c) || precedes (c,b), + (1) For all a, b, c, precedes(a,b) implies precedes(a,c) || precedes (c,b), - (2) For all a, b, precedes(a,b) implies !precedes(b,a). + (2) For all a, b, precedes(a,b) implies !precedes(b,a). Condition (1) is equivalent to transitivity of !precedes(): - (1)' For all a,b,c, !precedes(a,b) && !precedes(b,c) implies !precedes(a,c). + (1)' For all a,b,c, !precedes(a,b) && !precedes(b,c) implies !precedes(a,c). (1) and (2) together imply transitivity of precedes(): @@ -95,14 +95,14 @@ DESCRIPTION not y_j1 precedes or follows y_j2 will be determined by the sorting algorithm by methods that are difficult to describe; such a situation may be acceptable to a user not concerned with - the order of occurrences of a and b in the result. To permit + the order of occurrences of a and b in the result. To permit this, we may now describe the role of precedes(a,b) by the rules: precedes(a,b) && !precedes(b,a): a is to precede b; !precedes(a,b) && !precedes(b,a): order of a and b not to be changed; - precedes(a,b) && precedes(b,a): order of a and b may be changed. + precedes(a,b) && precedes(b,a): order of a and b may be changed. Under the condition (1), the result of sort(x) will accord with these rules. @@ -119,13 +119,13 @@ DESCRIPTION null, numbers or strings, precedes(a,b) is given by (a < b). (If a and b are both null, they are considered to be equal, so a < b then returns zero.) For null values, numbers and - strings, this definition has the properties (1) and (2) - discussed above. + strings, this definition has the properties (1) and (2) + discussed above. If a and b are both xx-objects, a < b is defined to mean xx_rel(a,b) < 0; such a definition does not necessarily give < the properties usually expected - - transitivity and antisymmetry. In such cases, sort(x) + transitivity and antisymmetry. In such cases, sort(x) may not give the results expected by the "intentions" of the comparisons expressed by "a < b". @@ -180,7 +180,7 @@ DESCRIPTION iseven(a) Even numbers in possibly changed order before odd numbers in unchanged order. - iseven(a) && isoddd(b) Even numbers in unchanged order before + iseven(a) && isoddd(b) Even numbers in unchanged order before odd numbers in unchanged order. iseven(a) ? iseven(b) ? a < b : 1 : 0 @@ -211,34 +211,34 @@ EXAMPLES > print sort(A) list (5 elements, 5 nonzero): - [[0]] = 1 - [[1]] = 2 - [[2]] = 2 - [[3]] = 4 - [[4]] = 7 + [[0]] = 1 + [[1]] = 2 + [[2]] = 2 + [[3]] = 4 + [[4]] = 7 > B = list("pear", 2, null(), -3, "orange", null(), "apple", 0) > print sort(B) list (8 elements, 7 nonzero): - [[0]] = NULL - [[1]] = NULL - [[2]] = -3 - [[3]] = 0 - [[4]] = 2 - [[5]] = "apple" - [[6]] = "orange" - [[7]] = "pear" + [[0]] = NULL + [[1]] = NULL + [[2]] = -3 + [[3]] = 0 + [[4]] = 2 + [[5]] = "apple" + [[6]] = "orange" + [[7]] = "pear" > define precedes(a,b) = (iseven(a) && isodd(b)) > print sort(A) list (5 elements, 5 nonzero): - [[0]] = 2 - [[1]] = 4 - [[2]] = 2 - [[3]] = 1 - [[4]] = 7 + [[0]] = 2 + [[1]] = 4 + [[2]] = 2 + [[3]] = 1 + [[4]] = 7 LIMITS none diff --git a/help/sqrt b/help/sqrt index b024935..94a86d0 100644 --- a/help/sqrt +++ b/help/sqrt @@ -45,7 +45,7 @@ DESCRIPTION 1: return exact square root when real & imaginary are rational - z bits 5-0 (z & 31) + z bits 5-0 (z & 31) 0: round down or up according as y is positive or negative, sgn(r) = sgn(y) @@ -88,7 +88,7 @@ DESCRIPTION of the square root, if this is a multiple of y, it is returned exactly; otherwise the value returned for the part is the multiple of y nearest below or nearest above the true value. - For z = 0, the remainder has the sign of y; changing bit 0 + For z = 0, the remainder has the sign of y; changing bit 0 changes to the other possibility; for z = 2, the remainder has the sign of the true value, i.e. the rounding is towards zero; for z = 4, the remainder is always positive, i.e. the rounding is down; diff --git a/help/srand b/help/srand index 751ad8e..3e5c07c 100644 --- a/help/srand +++ b/help/srand @@ -25,14 +25,14 @@ DESCRIPTION /* reload default additive table xor-ed with low 64 seed bits */ seed_xor = seed & ((1<<64)-1); for (i=0; i < 55; ++i) { - additive[i] = xor(default_additive[i], seed_xor); + additive[i] = xor(default_additive[i], seed_xor); } /* shuffle the additive table */ seed >>= 64; for (i=55; seed > 0 && i > 0; --i) { - quomod(seed, i+1, seed, j); - swap(additive[i], additive[j]); + quomod(seed, i+1, seed, j); + swap(additive[i], additive[j]); } Seed must be >= 0. All seed values < 0 are reserved for future use. @@ -58,7 +58,7 @@ DESCRIPTION between the seed and the production of the generator. The randreseed64 process does not reduce the security of the - rand generator. Every seed is converted into a different + rand generator. Every seed is converted into a different unique seed. No seed is ignored or favored. See the rand help file for details. diff --git a/help/srandom b/help/srandom index 4d8288f..638c090 100644 --- a/help/srandom +++ b/help/srandom @@ -80,7 +80,7 @@ DESCRIPTION 2 args (seed, newn>=2^32): srandom(seed, newn) - The newn value is used as the new Blum modulus. This modulus + The newn value is used as the new Blum modulus. This modulus is assumed to be a product of two primes that are both 3 mod 4. The newn value is not factored, it is only checked to see if it is 1 mod 4. @@ -89,7 +89,7 @@ DESCRIPTION The seed arg is used to establish the initial quadratic value once newn has been made the Blum moduli. The seed must - be either 0 or >= 2^32. If seed == 0, the initial quadratic + be either 0 or >= 2^32. If seed == 0, the initial quadratic residue used with srandom(0) is used with the new Blum moduli. If seed >= 2^32, then srandom(seed, newn) has the same effect as: @@ -102,7 +102,7 @@ DESCRIPTION be suspect. The period of the generator determines how many bits will - be produced before it repeats. The period is determined + be produced before it repeats. The period is determined by the Blum modulus. Some newn values (that are a product of two 3 mod 4 primes) can produce a generator with a very short period making is useless for most applications. @@ -181,13 +181,13 @@ DESCRIPTION Using the default value of 25 might be a good choice. Unfortunately finding optimal values can be very slow for large - values of 'p' and 'q'. On a 200Mhz r4k, it can take as long as + values of 'p' and 'q'. On a 200Mhz r4k, it can take as long as 1 minute at 512 bits, and 5 minutes at 1024 bits. For the sake of speed, you may want to use to use one of the pre-compiled in Blum moduli via the [1 If you don't want to use a pre-compiled in Blum moduli you can - compute your own values ahead of time. This can be done by a + compute your own values ahead of time. This can be done by a method of your own choosing, or by using the seedrandom.cal script in the following way: @@ -209,7 +209,7 @@ DESCRIPTION The seed arg is used to establish the initial quadratic value once newn has been made the Blum moduli. The seed must be either 0 or >= 2^32. If seed == 0, the pre-compiled quadratic - residue for the given newn is selected. If seed >= 2^32, then + residue for the given newn is selected. If seed >= 2^32, then srandom(seed, newn) has the same effect as: srandom(0, newn); /* set Blum modulus & def quad res */ @@ -264,7 +264,7 @@ DESCRIPTION to having their Blum moduli factored, depending in their size, by small PCs in a reasonable to large supercomputers/highly parallel processors over a long time. Their value lies in their - speed relative the the default Blum generator. As of Feb 1997, + speed relative the the default Blum generator. As of Feb 1997, the Blum moduli associated with 13 <= newn < 20 appear to be well beyond the scope of hardware and algorithms, and 9 <= newn < 12 might be factorable with extreme difficulty. @@ -296,7 +296,7 @@ DESCRIPTION Note that while the newn is very likely to be a product of two primes both 3 mod 4, there is no guarantee that the period - of the generator will be long. The likelihood is that the + of the generator will be long. The likelihood is that the period will be long, however. See one of the 2 arg srandom calls above for more information on this issue. diff --git a/help/ssq b/help/ssq index c353cbb..b594358 100644 --- a/help/ssq +++ b/help/ssq @@ -5,7 +5,7 @@ SYNOPSIS ssq(x1, x2, ...) TYPES - x1, x2, ... any for which the required squaring and addition + x1, x2, ... any for which the required squaring and addition operations are defined return as determined by the operations on x1, x2, ... diff --git a/help/statement b/help/statement index ad64f90..3142d94 100644 --- a/help/statement +++ b/help/statement @@ -1,6 +1,6 @@ Statements - Statements are very much like C statements. Most statements act + Statements are very much like C statements. Most statements act identically to those in C, but there are minor differences and some additions. The following is a list of the statement types, with explanation of the non-C statements. In this list, upper @@ -43,10 +43,10 @@ Statements ------ switch (expr) { caseclauses } Switch statements work similarly to C, except for the - following. A switch can be done on any type of value, + following. A switch can be done on any type of value, and the case statements can be of any type of values. The case statements can also be expressions calculated - at runtime. The calculator compares the switch value + at runtime. The calculator compares the switch value with each case statement in the order specified, and selects the first case which matches. The default case is the exception, and only matches once all other cases @@ -79,7 +79,7 @@ Statements mat x[3] one dimension, bounds are 0-2 mat foo[4][5] two dimensions, bounds are 0-3 and 0-4 - mat a[-7:7] one dimension, bounds are (-7)-7 + mat a[-7:7] one dimension, bounds are (-7)-7 mat s[1:9,1:9] two dimensions, bounds are 1-9 and 1-9 Note that the MAT statement is not a declaration, but is @@ -101,9 +101,9 @@ Statements Initial values for the elements of a matrix can be specified by following the bounds information with an equals sign and - then a list of values enclosed in a pair of braces. Even if + then a list of values enclosed in a pair of braces. Even if the matrix has more than one dimension, the elements must be - specified as a linear list. If too few values are specified, + specified as a linear list. If too few values are specified, the remaining values are set to zero. If too many values are specified, a runtime error will result. Examples of some initializations are: @@ -114,7 +114,7 @@ Statements When an initialization is done, the bounds of the matrix can optionally be left out of the square brackets, and the correct bounds (zero based) will be set. This can only be - done for one-dimensional matrices. An example of this is: + done for one-dimensional matrices. An example of this is: mat fred[] = {99, 98, 97}; @@ -148,7 +148,7 @@ Statements obj point {x, y, z}; This defines an object type called point, whose elements - have the names x, y, and z. The elements are accessed + have the names x, y, and z. The elements are accessed similarly to structure element accesses, by using a period. For example, given a variable 'v' which is a point object, the three coordinates of the point can be referenced by: @@ -158,7 +158,7 @@ Statements v.z A particular object type can only be defined once, and - is global throughout all functions. However, different + is global throughout all functions. However, different object types can be used at the same time. In order to create variables of an object type, they @@ -212,7 +212,7 @@ Statements and printed, with no other output, except for the following special cases. The comma which separates expressions prints a single space, and a newline is printed after the last - expression unless the statement ends with a colon. As + expression unless the statement ends with a colon. As examples: print 3, 4; prints "3 4" and newline. @@ -228,7 +228,7 @@ Statements If a matrix or list is printed, then the elements contained within the matrix or list will also be printed, up to the maximum number specified by the "maxprint" configuration - parameter. If an element is also a matrix or a list, then + parameter. If an element is also a matrix or a list, then their values are not recursively printed. Objects are printed using their user-defined routine. Printing a file value prints the name of the file that was opened. @@ -236,7 +236,7 @@ Statements Also see the help topic: - command top level commands + command top level commands expression calc expression syntax builtin calc builtin functions usage how to invoke the calc command and calc -options diff --git a/help/strcat b/help/strcat index d34d871..a1b5e3b 100644 --- a/help/strcat +++ b/help/strcat @@ -11,7 +11,7 @@ TYPES DESCRIPTION strcat(x1, x2, ...) forms a string starting with a copy of - x1, followed by the characters in order of x2, etc. The + x1, followed by the characters in order of x2, etc. The length of the resulting string will be the sum of the lengths of the component strings. diff --git a/help/strerror b/help/strerror index 861d2df..8701dc8 100644 --- a/help/strerror +++ b/help/strerror @@ -25,7 +25,7 @@ EXAMPLE > errmax(errcount()+3) 0 > strerror(2) - "No such file or directory" + "No such file or directory" > x = 3 * ("a" + "b") > print strerror(x) diff --git a/help/strprintf b/help/strprintf index 6d7faf1..7ac63c0 100644 --- a/help/strprintf +++ b/help/strprintf @@ -16,7 +16,7 @@ DESCRIPTION EXAMPLE > strprintf("h=%d, i=%d", 2, 3); - "h=2, i=3" + "h=2, i=3" > c = config("epsilon", 1e-6); c = config("display", 6); > c = config("tilde", 1); c = config("outround", 0); @@ -24,7 +24,7 @@ EXAMPLE > fmt = "%f,%10f,%-10f,%10.4f,%.4f,%.f.\n"; > a = sqrt(3); > strprintf(fmt,a,a,a,a,a,a); - "1.732051, 1.732051,1.732051 , ~1.7320,~1.7320,~1. + "1.732051, 1.732051,1.732051 , ~1.7320,~1.7320,~1. " LIMITS diff --git a/help/strscanf b/help/strscanf index d065eac..da8acbf 100644 --- a/help/strscanf +++ b/help/strscanf @@ -17,7 +17,7 @@ DESCRIPTION Otherwise, until the terminating null character of either fmt or str is reached, characters other than '%' and whitespace are read from fmt and compared with the corresponding characters read from str. - If the characters match, reading continues. If they do not match + If the characters match, reading continues. If they do not match an integer value is returned. If whitespace is encountered in fmt, starting at the current positions in fmt and str, any whitespace characters are skipped and reading and comparison begins as before @@ -29,7 +29,7 @@ DESCRIPTION '%'. A single '%' read from fmt is taken to indicate the beginning of a conversion specification field consisting in succession of: - an optional '*', + an optional '*', optional decimal digits, one of 'c', 's', 'n', 'f', 'e', 'i' or a scanset specifier. @@ -38,7 +38,7 @@ DESCRIPTION other sequence of characters follows the '%', characters before the first exceptional character (which could be the terminating null character of the fmt string) are ignored, e.g. the sequence " %*3d " does - the same as " d ". If there is no '*' at the beginning of the specifier, + the same as " d ". If there is no '*' at the beginning of the specifier, and the list x_1, x_2, ... has not been exhausted, a value will be assigned to the next lvalue in the list; if no lvalue remains, the reading of fs stops and the function returns the number @@ -65,7 +65,7 @@ DESCRIPTION The cases 'f', 'e', 'r', 'i' may be considered to indicate expectation of floating-point, exponential, ratio, or integer representation of the - number to be read. For example, 'i' + number to be read. For example, 'i' might be taken to suggest a number like +2345; 'r' might suggest a representation like -27/49; 'e' might suggest a representation like 1.24e-7; 'f' might suggest a representation like 27.145. However, there @@ -79,7 +79,7 @@ DESCRIPTION 2+3/4*7i+3.15e7 - would be interpreted as for an ordinary evaluation. A decimal fraction + would be interpreted as for an ordinary evaluation. A decimal fraction may have more than one dot: dots after the first, which is taken to be the decimal point, are ignored. Thus "12.3..45e6.7" is interpreted as if it were "12.345e67". diff --git a/help/substr b/help/substr index 3086f59..33f5354 100644 --- a/help/substr +++ b/help/substr @@ -18,7 +18,7 @@ DESCRIPTION string of length min(strlen(str) - pos + 1, len) formed by consecutive characters of str starting at position pos, i.e. the string has length len if this is possible, otherwise it ends with - the last character of str. (The first character has pos = 1, the + the last character of str. (The first character has pos = 1, the second pos = 2, etc.) If pos = 0, the result is the same as for pos = 1. diff --git a/help/system b/help/system index aa5fe01..0667e32 100644 --- a/help/system +++ b/help/system @@ -20,7 +20,7 @@ DESCRIPTION and other waitpid values will change the return value. On POSIX P1003.1 compliant systems, if cmd is empty then this function - will determine if the shell is executable. If the shell is executable, + will determine if the shell is executable. If the shell is executable, 0 is returned otherwise non-zero is returned. diff --git a/help/test b/help/test index 3fbb1f4..f628a39 100644 --- a/help/test +++ b/help/test @@ -20,9 +20,9 @@ DESCRIPTION Matrix: every component of x tests as false - List: every element of x tests as false + List: every element of x tests as false - Association: x has no element + Association: x has no element File: x is not open diff --git a/help/time b/help/time index 3d85cd0..393e35b 100644 --- a/help/time +++ b/help/time @@ -11,7 +11,7 @@ DESCRIPTION The time() builtin returns the number of seconds since the Epoch, which according to Posix is: - Thr Jan 1 00:00:00 UTC 1970 + Thr Jan 1 00:00:00 UTC 1970 EXAMPLE > print time(); diff --git a/help/todo b/help/todo index da23788..87308f5 100644 --- a/help/todo +++ b/help/todo @@ -87,7 +87,7 @@ High priority items: as noted in the BUGS file or as displayed by 'calc help bugs'. * The shell script that is currently constructed to display a help - file (in help.c) is a gross hack. That code should be replaced + file (in help.c) is a gross hack. That code should be replaced with code that looks for the help file in the pre-defined help directories. When the specific help file is found and opened, then a $PAGER should be forked and execed after doing things such diff --git a/help/types b/help/types index 996da73..9117d4e 100644 --- a/help/types +++ b/help/types @@ -4,7 +4,7 @@ Builtin types null value This is the undefined value type. The function 'null' - returns this value. Functions which do not explicitly + returns this value. Functions which do not explicitly return a value return this type. If a function is called with fewer parameters than it is defined for, then the missing parameters have the null type. The null value is @@ -16,7 +16,7 @@ Builtin types can be arbitrarily large. The fractions are always in lowest terms. Integers have a denominator of 1. The numerator of the number contains the sign, so that - the denominator is always positive. When a number is + the denominator is always positive. When a number is entered in floating point or exponential notation, it is immediately converted to the appropriate fractional value. Printing a value as a floating point or exponential value @@ -31,7 +31,7 @@ Builtin types complex numbers Complex numbers are composed of real and imaginary parts, - which are both fractions as defined above. An integer which + which are both fractions as defined above. An integer which is followed by an 'i' character is a pure imaginary number. Complex numbers such as "2+3i" when typed in, are processed as the sum of a real and pure imaginary number, resulting @@ -54,7 +54,7 @@ Builtin types They are input using either of the single or double quote characters. The quote mark which starts the string also ends it. Various special characters can - also be inserted using back-slash. Example strings: + also be inserted using back-slash. Example strings: "hello\n" "that's all" @@ -81,8 +81,8 @@ Builtin types associations These are one to four dimensional matrices which can be indexed by arbitrary values, instead of just integers. - These are also known as associative arrays. The elements of - an association can be of any type. Very few operations are + These are also known as associative arrays. The elements of + an association can be of any type. Very few operations are permitted on an association except for indexing. Associations are created using the 'assoc' function. diff --git a/help/unexpected b/help/unexpected index f3dc2b1..86e52d7 100644 --- a/help/unexpected +++ b/help/unexpected @@ -1,7 +1,7 @@ Unexpected While calc is C-like, users of C will find some unexpected - surprises in calc syntax and usage. Persons familiar with C should + surprises in calc syntax and usage. Persons familiar with C should review this file. @@ -12,7 +12,7 @@ Unexpected expressions and for separation of expressions to be used for arguments or values in function calls or initialization lists. The precedence order of these different uses is: continuation, - separator, comma operator. For example, assuming the variables a, + separator, comma operator. For example, assuming the variables a, b, c, d, e, and object type xx have been defined, the arguments passed to f in: @@ -28,7 +28,7 @@ Unexpected In combination with other operators, the continuation use of the comma has the same precedence as [] and ., the separator use the - same as the comma operator. For example, assuming xx.mul() has + same as the comma operator. For example, assuming xx.mul() has been defined: f(a = b, obj xx c, d = {1,2} * obj xx e = {3,4}) @@ -73,7 +73,7 @@ Unexpected Operator-with-assignments: - += -= *= /= %= //= &= |= <<= >>= ^= **= + += -= *= /= %= //= &= |= <<= >>= ^= **= associate from left to right instead of right to left as in C. For example: @@ -84,7 +84,7 @@ Unexpected a = (a + b) * c - where only 'a' is required to be an lvalue. For the effect of: + where only 'a' is required to be an lvalue. For the effect of: b *= c; a += b @@ -101,7 +101,7 @@ Unexpected a || b will produce 0 or 1 depending on the logical evaluation - of the expression. In calc, this expression will produce + of the expression. In calc, this expression will produce either 'a' or 'b' and is equivalent to the expression: a ? a : b @@ -118,7 +118,7 @@ Unexpected a && b will produce 0 or 1 depending on the logical evaluation - of the expression. In calc, this expression will produce + of the expression. In calc, this expression will produce either 'a' or 'b' and is equivalent to the expression: a ? b : a diff --git a/help/usage b/help/usage index e73117f..4f44c32 100644 --- a/help/usage +++ b/help/usage @@ -28,10 +28,10 @@ Calc command line simply generate an error. Use if this flag may cause calc to execute functions that - are non-standard and that are not portable. Custom builtin + are non-standard and that are not portable. Custom builtin functions are disabled by default for this reason. - -d Disable the printing of the opening title. The printing + -d Disable the printing of the opening title. The printing of library debug and informational messages is also disabled as if config("lib_debug",0) had been executed. @@ -63,7 +63,7 @@ Calc command line The : separated strings are interpreted as signed 32 bit values. After an optional leading sign a leading zero indicates octal conversion, and a leading ``0x'' or ``0X'' hexadecimal - conversion. Otherwise, decimal conversion is assumed. + conversion. Otherwise, decimal conversion is assumed. By default, calc_debug is 0, lib_debug is 3 and lib_debug is 0. @@ -74,7 +74,7 @@ Calc command line -e Ignore any environment variables on startup. The getenv() builtin will still return values, however. - -h Print a help message. This option implies -q. This + -h Print a help message. This option implies -q. This is equivalent to the calc command help help. The help facility is disabled unless the mode is 5 or 7. See -m. @@ -95,7 +95,7 @@ Calc command line calc commands. -m mode - This flag sets the permission mode of calc. It + This flag sets the permission mode of calc. It controls the ability for calc to open files and execute programs. Mode may be a number from 0 to 7. @@ -141,7 +141,7 @@ Calc command line calc -p '2^21701-1' | fizzbin In pipe mode, calc does not prompt, does not print leading - tabs and does not print the initial header. The -p flag + tabs and does not print the initial header. The -p flag overrides -i. -q Disable the use of the $CALCRC startup scripts. @@ -177,7 +177,7 @@ Calc command line present calc with an already open file using sh, ksh or bash-like shells is to: - calc 3 * - * Interactive readline module. This is called to read lines of input, + * Interactive readline module. This is called to read lines of input, * while using emacs-like editing commands within a command stack. * The key bindings for the editing commands are (slightly) configurable. */ @@ -59,9 +59,9 @@ extern FILE *curstream(void); -#define STDIN 0 -#define SAVE_SIZE 256 /* size of save buffer */ -#define MAX_KEYS 60 /* number of key bindings */ +#define STDIN 0 +#define SAVE_SIZE 256 /* size of save buffer */ +#define MAX_KEYS 60 /* number of key bindings */ #define CONTROL(x) ((char)(((int)(x)) & 0x1f)) @@ -79,11 +79,11 @@ static struct { } HS; -typedef void (*FUNCPTR)(); +typedef void (*FUNCPTR)(); typedef struct { char *name; - FUNCPTR func; + FUNCPTR func; } FUNC; /* declare binding functions */ @@ -155,7 +155,7 @@ static FUNC funcs[] = {"quote-char", quote_char}, {"arrow-key", arrow_key}, {"quit", quit_calc}, - {NULL, NULL} + {NULL, NULL} }; @@ -185,11 +185,11 @@ static KEY_MAP maps[] = { }; -#define INTROUND (sizeof(int) - 1) -#define HISTLEN(hp) ((((hp)->len + INTROUND) & ~INTROUND) + sizeof(int)) -#define HISTOFFSET(hp) (((char *) (hp)) - histbuf) -#define FIRSTHIST ((HIST *) histbuf) -#define NEXTHIST(hp) ((HIST *) (((char *) (hp)) + HISTLEN(hp))) +#define INTROUND (sizeof(int) - 1) +#define HISTLEN(hp) ((((hp)->len + INTROUND) & ~INTROUND) + sizeof(int)) +#define HISTOFFSET(hp) (((char *) (hp)) - histbuf) +#define FIRSTHIST ((HIST *) histbuf) +#define NEXTHIST(hp) ((HIST *) (((char *) (hp)) + HISTLEN(hp))) typedef struct { @@ -211,7 +211,7 @@ static char histbuf[HIST_SIZE + 1]; static char save_buffer[SAVE_SIZE]; /* declare other static functions */ -static FUNCPTR find_func(char *name); +static FUNCPTR find_func(char *name); static HIST *get_event(int n); static HIST *find_event(char *pat, int len); static void read_key(void); @@ -516,9 +516,9 @@ do_bind_line(KEY_MAP *map, char *line) } else { key = CONTROL(*cp++); } - } - else if (key == '\\') + } else if (key == '\\') { key = *cp++; + } while (isspace((int)*cp)) cp++; @@ -582,8 +582,7 @@ do_default_line(KEY_MAP *map, char *line) func_name = cp; while ((*cp != '\0') && !isspace((int)*cp)) cp++; - if (*cp != '\0') - { + if (*cp != '\0') { *cp++ = '\0'; while (isspace((int)*cp)) cp++; @@ -592,15 +591,13 @@ do_default_line(KEY_MAP *map, char *line) if (func == NULL) return; - if (*cp == '\0') + if (*cp == '\0') { next = map; - else - { + } else { next_name = cp; while ((*cp != '\0') && !isspace((int)*cp)) cp++; - if (*cp != '\0') - { + if (*cp != '\0') { *cp++ = '\0'; while (isspace((int)*cp)) cp++; @@ -624,7 +621,7 @@ static int read_bindings(FILE *fp) { char *cp; - KEY_MAP *input_map; + KEY_MAP *input_map; char line[100]; base_map = find_map(base_map_name); @@ -677,7 +674,7 @@ read_key(void) cur_map = ent->next; if (ent->func) /* ignore Saber-C warning #65 - has 1 arg, expecting 0 */ - /* ok to ignore in proc read_key */ + /* ok to ignore in proc read_key */ (*ent->func)(key); else insert_char(key); @@ -691,7 +688,7 @@ read_key(void) static HIST * get_event(int n) { - register HIST * hp; + register HIST * hp; if ((n < 0) || (n >= HS.histcount)) return NULL; @@ -709,11 +706,11 @@ get_event(int n) static HIST * find_event(char *pat, int len) { - register HIST * hp; + register HIST * hp; for (hp = FIRSTHIST; hp->len; hp = NEXTHIST(hp)) { if ((hp->len == len) && (memcmp(hp->data, pat, len) == 0)) - return hp; + return hp; } return NULL; } @@ -1406,9 +1403,9 @@ beep(void) static void echo_char(int ch) { - if (isprint(ch)) + if (isprint(ch)) { putchar(ch); - else { + } else { putchar('^'); putchar((ch + '@') & 0x7f); } diff --git a/hist.h b/hist.h index 71c7901..5428a47 100644 --- a/hist.h +++ b/hist.h @@ -14,22 +14,22 @@ /* * Default binding file and history size. */ -#ifndef HIST_BINDING_FILE -#define HIST_BINDING_FILE "/usr/lib/hist.bind" +#ifndef HIST_BINDING_FILE +#define HIST_BINDING_FILE "/usr/lib/hist.bind" #endif -#ifndef HIST_SIZE -#define HIST_SIZE (1024*10) +#ifndef HIST_SIZE +#define HIST_SIZE (1024*10) #endif /* * path search defines */ -#define HOMECHAR '~' /* char which indicates home directory */ +#define HOMECHAR '~' /* char which indicates home directory */ #define DOTCHAR '.' /* char which indicates current directory */ -#define PATHCHAR '/' /* char which separates path components */ -#define LISTCHAR ':' /* char which separates paths in a list */ +#define PATHCHAR '/' /* char which separates path components */ +#define LISTCHAR ':' /* char which separates paths in a list */ /* @@ -37,10 +37,10 @@ * not prevent calling the other routines, but fancy command line editing * is then disabled. */ -#define HIST_SUCCESS 0 /* successfully inited */ -#define HIST_INITED 1 /* initialization is already done */ -#define HIST_NOFILE 2 /* bindings file could not be read */ -#define HIST_NOTTY 3 /* terminal modes could not be set */ +#define HIST_SUCCESS 0 /* successfully inited */ +#define HIST_INITED 1 /* initialization is already done */ +#define HIST_NOFILE 2 /* bindings file could not be read */ +#define HIST_NOTTY 3 /* terminal modes could not be set */ extern int hist_init(char *filename); diff --git a/input.c b/input.c index 34edbd7..0155110 100644 --- a/input.c +++ b/input.c @@ -79,7 +79,7 @@ static char *homeexpand(char *name); /* * Open an input file by possibly searching through a path list - * and also possibly applying the specified extension. For example: + * and also possibly applying the specified extension. For example: * opensearchfile("barf", ".:/tmp", ".c", once) searches in order * for the files "./barf", "./barf.c", "/tmp/barf", and "/tmp/barf.c". * @@ -145,7 +145,7 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) /* * If the name is absolute, or if there is no path list, then - * make one which just searches for the name straight. Then + * make one which just searches for the name straight. Then * search through the path list for the file, without and with * the specified extension. */ @@ -524,9 +524,9 @@ nextchar(void) if (cip->i_num) { ch = chartoint(*cip->i_cp++); cip->i_num--; - } - else + } else { ch = EOF; + } } else if (cip->i_fp) { /* from file */ ch = fgetc(cip->i_fp); } else if (!stdin_tty) { /* from file */ @@ -545,7 +545,7 @@ nextchar(void) /* * Read in the next line of input from the current input source. * The line is terminated with a null character, and does not contain - * the final newline character. The returned string is only valid + * the final newline character. The returned string is only valid * until the next such call, and so must be copied if necessary. * Returns NULL on end of file. */ @@ -908,6 +908,3 @@ addreadset(char *name, char *path, struct stat *sbuf) /* return index of the newly added entry */ return ret; } - - -/* END CODE */ diff --git a/jump.c b/jump.c index d639c37..137ee8f 100644 --- a/jump.c +++ b/jump.c @@ -42,7 +42,7 @@ * trivial prime. * * Instead of testing successive odd values, this system allows us to - * skip odd values divisible by trivial primes. This is process on the + * skip odd values divisible by trivial primes. This is process on the * average reduces the values we need to test by a factor of at least 2.4. */ diff --git a/jump.h b/jump.h index 6d94078..6de9787 100644 --- a/jump.h +++ b/jump.h @@ -52,7 +52,7 @@ * that are not divisible by trivial primes. * * Instead of testing successive odd values, this system allows us to - * skip odd values divisible by trivial primes. This is process on the + * skip odd values divisible by trivial primes. This is process on the * average reduces the values we need to test by a factor of at least 2.4. */ diff --git a/label.h b/label.h index bbcb34c..83f53d3 100644 --- a/label.h +++ b/label.h @@ -6,13 +6,13 @@ #if !defined(__LABEL_H__) -#define __LABEL_H__ +#define __LABEL_H__ #include "zmath.h" -#define NULL_LABEL ((LABEL *) 0) +#define NULL_LABEL ((LABEL *) 0) /* diff --git a/lib/Makefile b/lib/Makefile index 71ddf94..7a589e0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -60,14 +60,14 @@ all: ${CALC_FILES} ${MAKE_FILE} .all ## # -# File list generation. You can ignore this section. +# File list generation. You can ignore this section. # # # We will form the names of source files as if they were in a # sub-directory called calc/lib. # # NOTE: Due to bogus shells found on one common system we must have -# an non-emoty else clause for every if condition. *sigh* +# an non-emoty else clause for every if condition. *sigh* # ## diff --git a/lib/README b/lib/README index 82446bf..77edc5e 100644 --- a/lib/README +++ b/lib/README @@ -38,8 +38,8 @@ If you write something that you think is useful, please send it to: [[ Replace 'at' with @, 'dot' is with . and remove the spaces ]] By convention, a lib file only defines and/or initializes functions, -objects and variables. (The regress.cal and testxxx.cal regression test -suite is an exception.) Also by convention, an additional usage message +objects and variables. (The regress.cal and testxxx.cal regression test +suite is an exception.) Also by convention, an additional usage message regarding important object and functions is printed. If a lib file needs to load another lib file, it should use the -once @@ -192,7 +192,7 @@ mfactor.cal By default, start_k == 1, rept_loop = 10000 and p_elim = 17. The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and - requires about ~13 Megs of memory. The p_elim == 13 overhead + requires about ~13 Megs of memory. The p_elim == 13 overhead takes about 3 seconds and requires ~1.5 Megs of memory. The value p_elim == 17 is best for long factorizations. It is the @@ -306,7 +306,7 @@ pollard.cal poly.cal - Calculate with polynomials of one variable. There are many functions. + Calculate with polynomials of one variable. There are many functions. Read the documentation in the library file. @@ -350,7 +350,7 @@ quat.cal quat_scale(a, b) quat_shift(a, b) - Calculate using quaternions of the form: a + bi + cj + dk. In these + Calculate using quaternions of the form: a + bi + cj + dk. In these functions, quaternians are manipulated in the form: s + v, where s is a scalar and v is a vector of size 3. @@ -416,7 +416,7 @@ randrun.cal regress.cal Test the correct execution of the calculator by reading this library file. - Errors are reported with '****' mssages, or worse. :-) + Errors are reported with '****' mssages, or worse. :-) seedrandom.cal @@ -426,7 +426,7 @@ seedrandom.cal Given: seed1 - a large random value (at least 10^20 and perhaps < 10^93) seed2 - a large random value (at least 10^20 and perhaps < 10^93) - size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024) + size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024) trials - number of ptest() trials (default 25) (optional arg) Returns: diff --git a/lib/altbind b/lib/altbind index d7ffba0..e634a8f 100644 --- a/lib/altbind +++ b/lib/altbind @@ -5,7 +5,7 @@ # are used in place of those found below. map base-map -default insert-char +default insert-char ^@ set-mark ^A start-of-line ^B backward-char @@ -30,7 +30,7 @@ default insert-char ^[ ignore-char esc-map map esc-map -default ignore-char base-map +default ignore-char base-map G start-of-line H backward-history P forward-history diff --git a/lib/bigprime.cal b/lib/bigprime.cal index 29c4458..5ba472b 100644 --- a/lib/bigprime.cal +++ b/lib/bigprime.cal @@ -22,6 +22,6 @@ define bigprime(a, m, p) continue; if (pmod(a, n1 / p, n) == 1) continue; - print " " : n; + print " " : n; } } diff --git a/lib/bindings b/lib/bindings index bbcc573..2ba8792 100644 --- a/lib/bindings +++ b/lib/bindings @@ -5,7 +5,7 @@ # are used in place of those found below. map base-map -default insert-char +default insert-char ^@ set-mark ^A start-of-line ^B backward-char @@ -30,7 +30,7 @@ default insert-char ^[ ignore-char esc-map map esc-map -default ignore-char base-map +default ignore-char base-map G start-of-line H backward-history P forward-history diff --git a/lib/chrem.cal b/lib/chrem.cal index 7329ca9..ea97571 100644 --- a/lib/chrem.cal +++ b/lib/chrem.cal @@ -11,16 +11,16 @@ * where the residues r1, r2, ... and the moduli m1, m2, ... are * given integers. The Chinese remainder theorem states that if * m1, m2, ... are relatively prime in pairs, the above congruences - * have a unique solution modulo m1 * m2 * ... If m1, m2, ... + * have a unique solution modulo m1 * m2 * ... If m1, m2, ... * are not relatively prime in pairs, it is possible that no solution * exists. If solutions exist, the general solution is expressible as: * - * x = r (mod m) + * x = r (mod m) * - * where m = lcm(m1,m2,...), and if m > 0, 0 <= r < m. This + * where m = lcm(m1,m2,...), and if m > 0, 0 <= r < m. This * solution may be interpreted as: * - * x = r + k * m [[NOTE 1]] + * x = r + k * m [[NOTE 1]] * * where k is an arbitrary integer. * @@ -30,15 +30,15 @@ * * chrem(r1,m1 [,r2,m2, ...]) * - * r1, r2, ... remainder integers or null values - * m1, m2, ... moduli integers + * r1, r2, ... remainder integers or null values + * m1, m2, ... moduli integers * * chrem(r_list, [m_list]) * * r_list list (r1,r2, ...) * m_list list (m1,m2, ...) * - * If m_list is omitted, then 'defaultmlist' is used. + * If m_list is omitted, then 'defaultmlist' is used. * This default list is a global value that may be changed * by the user. Initially it is the first 8 primes. * @@ -50,13 +50,13 @@ * * The moduli may be any integers, not necessarily relatively prime in * pairs (as required for the Chinese remainder theorem). Any moduli - * may be zero; x = r (mod 0) has the meaning of x = r. + * may be zero; x = r (mod 0) has the meaning of x = r. * * returns: * * If args were integer pairs: * - * r ('r' is defined above, see [[NOTE 1]]) + * r ('r' is defined above, see [[NOTE 1]]) * * If 1 or 2 list args were given: * @@ -96,7 +96,7 @@ define chrem() local argc; /* number of args given */ local rlist; /* reminder list - ri */ local mlist; /* modulus list - mi */ - local list_args; /* true => args given are lists, not r1,m1, ... */ + local list_args; /* true => args given are lists, not r1,m1, ... */ local m,z,r,y,d,t,x,u,i; /* @@ -121,7 +121,7 @@ define chrem() mlist = list(); for (i=1; i <= argc; i+=2) { push(rlist, param(i)); - push(mlist, param(i+1)); + push(mlist, param(i+1)); } } diff --git a/lib/ellip.cal b/lib/ellip.cal index a83e157..ce292b4 100644 --- a/lib/ellip.cal +++ b/lib/ellip.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * Attempt to factor numbers using elliptic functions. - * y^2 = x^3 + a*x + b (mod N). + * y^2 = x^3 + a*x + b (mod N). * * Many points (x,y) (mod N) are found that solve the above equation, * starting from a trivial solution and 'multiplying' that point together @@ -55,7 +55,7 @@ * of the powers so far. * * If a factor is found, it is returned and is also saved in the global - * variable f. The number being factored is also saved in the global + * variable f. The number being factored is also saved in the global * variable N. */ diff --git a/lib/lucas.cal b/lib/lucas.cal index 6ce5d78..6a76b8f 100644 --- a/lib/lucas.cal +++ b/lib/lucas.cal @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* * lucas - perform a Lucas primality test on h*2^n-1 @@ -34,26 +34,26 @@ * Sergio Zarantonello proved the following 65087 digit number to be prime: * * 216193 - * 391581 * 2 -1 + * 391581 * 2 -1 * * At the time of discovery, this number was the largest known prime. * The primality was demonstrated by a program implementing the test * found in these routines. An Amdahl 1200 takes 1987 seconds to test * the primality of this number. A Cray 2 took several hours to - * confirm this prime. As of 31 Dec 1995, this prime was the 3rd + * confirm this prime. As of 31 Dec 1995, this prime was the 3rd * largest known prime and the largest known non-Mersenne prime. * * The same team also discovered the following twin prime pair: * * 11235 11235 - * 1706595 * 2 -1 1706595 * 2 +1 + * 1706595 * 2 -1 1706595 * 2 +1 * * At the time of discovery, this was the largest known twin prime pair. * * NOTE: Both largest known and largest known twin prime records have been - * broken. Rather than update this file each time, I'll just + * broken. Rather than update this file each time, I'll just * congratulate the finders and encourage others to try for - * larger finds. Records were made to be broken afterall! + * larger finds. Records were made to be broken afterall! * * ON GAINING A WORLD RECORD: * @@ -89,7 +89,7 @@ * 'h', the time to test each number remains relatively constant. * * It is clearly a win to eliminate potential test candidates by - * rejecting numbers that that are divisible by 'small' primes. We + * rejecting numbers that that are divisible by 'small' primes. We * (the "Amdahl 6") rejected all numbers that were divisible by primes * less than '2^40'. We stopped looking for small factors at '2^40' * when the rate of candidates being eliminated was slowed down to @@ -132,7 +132,7 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */ * ABOUT THE TEST: * * This routine will perform a primality test on h*2^n-1 based on - * the mathematics of Lucas, Lehmer and Riesel. One should read + * the mathematics of Lucas, Lehmer and Riesel. One should read * the following article: * * Ref1: @@ -153,7 +153,7 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */ * * This test is performed as follows: (see Ref1, Theorem 5) * - * a) generate u(0) (see the function gen_u0() below) + * a) generate u(0) (see the function gen_u0() below) * * b) generate u(n-2) according to the rule: * @@ -163,9 +163,9 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */ * * Now the following conditions must be true for the test to work: * - * n >= 2 + * n >= 2 * h >= 1 - * h < 2^n + * h < 2^n * h mod 2 == 1 * * A few misc notes: @@ -179,9 +179,9 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */ * as 2^39). * * The condition 'h mod 2 == 1' is not a problem. Say one is testing - * 'j*2^m-1', where j is even. If we note that: + * 'j*2^m-1', where j is even. If we note that: * - * j mod 2^x == 0 for x>0 implies j*2^m-1 == ((j/2^x)*2^(m+x))-1, + * j mod 2^x == 0 for x>0 implies j*2^m-1 == ((j/2^x)*2^(m+x))-1, * * then we can let h=j/2^x and n=m+x and test 'h*2^n-1' which is the value. * We need only consider odd values of h because we can rewrite our numbers @@ -227,7 +227,7 @@ lucas(h, n) */ oldh = h; oldn = n; - shiftdown = fcnt(h,2); /* h % 2^shiftdown == 0, max shiftdown */ + shiftdown = fcnt(h,2); /* h % 2^shiftdown == 0, max shiftdown */ if (shiftdown > 0) { h >>= shiftdown; n += shiftdown; @@ -238,13 +238,13 @@ lucas(h, n) */ if (h <= 0 || n <= 0) { print "ERROR: reduced args violate the rule: 0 < h < 2^n"; - print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n; + print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n; ldebug("lucas", "unknown: h <= 0 || n <= 0"); return -1; } if (highbit(h) >= n) { print "ERROR: reduced args violate the rule: h < 2^n"; - print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n; + print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n; ldebug("lucas", "unknown: highbit(h) >= n"); return -1; } @@ -351,7 +351,7 @@ lucas(h, n) * the v(1) into u(0). * * If gen_v1() returns a negative value, then we failed to - * generate a test for h*2^n-1. This is because h mod 3 == 0 + * generate a test for h*2^n-1. This is because h mod 3 == 0 * is hard to do, and in rare cases, exceed the tables found * in this program. We will generate an message and assume * the number is not prime, even though if we had a larger @@ -561,14 +561,14 @@ gen_u0(h, n, v1) quickmax = 8; mat d_qval[quickmax]; mat v1_qval[quickmax]; -d_qval[0] = 5; v1_qval[0] = 3; /* a=1 b=1 r=4 */ -d_qval[1] = 7; v1_qval[1] = 5; /* a=3 b=1 r=12 D=21 */ -d_qval[2] = 13; v1_qval[2] = 11; /* a=3 b=1 r=4 */ -d_qval[3] = 11; v1_qval[3] = 20; /* a=3 b=1 r=2 */ -d_qval[4] = 29; v1_qval[4] = 27; /* a=5 b=1 r=4 */ -d_qval[5] = 53; v1_qval[5] = 51; /* a=53 b=1 r=4 */ -d_qval[6] = 17; v1_qval[6] = 66; /* a=17 b=1 r=1 */ -d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ +d_qval[0] = 5; v1_qval[0] = 3; /* a=1 b=1 r=4 */ +d_qval[1] = 7; v1_qval[1] = 5; /* a=3 b=1 r=12 D=21 */ +d_qval[2] = 13; v1_qval[2] = 11; /* a=3 b=1 r=4 */ +d_qval[3] = 11; v1_qval[3] = 20; /* a=3 b=1 r=2 */ +d_qval[4] = 29; v1_qval[4] = 27; /* a=5 b=1 r=4 */ +d_qval[5] = 53; v1_qval[5] = 51; /* a=53 b=1 r=4 */ +d_qval[6] = 17; v1_qval[6] = 66; /* a=17 b=1 r=1 */ +d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ /* * gen_v1 - compute the v(1) for a given h*2^n-1 if we can @@ -671,7 +671,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * are true, and return the related v(1). * * Before we address the two conditions, we need some background information - * on two symbols, Legendre and Jacobi. In Ref 2, pp 278, 284-285, we find + * on two symbols, Legendre and Jacobi. In Ref 2, pp 278, 284-285, we find * the following definitions of J(a,p) and L(a,n): * * The Legendre symbol L(a,p) takes the value: @@ -724,7 +724,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * * From Ref2, table 32: * - * p mod 8 == +/-1 implies L(2,p) == 1 {note 3} + * p mod 8 == +/-1 implies L(2,p) == 1 {note 3} * p mod 12 == +/-1 implies L(3,p) == 1 {note 4} * * Since h*2^n-1 mod 8 == -1, for n>2, note 3 implies: @@ -737,14 +737,14 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * * By use of {A3.5}, {note 2}, {note 5} and {note 6}, one can show: * - * L((2^g)*(3^l)*(z^2), h*2^n-1) == 1 (g>=0,l>=0,z>0,n>2) {note 7} + * L((2^g)*(3^l)*(z^2), h*2^n-1) == 1 (g>=0,l>=0,z>0,n>2) {note 7} * * Returning to the testing of conditions, take condition 1: * * L(D, h*2^n-1) == -1 [condition 1] * * In order for J(D, h*2^n-1) to be defined, we must ensure that D - * is not a factor of h*2^n-1. This is done by pre-screening h*2^n-1 to + * is not a factor of h*2^n-1. This is done by pre-screening h*2^n-1 to * not have small factors and selecting D less than that factor check limit. * * By use of {note 7}, we can show that when we choose D to be: @@ -765,7 +765,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * == J(h*2^n-1 mod P, P)*(-1)^((h*2^n-2)*(P-1)/4) {note 0} * * When does J(h*2^n-1 mod P, P)*(-1)^((h*2^n-2)*(P-1)/4) take the value of -1, - * thus satisfy [condition 1]? The answer depends on P. Now P is a prime>2, + * thus satisfy [condition 1]? The answer depends on P. Now P is a prime>2, * thus P mod 4 == 1 or -1. * * Take P mod 4 == 1: @@ -780,7 +780,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * * Take P mod 4 == -1: * - * P mod 4 == -1 implies (-1)^((h*2^n-2)*(P-1)/4) == -1 + * P mod 4 == -1 implies (-1)^((h*2^n-2)*(P-1)/4) == -1 * * Thus: * @@ -832,7 +832,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * == J(h*2^n-1 mod Q, Q)*(-1)^((h*2^n-2)*(Q-1)/4) {note 0} * * When does J(h*2^n-1 mod Q, Q)*(-1)^((h*2^n-2)*(Q-1)/4) take the value of 1, - * thus satisfy [condition 2]? The answer depends on Q. Now Q is a prime>2, + * thus satisfy [condition 2]? The answer depends on Q. Now Q is a prime>2, * thus Q mod 4 == 1 or -1. * * Take Q mod 4 == 1: @@ -847,7 +847,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * * Take Q mod 4 == -1: * - * Q mod 4 == -1 implies (-1)^((h*2^n-2)*(Q-1)/4) == -1 + * Q mod 4 == -1 implies (-1)^((h*2^n-2)*(Q-1)/4) == -1 * * Thus: * @@ -855,7 +855,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * == L(h*2^n-1 mod Q, Q) * -1 * == -J(h*2^n-1 mod Q, Q) * - * Therefore [condition 2] is met by selecting D = Q*(2^j)*(3^k)*(z^2), + * Therefore [condition 2] is met by selecting D = Q*(2^j)*(3^k)*(z^2), * where Q is prime>2, j>=0, k>=0, z>0; if and only if one of the following * to cases are true: * @@ -894,7 +894,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * * r == Q*(2^j)*(3^k)*(z^2) (Q==1 or Q is prime>2, j>=0, k>=0, z>0) * - * one of the following is true: + * one of the following is true: * P mod 4 == 1 and J(h*2^n-1 mod P, P) == -1 * P mod 4 == -1 and J(h*2^n-1 mod P, P) == 1 * @@ -903,7 +903,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */ * Q mod 4 == -1 and J(h*2^n-1 mod Q, Q) == -1 * * If we cannot find a v(1) quickly enough, then we will give up - * testing h*2^n-1. This does not happen too often, so this hack + * testing h*2^n-1. This does not happen too often, so this hack * is not too bad. * *** @@ -971,28 +971,28 @@ gen_v1(h, n) * * We will check with: * - * v(1)=81 D=6557 a=79 b=1 r=316 + * v(1)=81 D=6557 a=79 b=1 r=316 * - * Now, D==79*83 and r=79*2^2. If we show that: + * Now, D==79*83 and r=79*2^2. If we show that: * * J(h*2^n-1 mod 79, 79) == -1 * J(h*2^n-1 mod 83, 83) == 1 * - * then we will satisfy [condition 1]. Observe: + * then we will satisfy [condition 1]. Observe: * - * 79 mod 4 == -1 implies (-1)^((h*2^n-2)*(79-1)/4) == -1 - * 83 mod 4 == -1 implies (-1)^((h*2^n-2)*(83-1)/4) == -1 + * 79 mod 4 == -1 implies (-1)^((h*2^n-2)*(79-1)/4) == -1 + * 83 mod 4 == -1 implies (-1)^((h*2^n-2)*(83-1)/4) == -1 * * J(D, h*2^n-1) == J(83, h*2^n-1) * J(79, h*2^n-1) * == J(h*2^n-1, 83) * (-1)^((h*2^n-2)*(83-1)/4) * - * J(h*2^n-1, 79) * (-1)^((h*2^n-2)*(79-1)/4) + * J(h*2^n-1, 79) * (-1)^((h*2^n-2)*(79-1)/4) * == J(h*2^n-1 mod 83, 83) * -1 * - * J(h*2^n-1 mod 79, 79) * -1 + * J(h*2^n-1 mod 79, 79) * -1 * == 1 * -1 * * -1 * -1 * == -1 * - * We will also satisfy [condition 2]. Observe: + * We will also satisfy [condition 2]. Observe: * * (a^2 - b^2*D)/r == (79^2 - 1^1*6557)/316 * == -1 diff --git a/lib/lucas_chk.cal b/lib/lucas_chk.cal index f083426..702d94c 100644 --- a/lib/lucas_chk.cal +++ b/lib/lucas_chk.cal @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* * primes of the form h*2^n-1 for 1<=h<200 and 1<=n<1000 @@ -259,7 +259,7 @@ static mat n_p[prime_cnt] = { 59, 75, 103, 163, 235, 375, 615, 767, 2, 18, 38, 62, 1, 5, 7, 9, 15, 19, 21, 35, 37, 39, 41, 49, 69, 111, 115, 141, 159, 181, - 201, 217, 487, 567, 677, 765, 811, 841, 917, 2, /* 900 */ + 201, 217, 487, 567, 677, 765, 811, 841, 917, 2, /* 900 */ 4, 6, 8, 12, 18, 26, 32, 34, 36, 42, 60, 78, 82, 84, 88, 154, 174, 208, 256, 366, 448, 478, 746, 5, 13, 15, 31, 77, 151, 181, @@ -299,7 +299,7 @@ read -once "lucas.cal"; * * input: * high_n skip tests on n_p[i] > high_n - * [quiet] if given and != 0, then do not print individual test results + * [quiet] if given and != 0, then do not print individual test results * * returns: * 1 all is ok diff --git a/lib/lucas_tbl.cal b/lib/lucas_tbl.cal index 1382354..92e2e4b 100644 --- a/lib/lucas_tbl.cal +++ b/lib/lucas_tbl.cal @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* * Lucasian criteria for primality @@ -53,103 +53,103 @@ mat r_val[trymax+1]; /* v1= 0 INVALID */ /* v1= 1 INVALID */ /* v1= 2 INVALID */ -d_val[ 3]= 5; a_val[ 3]= 1; b_val[ 3]=1; r_val[ 3]=4; -d_val[ 4]= 3; a_val[ 4]= 1; b_val[ 4]=1; r_val[ 4]=2; -d_val[ 5]= 21; a_val[ 5]= 3; b_val[ 5]=1; r_val[ 5]=12; -d_val[ 6]= 2; a_val[ 6]= 1; b_val[ 6]=1; r_val[ 6]=1; +d_val[ 3]= 5; a_val[ 3]= 1; b_val[ 3]=1; r_val[ 3]=4; +d_val[ 4]= 3; a_val[ 4]= 1; b_val[ 4]=1; r_val[ 4]=2; +d_val[ 5]= 21; a_val[ 5]= 3; b_val[ 5]=1; r_val[ 5]=12; +d_val[ 6]= 2; a_val[ 6]= 1; b_val[ 6]=1; r_val[ 6]=1; /* v1= 7 INVALID */ -d_val[ 8]= 15; a_val[ 8]= 3; b_val[ 8]=1; r_val[ 8]=6; -d_val[ 9]= 77; a_val[ 9]= 7; b_val[ 9]=1; r_val[ 9]=28; -d_val[10]= 6; a_val[10]= 2; b_val[10]=1; r_val[10]=2; -d_val[11]= 13; a_val[11]= 3; b_val[11]=1; r_val[11]=4; -d_val[12]= 35; a_val[12]= 5; b_val[12]=1; r_val[12]=10; -d_val[13]= 165; a_val[13]=11; b_val[13]=1; r_val[13]=44; +d_val[ 8]= 15; a_val[ 8]= 3; b_val[ 8]=1; r_val[ 8]=6; +d_val[ 9]= 77; a_val[ 9]= 7; b_val[ 9]=1; r_val[ 9]=28; +d_val[10]= 6; a_val[10]= 2; b_val[10]=1; r_val[10]=2; +d_val[11]= 13; a_val[11]= 3; b_val[11]=1; r_val[11]=4; +d_val[12]= 35; a_val[12]= 5; b_val[12]=1; r_val[12]=10; +d_val[13]= 165; a_val[13]=11; b_val[13]=1; r_val[13]=44; /* v1=14 INVALID */ -d_val[15]= 221; a_val[15]=13; b_val[15]=1; r_val[15]=52; -d_val[16]= 7; a_val[16]= 3; b_val[16]=1; r_val[16]=2; -d_val[17]= 285; a_val[17]=15; b_val[17]=1; r_val[17]=60; +d_val[15]= 221; a_val[15]=13; b_val[15]=1; r_val[15]=52; +d_val[16]= 7; a_val[16]= 3; b_val[16]=1; r_val[16]=2; +d_val[17]= 285; a_val[17]=15; b_val[17]=1; r_val[17]=60; /* v1=18 INVALID */ -d_val[19]= 357; a_val[19]=17; b_val[19]=1; r_val[19]=68; -d_val[20]= 11; a_val[20]= 3; b_val[20]=1; r_val[20]=2; -d_val[21]= 437; a_val[21]=19; b_val[21]=1; r_val[21]=76; -d_val[22]= 30; a_val[22]= 5; b_val[22]=1; r_val[22]=5; +d_val[19]= 357; a_val[19]=17; b_val[19]=1; r_val[19]=68; +d_val[20]= 11; a_val[20]= 3; b_val[20]=1; r_val[20]=2; +d_val[21]= 437; a_val[21]=19; b_val[21]=1; r_val[21]=76; +d_val[22]= 30; a_val[22]= 5; b_val[22]=1; r_val[22]=5; /* v1=23 INVALID */ -d_val[24]= 143; a_val[24]=11; b_val[24]=1; r_val[24]=22; -d_val[25]= 69; a_val[25]= 9; b_val[25]=1; r_val[25]=12; -d_val[26]= 42; a_val[26]= 6; b_val[26]=1; r_val[26]=6; -d_val[27]= 29; a_val[27]= 5; b_val[27]=1; r_val[27]=4; -d_val[28]= 195; a_val[28]=13; b_val[28]=1; r_val[28]=26; -d_val[29]= 93; a_val[29]= 9; b_val[29]=1; r_val[29]=12; -d_val[30]= 14; a_val[30]= 4; b_val[30]=1; r_val[30]=2; -d_val[31]= 957; a_val[31]=29; b_val[31]=1; r_val[31]=116; -d_val[32]= 255; a_val[32]=15; b_val[32]=1; r_val[32]=30; -d_val[33]=1085; a_val[33]=31; b_val[33]=1; r_val[33]=124; +d_val[24]= 143; a_val[24]=11; b_val[24]=1; r_val[24]=22; +d_val[25]= 69; a_val[25]= 9; b_val[25]=1; r_val[25]=12; +d_val[26]= 42; a_val[26]= 6; b_val[26]=1; r_val[26]=6; +d_val[27]= 29; a_val[27]= 5; b_val[27]=1; r_val[27]=4; +d_val[28]= 195; a_val[28]=13; b_val[28]=1; r_val[28]=26; +d_val[29]= 93; a_val[29]= 9; b_val[29]=1; r_val[29]=12; +d_val[30]= 14; a_val[30]= 4; b_val[30]=1; r_val[30]=2; +d_val[31]= 957; a_val[31]=29; b_val[31]=1; r_val[31]=116; +d_val[32]= 255; a_val[32]=15; b_val[32]=1; r_val[32]=30; +d_val[33]=1085; a_val[33]=31; b_val[33]=1; r_val[33]=124; /* v1=34 INVALID */ -d_val[35]=1221; a_val[35]=33; b_val[35]=1; r_val[35]=132; -d_val[36]= 323; a_val[36]=17; b_val[36]=1; r_val[36]=34; -d_val[37]=1365; a_val[37]=35; b_val[37]=1; r_val[37]=140; -d_val[38]= 10; a_val[38]= 3; b_val[38]=1; r_val[38]=1; -d_val[39]=1517; a_val[39]=37; b_val[39]=1; r_val[39]=148; -d_val[40]= 399; a_val[40]=19; b_val[40]=1; r_val[40]=38; -d_val[41]=1677; a_val[41]=39; b_val[41]=1; r_val[41]=156; -d_val[42]= 110; a_val[42]=10; b_val[42]=1; r_val[42]=10; -d_val[43]= 205; a_val[43]=15; b_val[43]=1; r_val[43]=20; -d_val[44]= 483; a_val[44]=21; b_val[44]=1; r_val[44]=42; -d_val[45]=2021; a_val[45]=43; b_val[45]=1; r_val[45]=172; -d_val[46]= 33; a_val[46]= 6; b_val[46]=1; r_val[46]=3; +d_val[35]=1221; a_val[35]=33; b_val[35]=1; r_val[35]=132; +d_val[36]= 323; a_val[36]=17; b_val[36]=1; r_val[36]=34; +d_val[37]=1365; a_val[37]=35; b_val[37]=1; r_val[37]=140; +d_val[38]= 10; a_val[38]= 3; b_val[38]=1; r_val[38]=1; +d_val[39]=1517; a_val[39]=37; b_val[39]=1; r_val[39]=148; +d_val[40]= 399; a_val[40]=19; b_val[40]=1; r_val[40]=38; +d_val[41]=1677; a_val[41]=39; b_val[41]=1; r_val[41]=156; +d_val[42]= 110; a_val[42]=10; b_val[42]=1; r_val[42]=10; +d_val[43]= 205; a_val[43]=15; b_val[43]=1; r_val[43]=20; +d_val[44]= 483; a_val[44]=21; b_val[44]=1; r_val[44]=42; +d_val[45]=2021; a_val[45]=43; b_val[45]=1; r_val[45]=172; +d_val[46]= 33; a_val[46]= 6; b_val[46]=1; r_val[46]=3; /* v1=47 INVALID */ -d_val[48]= 23; a_val[48]= 5; b_val[48]=1; r_val[48]=2; -d_val[49]=2397; a_val[49]=47; b_val[49]=1; r_val[49]=188; -d_val[50]= 39; a_val[50]= 6; b_val[50]=1; r_val[50]=3; -d_val[51]= 53; a_val[51]= 7; b_val[51]=1; r_val[51]=4; +d_val[48]= 23; a_val[48]= 5; b_val[48]=1; r_val[48]=2; +d_val[49]=2397; a_val[49]=47; b_val[49]=1; r_val[49]=188; +d_val[50]= 39; a_val[50]= 6; b_val[50]=1; r_val[50]=3; +d_val[51]= 53; a_val[51]= 7; b_val[51]=1; r_val[51]=4; /* v1=52 INVALID */ -d_val[53]=2805; a_val[53]=51; b_val[53]=1; r_val[53]=204; -d_val[54]= 182; a_val[54]=13; b_val[54]=1; r_val[54]=13; -d_val[55]=3021; a_val[55]=53; b_val[55]=1; r_val[55]=212; -d_val[56]= 87; a_val[56]= 9; b_val[56]=1; r_val[56]=6; -d_val[57]=3245; a_val[57]=55; b_val[57]=1; r_val[57]=220; -d_val[58]= 210; a_val[58]=14; b_val[58]=1; r_val[58]=14; -d_val[59]=3477; a_val[59]=57; b_val[59]=1; r_val[59]=228; -d_val[60]= 899; a_val[60]=29; b_val[60]=1; r_val[60]=58; -d_val[61]= 413; a_val[61]=21; b_val[61]=1; r_val[61]=28; +d_val[53]=2805; a_val[53]=51; b_val[53]=1; r_val[53]=204; +d_val[54]= 182; a_val[54]=13; b_val[54]=1; r_val[54]=13; +d_val[55]=3021; a_val[55]=53; b_val[55]=1; r_val[55]=212; +d_val[56]= 87; a_val[56]= 9; b_val[56]=1; r_val[56]=6; +d_val[57]=3245; a_val[57]=55; b_val[57]=1; r_val[57]=220; +d_val[58]= 210; a_val[58]=14; b_val[58]=1; r_val[58]=14; +d_val[59]=3477; a_val[59]=57; b_val[59]=1; r_val[59]=228; +d_val[60]= 899; a_val[60]=29; b_val[60]=1; r_val[60]=58; +d_val[61]= 413; a_val[61]=21; b_val[61]=1; r_val[61]=28; /* v1=62 INVALID */ -d_val[63]=3965; a_val[63]=61; b_val[63]=1; r_val[63]=244; -d_val[64]=1023; a_val[64]=31; b_val[64]=1; r_val[64]=62; -d_val[65]= 469; a_val[65]=21; b_val[65]=1; r_val[65]=28; -d_val[66]= 17; a_val[66]= 4; b_val[66]=1; r_val[66]=1; -d_val[67]=4485; a_val[67]=65; b_val[67]=1; r_val[67]=260; -d_val[68]=1155; a_val[68]=33; b_val[68]=1; r_val[68]=66; -d_val[69]=4757; a_val[69]=67; b_val[69]=1; r_val[69]=268; -d_val[70]= 34; a_val[70]= 6; b_val[70]=1; r_val[70]=2; -d_val[71]=5037; a_val[71]=69; b_val[71]=1; r_val[71]=276; -d_val[72]=1295; a_val[72]=35; b_val[72]=1; r_val[72]=70; -d_val[73]= 213; a_val[73]=15; b_val[73]=1; r_val[73]=12; -d_val[74]= 38; a_val[74]= 6; b_val[74]=1; r_val[74]=2; -d_val[75]=5621; a_val[75]=73; b_val[75]=1; r_val[75]=292; -d_val[76]=1443; a_val[76]=37; b_val[76]=1; r_val[76]=74; -d_val[77]= 237; a_val[77]=15; b_val[77]=1; r_val[77]=12; -d_val[78]= 95; a_val[78]=10; b_val[78]=1; r_val[78]=5; +d_val[63]=3965; a_val[63]=61; b_val[63]=1; r_val[63]=244; +d_val[64]=1023; a_val[64]=31; b_val[64]=1; r_val[64]=62; +d_val[65]= 469; a_val[65]=21; b_val[65]=1; r_val[65]=28; +d_val[66]= 17; a_val[66]= 4; b_val[66]=1; r_val[66]=1; +d_val[67]=4485; a_val[67]=65; b_val[67]=1; r_val[67]=260; +d_val[68]=1155; a_val[68]=33; b_val[68]=1; r_val[68]=66; +d_val[69]=4757; a_val[69]=67; b_val[69]=1; r_val[69]=268; +d_val[70]= 34; a_val[70]= 6; b_val[70]=1; r_val[70]=2; +d_val[71]=5037; a_val[71]=69; b_val[71]=1; r_val[71]=276; +d_val[72]=1295; a_val[72]=35; b_val[72]=1; r_val[72]=70; +d_val[73]= 213; a_val[73]=15; b_val[73]=1; r_val[73]=12; +d_val[74]= 38; a_val[74]= 6; b_val[74]=1; r_val[74]=2; +d_val[75]=5621; a_val[75]=73; b_val[75]=1; r_val[75]=292; +d_val[76]=1443; a_val[76]=37; b_val[76]=1; r_val[76]=74; +d_val[77]= 237; a_val[77]=15; b_val[77]=1; r_val[77]=12; +d_val[78]= 95; a_val[78]=10; b_val[78]=1; r_val[78]=5; /* v1=79 INVALID */ -d_val[80]=1599; a_val[80]=39; b_val[80]=1; r_val[80]=78; -d_val[81]=6557; a_val[81]=79; b_val[81]=1; r_val[81]=316; -d_val[82]= 105; a_val[82]=10; b_val[82]=1; r_val[82]=5; -d_val[83]= 85; a_val[83]= 9; b_val[83]=1; r_val[83]=4; -d_val[84]=1763; a_val[84]=41; b_val[84]=1; r_val[84]=82; -d_val[85]=7221; a_val[85]=83; b_val[85]=1; r_val[85]=332; -d_val[86]= 462; a_val[86]=21; b_val[86]=1; r_val[86]=21; -d_val[87]=7565; a_val[87]=85; b_val[87]=1; r_val[87]=340; -d_val[88]= 215; a_val[88]=15; b_val[88]=1; r_val[88]=10; -d_val[89]=7917; a_val[89]=87; b_val[89]=1; r_val[89]=348; -d_val[90]= 506; a_val[90]=22; b_val[90]=1; r_val[90]=22; -d_val[91]=8277; a_val[91]=89; b_val[91]=1; r_val[91]=356; -d_val[92]= 235; a_val[92]=15; b_val[92]=1; r_val[92]=10; -d_val[93]=8645; a_val[93]=91; b_val[93]=1; r_val[93]=364; -d_val[94]= 138; a_val[94]=12; b_val[94]=1; r_val[94]=6; -d_val[95]=9021; a_val[95]=93; b_val[95]=1; r_val[95]=372; -d_val[96]= 47; a_val[96]= 7; b_val[96]=1; r_val[96]=2; -d_val[97]=1045; a_val[97]=33; b_val[97]=1; r_val[97]=44; +d_val[80]=1599; a_val[80]=39; b_val[80]=1; r_val[80]=78; +d_val[81]=6557; a_val[81]=79; b_val[81]=1; r_val[81]=316; +d_val[82]= 105; a_val[82]=10; b_val[82]=1; r_val[82]=5; +d_val[83]= 85; a_val[83]= 9; b_val[83]=1; r_val[83]=4; +d_val[84]=1763; a_val[84]=41; b_val[84]=1; r_val[84]=82; +d_val[85]=7221; a_val[85]=83; b_val[85]=1; r_val[85]=332; +d_val[86]= 462; a_val[86]=21; b_val[86]=1; r_val[86]=21; +d_val[87]=7565; a_val[87]=85; b_val[87]=1; r_val[87]=340; +d_val[88]= 215; a_val[88]=15; b_val[88]=1; r_val[88]=10; +d_val[89]=7917; a_val[89]=87; b_val[89]=1; r_val[89]=348; +d_val[90]= 506; a_val[90]=22; b_val[90]=1; r_val[90]=22; +d_val[91]=8277; a_val[91]=89; b_val[91]=1; r_val[91]=356; +d_val[92]= 235; a_val[92]=15; b_val[92]=1; r_val[92]=10; +d_val[93]=8645; a_val[93]=91; b_val[93]=1; r_val[93]=364; +d_val[94]= 138; a_val[94]=12; b_val[94]=1; r_val[94]=6; +d_val[95]=9021; a_val[95]=93; b_val[95]=1; r_val[95]=372; +d_val[96]= 47; a_val[96]= 7; b_val[96]=1; r_val[96]=2; +d_val[97]=1045; a_val[97]=33; b_val[97]=1; r_val[97]=44; /* v1=98 INVALID */ -d_val[99]=9797; a_val[99]=97; b_val[99]=1; r_val[99]=388; +d_val[99]=9797; a_val[99]=97; b_val[99]=1; r_val[99]=388; d_val[100]= 51; a_val[100]= 7; b_val[100]=1; r_val[100]=2; if (config("lib_debug") & 3) { diff --git a/lib/mfactor.cal b/lib/mfactor.cal index 7a876aa..fb55ea1 100644 --- a/lib/mfactor.cal +++ b/lib/mfactor.cal @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ @@ -64,10 +64,10 @@ * k = (Q*g + hx/n)/2 * * This allows us to quickly eliminate factor values that are divisible - * by 2, 3, 5, 7, 11, 13 or 17. (well <= p value found below) + * by 2, 3, 5, 7, 11, 13 or 17. (well <= p value found below) * * The following loop shows how test_factor is advanced to higher test - * values using hset[]. Here, hcount is the number of elements in hset[]. + * values using hset[]. Here, hcount is the number of elements in hset[]. * It can be shown that hset[0] == 0. We add hset[hcount] to the hset[] * array for looping control convenience. * @@ -83,22 +83,22 @@ * * The test, mfactor(67, 1, 10000) took on an 200 Mhz r4k (user CPU seconds): * - * 210.83 (prior to use of hset[]) - * 78.35 (hset[] for p_elim = 7) - * 73.87 (hset[] for p_elim = 11) - * 73.92 (hset[] for p_elim = 13) - * 234.16 (hset[] for p_elim = 17) + * 210.83 (prior to use of hset[]) + * 78.35 (hset[] for p_elim = 7) + * 73.87 (hset[] for p_elim = 11) + * 73.92 (hset[] for p_elim = 13) + * 234.16 (hset[] for p_elim = 17) * p_elim == 19 requires over 190 Megs of memory * * Over a long period of time, the call to load_hset() becomes insignificant. * If we look at the user CPU seconds from the first 10000 cycle to the * end of the test we find: * - * 205.00 (prior to use of hset[]) - * 75.89 (hset[] for p_elim = 7) - * 73.74 (hset[] for p_elim = 11) - * 70.61 (hset[] for p_elim = 13) - * 57.78 (hset[] for p_elim = 17) + * 205.00 (prior to use of hset[]) + * 75.89 (hset[] for p_elim = 7) + * 73.74 (hset[] for p_elim = 11) + * 70.61 (hset[] for p_elim = 13) + * 57.78 (hset[] for p_elim = 17) * p_elim == 19 rejected because of memory size * * The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and @@ -124,7 +124,7 @@ * * We know that factors of a Mersenne number are of the form: * - * 2*k*n+1 and +/- 1 mod 8 + * 2*k*n+1 and +/- 1 mod 8 * * We make use of the hset[] difference array to eliminate factor * candidates that would otherwise be divisible by 2, 3, 5, 7 ... p_elim. @@ -140,7 +140,7 @@ * * NOTE: The p_elim argument is optional and defaults to 17. A p_elim value * of 17 is faster than 13 for even medium length runs. However 13 - * uses less memory and has a shorter startup time. + * uses less memory and has a shorter startup time. */ define mfactor(n, start_k, rept_loop, p_elim) { diff --git a/lib/natnumset.cal b/lib/natnumset.cal index 795ff1b..da85e1c 100644 --- a/lib/natnumset.cal +++ b/lib/natnumset.cal @@ -62,9 +62,9 @@ * !A = 1 or 0 according as A is empty or not empty * +A = sum of the members of A * - * min(A) = least member of A, -1 for empty set - * max(A) = greatest member of A, -1 for empty set - * sum(A) = sum of the members of A + * min(A) = least member of A, -1 for empty set + * max(A) = greatest member of A, -1 for empty set + * sum(A) = sum of the members of A * * In the following a and b denote arbitrary members of A and B: * diff --git a/lib/pix.cal b/lib/pix.cal index 6131f0c..d388d36 100644 --- a/lib/pix.cal +++ b/lib/pix.cal @@ -1,21 +1,21 @@ /* * Here is an iterative method of finding the number of primes less than - * or equal to a given number. This method is from "Computer Recreations" + * or equal to a given number. This method is from "Computer Recreations" * June 1996 issue of Scientific American. * * NOTE: For reasonable values of x, the builtin function pix(x) is - * much faster. This code is provided because the method - * is interesting. + * much faster. This code is provided because the method + * is interesting. */ define pi_of_x(x) { - local An; /* A(n) */ - local An1; /* A(n-1) */ - local An2; /* A(n-2) */ - local An3; /* A(n-3) */ - local primes; /* number of primes found */ - local n; /* loop counter */ + local An; /* A(n) */ + local An1; /* A(n-1) */ + local An2; /* A(n-2) */ + local An3; /* A(n-3) */ + local primes; /* number of primes found */ + local n; /* loop counter */ /* * setup diff --git a/lib/poly.cal b/lib/poly.cal index ddb285c..99ccd37 100644 --- a/lib/poly.cal +++ b/lib/poly.cal @@ -1,6 +1,6 @@ /* * A collection of functions designed for calculations involving - * polynomials in one variable (by Ernest W. Bowen). + * polynomials in one variable (by Ernest W. Bowen). * * On starting the program the independent variable has identifier x * and name "x", i.e. the user can refer to it as x, the @@ -24,25 +24,25 @@ * would assign to q a number value. As with number expressions * involving operations, the expression used to define the * polynomial is usually lost; in the above example, the normal - * computer display for p will be x^2 - 2x + 1. Different + * computer display for p will be x^2 - 2x + 1. Different * identifiers may of course have the same polynomial value. * * The polynomial we think of as a_0 + a_1 * x + ... + a_n * x^n, * for number coefficients a_0, a_1, ... a_n may also be - * constructed as pol(a_0, a_1, ..., a_n). Note that here the + * constructed as pol(a_0, a_1, ..., a_n). Note that here the * coefficients are to be in ascending power order. The independent * variable is pol(0,1), so to use t, say, as an identifier for * this, one may assign t = pol(0,1). To simultaneously specify * an identifier and a name for the independent variable, there is - * the instruction var, used as in identifier = var(name). For + * the instruction var, used as in identifier = var(name). For * example, to use "t" in the way "x" is initially, one may give - * the instruction t = var("t"). + * the instruction t = var("t"). * * There are four parameters pmode, order, iod and ims for controlling * the format in which polynomials are displayed. * The parameter pmode may have values "alg" or "list": the * former gives a display as an algebraic formula, while - * the latter only lists the coefficients. Whether the terms or + * the latter only lists the coefficients. Whether the terms or * coefficients are in ascending or descending power order is * controlled by order being "up" or "down". If the * parameter iod (for integer-only display), the polynomial @@ -69,7 +69,7 @@ * polynomial, list or matrix were a function. For example, * if a = 1 + x^2, a(2) will return the value 5, just as if * define a(t) = 1 + t^2; - * had been used. However, when the polynomial definition is + * had been used. However, when the polynomial definition is * used, changing the polynomial a will change a(t) to the value * of the new polynomial at t. For example, * after @@ -87,7 +87,7 @@ * Matrices with polynomial elements may be added, subtracted and * multiplied as long as the usual rules for compatibility are * observed. Also, matrices may be multiplied by polynomials, - * i.e. if p is a polynomial and A a matrix whose elements + * i.e. if p is a polynomial and A a matrix whose elements * may be numbers or polynomials, p * A returns the matrix of * the same shape as A with each element multiplied by p. * Square matrices may also be 'substituted for the variable' in @@ -106,7 +106,7 @@ * Functions defined include: * * monic(a) returns the monic multiple of a, i.e., if a != 0, - * the multiple of a with leading coefficient 1 + * the multiple of a with leading coefficient 1 * conj(a) returns the complex conjugate of a * ispmult(a,b) returns 1 or 0 according as a is or is not * a polynomial multiple of b @@ -119,7 +119,7 @@ * by Newtonian divided difference interpolation, where * X is a list of x-values, Y a list of corresponding * y-values. If t is omitted, the interpolating - * polynomial is returned. A y-value may be replaced by + * polynomial is returned. A y-value may be replaced by * list (y, y_1, y_2, ...), where y_1, y_2, ... are * the reduced derivatives at the corresponding x; * i.e. y_r is the r-th derivative divided by fact(r). @@ -328,7 +328,7 @@ define poly_cmp(a,b) { local sa, sb; sa = findlist(a); sb=findlist(b); - return (sa != sb); + return (sa != sb); } define poly_mul(a,b) { @@ -547,7 +547,7 @@ define D(a, n) { local i,j,v; if (isnull(n)) n = 1; if (!isint(n) || n < 1) quit "Bad order for derivative"; - if (ismat(a)) { + if (ismat(a)) { v = a; for (i = matmin(a,1); i <= matmax(a,1); i++) for (j = matmin(a,2); j <= matmax(a,2); j++) @@ -561,7 +561,7 @@ define D(a, n) { define Dp(a,n) { local i, v; if (n > 1) return Dp(Dp(a, n-1), 1); - obj poly v; + obj poly v; v.p=list(); for (i=1; i 0 ? 1 : 0; + local to_past_idx = divisions > 0 ? 1 : 0; if (divisions < 0) { divisions = -divisions; diff --git a/lib/randbitrun.cal b/lib/randbitrun.cal index d3ec206..645b693 100644 --- a/lib/randbitrun.cal +++ b/lib/randbitrun.cal @@ -5,17 +5,17 @@ * The odds that we will have n bits the same in a row is 1/2^n. */ /* - * Copyright 1995 by Landon Curt Noll. All Rights Reserved. + * Copyright 1995 by Landon Curt Noll. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright, this permission notice, and the * disclaimer below appear in all of the following: * - * * supporting documentation - * * source copies - * * source works derived from this source - * * binaries derived from this source or from derived source + * * supporting documentation + * * source copies + * * source works derived from this source + * * binaries derived from this source or from derived source * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO @@ -36,7 +36,7 @@ define randbitrun(run_cnt) local last; /* last random number */ local current; /* current random number */ local MAX_RUN = 18; /* max run we will keep track of */ - local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ + local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */ /* @@ -77,7 +77,7 @@ define randbitrun(run_cnt) /* look for a run break */ if (current != last) { - /* record the stats */ + /* record the stats */ if (run > max_run) { max_run = run; } diff --git a/lib/randmprime.cal b/lib/randmprime.cal index a19a93d..23952d9 100644 --- a/lib/randmprime.cal +++ b/lib/randmprime.cal @@ -21,10 +21,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* obtain our required libs */ @@ -64,7 +64,7 @@ randmprime(bits, seed, dbg) bits = 1; } if (param(0) == 2 || dbg < 0) { - dbg = 0; + dbg = 0; } /* seed generator */ @@ -96,7 +96,7 @@ randmprime(bits, seed, dbg) /* bump h, and n if needed */ if (dbg >= 2) { stop = runtime(); - print "DEBUG2: last test:", stop-start, " total time:", stop-init; + print "DEBUG2: last test:", stop-start, " total time:", stop-init; } if (dbg >= 1) { print "DEBUG1: composite: (h+" : plush : ")*2^" : n : "-1"; diff --git a/lib/randombitrun.cal b/lib/randombitrun.cal index acc8526..5d118f5 100644 --- a/lib/randombitrun.cal +++ b/lib/randombitrun.cal @@ -5,17 +5,17 @@ * The odds that we will have n bits the same in a row is 1/2^n. */ /* - * Copyright 1997 by Landon Curt Noll. All Rights Reserved. + * Copyright 1997 by Landon Curt Noll. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright, this permission notice, and the * disclaimer below appear in all of the following: * - * * supporting documentation - * * source copies - * * source works derived from this source - * * binaries derived from this source or from derived source + * * supporting documentation + * * source copies + * * source works derived from this source + * * binaries derived from this source or from derived source * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO @@ -36,7 +36,7 @@ define randombitrun(run_cnt) local last; /* last random number */ local current; /* current random number */ local MAX_RUN = 18; /* max run we will keep track of */ - local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ + local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */ /* @@ -77,7 +77,7 @@ define randombitrun(run_cnt) /* look for a run break */ if (current != last) { - /* record the stats */ + /* record the stats */ if (run > max_run) { max_run = run; } diff --git a/lib/randomrun.cal b/lib/randomrun.cal index 5232613..3889808 100644 --- a/lib/randomrun.cal +++ b/lib/randomrun.cal @@ -14,17 +14,17 @@ * chi-square test and to make estimating the run length probs easy. */ /* - * Copyright 1997 by Landon Curt Noll. All Rights Reserved. + * Copyright 1997 by Landon Curt Noll. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright, this permission notice, and the * disclaimer below appear in all of the following: * - * * supporting documentation - * * source copies - * * source works derived from this source - * * binaries derived from this source or from derived source + * * supporting documentation + * * source copies + * * source works derived from this source + * * binaries derived from this source or from derived source * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO @@ -45,7 +45,7 @@ define randomrun(run_cnt) local last; /* last random number */ local current; /* current random number */ local MAX_RUN = 9; /* max run we will keep track of */ - local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ + local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */ /* @@ -86,7 +86,7 @@ define randomrun(run_cnt) /* look for a run break */ if (current < last) { - /* record the stats */ + /* record the stats */ if (run > max_run) { max_run = run; } diff --git a/lib/randrun.cal b/lib/randrun.cal index 69c6a46..e131279 100644 --- a/lib/randrun.cal +++ b/lib/randrun.cal @@ -14,17 +14,17 @@ * chi-square test and to make estimating the run length probs easy. */ /* - * Copyright 1995 by Landon Curt Noll. All Rights Reserved. + * Copyright 1995 by Landon Curt Noll. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright, this permission notice, and the * disclaimer below appear in all of the following: * - * * supporting documentation - * * source copies - * * source works derived from this source - * * binaries derived from this source or from derived source + * * supporting documentation + * * source copies + * * source works derived from this source + * * binaries derived from this source or from derived source * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO @@ -45,7 +45,7 @@ define randrun(run_cnt) local last; /* last random number */ local current; /* current random number */ local MAX_RUN = 9; /* max run we will keep track of */ - local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ + local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */ local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */ /* @@ -86,7 +86,7 @@ define randrun(run_cnt) /* look for a run break */ if (current < last) { - /* record the stats */ + /* record the stats */ if (run > max_run) { max_run = run; } diff --git a/lib/regress.cal b/lib/regress.cal index 317f3e8..8d08839 100644 --- a/lib/regress.cal +++ b/lib/regress.cal @@ -4,11 +4,11 @@ * provided that this copyright notice remains intact. * * Test the correct execution of the calculator by reading this library file. - * Errors are reported with '****' messages, or worse. :-) + * Errors are reported with '****' messages, or worse. :-) * * NOTE: Unlike most calc lib files, this one performs its work when - * it is read. Normally one would just define functions and - * values for later use. In the case of the regression test, + * it is read. Normally one would just define functions and + * values for later use. In the case of the regression test, * we do not want to do this. */ @@ -148,7 +148,7 @@ define test_booleans() else prob = prob + 1; - vrfy(1, '311: vrfy 1'); + vrfy(1, '311: vrfy 1'); vrfy(2 == 2, '312: vrfy 2 == 2'); vrfy(2 != 3, '313: vrfy 2 != 3'); vrfy(2 < 3, '314: vrfy 2 < 3'); @@ -159,7 +159,7 @@ define test_booleans() vrfy(3 >= 2, '319: vrfy 3 >= 2'); vrfy(!0, '320: vrfy !0'); vrfy(!1 == 0,'321: vrfy !1 == 0'); - vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3'); + vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3'); print '323: Ending test_booleans'; } @@ -269,7 +269,7 @@ define test_variables() x = 2 && 0; vrfy(x == 0, '381: (2 && 0) == 0'); x = 0 && 3; vrfy(x == 0, '382: (0 && 3) == 0'); x = 2 || prob('2 || prob()'); - print "383: x = 2 || prob('2 || prob()'"; + print "383: x = 2 || prob('2 || prob()'"; x = 0 && prob('0 && prob()'); print "384: x = 0 && prob('0 && prob()'"; @@ -305,34 +305,34 @@ define test_arithmetic() vrfy(6+12/3==10, '418: 6+12/3 == 10'); vrfy(2+3==1+4, '419: 2+3 == 1+4'); vrfy(-(2+3)==-5, '420: -(2+3) == -5'); - vrfy(7&18==2, '421: 7&18 == 2'); - vrfy(3|17==19, '422: 3|17 == 19'); - vrfy(2&3|1==3, '423: 2&3|1 == 3'); + vrfy(7&18==2, '421: 7&18 == 2'); + vrfy(3|17==19, '422: 3|17 == 19'); + vrfy(2&3|1==3, '423: 2&3|1 == 3'); vrfy(2&(3|1)==2, '424: 2&(3|1) == 2'); - vrfy(3<<4==48, '425: 3<<4 == 48'); - vrfy(5>>1==2, '426: 5>>1 == 2'); - vrfy(3<<-1==1, '427: 3<<-1 == 1'); - vrfy(5>>-2==20, '428: 5>>-2 == 20'); + vrfy(3<<4==48, '425: 3<<4 == 48'); + vrfy(5>>1==2, '426: 5>>1 == 2'); + vrfy(3<<-1==1, '427: 3<<-1 == 1'); + vrfy(5>>-2==20, '428: 5>>-2 == 20'); vrfy(1<<2<<3==65536, '429: 1<<2<<3 == 65536'); vrfy((1<<2)<<3==32, '430: (1<<2)<<3 == 32'); vrfy(2^3^2==512, '431: 2^3^2 == 512'); vrfy((2^3)^2==64, '432: (2^3)^2 == 64'); - vrfy(4//3==1, '433: 4//3==1'); - vrfy(4//-3==-1, '434: 4//-3==-1'); + vrfy(4//3==1, '433: 4//3==1'); + vrfy(4//-3==-1, '434: 4//-3==-1'); vrfy(0.75//-0.51==-1, '435: 0.75//-0.51==-1'); vrfy(0.75//-0.50==-1, '436: 0.75//-0.50==-1'); vrfy(0.75//-0.49==-1, '437: 0.75//-0.49==-1'); vrfy((3/4)//(-1/4)==-3, '438: (3/4)//(-1/4)==-3'); - vrfy(7%3==1, '439: 7%3==1'); + vrfy(7%3==1, '439: 7%3==1'); vrfy(0-.5==-.5, '440: 0-.5==-.5'); - vrfy(0^0 == 1, '441: 0^0 == 1'); - vrfy(0^1 == 0, '442: 0^1 == 0'); - vrfy(1^0 == 1, '443: 1^0 == 1'); - vrfy(1^1 == 1, '444: 1^1 == 1'); + vrfy(0^0 == 1, '441: 0^0 == 1'); + vrfy(0^1 == 0, '442: 0^1 == 0'); + vrfy(1^0 == 1, '443: 1^0 == 1'); + vrfy(1^1 == 1, '444: 1^1 == 1'); vrfy(1/(.8+.8i)==.625-.625i, '445: 1/(.8+.8i)==.625-.625i'); vrfy((.6+.8i)*(3.6-4.8i)==6, '446: (.6+.8i)*(3.6-4.8i)==6'); vrfy(-16^-2 == -1/256, '447: -16^-2 == -1/256'); - vrfy(-7^2 == -49, '448: -7^2 == -49'); + vrfy(-7^2 == -49, '448: -7^2 == -49'); vrfy(-3! == -6, '449: -3! == -6'); print '450: Ending test_arithmetic'; @@ -353,14 +353,14 @@ define test_config() /* check the set and return of all config */ callcfg = config("all"); - print '501: callcfg = config("all")'; + print '501: callcfg = config("all")'; callcfg = config("all", "oldstd"); - print '502: callcfg = config("all","oldstd")'; + print '502: callcfg = config("all","oldstd")'; oldcfg = config("all", "newstd"); - print '503: oldcfg = config("all","newstd")'; + print '503: oldcfg = config("all","newstd")'; vrfy(callcfg == startcfg, '504: callcfg == startcfg'); newcfg = config("all"); - print '505: newcfg = config("all")'; + print '505: newcfg = config("all")'; vrfy(config("all") == newcfg, '506: config("all") == newcfg'); vrfy(config("all", oldcfg) == newcfg, '507: config("all", oldcfg) == newcfg'); @@ -455,8 +455,8 @@ define test_config() /* restore calling config */ vrfy(config("all",callcfg) == oldcfg, '550: config("all",callcfg) == oldcfg'); - vrfy(config("all") == callcfg, '551: config("all") == callcfg'); - vrfy(config("all") == startcfg, '552: config("all") == startcfg'); + vrfy(config("all") == callcfg, '551: config("all") == callcfg'); + vrfy(config("all") == startcfg, '552: config("all") == startcfg'); print '553: Ending test_config'; } @@ -707,19 +707,19 @@ define test_functions() print '700: Beginning test_functions'; - vrfy(abs(3) == 3, '701: abs(3) == 3'); - vrfy(abs(-4) == 4, '702: abs(-4) == 4'); - vrfy(avg(7) == 7, '703: avg(7) == 7'); + vrfy(abs(3) == 3, '701: abs(3) == 3'); + vrfy(abs(-4) == 4, '702: abs(-4) == 4'); + vrfy(avg(7) == 7, '703: avg(7) == 7'); vrfy(avg(3,5) == 4, '704: avg(3,5) == 4'); vrfy(cmp(2,3) == -1, '705: cmp(2,3) == -1'); vrfy(cmp(6,6) == 0, '706: cmp(6,6) == 0'); vrfy(cmp(7,4) == 1, '707: cmp(7,4) == 1'); vrfy(comb(9,9) == 1, '708: comb(9,9) == 1'); vrfy(comb(5,2) == 10, '709: comb(5,2) == 10'); - vrfy(conj(4) == 4, '710: conj(4) == 4'); + vrfy(conj(4) == 4, '710: conj(4) == 4'); vrfy(conj(2-3i) == 2+3i, '711: conj(2-3i) == 2+3i'); - vrfy(den(17) == 1, '712: den(17) == 1'); - vrfy(den(3/7) == 7, '713: den(3/7) == 7'); + vrfy(den(17) == 1, '712: den(17) == 1'); + vrfy(den(3/7) == 7, '713: den(3/7) == 7'); vrfy(den(-2/3) == 3, '714: den(-2/3) == 3'); vrfy(digits(0) == 1, '715: digits(0) == 1'); vrfy(digits(9) == 1, '716: digits(9) == 1'); @@ -728,15 +728,15 @@ define test_functions() vrfy(eval('2+3') == 5, "719: eval('2+3') == 5"); vrfy(fcnt(11,3) == 0, '720: fcnt(11,3) == 0'); vrfy(fcnt(18,3) == 2, '721: fcnt(18,3) == 2'); - vrfy(fib(0) == 0, '722: fib(0) == 0'); - vrfy(fib(1) == 1, '723: fib(1) == 1'); - vrfy(fib(9) == 34, '724: fib(9) == 34'); + vrfy(fib(0) == 0, '722: fib(0) == 0'); + vrfy(fib(1) == 1, '723: fib(1) == 1'); + vrfy(fib(9) == 34, '724: fib(9) == 34'); vrfy(frem(12,5) == 12, '725: frem(12,5) == 12'); vrfy(frem(45,3) == 5, '726: frem(45,3) == 5'); vrfy(fact(0) == 1, '727: fact(0) == 1'); - vrfy(fact(1) == 1, '728: fact(1) == 1'); + vrfy(fact(1) == 1, '728: fact(1) == 1'); vrfy(fact(5) == 120, '729: fact(5) == 120'); - vrfy(frac(3) == 0, '730: frac(3) == 0'); + vrfy(frac(3) == 0, '730: frac(3) == 0'); vrfy(frac(2/3) == 2/3, '731: frac(2/3) == 2/3'); vrfy(frac(17/3) == 2/3, '732: frac(17/3) == 2/3'); vrfy(gcd(0,3) == 3, '733: gcd(0,3) == 3'); @@ -749,9 +749,9 @@ define test_functions() vrfy(highbit(15) == 3, '740: highbit(15) == 3'); vrfy(hypot(3,4) == 5, '741: hypot(3,4) == 5'); vrfy(ilog(90,3) == 4, '742: ilog(90,3) == 4'); - vrfy(ilog10(123) == 2, '743: ilog10(123) == 2'); + vrfy(ilog10(123) == 2, '743: ilog10(123) == 2'); vrfy(ilog2(17) == 4, '744: ilog2(17) == 4'); - vrfy(im(3) == 0, '745: im(3) == 0'); + vrfy(im(3) == 0, '745: im(3) == 0'); vrfy(im(2+3i) == 3, '746: im(2+3i) == 3'); vrfy(fact(20) == 2432902008176640000, '747: fact(20) == 2432902008176640000'); @@ -765,31 +765,31 @@ define test_functions() print '754: test unused'; print '755: test unused'; print '756: test unused'; - vrfy(int(5) == 5, '757: int(5) == 5'); - vrfy(int(19/3) == 6, '758: int(19/3) == 6'); + vrfy(int(5) == 5, '757: int(5) == 5'); + vrfy(int(19/3) == 6, '758: int(19/3) == 6'); vrfy(inverse(3/2) == 2/3, '759: inverse(3/2) == 2/3'); - vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4'); - vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4'); - vrfy(iseven(10) == 1, '762: iseven(10) == 1'); - vrfy(iseven(13) == 0, '763: iseven(13) == 0'); - vrfy(iseven('a') == 0, "764: iseven('a') == 0"); - vrfy(isint(7) == 1, '765: isint(7) == 1'); + vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4'); + vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4'); + vrfy(iseven(10) == 1, '762: iseven(10) == 1'); + vrfy(iseven(13) == 0, '763: iseven(13) == 0'); + vrfy(iseven('a') == 0, "764: iseven('a') == 0"); + vrfy(isint(7) == 1, '765: isint(7) == 1'); vrfy(isint(19/2) == 0, '766: isint(19/2) == 0'); vrfy(isint('a') == 0, "767: isint('a') == 0"); vrfy(islist(3) == 0, '768: islist(3) == 0'); vrfy(islist(list(2,3)) == 1, '769: islist(list(2,3)) == 1'); vrfy(ismat(3) == 0, '770: ismat(3) == 0'); - vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0'); - vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1'); - vrfy(isnull(3) == 0, '773: isnull(3) == 0'); - vrfy(isnull(null()) == 1, '774: isnull(null()) == 1'); - vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1'); - vrfy(isnum('xx') == 0, "776: isnum('xx') == 0"); - vrfy(isobj(3) == 0, '777: isobj(3) == 0'); - vrfy(isodd(7) == 1, '778: isodd(7) == 1'); - vrfy(isodd(8) == 0, '779: isodd(8) == 0'); - vrfy(isodd('x') == 0, "780: isodd('a') == 0"); - vrfy(isqrt(27) == 5, '781: isqrt(27) == 5'); + vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0'); + vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1'); + vrfy(isnull(3) == 0, '773: isnull(3) == 0'); + vrfy(isnull(null()) == 1, '774: isnull(null()) == 1'); + vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1'); + vrfy(isnum('xx') == 0, "776: isnum('xx') == 0"); + vrfy(isobj(3) == 0, '777: isobj(3) == 0'); + vrfy(isodd(7) == 1, '778: isodd(7) == 1'); + vrfy(isodd(8) == 0, '779: isodd(8) == 0'); + vrfy(isodd('x') == 0, "780: isodd('a') == 0"); + vrfy(isqrt(27) == 5, '781: isqrt(27) == 5'); vrfy(isreal(3) == 1, '782: isreal(3) == 1'); vrfy(isreal('x') == 0, "783: isreal('x') == 0"); vrfy(isreal(2+3i) == 0, '784: isreal(2+3i) == 0'); @@ -805,7 +805,7 @@ define test_functions() print '794: test unused'; vrfy(istype(9,4) == 1, '795: istype(9,4) == 1'); vrfy(istype(3,'xx') == 0, "796: istype(3,'xx') == 0"); - vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1'); + vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1'); vrfy(jacobi(6,13) == -1, '798: jacobi(6,13) == -1'); vrfy(lcm(3,4,5,6) == 60, '799: lcm(3,4,5,6) == 60'); vrfy(lcmfact(8) == 840, '800: lcmfact(8) == 840'); @@ -821,14 +821,14 @@ define test_functions() vrfy(minv(13,97) == 15, '810: minv(13,97) == 15'); vrfy(mne(16,37,10) == 1, '811: mne(16,37,10) == 1'); vrfy(mne(46,79,11) == 0, '812: mne(46,79,11) == 0'); - vrfy(norm(4) == 16, '813: norm(4) == 16'); - vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13'); - vrfy(num(7) == 7, '815: num(7) == 7'); + vrfy(norm(4) == 16, '813: norm(4) == 16'); + vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13'); + vrfy(num(7) == 7, '815: num(7) == 7'); vrfy(num(11/4) == 11, '816: num(11/4) == 11'); - vrfy(num(-9/5) == -9, '817: num(-9/5) == -9'); + vrfy(num(-9/5) == -9, '817: num(-9/5) == -9'); vrfy(char(ord('a')+2) == 'c', "818: char(ord('a')+2) == 'c'"); - vrfy(perm(7,3) == 210, '819: perm(7,3) == 210'); - vrfy(pfact(10) == 210, '820: pfact(10) == 210'); + vrfy(perm(7,3) == 210, '819: perm(7,3) == 210'); + vrfy(pfact(10) == 210, '820: pfact(10) == 210'); vrfy(places(3/7) == -1, '821: places(3/7) == -1'); vrfy(places(.347) == 3, '822: places(.347) == 3'); vrfy(places(17) == 0, '823: places(17) == 0'); @@ -836,21 +836,21 @@ define test_functions() vrfy(poly(2,3,5,2) == 19, '825: poly(2,3,5,2) == 19'); vrfy(ptest(101,10) == 1, '826: ptest(101,10) == 1'); vrfy(ptest(221,30) == 0, '827: ptest(221,30) == 0'); - vrfy(re(9) == 9, '828: re(9) == 9'); - vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7'); - vrfy(scale(3,4) == 48, '830: scale(3,4) == 48'); - vrfy(sgn(-4) == -1, '831: sgn(-4) == -1'); - vrfy(sgn(0) == 0, '832: sgn(0) == 0'); - vrfy(sgn(3) == 1, '833: sgn(3) == 1'); - vrfy(size(7) == 1, '834: size(7) == 1'); - vrfy(sqrt(121) == 11, '835: sqrt(121) == 11'); + vrfy(re(9) == 9, '828: re(9) == 9'); + vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7'); + vrfy(scale(3,4) == 48, '830: scale(3,4) == 48'); + vrfy(sgn(-4) == -1, '831: sgn(-4) == -1'); + vrfy(sgn(0) == 0, '832: sgn(0) == 0'); + vrfy(sgn(3) == 1, '833: sgn(3) == 1'); + vrfy(size(7) == 1, '834: size(7) == 1'); + vrfy(sqrt(121) == 11, '835: sqrt(121) == 11'); vrfy(ssq(2,3,4) == 29, '836: ssq(2,3,4) == 29'); - vrfy(str(45) == '45', "837: str(45) == '45'"); + vrfy(str(45) == '45', "837: str(45) == '45'"); vrfy(strcat('a','bc','def')=='abcdef', "838: strcat('a','bc','def')=='abcdef'"); - vrfy(strlen('') == 0, "839: strlen('') == 0"); + vrfy(strlen('') == 0, "839: strlen('') == 0"); vrfy(strlen('abcd') == 4, "840: strlen('abcd') == 4"); - vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'"); + vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'"); vrfy(substr('abcd',3,4) == 'cd', "842: substr('abcd',3,4) == 'cd'"); vrfy(substr('abcd',1,3) == 'abc', "843: substr('abcd',1,3) == 'abc'"); vrfy(xor(17,17) == 0, '844: xor(17,17) == 0'); @@ -924,7 +924,7 @@ define test_functions() vrfy(istype(2, 3i) == 0, '912: istype(2, 3i) == 0'); vrfy(istype(2i+2, 3i) == 1, '913: istype(2i+2, 3i) == 1'); a = epsilon(); - print '914: a = epsilon()'; + print '914: a = epsilon()'; vrfy(epsilon(a) == epsilon(), '915: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '916: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '917: epsilon(a) == epsilon()'); @@ -1060,7 +1060,7 @@ define test_functions() vrfy(fib(-1) == 1, '1033: fib(-1) == 1'); vrfy(fib(-10) == -55, '1034: fib(-10) == -55'); vrfy(ilog(1/8, 3) == -2, '1035: ilog(1/8, 3) == -2'); - vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1'); + vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1'); vrfy(iroot(1,9) == 1, '1037: iroot(1,9) == 1'); vrfy(iroot(pi()^8,5) == 6, '1038: iroot(pi()^8,5)'); vrfy(isqrt(8.5) == 2, '1039: isqrt(8.5) == 2'); @@ -1162,7 +1162,7 @@ define test_functions() vrfy(popcnt(-237/39929) == 17, '1099: popcnt(-237/39929) == 17'); vrfy(popcnt(pi(1e-20)) == 65, '1100: popcnt(pi(1e-20)) == 65'); - vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69'); + vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69'); vrfy(popcnt(17^777) == 1593, '1102: popcnt(17^777) == 1593'); /* @@ -1302,7 +1302,7 @@ define test_list() vrfy(isnull(search(a,3,2)), '1407: isnull(search(a,3,2))'); vrfy(rsearch(a,3,2) == 1, '1408: rsearch(a,3,2) == 1'); push(a,7); - print '1409: push(a,7)'; + print '1409: push(a,7)'; vrfy(search(a,7) == 0, '1410: search(a,7) == 0'); vrfy(pop(a) == 7, '1411: pop(a) == 7'); vrfy(size(a) == 3, '1412: size(a) == 3'); @@ -1482,7 +1482,7 @@ define test_rand() vrfy(srand() == init, '1520: srand() == init'); tmp = srand(0x87e6ec938ff55aa5<<64); print '1521: tmp = srand(0x87e6ec938ff55aa5<<64)'; - vrfy(srand() == init, '1522: srand() == init'); + vrfy(srand() == init, '1522: srand() == init'); tmp = srand(state0); print '1523: tmp = srand(state0)'; vrfy(srand() == init, '1524: srand() == init'); @@ -1506,10 +1506,10 @@ define test_rand() print '1533: tmp = srand(0)'; vrfy(randbit(32) == 0xc79ef743, '1534: randbit(32) == 0xc79ef743'); vrfy(randbit(32) == 0xe2e6849c, '1535: randbit(32) == 0xe2e6849c'); - vrfy(randbit(1) == 0x1, '1536: randbit(1) == 0x1'); - vrfy(randbit(5) == 0x3, '1537: randbit(5) == 0x3'); - vrfy(randbit(33) == 0x96e595f6, '1538: randbit(33) == 0x96e595f6'); - vrfy(randbit(25) == 0x1321284, '1539: randbit(25) == 0x1321284'); + vrfy(randbit(1) == 0x1, '1536: randbit(1) == 0x1'); + vrfy(randbit(5) == 0x3, '1537: randbit(5) == 0x3'); + vrfy(randbit(33) == 0x96e595f6, '1538: randbit(33) == 0x96e595f6'); + vrfy(randbit(25) == 0x1321284, '1539: randbit(25) == 0x1321284'); vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1'); vrfy(randbit(13) == 0x7a5, '1541: randbit(13) == 0x7a5'); vrfy(randbit(18) == 0x1a63e, '1542: randbit(18) == 0x1a63e'); @@ -1608,43 +1608,43 @@ define test_mode() tmp = config("mode", "bin"); print '1619: tmp = config("mode", "bin")'; vrfy(tmp == "octal", '1620: tmp == "octal"'); - vrfy(base() == 2, '1621: base() == 2'); + vrfy(base() == 2, '1621: base() == 2'); tmp = config("mode", "real"); - print '1622: tmp = config("mode", "real")'; - vrfy(tmp == "binary", '1623: tmp == "binary"'); + print '1622: tmp = config("mode", "real")'; + vrfy(tmp == "binary", '1623: tmp == "binary"'); tmp = base(1/3); - print '1624: tmp = base(1/3)'; - vrfy(config("mode") == "frac", '1625: config("mode") == "frac"'); + print '1624: tmp = base(1/3)'; + vrfy(config("mode") == "frac", '1625: config("mode") == "frac"'); tmp = base(-10); - print '1626: tmp = base(-10)'; - vrfy(config("mode") == "int", '1627: config("mode") == "int"'); + print '1626: tmp = base(-10)'; + vrfy(config("mode") == "int", '1627: config("mode") == "int"'); tmp = base(10); - print '1628: tmp = base(10)'; - vrfy(config("mode") == "real", '1629: config("mode") == "real"'); + print '1628: tmp = base(10)'; + vrfy(config("mode") == "real", '1629: config("mode") == "real"'); tmp = base(1e20); - print '1630: tmp = base(1e20)'; - vrfy(config("mode") == "exp", '1631: config("mode") == "exp"'); + print '1630: tmp = base(1e20)'; + vrfy(config("mode") == "exp", '1631: config("mode") == "exp"'); tmp = base(16); - print '1632: tmp = base(16)'; + print '1632: tmp = base(16)'; vrfy(config("mode") == "hexadecimal", \ '1633: config("mode") == "hexadecimal"'); tmp = base(8); - print '1634: tmp = base(8)'; + print '1634: tmp = base(8)'; vrfy(config("mode") == "octal", '1635: config("mode") == "octal"'); tmp = base(2); - print '1636: tmp = base(2)'; + print '1636: tmp = base(2)'; vrfy(config("mode") == "binary",'1637: config("mode") == "binary"'); tmp = base(8); - print '1638: tmp = base(8)'; + print '1638: tmp = base(8)'; vrfy(str(0x80000000) == "020000000000", \ '1639: str(0x8000000) == \"020000000000\"'); vrfy(str(0xffffffff) == "037777777777", \ @@ -1653,7 +1653,7 @@ define test_mode() '1641: str(3e9) == \"026264057000\"'); tmp = base(16); - print '1642: tmp = base(16)'; + print '1642: tmp = base(16)'; vrfy(str(0x80000000) == "0x80000000", \ '1643: str(0x8000000) == \"0x80000000\"'); vrfy(str(0xffffffff) == "0xffffffff", \ @@ -1662,7 +1662,7 @@ define test_mode() '1645: str(3e9) == \"0xb2d05e00\"'); tmp = base(10); - print '1646: tmp = base(10)'; + print '1646: tmp = base(10)'; vrfy(config("mode") == "real", \ '1647: config("mode") == "real"'); @@ -1799,7 +1799,7 @@ define test_prime() vrfy(nextprime(65536) == 65537, '1944: nextprime(65536) == 65537'); vrfy(nextprime(1234576,2)==1234577, - '1945: nextprime(1234576,2)==1234577'); + '1945: nextprime(1234576,2)==1234577'); vrfy(nextprime(2^31-9) == 2^31-1, '1946: nextprime(2^31-9) == 2^31-1'); vrfy(nextprime(2^31-1) == 2^31+11, @@ -1807,10 +1807,10 @@ define test_prime() vrfy(nextprime(3e9) == 3e9+19,'1948: nextprime(3e9) == 3e9+19'); vrfy(nextprime(2^32-7) == 2^32-5, '1949: nextprime(2^32-7) == 2^32-5'); - vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1'); + vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1'); vrfy(nextprime(2^32+5,-1) == -1,'1951: nextprime(2^32+5,-1) == -1'); - vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1'); - vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2'); + vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1'); + vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2'); vrfy(prevprime(-3,-1) == 2, '1954: prevprime(-3,-1) == 2'); vrfy(prevprime(0,-1) == 0, '1955: prevprime(0,-1) == 0'); vrfy(prevprime(1,-1) == 0, '1956: prevprime(1,-1) == 0'); @@ -1841,7 +1841,7 @@ define test_prime() vrfy(prevprime(65539) == 65537, '1972: prevprime(65539) == 65537'); vrfy(prevprime(1234578,2)==1234577, - '1973: prevprime(1234578,2)==1234577'); + '1973: prevprime(1234578,2)==1234577'); vrfy(prevprime(2^31-1) == 2^31-19, '1974: prevprime(2^31-1) == 2^31-19'); vrfy(prevprime(2^31+11) == 2^31-1, @@ -1851,9 +1851,9 @@ define test_prime() '1977: prevprime(2^32-3) == 2^32-5'); vrfy(prevprime(2^32-1) == 2^32-5, '1978: prevprime(2^32-1) == 2^32-5'); - vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1'); - vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1'); - vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2'); + vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1'); + vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1'); + vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2'); vrfy(pix(-1) == 0, '1982: pix(-1) == 0'); vrfy(pix(1) == 0, '1983: pix(1) == 0'); vrfy(pix(2) == 1, '1984: pix(2) == 1'); @@ -1865,9 +1865,9 @@ define test_prime() vrfy(pix(2^19+59) == 43393, '1990: pix(2^19+59) == 43393'); vrfy(pix(1000000) == 78498, '1991: pix(1000000) == 78498'); vrfy(pix(10000000) == 664579, '1992: pix(10000000) == 664579'); - vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220'); - vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221'); - vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221'); + vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220'); + vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221'); + vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221'); vrfy(pfact(40) == 7420738134810,'1996: pfact(40) == 7420738134810'); vrfy(pfact(200)/pfact(198)==199,'1997: pfact(200)/pfact(198)==199'); vrfy(nextprime(3e9)==nextcand(3e9), @@ -1919,7 +1919,7 @@ define test_prime() vrfy(lfactor(1001,100) == 7, '2023: lfactor(1001,100) == 7'); vrfy(lfactor(1001,4) == 7, '2024: lfactor(1001,4) == 7'); vrfy(lfactor(1001,3) == 1, '2025: lfactor(1001,3) == 1'); - vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1'); + vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1'); vrfy(lfactor(2^19-1,10000) == 1,'2027: lfactor(2^19-1,10000) == 1'); vrfy(lfactor(2^31-1,10000) == 1,'2028: lfactor(2^31-1,10000) == 1'); vrfy(lfactor(2^32-5,10000) == 1,'2029: lfactor(2^32-5,10000) == 1'); @@ -1974,19 +1974,19 @@ define test_newop() print '2200: Beginning new operator functionality test'; (v = 3) = 4; - print '2201: (v = 3) = 4'; + print '2201: (v = 3) = 4'; vrfy(v == 4, '2202: v == 4'); (v += 3) *= 4; - print '2203: (v += 3) *= 4'; + print '2203: (v += 3) *= 4'; vrfy(v == 28, '2204: v == 28'); vrfy(A == A2, '2205: A == A2'); matfill(B = A, 4); print '2206: matfill(B = A, 4)'; vrfy(A == A2, '2207: A == A2'); vrfy(size(B) == 3, '2208: size(B) == 3'); - vrfy(B[0] == 4, '2209: B[0] == 4'); - vrfy(B[1] == 4, '2210: B[1] == 4'); - vrfy(B[2] == 4, '2211: B[2] == 4'); + vrfy(B[0] == 4, '2209: B[0] == 4'); + vrfy(B[1] == 4, '2210: B[1] == 4'); + vrfy(B[2] == 4, '2211: B[2] == 4'); a = 3; print '2212: a = 3'; ++(b = a); @@ -2562,7 +2562,7 @@ define test_matrix() matfill(e,1,0); print '2862: matfill(e,1,0)'; vrfy(matsum(d) == 945, '2863: matsum(d) == 945'); - vrfy(matsum(e) == 20, '2864: matsum(e) == 20'); + vrfy(matsum(e) == 20, '2864: matsum(e) == 20'); vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1'); vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4'); vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4'); @@ -2603,7 +2603,7 @@ define test_matrix() vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp'); vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp'); matfill(zero3,0); - print '2900: matfill(zero3,0)'; + print '2900: matfill(zero3,0)'; vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3'); vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38'); vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38'); @@ -2657,12 +2657,12 @@ define test_strings() print '3000: Beginning test_strings'; x = 'string'; - print "3001: x = 'string'"; + print "3001: x = 'string'"; y = "string"; - print '3002: y = "string"'; + print '3002: y = "string"'; z = x; - print '3003: z = x'; - vrfy(z == "string", '3004: z == "string"'); + print '3003: z = x'; + vrfy(z == "string", '3004: z == "string"'); vrfy(z != "foo", '3005: z != "foo"'); vrfy(z != 3, '3006: z != 3'); vrfy('' == "", '3007: \'\' == ""'); @@ -2701,7 +2701,7 @@ define test_matobj() vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552'); vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78'); md = 0; - print '3105: md = 0'; + print '3105: md = 0'; B[0,0] = res(2); print '3106: B[0,0] = res(2)'; B[0,1] = res(3); @@ -2888,8 +2888,8 @@ define test_error() vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)'); vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)'); vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)'); - vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)'); - vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)'); + vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)'); + vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)'); vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)'); vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)'); vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)'); @@ -2903,8 +2903,8 @@ define test_error() print '3618: strx = "x"'; vrfy(--strx == error(10011), '3619: strx == error(10011)'); vrfy(int("x") == error(10012), '3620: int("x") == error(10012)'); - vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)'); - vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)'); + vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)'); + vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)'); vrfy(appr("x",.1) == error(10015), '3623: appr("x",.1) == error(10015)'); vrfy(appr(1.27,.1i) == error(10016), @@ -2954,7 +2954,7 @@ define test_error() vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)'); vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)'); vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)'); - vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)'); + vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)'); vrfy(scale("x",2) == error(10033), '3651: scale("x",2) == error(10033)'); vrfy(scale(3,"x") == error(10034), @@ -3035,8 +3035,8 @@ define test_error() b = newerror("beta"); print '3705: c = newerror("alpha")'; c = newerror("alpha"); - vrfy(a == c, '3706: a == c'); - vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"'); + vrfy(a == c, '3706: a == c'); + vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"'); print '3708: n = iserror(a)'; n = iserror(a); vrfy(a == error(n), '3709: a == error(n)'); @@ -3338,7 +3338,7 @@ define test_matdcl() vrfy(ismat(mat_X2), '4307: ismat(mat_X2)'); vrfy(ismat(mat_X3), '4308: ismat(mat_X3)'); mat_Y0 = mat[4]; - print '4309: mat_Y0 = mat[4]'; + print '4309: mat_Y0 = mat[4]'; vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4'); vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2'); vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2'); @@ -3390,9 +3390,9 @@ define test_matdcl() for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]); print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])'; mat_X0==(mat[4]={2,1,2,3}); - print '4350: mat_X0==(mat[4]={2,1,2,3})'; + print '4350: mat_X0==(mat[4]={2,1,2,3})'; vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0'); - vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0'); + vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0'); vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1'); vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3'); vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2'); @@ -3449,7 +3449,7 @@ define test_objmat() vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})'); R = {M2,M3}; print '4409: R = {M2,M3}'; - vrfy(norm(R) == M4, '4410: norm(R) == M4'); + vrfy(norm(R) == M4, '4410: norm(R) == M4'); vrfy(det(surd_value(R^2)) == -23-6i, \ '4411: det(surd_value(R^2)) == -23-6i'); vrfy(det(norm(R^5))==268107761663283843865, \ @@ -3484,13 +3484,13 @@ define test_objmat() '4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})'); mat A[3] = {2,3,5}; - print '4425: mat A[3] = {2,3,5}'; + print '4425: mat A[3] = {2,3,5}'; mat A[3] = {A[0], A[2], A[1]}; print '4426: mat A[3] = {A[0], A[2], A[1]}'; vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})'); B = mat[3] = {2,5,3}; - print '4428: B = mat[3] = {2,5,3}'; + print '4428: B = mat[3] = {2,5,3}'; vrfy(A == B, '4429: A == B'); mat A[2] = {A[1], A[2]}; @@ -3727,7 +3727,7 @@ define test_strprintf() vrfy(strprintf("%5s", "abc") == " abc", '4833: strprintf("%5s", "abc") == " abc"'); vrfy(strprintf("%-5s", "abc") == "abc ", - '4834: strprintf("%-5s", "abc") == "abc "'); + '4834: strprintf("%-5s", "abc") == "abc "'); /* restore config */ c = config("all", callcfg); @@ -3817,8 +3817,8 @@ define test_listsearch() vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8'); vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4'); vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)'); - vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)'); - vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)'); + vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)'); + vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)'); vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7'); print '4919: Ending test_strprintf'; @@ -3905,7 +3905,7 @@ define test_filesearch() vrfy(ftell(f) == 17, '5029: ftell(f) == 17'); vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5'); vrfy(ftell(f) == 5, '5031: ftell(f) == 5'); - vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6'); + vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6'); vrfy(ftell(f) == 10, '5033: ftell(f) == 10'); vrfy(rsearch(f, "beta", 100) == 6, '5034: rsearch(f, "beta", 100) == 6'); @@ -3916,16 +3916,16 @@ define test_filesearch() vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13'); vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14'); vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))'); - vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14'); + vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14'); vrfy(isnull(search(f, "beta", 7)), '5043: isnull(search(f, "beta", 7))'); vrfy(ftell(f) == 14, '5044: ftell(f) == 14'); vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4'); vrfy(ftell(f) == 5, '5046: ftell(f) == 5'); - vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))'); + vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))'); vrfy(ftell(f) == 4, '5048: ftell(f) == 4'); vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4'); - vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12'); + vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12'); vrfy(ftell(f) == 12, '5051: ftell(f) == 12'); vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9'); @@ -4157,7 +4157,7 @@ define test_random() vrfy(srandom() == init, '5320: srandom() == init'); tmp = srandom(0x87e6ec938ff55aa5<<64); print '5321: tmp = srandom(0x87e6ec938ff55aa5<<64)'; - vrfy(srandom() == init, '5322: srandom() == init'); + vrfy(srandom() == init, '5322: srandom() == init'); tmp = srandom(state0); print '5323: tmp = srandom(state0)'; vrfy(srandom() == init, '5324: srandom() == init'); @@ -4184,7 +4184,7 @@ define test_random() vrfy(randombit(1) == 0x1, '5336: randombit(1) == 0x1'); vrfy(randombit(5) == 0xe, '5337: randombit(5) == 0xe'); vrfy(randombit(33) == 0xececfda2, '5338: randombit(33) == 0xececfda2'); - vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb'); + vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb'); vrfy(randombit(2) == 0x3, '5340: randombit(2) == 0x3'); vrfy(randombit(13) == 0xd3, '5341: randombit(13) == 0xd3'); vrfy(randombit(18) == 0x37a76, '5342: randombit(18) == 0x37a76'); @@ -4671,8 +4671,8 @@ define test_commaeq() */ obj xy5600 A = {1, 2} = {3, 4}; print '5612: obj xy5600 A = {1, 2} = {3, 4}'; - vrfy(A.x == 3, '5613: A.x == 3'); - vrfy(A.y == 4, '5614: A.y == 4'); + vrfy(A.x == 3, '5613: A.x == 3'); + vrfy(A.y == 4, '5614: A.y == 4'); obj xy5600 B = {A,A}; print '5613: obj xy5600 B = {A,A}'; vrfy(B.x.x == 3, '5615: B.x.x == 3'); @@ -6011,7 +6011,7 @@ define test_blk() /* Assignment of copy with initialization */ - B = A; + B = A; print '6733: B = A;'; C=blk(A)={,,,,,,,,,,0xbb}; print '6734: C=blk(A)={,,,,,,,,,,0xbb};'; @@ -6135,7 +6135,7 @@ define test_blkcpy() { local A, B, C, A1, A2, B1, fs, S, M1, M2, L1, L2, x; - print '6800: Beginning test_blkcpy'; + print '6800: Beginning test_blkcpy'; A = blk() = {1,2,3,4,5}; print '6801: A = blk() = {1,2,3,4,5};'; @@ -6230,7 +6230,7 @@ define test_blkcpy() vrfy(M2 == (mat[4]={1,2,3,4}), '6844: M2 == (mat[4]={1,2,3,4}'); blkcpy(M2, M2, 2, 2, 0); print '6845: blkcpy(M2, M2, 2, 2, 0);'; - vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}'); + vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}'); /* blkcpy between blocks and matrices */ @@ -6394,7 +6394,7 @@ define test_sha() vrfy(y == sha(1), '7106: y == sha(1)'); vrfy(sha(y,2) == sha(1,2), '7107: sha(y,2) == sha(1,2)'); - vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef, + vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef, '7108: sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef'); vrfy(sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2, @@ -6426,10 +6426,10 @@ define test_sha() vrfy(sha(sha(isqrt(2e1000))) == 0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0, '7120: sha(sha(isqrt(2e1000)==0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0'); - vrfy(sha("x", "y", "z") == sha("xyz"), + vrfy(sha("x", "y", "z") == sha("xyz"), '7121: sha("x", "y", "z") == sha("xyz")'); - vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == + vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == 0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a, '7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...'); @@ -6494,17 +6494,17 @@ define test_sha1() print '7204: z = sha1(1);'; vrfy(sha1(y,1) == z, '7205: sha1(y,1) == z'); vrfy(sha1(z,2) == sha1(1,2), '7206: sha1(z,2) == sha1(1,2)'); - vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709, + vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709, '7207: sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709'); - vrfy(sha1("x", "y", "z") == sha1("xyz"), + vrfy(sha1("x", "y", "z") == sha1("xyz"), '7208: sha1("x", "y", "z") == sha1("xyz")'); - vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == + vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == 0xc3e1b562bf45b3bcfc055ac65b5b39cdeb6a6c55, '7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...'); - z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi()); + z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi()); print '7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());'; vrfy(sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f, '7211: sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f'); @@ -6582,17 +6582,17 @@ define test_md5() vrfy(y == z, '7306: y == z'); vrfy(md5(z,2) == md5(1,2), '7307: md5(z,2) == md5(1,2)'); - vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e, + vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e, '7308: md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e'); - vrfy(md5("x", "y", "z") == md5("xyz"), + vrfy(md5("x", "y", "z") == md5("xyz"), '7309: md5("x", "y", "z") == md5("xyz")'); - vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == + vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == 0x39a5a8e24a2eb65a51af462c8bdd5e3, '7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...'); - z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi()); + z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi()); print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());'; vrfy(md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5, '7312: md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5'); @@ -6675,7 +6675,7 @@ define test_ptr() /* testing octet pointers */ B = blk() = {1,2,3,4,5,6}; - print '7503: B = blk() = {1,2,3,4,5,6};'; + print '7503: B = blk() = {1,2,3,4,5,6};'; vrfy(isoctet(B[0]) == 1, '7504: isoctet(B[0]) == 1'); vrfy(isnum(B[0]) == 0, '7505: isnum(B[0]) == 0'); vrfy(isptr(B[0]) == 0, '7506: isptr(B[0]) == 0'); @@ -6721,7 +6721,7 @@ define test_ptr() vrfy(B[3] == 8, '7537: B[3] == 8'); p0 = p++; print '7538: p0 = p++;'; - vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]'); + vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]'); q0 = --q; print '7540: q0 = --q'; vrfy(q0 == &B[4] && q == q0, '7541: q0 == &B[4] && q == q0'); @@ -6753,7 +6753,7 @@ define test_ptr() vrfy(g7500c(&A[0],2) == 3, '7558: g7500c(&A[0], 2) == 3'); vrfy(g7500d(`A[0]) == &A[0], '7559: g7500d(`A[0]) == &A[0]'); p = &A[0]; - print '7560: p = &A[0];'; + print '7560: p = &A[0];'; vrfy(g7500a(*p, 6) == 6, '7561: g7500a(*p, 6) == 6'); vrfy(*p == 6, '7562: *p == 6'); vrfy(g7500a(`*p,6) == 6, '7563: g7500a(`*p,6) == 6'); @@ -6806,8 +6806,8 @@ define test_ptr() vrfy(M[1] == 2 && M[2] == 3, '7597: M[1] == 2 && M[2] == 3'); A = *M = {7,8}; print '7598: A = *M = {7,8};'; - vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})'); - vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})'); + vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})'); + vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})'); /* Values which point to themselves */ @@ -7078,7 +7078,7 @@ define test_natnumset() vrfy(#~A == 97, '8109: #~A == 97'); vrfy(A + 5 == set(5,7,22,29), '8110: A + 5 == set(5,7,22,29)'); vrfy(A - 5 == set(12,19), '8111: A - 5 == set(12,19)'); - vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)'); + vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)'); vrfy(2 * A == set(0,4,34,48), '8113: 2 * A == set(0,4,34,48)'); vrfy(10 * A == set(0,20), '8114: 10 * A == set(0,20)'); vrfy(A + A == set(0,2,4,17,19,24,26,34,41,48), @@ -7416,7 +7416,7 @@ saveval(1); print '7402: a7400 = 2;'; a7400 = 2; vrfy(. == 2, '7403: . == 2;'); -vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)'); +vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)'); vrfy(. == 5, '7405: . == 5;'); print '7406: a7400 = 5; b7400 = 6;'; a7400 = 5; b7400 = 6; diff --git a/lib/seedrandom.cal b/lib/seedrandom.cal index 0fcc417..5d88b59 100644 --- a/lib/seedrandom.cal +++ b/lib/seedrandom.cal @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* @@ -57,10 +57,10 @@ define seedrandom(seed1, seed2, size, trials) { local p; /* first Blum prime */ local fp; /* prime co-factor of p-1 */ - local sp; /* min bit size of p */ + local sp; /* min bit size of p */ local q; /* second Blum prime */ local fq; /* prime co-factor of q-1 */ - local sq; /* min bit size of q */ + local sq; /* min bit size of q */ local n; /* Blum modulus */ local binsize; /* smallest power of 2 > n=p*q */ local r; /* initial quadratic residue */ @@ -135,7 +135,7 @@ define seedrandom(seed1, seed2, size, trials) * seed the Blum generator */ n = p*q; /* the Blum modulus */ - binsize = highbit(n)+1; /* smallest power of 2 > p*q */ + binsize = highbit(n)+1; /* smallest power of 2 > p*q */ r = pmod(rand(1< 1) { if (err) { diff --git a/lib/test2700.cal b/lib/test2700.cal index adefa61..56194fa 100644 --- a/lib/test2700.cal +++ b/lib/test2700.cal @@ -124,7 +124,7 @@ define testcsqrt(str, n, verbose) } -define checksqrt(x,y,z,v) /* Returns >0 if an error is detected */ +define checksqrt(x,y,z,v) /* Returns >0 if an error is detected */ { local A, B, X, Y, t1, t2, eps, u, n, f, s; diff --git a/lib/test3500.cal b/lib/test3500.cal index 5a31184..23d8818 100644 --- a/lib/test3500.cal +++ b/lib/test3500.cal @@ -12,7 +12,7 @@ * Stringent tests of the functions frem, fcnt, gcdrem. * * testf(n) gives n tests of frem(x,y) and fcnt(x,y) with randomly - * integers x and y generated so that x = f * y^k where f, y and + * integers x and y generated so that x = f * y^k where f, y and * k are randomly generated. * * testg(n) gives n tests of gcdrem(x,y) with x and y generated as for @@ -22,7 +22,7 @@ * powers of small primes some of which are common to both x and y. * This test uses f = abs(x) and iteratively f = frem(f,p) where * p varies over the prime divisors of y; the final value for f - * should equal g. For both x and y the primes are raised to the + * should equal g. For both x and y the primes are raised to the * power rand(N); N defaults to 10. * * If verbose is > 1, the numbers x, y and values for some of the diff --git a/lib/test4000.cal b/lib/test4000.cal index f52e091..3adcf85 100644 --- a/lib/test4000.cal +++ b/lib/test4000.cal @@ -53,7 +53,7 @@ * modulus to 1. */ -global defaultverbose = 1; /* default verbose value */ +global defaultverbose = 1; /* default verbose value */ global err; /* @@ -302,7 +302,7 @@ define testnextcand(str, N, n, count, skip, residue, modulus, verbose) if (isnull(count)) count = COUNT; if (isnull(n)) { - n = ceil(K3/(H3 + N^3)); + n = ceil(K3/(H3 + N^3)); print "n =",n; } if (isnull(skip)) @@ -356,7 +356,7 @@ define testprevcand(str, N, n, count, skip, residue, modulus, verbose) if (isnull(count)) count = COUNT; if (isnull(n)) { - n = ceil(K3/(H3 + N^3)); + n = ceil(K3/(H3 + N^3)); print "n =",n; } if (isnull(skip)) diff --git a/lib/test4100.cal b/lib/test4100.cal index 318942c..cee31bd 100644 --- a/lib/test4100.cal +++ b/lib/test4100.cal @@ -48,7 +48,7 @@ * */ -global defaultverbose = 1; /* default verbose value */ +global defaultverbose = 1; /* default verbose value */ global err; /* diff --git a/lib/test8400.cal b/lib/test8400.cal index 16ba708..6580500 100644 --- a/lib/test8400.cal +++ b/lib/test8400.cal @@ -3,10 +3,10 @@ * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * - * By: Landon Curt Noll - * http://reality.sgi.com/chongo/ + * By: Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * This library is used by the 8400 series of the regress.cal test suite. */ diff --git a/lib/unitfrac.cal b/lib/unitfrac.cal index 8f2416f..91d2fd8 100644 --- a/lib/unitfrac.cal +++ b/lib/unitfrac.cal @@ -6,7 +6,7 @@ * Represent a fraction as sum of distinct unit fractions. * The output is the unit fractions themselves, and in square brackets, * the number of digits in the numerator and denominator of the value left - * to be found. Numbers larger than 3.5 become very difficult to calculate. + * to be found. Numbers larger than 3.5 become very difficult to calculate. */ define unitfrac(x) @@ -21,9 +21,9 @@ define unitfrac(x) if (n > d) d = n; di = 1/d; - print ' [': digits(num(x)): '/': digits(den(x)): ']',, di; + print ' [': digits(num(x)): '/': digits(den(x)): ']',, di; x -= di; d++; } while ((num(x) > 1) || (x == di) || (x == 1)); - print ' [1/1]',, x; + print ' [1/1]',, x; } diff --git a/lib/xx_print.cal b/lib/xx_print.cal index b687f7a..91f9c7b 100644 --- a/lib/xx_print.cal +++ b/lib/xx_print.cal @@ -56,7 +56,7 @@ define mat_print (a) { for (i = matmin(a,1); i <= matmax(a,1); i++) { if (i >= matmin(a,1) + matcolmax) { - print " ..."; + print " ..."; break; } for (j = matmin(a,2); j <= matmax(a,2); j++) { diff --git a/lib_calc.c b/lib_calc.c index 6a9e7a0..10a4596 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -77,7 +77,7 @@ run run_state = RUN_UNKNOWN; /* calc startup and run state */ * global permissions */ int allow_read = TRUE; /* FALSE => may not open any files for reading */ -int allow_write = TRUE; /* FALSE => may not open any files for writing */ +int allow_write = TRUE; /* FALSE => may not open any files for writing */ int allow_exec = TRUE; /* FALSE => may not execute any commands */ @@ -285,7 +285,7 @@ reinitialize(void) * cvmalloc_error - for users of the SGI Workshop Debugger * * usage: - * message - error message passed along via libmalloc_cv.a + * message - error message passed along via libmalloc_cv.a */ void cvmalloc_error(char *message) diff --git a/lib_util.c b/lib_util.c index 183cfd1..9ad656b 100644 --- a/lib_util.c +++ b/lib_util.c @@ -37,28 +37,28 @@ /* * lowhex2bin - quick low order ASCII hex to binary conversion * - * We just use mod 16 for non-hex ASCII chars. We use just mod 128 + * We just use mod 16 for non-hex ASCII chars. We use just mod 128 * for non-ASCII to ASCII conversion. * * | 00 nul | 01 soh | 02 stx | 03 etx | 04 eot | 05 enq | 06 ack | 07 bel | - * | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | + * | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | * | 10 dle | 11 dc1 | 12 dc2 | 13 dc3 | 14 dc4 | 15 nak | 16 syn | 17 etb | * | 18 can | 19 em | 1a sub | 1b esc | 1c fs | 1d gs | 1e rs | 1f us | - * | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | - * | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / | - * | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | - * | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | - * | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | - * | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | - * | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | - * | 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ | - * | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | - * | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | - * | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | - * | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del | + * | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | + * | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / | + * | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | + * | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | + * | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | + * | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | + * | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | + * | 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ | + * | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | + * | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | + * | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | + * | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del | */ int lowhex2bin[256] = { - /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ 0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf, /* 0 */ 0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf, /* 1 */ 0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf, /* 2 */ @@ -134,7 +134,7 @@ convstr2z(char *str) /* * firewall - */ + */ if (str == NULL || *str == '\0') { /* NULL or empty strings return 0 */ return _zero_; @@ -193,7 +193,7 @@ convhex2z(char *hex) /* * firewall - */ + */ if (hex == NULL || hex[0] == '\0') { /* NULL or empty strings return 0 */ return _zero_; diff --git a/lint.sed b/lint.sed index 35eb60e..69590a8 100644 --- a/lint.sed +++ b/lint.sed @@ -1,37 +1,37 @@ /: warning: conversion from long may lose accuracy$/d /: warning: possible pointer alignment problem$/d /^Lint pass[0-9][0-9]*:$/d -/^[a-zA-Z][a-zA-Z0-9_-]*\.c:[ ]*$/d +/^[a-zA-Z][a-zA-Z0-9_-]*\.c:[ ]*$/d /^addglobal, arg\. 2 used inconsistently[ ]/d /^addopptr, arg\. 2 used inconsistently[ ]/d /^codegen\.c([0-9]*):getassignment returns value which is sometimes ignored$/d -/^errno used([ ]*func\.c([0-9]*)[ ]*), but not defined$/d -/^exit value declared inconsistently[ ]/d +/^errno used([ ]*func\.c([0-9]*)[ ]*), but not defined$/d +/^exit value declared inconsistently[ ]/d /^fclose returns value which is sometimes ignored$/d /^fflush returns value which is always ignored$/d /^fprintf returns value which is always ignored$/d /^fputc returns value which is always ignored$/d /^fputs returns value which is always ignored$/d -/^free, arg\. 1 used inconsistently[ ]/d -/^geteuid value declared inconsistently[ ]/d -/^geteuid value used inconsistently[ ]/d -/^getpwuid, arg\. 1 used inconsistently[ ]/d -/^malloc, arg\. 1 used inconsistently[ ]/d +/^free, arg\. 1 used inconsistently[ ]/d +/^geteuid value declared inconsistently[ ]/d +/^geteuid value used inconsistently[ ]/d +/^getpwuid, arg\. 1 used inconsistently[ ]/d +/^malloc, arg\. 1 used inconsistently[ ]/d /^math_setdigits returns value which is always ignored$/d /^math_setmode returns value which is sometimes ignored$/d /^memcpy returns value which is always ignored$/d -/^memcpy value declared inconsistently[ ]/d -/^memcpy, arg\. [1-3] used inconsistently[ ]/d -/^memset value declared inconsistently[ ]/d +/^memcpy value declared inconsistently[ ]/d +/^memcpy, arg\. [1-3] used inconsistently[ ]/d +/^memset value declared inconsistently[ ]/d /^printf returns value which is always ignored$/d /^putc returns value which is always ignored$/d -/^qcfappr, arg\. 2 used inconsistently[ ]/d -/^realloc, arg\. [1-2] used inconsistently[ ]/d +/^qcfappr, arg\. 2 used inconsistently[ ]/d +/^realloc, arg\. [1-2] used inconsistently[ ]/d /^sprintf returns value which is always ignored/d /^strcat returns value which is always ignored/d /^strcpy returns value which is always ignored/d /^strncpy returns value which is always ignored/d -/^strncpy, arg\. [1-3] used inconsistently[ ]/d +/^strncpy, arg\. [1-3] used inconsistently[ ]/d /^system returns value which is always ignored/d /^times returns value which is always ignored/d /^vsprintf returns value which is always ignored/d diff --git a/listfunc.c b/listfunc.c index 064c09c..fcb9bd9 100644 --- a/listfunc.c +++ b/listfunc.c @@ -35,9 +35,9 @@ insertlistfirst(LIST *lp, VALUE *vp) ep = elemalloc(); copyvalue(vp, &ep->e_value); - if (lp->l_count == 0) + if (lp->l_count == 0) { lp->l_last = ep; - else { + } else { lp->l_cacheindex++; lp->l_first->e_prev = ep; ep->e_next = lp->l_first; @@ -61,9 +61,9 @@ insertlistlast(LIST *lp, VALUE *vp) ep = elemalloc(); copyvalue(vp, &ep->e_value); - if (lp->l_count == 0) + if (lp->l_count == 0) { lp->l_first = ep; - else { + } else { lp->l_last->e_next = ep; ep->e_prev = lp->l_last; } @@ -246,8 +246,7 @@ listsegment(LIST *lp, long n1, long n2) insertlistlast(newlp, &ep->e_value); ep = ep->e_next; } - } - else { + } else { i = n1 - n2 + 1; while(n2-- > 0 && ep) ep = ep->e_next; @@ -351,7 +350,7 @@ listfindex(LIST *lp, long index) /* * Return the element at a specified index number of a list. * The list is indexed starting at zero, and negative indices - * indicate to index from the end of the list. This routine finds + * indicate to index from the end of the list. This routine finds * the element by chaining through the list from the closest one * of the first, last, and cached elements. Returns NULL if the * element does not exist. @@ -414,7 +413,7 @@ listelement(LIST *lp, long index) } /* * Now walk forwards or backwards from the selected element - * until we reach the correct element. Cache the location of + * until we reach the correct element. Cache the location of * the found element for future use. */ if (forward) { diff --git a/longbits.c b/longbits.c index acc015d..910ed0f 100644 --- a/longbits.c +++ b/longbits.c @@ -47,7 +47,7 @@ * U(x) form a 33 to 64 bit unsigned constant * * We will also note if we have a standard 64 bit type (i.e., long). If we - * do, we will typedef it and define HAVE_B64. If we do not then if longlong.h + * do, we will typedef it and define HAVE_B64. If we do not then if longlong.h * says we can use long long types, we will use that. If we cannot use a * long long type, then HAVE_B64 will not be defined. * diff --git a/matfunc.c b/matfunc.c index 10a9233..5243e7b 100644 --- a/matfunc.c +++ b/matfunc.c @@ -965,7 +965,7 @@ matinv(MATRIX *m) /* * Now loop over each row, and eliminate all entries in the * corresponding column by using row operations. Do the same - * operations on the resulting matrix. Copy the original matrix + * operations on the resulting matrix. Copy the original matrix * so that we don't destroy it. */ m = matcopy(m); @@ -1036,7 +1036,7 @@ matinv(MATRIX *m) VALUE matdet(MATRIX *m) { - long n; /* original matrix is n x n */ + long n; /* original matrix is n x n */ long k; /* working submatrix is k x k */ long i, j; VALUE *pivot, *div, *val; @@ -1586,7 +1586,7 @@ matprint(MATRIX *m, long max_print) math_str(":\n"); vp = m->m_table; for (index = 0; index < max_print; index++) { - msg = " ["; + msg = " ["; j = index; for (i = 0; i < dim; i++) { math_fmt("%s%ld", msg, m->m_min[i] + (j / sizes[i])); diff --git a/math_error.c b/math_error.c index b0e2c2d..b5baef9 100644 --- a/math_error.c +++ b/math_error.c @@ -50,10 +50,10 @@ * * if ((error = setjmp(calc_jmp_buf)) != 0) { * - * (* reinitialize calc after a longjmp *) - * reinitialize(); + * (* reinitialize calc after a longjmp *) + * reinitialize(); * - * (* report the error *) + * (* report the error *) * printf("Ouch: %s\n", calc_error); * } * calc_jmp = 1; diff --git a/math_error.h b/math_error.h index 80bfd67..617cab8 100644 --- a/math_error.h +++ b/math_error.h @@ -23,7 +23,7 @@ * PERFORMANCE OF THIS SOFTWARE. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * diff --git a/md5.c b/md5.c index c262b75..caf532a 100644 --- a/md5.c +++ b/md5.c @@ -3,11 +3,11 @@ * md5 - RSA Data Security, Inc. MD5 Message-Digest Algorithm * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -23,13 +23,13 @@ ** ** ** License is also granted to make and use derivative works ** ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** + ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** ** material mentioning or referencing the derived work. ** ** ** - ** RSA Data Security, Inc. makes no representations concerning ** + ** RSA Data Security, Inc. makes no representations concerning ** ** either the merchantability of this software or the suitability ** ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** + ** is" without express or implied warranty of any kind. ** ** ** ** These notices must be retained in any copies of any part of this ** ** documentation and/or software. ** @@ -39,7 +39,7 @@ /* *********************************************************************** ** Message-digest routines: ** - ** To form the message digest for a message M ** + ** To form the message digest for a message M ** ** (1) Initialize a context buffer md5Ctx using MD5Init ** ** (2) Call MD5Update on md5Ctx and M ** ** (3) Call MD5Final on md5Ctx ** @@ -254,8 +254,7 @@ MD5Final(HASH *state) SWAP_B8_IN_B32(md5Ctx->data + i, md5Ctx->data + i); } - } - else { + } else { if (count % 4) { math_error("This should not happen in MD5Final"); /*NOTREACHED*/ @@ -657,13 +656,13 @@ MD5_print(HASH *state) * form the hash value */ if (conf->calc_debug & CALCDBG_HASH_STATE) { - char buf[DEBUG_SIZE+1]; /* hash value buffer */ + char buf[DEBUG_SIZE+1]; /* hash value buffer */ /* * print numeric debug value * * NOTE: This value represents only the hash value as of - * the last full update or finalization. Thus it + * the last full update or finalization. Thus it * may NOT be the actual hash value. */ sprintf(buf, diff --git a/md5.h b/md5.h index 2e3dc7f..8d6fe14 100644 --- a/md5.h +++ b/md5.h @@ -3,11 +3,11 @@ * md5 - RSA Data Security, Inc. MD5 Message-Digest Algorithm * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -23,13 +23,13 @@ ** ** ** License is also granted to make and use derivative works ** ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** + ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** ** material mentioning or referencing the derived work. ** ** ** - ** RSA Data Security, Inc. makes no representations concerning ** + ** RSA Data Security, Inc. makes no representations concerning ** ** either the merchantability of this software or the suitability ** ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** + ** is" without express or implied warranty of any kind. ** ** ** ** These notices must be retained in any copies of any part of this ** ** documentation and/or software. ** diff --git a/nametype.h b/nametype.h index 416c692..645c2dd 100644 --- a/nametype.h +++ b/nametype.h @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * diff --git a/obj.c b/obj.c index 8085dcb..08b0d40 100644 --- a/obj.c +++ b/obj.c @@ -19,21 +19,21 @@ /* * Types of values returned by calling object routines. */ -#define A_VALUE 0 /* returns arbitrary value */ +#define A_VALUE 0 /* returns arbitrary value */ #define A_INT 1 /* returns integer value */ -#define A_UNDEF 2 /* returns no value */ +#define A_UNDEF 2 /* returns no value */ /* * Error handling actions for when the function is undefined. */ #define ERR_NONE 0 /* no special action */ #define ERR_PRINT 1 /* print element */ -#define ERR_CMP 2 /* compare two values */ +#define ERR_CMP 2 /* compare two values */ #define ERR_TEST 3 /* test value for nonzero */ -#define ERR_POW 4 /* call generic power routine */ -#define ERR_ONE 5 /* return number 1 */ -#define ERR_INC 6 /* increment by one */ -#define ERR_DEC 7 /* decrement by one */ +#define ERR_POW 4 /* call generic power routine */ +#define ERR_ONE 5 /* return number 1 */ +#define ERR_INC 6 /* increment by one */ +#define ERR_DEC 7 /* decrement by one */ #define ERR_SQUARE 8 /* square value */ #define ERR_VALUE 9 /* return value */ #define ERR_ASSIGN 10 /* assign value */ @@ -47,49 +47,49 @@ static struct objectinfo { char *comment; /* useful comment if any */ } objectinfo[] = { {1, A_UNDEF, ERR_PRINT, "print", "print value, default prints elements"}, - {1, A_VALUE, ERR_ONE, "one", "multiplicative identity, default is 1"}, - {1, A_INT, ERR_TEST, "test", "logical test (false,true => 0,1), default tests elements"}, - {2, A_VALUE, ERR_NONE, "add", NULL}, - {2, A_VALUE, ERR_NONE, "sub", NULL}, - {1, A_VALUE, ERR_NONE, "neg", "negative"}, - {2, A_VALUE, ERR_NONE, "mul", NULL}, - {2, A_VALUE, ERR_NONE, "div", "non-integral division"}, - {1, A_VALUE, ERR_NONE, "inv", "multiplicative inverse"}, - {2, A_VALUE, ERR_NONE, "abs", "absolute value within given error"}, - {1, A_VALUE, ERR_NONE, "norm", "square of absolute value"}, - {1, A_VALUE, ERR_NONE, "conj", "conjugate"}, - {2, A_VALUE, ERR_POW, "pow", "integer power, default does multiply, square, inverse"}, - {1, A_VALUE, ERR_NONE, "sgn", "sign of value (-1, 0, 1)"}, - {2, A_INT, ERR_CMP, "cmp", "equality (equal,nonequal => 0,1), default tests elements"}, - {2, A_VALUE, ERR_NONE, "rel", "relative order, positive for >, etc."}, - {3, A_VALUE, ERR_NONE, "quo", "integer quotient"}, - {3, A_VALUE, ERR_NONE, "mod", "remainder of division"}, - {1, A_VALUE, ERR_NONE, "int", "integer part"}, - {1, A_VALUE, ERR_NONE, "frac", "fractional part"}, - {1, A_VALUE, ERR_INC, "inc", "increment, default adds 1"}, - {1, A_VALUE, ERR_DEC, "dec", "decrement, default subtracts 1"}, + {1, A_VALUE, ERR_ONE, "one", "multiplicative identity, default is 1"}, + {1, A_INT, ERR_TEST, "test", "logical test (false,true => 0,1), default tests elements"}, + {2, A_VALUE, ERR_NONE, "add", NULL}, + {2, A_VALUE, ERR_NONE, "sub", NULL}, + {1, A_VALUE, ERR_NONE, "neg", "negative"}, + {2, A_VALUE, ERR_NONE, "mul", NULL}, + {2, A_VALUE, ERR_NONE, "div", "non-integral division"}, + {1, A_VALUE, ERR_NONE, "inv", "multiplicative inverse"}, + {2, A_VALUE, ERR_NONE, "abs", "absolute value within given error"}, + {1, A_VALUE, ERR_NONE, "norm", "square of absolute value"}, + {1, A_VALUE, ERR_NONE, "conj", "conjugate"}, + {2, A_VALUE, ERR_POW, "pow", "integer power, default does multiply, square, inverse"}, + {1, A_VALUE, ERR_NONE, "sgn", "sign of value (-1, 0, 1)"}, + {2, A_INT, ERR_CMP, "cmp", "equality (equal,nonequal => 0,1), default tests elements"}, + {2, A_VALUE, ERR_NONE, "rel", "relative order, positive for >, etc."}, + {3, A_VALUE, ERR_NONE, "quo", "integer quotient"}, + {3, A_VALUE, ERR_NONE, "mod", "remainder of division"}, + {1, A_VALUE, ERR_NONE, "int", "integer part"}, + {1, A_VALUE, ERR_NONE, "frac", "fractional part"}, + {1, A_VALUE, ERR_INC, "inc", "increment, default adds 1"}, + {1, A_VALUE, ERR_DEC, "dec", "decrement, default subtracts 1"}, {1, A_VALUE, ERR_SQUARE,"square", "default multiplies by itself"}, - {2, A_VALUE, ERR_NONE, "scale", "multiply by power of 2"}, - {2, A_VALUE, ERR_NONE, "shift", "shift left by n bits (right if negative)"}, - {3, A_VALUE, ERR_NONE, "round", "round to given number of decimal places"}, - {3, A_VALUE, ERR_NONE, "bround", "round to given number of binary places"}, - {3, A_VALUE, ERR_NONE, "root", "root of value within given error"}, - {3, A_VALUE, ERR_NONE, "sqrt", "square root within given error"}, - {2, A_VALUE, ERR_NONE, "or", "bitwise or"}, - {2, A_VALUE, ERR_NONE, "and", "bitwise and"}, + {2, A_VALUE, ERR_NONE, "scale", "multiply by power of 2"}, + {2, A_VALUE, ERR_NONE, "shift", "shift left by n bits (right if negative)"}, + {3, A_VALUE, ERR_NONE, "round", "round to given number of decimal places"}, + {3, A_VALUE, ERR_NONE, "bround", "round to given number of binary places"}, + {3, A_VALUE, ERR_NONE, "root", "root of value within given error"}, + {3, A_VALUE, ERR_NONE, "sqrt", "square root within given error"}, + {2, A_VALUE, ERR_NONE, "or", "bitwise or"}, + {2, A_VALUE, ERR_NONE, "and", "bitwise and"}, {1, A_VALUE, ERR_NONE, "not", "logical not"}, - {1, A_VALUE, ERR_NONE, "fact", "factorial or postfix !"}, - {1, A_VALUE, ERR_VALUE, "min", "value for min(...)"}, - {1, A_VALUE, ERR_VALUE, "max", "value for max(...)"}, - {1, A_VALUE, ERR_VALUE, "sum", "value for sum(...)"}, + {1, A_VALUE, ERR_NONE, "fact", "factorial or postfix !"}, + {1, A_VALUE, ERR_VALUE, "min", "value for min(...)"}, + {1, A_VALUE, ERR_VALUE, "max", "value for max(...)"}, + {1, A_VALUE, ERR_VALUE, "sum", "value for sum(...)"}, {2, A_UNDEF, ERR_ASSIGN, "assign", "assign, defaults to a = b"}, {2, A_VALUE, ERR_NONE, "xor", "value for binary ~"}, - {1, A_VALUE, ERR_NONE, "comp", "value for unary ~"}, - {1, A_VALUE, ERR_NONE, "content", "unary hash op"}, - {2, A_VALUE, ERR_NONE, "hashop", "binary hash op"}, + {1, A_VALUE, ERR_NONE, "comp", "value for unary ~"}, + {1, A_VALUE, ERR_NONE, "content", "unary hash op"}, + {2, A_VALUE, ERR_NONE, "hashop", "binary hash op"}, {1, A_VALUE, ERR_NONE, "backslash", "unary backslash op"}, - {2, A_VALUE, ERR_NONE, "setminus", "binary backslash op"}, - {1, A_VALUE, ERR_NONE, "plus", "unary + op"}, + {2, A_VALUE, ERR_NONE, "setminus", "binary backslash op"}, + {1, A_VALUE, ERR_NONE, "plus", "unary + op"}, {0, 0, 0, NULL} }; @@ -135,7 +135,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) { FUNC *fp; /* function to call */ static OBJECTACTIONS *oap; /* object to call for */ - struct objectinfo *oip; /* information about action */ + struct objectinfo *oip; /* information about action */ long index; /* index of function (negative if undefined) */ VALUE val; /* return value */ VALUE tmp; /* temp value */ @@ -150,11 +150,11 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) /*NOTREACHED*/ } oip = &objectinfo[action]; - if (v1->v_type == V_OBJ) + if (v1->v_type == V_OBJ) { oap = v1->v_obj->o_actions; - else if (v2->v_type == V_OBJ) + } else if (v2->v_type == V_OBJ) { oap = v2->v_obj->o_actions; - else { + } else { math_error("Object routine called with non-object"); /*NOTREACHED*/ } @@ -287,7 +287,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) /* * Routine called to clear the cache of known undefined functions for - * the objects. This changes negative indices back into positive ones + * the objects. This changes negative indices back into positive ones * so that they will all be checked for existence again. */ void @@ -495,7 +495,7 @@ defineobject(char *name, int indices[], int count) if (hp->h_count >= maxobjcount) { if (maxobjcount == 0) { newobjects = (OBJECTACTIONS **) malloc( - OBJALLOC * sizeof(OBJECTACTIONS *)); + OBJALLOC * sizeof(OBJECTACTIONS *)); maxobjcount = OBJALLOC; } else { maxobjcount += OBJALLOC; @@ -597,7 +597,7 @@ objtypename(unsigned long index) /* * Return the value table offset to be used for an object element name. * This converts the element index from the element table into an offset - * into the object value array. Returns -1 if the element index is unknown. + * into the object value array. Returns -1 if the element index is unknown. */ int objoffset(OBJECT *op, long index) diff --git a/opcodes.c b/opcodes.c index 19ce30d..7d3a97e 100644 --- a/opcodes.c +++ b/opcodes.c @@ -24,7 +24,7 @@ #include "block.h" #include "string.h" -#define QUICKLOCALS 20 /* local vars to handle quickly */ +#define QUICKLOCALS 20 /* local vars to handle quickly */ static VALUE stackarray[MAXSTACK]; /* storage for stack */ @@ -65,7 +65,7 @@ static void o_getvalue(void); #define OPLOC 8 /* opcode needs local variable pointer (with one arg) */ #define OPSTR 9 /* opcode has a string constant arg */ #define OPARG 10 /* opcode is given number of arguments */ -#define OPSTI 11 /* opcode is static initialization */ +#define OPSTI 11 /* opcode is static initialization */ /* @@ -518,7 +518,7 @@ o_indexaddr(FUNC *fp, long dim, long writeflag) vp = associndex(val->v_assoc, flag, dim, indices); break; case V_NBLOCK: - case V_BLOCK: + case V_BLOCK: if (val->v_type == V_BLOCK) blk = val->v_block; else @@ -1441,8 +1441,7 @@ o_abs(void) if (v2->v_type == V_ADDR) v2 = v2->v_addr; if ((v1->v_type != V_NUM) || (v2->v_type != V_NUM) || - !qispos(v2->v_num)) - { + !qispos(v2->v_num)) { absvalue(v1, v2, &tmp); freevalue(stack--); freevalue(stack); @@ -1600,11 +1599,11 @@ o_bit (void) } freevalue(stack--); freevalue(stack); - if (r > 1) + if (r > 1) { *stack = error_value(E_BIT1); - else if (r < 0) + } else if (r < 0) { stack->v_type = V_NULL; - else { + } else { stack->v_type = V_NUM; stack->v_num = itoq(r); } @@ -2114,14 +2113,14 @@ o_isdefined(void) /*NOTREACHED*/ } r = 0; - index = getbuiltinfunc(vp->v_str->s_str); - if (index >= 0) { - r = 1; - } else { - index = getuserfunc(vp->v_str->s_str); - if (index >= 0) - r = 2; - } + index = getbuiltinfunc(vp->v_str->s_str); + if (index >= 0) { + r = 1; + } else { + index = getuserfunc(vp->v_str->s_str); + if (index >= 0) + r = 2; + } freevalue(stack); stack->v_num = itoq(r); stack->v_type = V_NUM; @@ -2144,7 +2143,7 @@ o_isobjtype(void) } index = checkobject(vp->v_str->s_str); freevalue(stack); - stack->v_num = itoq(index >= 0); + stack->v_num = itoq(index >= 0); stack->v_type = V_NUM; stack->v_subtype = V_NOSUBTYPE; } @@ -2796,7 +2795,7 @@ o_le(void) stack->v_type = V_NUM; stack->v_subtype = V_NOSUBTYPE; if (tmp.v_type == V_NUM) { - stack->v_num = !qispos(tmp.v_num) ? qlink(&_qone_): + stack->v_num = !qispos(tmp.v_num) ? qlink(&_qone_): qlink(&_qzero_); } else if (tmp.v_type == V_COM) { stack->v_num = qlink(&_qzero_); @@ -2825,7 +2824,7 @@ o_ge(void) stack->v_type = V_NUM; stack->v_subtype = V_NOSUBTYPE; if (tmp.v_type == V_NUM) { - stack->v_num = !qisneg(tmp.v_num) ? qlink(&_qone_): + stack->v_num = !qisneg(tmp.v_num) ? qlink(&_qone_): qlink(&_qzero_); } else if (tmp.v_type == V_COM) { stack->v_num = qlink(&_qzero_); @@ -2854,7 +2853,7 @@ o_lt(void) stack->v_type = V_NUM; stack->v_subtype = V_NOSUBTYPE; if (tmp.v_type == V_NUM) { - stack->v_num = qisneg(tmp.v_num) ? qlink(&_qone_): + stack->v_num = qisneg(tmp.v_num) ? qlink(&_qone_): qlink(&_qzero_); } else if (tmp.v_type == V_COM) { stack->v_num = qlink(&_qzero_); @@ -3486,127 +3485,127 @@ showsizes(void) * Information about each opcode. */ static struct opcode opcodes[MAX_OPCODE+1] = { - {o_nop, OPNUL, "NOP"}, /* no operation */ - {o_localaddr, OPLOC, "LOCALADDR"}, /* address of local variable */ - {o_globaladdr, OPGLB, "GLOBALADDR"}, /* address of global variable */ - {o_paramaddr, OPPAR, "PARAMADDR"}, /* address of paramater variable */ - {o_localvalue, OPLOC, "LOCALVALUE"}, /* value of local variable */ - {o_globalvalue, OPGLB, "GLOBALVALUE"}, /* value of global variable */ - {o_paramvalue, OPPAR, "PARAMVALUE"}, /* value of paramater variable */ - {o_number, OPONE, "NUMBER"}, /* constant real numeric value */ - {o_indexaddr, OPTWO, "INDEXADDR"}, /* array index address */ - {o_printresult, OPNUL, "PRINTRESULT"}, /* print result of top-level expression */ - {o_assign, OPNUL, "ASSIGN"}, /* assign value to variable */ - {o_add, OPNUL, "ADD"}, /* add top two values */ - {o_sub, OPNUL, "SUB"}, /* subtract top two values */ - {o_mul, OPNUL, "MUL"}, /* multiply top two values */ - {o_div, OPNUL, "DIV"}, /* divide top two values */ - {o_mod, OPNUL, "MOD"}, /* take mod of top two values */ - {o_save, OPNUL, "SAVE"}, /* save value for later use */ - {o_negate, OPNUL, "NEGATE"}, /* negate top value */ - {o_invert, OPNUL, "INVERT"}, /* invert top value */ - {o_int, OPNUL, "INT"}, /* take integer part */ - {o_frac, OPNUL, "FRAC"}, /* take fraction part */ - {o_numerator, OPNUL, "NUMERATOR"}, /* take numerator */ - {o_denominator, OPNUL, "DENOMINATOR"}, /* take denominator */ - {o_duplicate, OPNUL, "DUPLICATE"}, /* duplicate top value */ - {o_pop, OPNUL, "POP"}, /* pop top value */ - {o_return, OPRET, "RETURN"}, /* return value of function */ - {o_jumpz, OPJMP, "JUMPZ"}, /* jump if value zero */ - {o_jumpnz, OPJMP, "JUMPNZ"}, /* jump if value nonzero */ - {o_jump, OPJMP, "JUMP"}, /* jump unconditionally */ - {o_usercall, OPTWO, "USERCALL"}, /* call a user function */ - {o_getvalue, OPNUL, "GETVALUE"}, /* convert address to value */ - {o_eq, OPNUL, "EQ"}, /* test elements for equality */ - {o_ne, OPNUL, "NE"}, /* test elements for inequality */ - {o_le, OPNUL, "LE"}, /* test elements for <= */ - {o_ge, OPNUL, "GE"}, /* test elements for >= */ - {o_lt, OPNUL, "LT"}, /* test elements for < */ - {o_gt, OPNUL, "GT"}, /* test elements for > */ - {o_preinc, OPNUL, "PREINC"}, /* add one to variable (++x) */ - {o_predec, OPNUL, "PREDEC"}, /* subtract one from variable (--x) */ - {o_postinc, OPNUL, "POSTINC"}, /* add one to variable (x++) */ - {o_postdec, OPNUL, "POSTDEC"}, /* subtract one from variable (x--) */ - {o_debug, OPONE, "DEBUG"}, /* debugging point */ - {o_print, OPONE, "PRINT"}, /* print value */ - {o_assignpop, OPNUL, "ASSIGNPOP"}, /* assign to variable and pop it */ - {o_zero, OPNUL, "ZERO"}, /* put zero on the stack */ - {o_one, OPNUL, "ONE"}, /* put one on the stack */ - {o_printeol, OPNUL, "PRINTEOL"}, /* print end of line */ - {o_printspace, OPNUL, "PRINTSPACE"}, /* print a space */ - {o_printstring, OPONE, "PRINTSTR"}, /* print constant string */ - {o_dupvalue, OPNUL, "DUPVALUE"}, /* duplicate value of top value */ - {o_oldvalue, OPNUL, "OLDVALUE"}, /* old value from previous calc */ - {o_quo, OPNUL, "QUO"}, /* integer quotient of top values */ - {o_power, OPNUL, "POWER"}, /* value raised to a power */ - {o_quit, OPONE, "QUIT"}, /* quit program */ - {o_call, OPTWO, "CALL"}, /* call built-in routine */ - {o_getepsilon, OPNUL, "GETEPSILON"}, /* get allowed error for calculations */ - {o_and, OPNUL, "AND"}, /* arithmetic and or top two values */ - {o_or, OPNUL, "OR"}, /* arithmetic or of top two values */ - {o_not, OPNUL, "NOT"}, /* logical not or top value */ - {o_abs, OPNUL, "ABS"}, /* absolute value of top value */ - {o_sgn, OPNUL, "SGN"}, /* sign of number */ - {o_isint, OPNUL, "ISINT"}, /* whether number is an integer */ - {o_condorjump, OPJMP, "CONDORJUMP"}, /* conditional or jump */ - {o_condandjump, OPJMP, "CONDANDJUMP"}, /* conditional and jump */ - {o_square, OPNUL, "SQUARE"}, /* square top value */ - {o_string, OPONE, "STRING"}, /* string constant value */ - {o_isnum, OPNUL, "ISNUM"}, /* whether value is a number */ - {o_undef, OPNUL, "UNDEF"}, /* load undefined value on stack */ - {o_isnull, OPNUL, "ISNULL"}, /* whether value is the null value */ - {o_argvalue, OPARG, "ARGVALUE"}, /* load value of arg (parameter) n */ - {o_matcreate, OPONE, "MATCREATE"}, /* create matrix */ - {o_ismat, OPNUL, "ISMAT"}, /* whether value is a matrix */ - {o_isstr, OPNUL, "ISSTR"}, /* whether value is a string */ - {o_getconfig, OPNUL, "GETCONFIG"}, /* get value of configuration parameter */ - {o_leftshift, OPNUL, "LEFTSHIFT"}, /* left shift of integer */ - {o_rightshift, OPNUL, "RIGHTSHIFT"}, /* right shift of integer */ - {o_casejump, OPJMP, "CASEJUMP"}, /* test case and jump if not matched */ - {o_isodd, OPNUL, "ISODD"}, /* whether value is odd integer */ - {o_iseven, OPNUL, "ISEVEN"}, /* whether value is even integer */ - {o_fiaddr, OPNUL, "FIADDR"}, /* 'fast index' matrix address */ - {o_fivalue, OPNUL, "FIVALUE"}, /* 'fast index' matrix value */ - {o_isreal, OPNUL, "ISREAL"}, /* whether value is real number */ - {o_imaginary, OPONE, "IMAGINARY"}, /* constant imaginary numeric value */ - {o_re, OPNUL, "RE"}, /* real part of complex number */ - {o_im, OPNUL, "IM"}, /* imaginary part of complex number */ - {o_conjugate, OPNUL, "CONJUGATE"}, /* complex conjugate */ - {o_objcreate, OPONE, "OBJCREATE"}, /* create object */ - {o_isobj, OPNUL, "ISOBJ"}, /* whether value is an object */ - {o_norm, OPNUL, "NORM"}, /* norm of value (square of abs) */ - {o_elemaddr, OPONE, "ELEMADDR"}, /* address of element of object */ - {o_elemvalue, OPONE, "ELEMVALUE"}, /* value of element of object */ - {o_istype, OPNUL, "ISTYPE"}, /* whether types are the same */ - {o_scale, OPNUL, "SCALE"}, /* scale value by a power of two */ + {o_nop, OPNUL, "NOP"}, /* no operation */ + {o_localaddr, OPLOC, "LOCALADDR"}, /* address of local variable */ + {o_globaladdr, OPGLB, "GLOBALADDR"}, /* address of global variable */ + {o_paramaddr, OPPAR, "PARAMADDR"}, /* address of paramater variable */ + {o_localvalue, OPLOC, "LOCALVALUE"}, /* value of local variable */ + {o_globalvalue, OPGLB, "GLOBALVALUE"}, /* value of global variable */ + {o_paramvalue, OPPAR, "PARAMVALUE"}, /* value of paramater variable */ + {o_number, OPONE, "NUMBER"}, /* constant real numeric value */ + {o_indexaddr, OPTWO, "INDEXADDR"}, /* array index address */ + {o_printresult, OPNUL, "PRINTRESULT"}, /* print result of top-level expression */ + {o_assign, OPNUL, "ASSIGN"}, /* assign value to variable */ + {o_add, OPNUL, "ADD"}, /* add top two values */ + {o_sub, OPNUL, "SUB"}, /* subtract top two values */ + {o_mul, OPNUL, "MUL"}, /* multiply top two values */ + {o_div, OPNUL, "DIV"}, /* divide top two values */ + {o_mod, OPNUL, "MOD"}, /* take mod of top two values */ + {o_save, OPNUL, "SAVE"}, /* save value for later use */ + {o_negate, OPNUL, "NEGATE"}, /* negate top value */ + {o_invert, OPNUL, "INVERT"}, /* invert top value */ + {o_int, OPNUL, "INT"}, /* take integer part */ + {o_frac, OPNUL, "FRAC"}, /* take fraction part */ + {o_numerator, OPNUL, "NUMERATOR"}, /* take numerator */ + {o_denominator, OPNUL, "DENOMINATOR"}, /* take denominator */ + {o_duplicate, OPNUL, "DUPLICATE"}, /* duplicate top value */ + {o_pop, OPNUL, "POP"}, /* pop top value */ + {o_return, OPRET, "RETURN"}, /* return value of function */ + {o_jumpz, OPJMP, "JUMPZ"}, /* jump if value zero */ + {o_jumpnz, OPJMP, "JUMPNZ"}, /* jump if value nonzero */ + {o_jump, OPJMP, "JUMP"}, /* jump unconditionally */ + {o_usercall, OPTWO, "USERCALL"}, /* call a user function */ + {o_getvalue, OPNUL, "GETVALUE"}, /* convert address to value */ + {o_eq, OPNUL, "EQ"}, /* test elements for equality */ + {o_ne, OPNUL, "NE"}, /* test elements for inequality */ + {o_le, OPNUL, "LE"}, /* test elements for <= */ + {o_ge, OPNUL, "GE"}, /* test elements for >= */ + {o_lt, OPNUL, "LT"}, /* test elements for < */ + {o_gt, OPNUL, "GT"}, /* test elements for > */ + {o_preinc, OPNUL, "PREINC"}, /* add one to variable (++x) */ + {o_predec, OPNUL, "PREDEC"}, /* subtract one from variable (--x) */ + {o_postinc, OPNUL, "POSTINC"}, /* add one to variable (x++) */ + {o_postdec, OPNUL, "POSTDEC"}, /* subtract one from variable (x--) */ + {o_debug, OPONE, "DEBUG"}, /* debugging point */ + {o_print, OPONE, "PRINT"}, /* print value */ + {o_assignpop, OPNUL, "ASSIGNPOP"}, /* assign to variable and pop it */ + {o_zero, OPNUL, "ZERO"}, /* put zero on the stack */ + {o_one, OPNUL, "ONE"}, /* put one on the stack */ + {o_printeol, OPNUL, "PRINTEOL"}, /* print end of line */ + {o_printspace, OPNUL, "PRINTSPACE"}, /* print a space */ + {o_printstring, OPONE, "PRINTSTR"}, /* print constant string */ + {o_dupvalue, OPNUL, "DUPVALUE"}, /* duplicate value of top value */ + {o_oldvalue, OPNUL, "OLDVALUE"}, /* old value from previous calc */ + {o_quo, OPNUL, "QUO"}, /* integer quotient of top values */ + {o_power, OPNUL, "POWER"}, /* value raised to a power */ + {o_quit, OPONE, "QUIT"}, /* quit program */ + {o_call, OPTWO, "CALL"}, /* call built-in routine */ + {o_getepsilon, OPNUL, "GETEPSILON"}, /* get allowed error for calculations */ + {o_and, OPNUL, "AND"}, /* arithmetic and or top two values */ + {o_or, OPNUL, "OR"}, /* arithmetic or of top two values */ + {o_not, OPNUL, "NOT"}, /* logical not or top value */ + {o_abs, OPNUL, "ABS"}, /* absolute value of top value */ + {o_sgn, OPNUL, "SGN"}, /* sign of number */ + {o_isint, OPNUL, "ISINT"}, /* whether number is an integer */ + {o_condorjump, OPJMP, "CONDORJUMP"}, /* conditional or jump */ + {o_condandjump, OPJMP, "CONDANDJUMP"}, /* conditional and jump */ + {o_square, OPNUL, "SQUARE"}, /* square top value */ + {o_string, OPONE, "STRING"}, /* string constant value */ + {o_isnum, OPNUL, "ISNUM"}, /* whether value is a number */ + {o_undef, OPNUL, "UNDEF"}, /* load undefined value on stack */ + {o_isnull, OPNUL, "ISNULL"}, /* whether value is the null value */ + {o_argvalue, OPARG, "ARGVALUE"}, /* load value of arg (parameter) n */ + {o_matcreate, OPONE, "MATCREATE"}, /* create matrix */ + {o_ismat, OPNUL, "ISMAT"}, /* whether value is a matrix */ + {o_isstr, OPNUL, "ISSTR"}, /* whether value is a string */ + {o_getconfig, OPNUL, "GETCONFIG"}, /* get value of configuration parameter */ + {o_leftshift, OPNUL, "LEFTSHIFT"}, /* left shift of integer */ + {o_rightshift, OPNUL, "RIGHTSHIFT"}, /* right shift of integer */ + {o_casejump, OPJMP, "CASEJUMP"}, /* test case and jump if not matched */ + {o_isodd, OPNUL, "ISODD"}, /* whether value is odd integer */ + {o_iseven, OPNUL, "ISEVEN"}, /* whether value is even integer */ + {o_fiaddr, OPNUL, "FIADDR"}, /* 'fast index' matrix address */ + {o_fivalue, OPNUL, "FIVALUE"}, /* 'fast index' matrix value */ + {o_isreal, OPNUL, "ISREAL"}, /* whether value is real number */ + {o_imaginary, OPONE, "IMAGINARY"}, /* constant imaginary numeric value */ + {o_re, OPNUL, "RE"}, /* real part of complex number */ + {o_im, OPNUL, "IM"}, /* imaginary part of complex number */ + {o_conjugate, OPNUL, "CONJUGATE"}, /* complex conjugate */ + {o_objcreate, OPONE, "OBJCREATE"}, /* create object */ + {o_isobj, OPNUL, "ISOBJ"}, /* whether value is an object */ + {o_norm, OPNUL, "NORM"}, /* norm of value (square of abs) */ + {o_elemaddr, OPONE, "ELEMADDR"}, /* address of element of object */ + {o_elemvalue, OPONE, "ELEMVALUE"}, /* value of element of object */ + {o_istype, OPNUL, "ISTYPE"}, /* whether types are the same */ + {o_scale, OPNUL, "SCALE"}, /* scale value by a power of two */ {o_islist, OPNUL, "ISLIST"}, /* whether value is a list */ {o_swap, OPNUL, "SWAP"}, /* swap values of two variables */ {o_issimple, OPNUL, "ISSIMPLE"}, /* whether value is simple type */ {o_cmp, OPNUL, "CMP"}, /* compare values returning -1, 0, 1 */ {o_quomod, OPNUL, "QUOMOD"}, /* calculate quotient and remainder */ {o_setconfig, OPNUL, "SETCONFIG"}, /* set configuration parameter */ - {o_setepsilon, OPNUL, "SETEPSILON"}, /* set allowed error for calculations */ - {o_isfile, OPNUL, "ISFILE"}, /* whether value is a file */ - {o_isassoc, OPNUL, "ISASSOC"}, /* whether value is an association */ - {o_nop, OPSTI, "INITSTATIC"}, /* once only code for static init */ + {o_setepsilon, OPNUL, "SETEPSILON"}, /* set allowed error for calculations */ + {o_isfile, OPNUL, "ISFILE"}, /* whether value is a file */ + {o_isassoc, OPNUL, "ISASSOC"}, /* whether value is an association */ + {o_nop, OPSTI, "INITSTATIC"}, /* once only code for static init */ {o_eleminit, OPONE, "ELEMINIT"}, /* assign element of matrix or object */ - {o_isconfig, OPNUL, "ISCONFIG"}, /* whether value is a configuration state */ - {o_ishash, OPNUL, "ISHASH"}, /* whether value is a hash state */ - {o_isrand, OPNUL, "ISRAND"}, /* whether value is a rand element */ - {o_israndom, OPNUL, "ISRANDOM"}, /* whether value is a random element */ + {o_isconfig, OPNUL, "ISCONFIG"}, /* whether value is a configuration state */ + {o_ishash, OPNUL, "ISHASH"}, /* whether value is a hash state */ + {o_isrand, OPNUL, "ISRAND"}, /* whether value is a rand element */ + {o_israndom, OPNUL, "ISRANDOM"}, /* whether value is a random element */ {o_show, OPONE, "SHOW"}, /* show current state data */ {o_initfill, OPNUL, "INITFILL"}, /* initially fill matrix */ {o_assignback, OPNUL, "ASSIGNBACK"}, /* assign in reverse order */ - {o_test, OPNUL, "TEST"}, /* test that value is "nonzero" */ + {o_test, OPNUL, "TEST"}, /* test that value is "nonzero" */ {o_isdefined, OPNUL, "ISDEFINED"}, /* whether a string names a function */ {o_isobjtype, OPNUL, "ISOBJTYPE"}, /* whether a string names an object type */ {o_isblock, OPNUL, "ISBLK"}, /* whether value is a block */ {o_ptr, OPNUL, "PTR"}, /* octet pointer */ {o_deref, OPNUL, "DEREF"}, /* dereference an octet pointer */ - {o_isoctet, OPNUL, "ISOCTET"}, /* whether a value is an octet */ - {o_isptr, OPNUL, "ISPTR"}, /* whether a value is a pointer */ + {o_isoctet, OPNUL, "ISOCTET"}, /* whether a value is an octet */ + {o_isptr, OPNUL, "ISPTR"}, /* whether a value is a pointer */ {o_setsaveval, OPNUL, "SAVEVAL"}, /* enable or disable saving */ - {o_links, OPNUL, "LINKS"}, /* links to number or string */ + {o_links, OPNUL, "LINKS"}, /* links to number or string */ {o_bit, OPNUL, "BIT"}, /* whether bit is set */ {o_comp, OPNUL, "COMP"}, /* complement value */ {o_xor, OPNUL, "XOR"}, /* xor (~) of values */ @@ -3707,7 +3706,7 @@ calculate(FUNC *fp, int argcount) switch (op->o_type) { case OPNUL: /* no extra arguments */ /* ignore Saber-C warning #65 - has 1 arg, expected 0 */ - /* ok to ignore in proc calculate */ + /* ok to ignore in proc calculate */ (*op->o_func)(fp); break; @@ -3732,7 +3731,7 @@ calculate(FUNC *fp, int argcount) case OPGLB: /* global symbol reference (pointer arg) */ /* ignore Saber-C warning #68 - benign type mismatch */ - /* ok to ignore in proc calculate */ + /* ok to ignore in proc calculate */ (*op->o_func)(fp, *((char **) &fp->f_opcodes[pc])); pc += PTR_SIZE; break; @@ -3937,6 +3936,3 @@ calclevel(void) { return calc_depth - 1; } - - -/* END CODE */ diff --git a/opcodes.h b/opcodes.h index 883a9f3..d44aa39 100644 --- a/opcodes.h +++ b/opcodes.h @@ -6,7 +6,7 @@ #if !defined(__OPCODES_H__) -#define __OPCODES_H__ +#define __OPCODES_H__ /* @@ -21,7 +21,7 @@ #define OP_PARAMVALUE 6L /* load value of paramater variable */ #define OP_NUMBER 7L /* load constant real numeric value */ #define OP_INDEXADDR 8L /* load array index address */ -#define OP_PRINTRESULT 9L /* print result of top-level expression */ +#define OP_PRINTRESULT 9L /* print result of top-level expression */ #define OP_ASSIGN 10L /* assign value to variable */ #define OP_ADD 11L /* add top two values */ #define OP_SUB 12L /* subtract top two values */ @@ -105,17 +105,17 @@ #define OP_ELEMVALUE 90L /* value of element of object */ #define OP_ISTYPE 91L /* whether two values are the same type */ #define OP_SCALE 92L /* scale value by a power of two */ -#define OP_ISLIST 93L /* whether value is a list */ -#define OP_SWAP 94L /* swap values of two variables */ -#define OP_ISSIMPLE 95L /* whether value is a simple type */ -#define OP_CMP 96L /* compare values returning -1, 0, or 1 */ -#define OP_QUOMOD 97L /* calculate quotient and remainder */ -#define OP_SETCONFIG 98L /* set configuration parameter */ -#define OP_SETEPSILON 99L /* set allowed error for calculations */ -#define OP_ISFILE 100L /* whether value is a file */ -#define OP_ISASSOC 101L /* whether value is an association */ -#define OP_INITSTATIC 102L /* once only code for static initialization */ -#define OP_ELEMINIT 103L /* assign element of matrix or object */ +#define OP_ISLIST 93L /* whether value is a list */ +#define OP_SWAP 94L /* swap values of two variables */ +#define OP_ISSIMPLE 95L /* whether value is a simple type */ +#define OP_CMP 96L /* compare values returning -1, 0, or 1 */ +#define OP_QUOMOD 97L /* calculate quotient and remainder */ +#define OP_SETCONFIG 98L /* set configuration parameter */ +#define OP_SETEPSILON 99L /* set allowed error for calculations */ +#define OP_ISFILE 100L /* whether value is a file */ +#define OP_ISASSOC 101L /* whether value is an association */ +#define OP_INITSTATIC 102L /* once only code for static initialization */ +#define OP_ELEMINIT 103L /* assign element of matrix or object */ #define OP_ISCONFIG 104L /* whether value is a configuration state */ #define OP_ISHASH 105L /* whether value is a hash state */ #define OP_ISRAND 106L /* whether value is additive 55 random state */ diff --git a/pix.c b/pix.c index d3fa237..068bc74 100644 --- a/pix.c +++ b/pix.c @@ -30,7 +30,7 @@ /* * pi10b - number of primes <= 2^18 in multiples of 2^10 * - * pi10b[x] == pi(x*1024) for 0 <= x <= 256 + * pi10b[x] == pi(x*1024) for 0 <= x <= 256 */ CONST unsigned short pi10b[(MAX_PI10B/1024)+1+1] = { 0, 172, 309, 439, 564, 685, 801, 916, 1028, 1142, 1254, 1362, 1469, 1580, @@ -62,7 +62,7 @@ CONST unsigned short pi10b[(MAX_PI10B/1024)+1+1] = { * pi18b - primes found in a given 2^18 interval * * i i*16 + j*2 + 1 is prime - * 0 ==> i*16 + j*2 + 1 is not prime + * pr_map[i] & (1< i*16 + j*2 + 1 is prime + * 0 ==> i*16 + j*2 + 1 is not prime * * This table is useful to quickly determining if a 16 bit odd number * is prime. Use the prime[] array to quickly walk thru the 16 bit diff --git a/prime.h b/prime.h index 2c8f5c4..75647de 100644 --- a/prime.h +++ b/prime.h @@ -32,13 +32,13 @@ #define MAX_MAP_PRIME ((FULL)65521) /* (2^16-15) larest prime in prmap */ -#define MAX_MAP_VAL ((FULL)65535) /* (2^16-1) larest bit in pr_map */ -#define MAX_SM_PRIME ((FULL)0xfffffffb) /* (2^32-5) larest 32 bit prime */ -#define MAX_SM_VAL ((FULL)0xffffffff) /* (2^32-1) larest 32 bit value */ +#define MAX_MAP_VAL ((FULL)65535) /* (2^16-1) larest bit in pr_map */ +#define MAX_SM_PRIME ((FULL)0xfffffffb) /* (2^32-5) larest 32 bit prime */ +#define MAX_SM_VAL ((FULL)0xffffffff) /* (2^32-1) larest 32 bit value */ #define MAP_POPCNT 6541 /* number of odd primes in pr_map */ -#define NXT_MAP_PRIME ((FULL)65537) /* (2^16+1) smallest prime > 2^16 */ +#define NXT_MAP_PRIME ((FULL)65537) /* (2^16+1) smallest prime > 2^16 */ #define PIX_32B ((FULL)203280221) /* pix(2^32-1) - max pix() value */ @@ -56,8 +56,8 @@ /* * If n is odd and 1 <= n <= MAX_MAP_VAL, then: * - * pr_map_bit(n) != 0 ==> n is prime - * pr_map_bit(n) == 0 ==> n is NOT prime + * pr_map_bit(n) != 0 ==> n is prime + * pr_map_bit(n) == 0 ==> n is NOT prime */ #define pr_map_bit(n) (pr_map[(HALF)(n)>>4] & (1 << (((HALF)(n)>>1)&0x7))) diff --git a/qfunc.c b/qfunc.c index 533e888..8fff4d3 100644 --- a/qfunc.c +++ b/qfunc.c @@ -192,7 +192,7 @@ qpowi(NUMBER *q1, NUMBER *q2) return qlink(q1); } /* - * Not a trivial case. Do the real work. + * Not a trivial case. Do the real work. */ r = qalloc(); if (!zisunit(num)) @@ -211,7 +211,7 @@ qpowi(NUMBER *q1, NUMBER *q2) /* * Given the legs of a right triangle, compute its hypothenuse within - * the specified error. This is sqrt(a^2 + b^2). + * the specified error. This is sqrt(a^2 + b^2). */ NUMBER * qhypot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) @@ -303,35 +303,10 @@ qsqrt(NUMBER *q1, NUMBER *epsilon, long rnd) if (qiszero(q1)) return qlink(&_qzero_); sign = (rnd & 64) != 0; -#if 0 - if (qiszero(epsilon)) { - s1 = zesqrt(q1->num, &tmp1); - if (s1) { - if (qisint(q1)) { - r = qalloc(); - tmp1.sign = sign; - r->num = tmp1; - return r; - } - s2 = zesqrt(q1->den, &tmp2); - if (s2) { - r = qalloc(); - tmp1.sign = sign; - r->num = tmp1; - r->den = tmp2; - return r; - } - zfree(tmp2); - } - zfree(tmp1); - return qlink(&_qzero_); - } -#else if (qiszero(epsilon)) { math_error("Zero epsilon for qsqrt"); /*NOTREACHED*/ } -#endif etemp = *epsilon; etemp.num.sign = 0; @@ -384,8 +359,7 @@ qsqrt(NUMBER *q1, NUMBER *epsilon, long rnd) zshift(tmp1, -1, &mul); up = (*tmp1.v & 1) ? s1 + s2 : -1; zfree(tmp1); - } - else { + } else { s1 = zquo(tmp2, divisor, &quo, 0); zfree(tmp2); s2 = zsqrt(quo, &mul, 0); @@ -494,7 +468,7 @@ qiroot(NUMBER *q1, NUMBER *q2) /* * Return the greatest integer of the base 2 log of a number. - * This is the number such that 1 <= x / log2(x) < 2. + * This is the number such that 1 <= x / log2(x) < 2. * Examples: qilog2(8) = 3, qilog2(1.3) = 1, qilog2(1/7) = -3. * * given: @@ -535,7 +509,7 @@ qilog2(NUMBER *q) /* * Return the greatest integer of the base 10 log of a number. - * This is the number such that 1 <= x / log10(x) < 10. + * This is the number such that 1 <= x / log10(x) < 10. * Examples: qilog10(100) = 2, qilog10(12.3) = 1, qilog10(.023) = -2. * * given: @@ -568,9 +542,9 @@ qilog10(NUMBER *q) } /* * Here if the number is less than one. - * If the number is the inverse of a power of ten, then the obvious answer - * will be off by one. Subtracting one if the number is the inverse of an - * integer will fix it. + * If the number is the inverse of a power of ten, then the + * obvious answer will be off by one. Subtracting one if the + * number is the inverse of an integer will fix it. */ if (zisunit(tmp1)) zsub(q->den, _one_, &tmp2); @@ -646,7 +620,7 @@ qdigits(NUMBER *q) /* * Return the digit at the specified decimal place of a number represented * in floating point. The lowest digit of the integral part of a number - * is the zeroth decimal place. Negative decimal places indicate digits + * is the zeroth decimal place. Negative decimal places indicate digits * to the right of the decimal point. Examples: qdigit(1234.5678, 1) = 3, * qdigit(1234.5678, -3) = 7. */ @@ -1028,7 +1002,7 @@ qround(NUMBER *q, long places, long rnd) } /* - * Approximate a number to nearest multiple of a given number. Whether + * Approximate a number to nearest multiple of a given number. Whether * rounding is down, up, etc. is determined by rnd. */ NUMBER * @@ -1095,8 +1069,7 @@ qcfappr(NUMBER *q, NUMBER *epsilon, long rnd) zfree(denbnd); return qlink(q); } - } - else { + } else { if (rnd & 16) epsilon1 = qscale(epsilon, -1); else @@ -1107,9 +1080,9 @@ qcfappr(NUMBER *q, NUMBER *epsilon, long rnd) zfree(tmp1); qfree(epsilon1); } - if (rnd & 16 && !zistwo(q->den)) + if (rnd & 16 && !zistwo(q->den)) { s = 0; - else { + } else { s = esign ? -1 : 1; if (rnd & 1) s = -s; @@ -1164,8 +1137,7 @@ qcfappr(NUMBER *q, NUMBER *epsilon, long rnd) zfree(tmp1); } zfree(denbnd); - } - else { + } else { if (s < 0) { zfree(tmp1); zfree(tmp2); @@ -1251,9 +1223,9 @@ qcfsim(NUMBER *q, long rnd) if (qiszero(q) && rnd & 26) return qlink(&_qzero_); - if (rnd & 24) + if (rnd & 24) { s = q->num.sign; - else { + } else { s = rnd & 1; if (rnd & 2) s ^= q->num.sign; @@ -1558,5 +1530,3 @@ qprimetest(NUMBER *q1, NUMBER *q2, NUMBER *q3) } return zprimetest(q1->num, ztoi(q2->num), q3->num); } - -/* END CODE */ diff --git a/qio.c b/qio.c index bd05cae..b8b502e 100644 --- a/qio.c +++ b/qio.c @@ -11,15 +11,10 @@ #include "args.h" -#define PUTCHAR(ch) math_chr(ch) -#define PUTSTR(str) math_str(str) -#define PRINTF1(fmt, a1) math_fmt(fmt, a1) -#define PRINTF2(fmt, a1, a2) math_fmt(fmt, a1, a2) - -#if 0 -static long etoalen; -static char *etoabuf = NULL; -#endif +#define PUTCHAR(ch) math_chr(ch) +#define PUTSTR(str) math_str(str) +#define PRINTF1(fmt, a1) math_fmt(fmt, a1) +#define PRINTF2(fmt, a1, a2) math_fmt(fmt, a1, a2) static long scalefactor; static ZVALUE scalenumber = { 0, 0, 0 }; @@ -152,72 +147,6 @@ qprintf(char *fmt, ...) } -#if 0 -/* - * Read a number from the specified FILE stream (NULL means stdin). - * The number can be an integer, a fraction, a real number, an - * exponential number, or a hex, octal or binary number. Leading blanks - * are skipped. Illegal numbers return NULL. Unrecognized characters - * remain to be read on the line. - * q = qreadval(fp); - * - * given: - * fp file stream to read from (or NULL) - */ -NUMBER * -qreadval(FILE *fp) -{ - NUMBER *r; /* returned number */ - char *cp; /* current buffer location */ - long savecc; /* characters saved in buffer */ - long scancc; /* characters parsed correctly */ - int ch; /* current character */ - - if (fp == NULL) - fp = stdin; - if (etoabuf == NULL) { - etoabuf = (char *)malloc(OUTBUFSIZE + 2); - if (etoabuf == NULL) - return NULL; - etoalen = OUTBUFSIZE; - } - cp = etoabuf; - ch = fgetc(fp); - while ((ch == ' ') || (ch == '\t')) - ch = fgetc(fp); - savecc = 0; - for (;;) { - if (ch == EOF) - return NULL; - if (savecc >= etoalen) - { - cp = (char *)realloc(etoabuf, etoalen + OUTBUFSIZE + 2); - if (cp == NULL) - return NULL; - etoabuf = cp; - etoalen += OUTBUFSIZE; - cp += savecc; - } - *cp++ = (char)ch; - *cp = '\0'; - scancc = qparse(etoabuf, QPF_SLASH); - if (scancc != ++savecc) - break; - ch = fgetc(fp); - } - ungetc(ch, fp); - if (scancc < 0) - return NULL; - r = str2q(etoabuf); - if (ziszero(r->den)) { - qfree(r); - r = NULL; - } - return r; -} -#endif - - /* * Print a number in the specified output mode. * If MODE_DEFAULT is given, then the default output mode is used. @@ -734,5 +663,3 @@ fitprint(NUMBER *q, long width) PUTCHAR('/'); fitzprint(q->den, dendigits, width2); } - -/* END CODE */ diff --git a/qmath.c b/qmath.c index ad968aa..64a67d0 100644 --- a/qmath.c +++ b/qmath.c @@ -422,7 +422,7 @@ qmul(NUMBER *q1, NUMBER *q2) return qlink(q2); if (qisone(q2)) return qlink(q1); - if (qisint(q1) && qisint(q2)) { /* easy results if integers */ + if (qisint(q1) && qisint(q2)) { /* easy results if integers */ r = qalloc(); zmul(q1->num, q2->num, &r->num); return r; @@ -573,9 +573,9 @@ qquo(NUMBER *q1, NUMBER *q2, long rnd) if (qiszero(q1) || qiszero(q2)) return qlink(&_qzero_); - if (qisint(q1) && qisint(q2)) + if (qisint(q1) && qisint(q2)) { zquo(q1->num, q2->num, &tmp, rnd); - else { + } else { zmul(q1->num, q2->den, &tmp1); zmul(q2->num, q1->den, &tmp2); zquo(tmp1, tmp2, &tmp, rnd); @@ -1072,7 +1072,7 @@ qandnot(NUMBER *q1, NUMBER *q2) } /* - * Return the bitwise "complement" of a number. This is - q -1 if q is an + * Return the bitwise "complement" of a number. This is - q -1 if q is an * integer, - q otherwise. */ NUMBER * @@ -1132,26 +1132,6 @@ qtenpow(long n) } -#if 0 -/* - * Test to see if the specified bit of a number is on (counted from zero). - * Returns TRUE if the bit is set, or FALSE if it is not. - * i = qbittest(q, n); - */ -BOOL -qbittest(NUMBER *q, long n) -{ - int x, y; - - if ((n < 0) || (n >= (q->num.len * BASEB))) - return FALSE; - x = q->num.v[n / BASEB]; - y = (1 << (n % BASEB)); - return ((x & y) != 0); -} -#endif - - /* * Return the precision of a number (usually for examining an epsilon value). * The precision of a number e less than 1 is the positive @@ -1173,23 +1153,6 @@ qprecision(NUMBER *q) } -#if 0 -/* - * Return an integer indicating the sign of a number (-1, 0, or 1). - * i = qtst(q); - */ -FLAG -qtest(NUMBER *q) -{ - if (!ztest(q->num)) - return 0; - if (q->num.sign) - return -1; - return 1; -} -#endif - - /* * Determine whether or not one number exactly divides another one. * Returns TRUE if the first number is an integer multiple of the second one. @@ -1246,19 +1209,19 @@ qrel(NUMBER *q1, NUMBER *q2) /* * Quick check failed, must actually do the full comparison. */ - if (zisunit(q2->den)) + if (zisunit(q2->den)) { z1 = q1->num; - else if (zisone(q1->num)) + } else if (zisone(q1->num)) { z1 = q2->den; - else { + } else { z1f = 1; zmul(q1->num, q2->den, &z1); } - if (zisunit(q1->den)) + if (zisunit(q1->den)) { z2 = q2->num; - else if (zisone(q2->num)) + } else if (zisone(q2->num)) { z2 = q1->den; - else { + } else { z2f = 1; zmul(q2->num, q1->den, &z2); } @@ -1360,7 +1323,7 @@ qcmpi(NUMBER *q, long n) * Number node allocation routines */ -#define NNALLOC 1000 +#define NNALLOC 1000 static NUMBER *freeNum = NULL; @@ -1446,8 +1409,8 @@ shownumbers(void) long i, j, k; long count = 0; - printf("Index Links Digits Value\n"); - printf("----- ----- ------ -----\n"); + printf("Index Links Digits Value\n"); + printf("----- ----- ------ -----\n"); for (i = 0, k = 0; i < INITCONSTCOUNT; i++) { count++; @@ -1470,5 +1433,3 @@ shownumbers(void) } printf("\nNumber: %ld\n", count); } - -/* END CODE */ diff --git a/qmath.h b/qmath.h index d8bae6a..9eb772e 100644 --- a/qmath.h +++ b/qmath.h @@ -8,7 +8,7 @@ #if !defined(__QMATH_H__) -#define __QMATH_H__ +#define __QMATH_H__ #include "zmath.h" @@ -148,17 +148,6 @@ extern void setepsilon(NUMBER *q); extern NUMBER *qbitvalue(long i); extern NUMBER *qtenpow(long i); -#if 0 -extern NUMBER *qmulmod(NUMBER *q1, NUMBER *q2, NUMBER *q3); -extern NUMBER *qsquaremod(NUMBER *q1, NUMBER *q2); -extern NUMBER *qaddmod(NUMBER *q1, NUMBER *q2, NUMBER *q3); -extern NUMBER *qsubmod(NUMBER *q1, NUMBER *q2, NUMBER *q3); -extern NUMBER *qreadval(FILE *fp); -extern NUMBER *qnegmod(NUMBER *q1, NUMBER *q2); -extern BOOL qbittest(NUMBER *q, long i); -extern FLAG qtest(NUMBER *q); -#endif - /* * Transcendental functions. These all take an epsilon argument to diff --git a/qmod.c b/qmod.c index 57060d8..c46c1b0 100644 --- a/qmod.c +++ b/qmod.c @@ -108,8 +108,7 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod) if (qiszero(q2)) { /* zero modulus case */ qq = qlink(&_qzero_); qm = qlink(q1); - } - else if (qisint(q1) && qisint(q2)) { /* integer case */ + } else if (qisint(q1) && qisint(q2)) { /* integer case */ zdiv(q1->num, q2->num, &tmp1, &tmp2, conf->quomod); if (ziszero(tmp1)) { zfree(tmp1); @@ -127,8 +126,7 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod) qm->num = tmp2; } } - } - else { /* fractional case */ + } else { /* fractional case */ zmul(q1->num, q2->den, &tmp1); zmul(q2->num, q1->den, &tmp2); zdiv(tmp1, tmp2, &tmp3, &tmp4, conf->quomod); @@ -160,118 +158,6 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod) } -#if 0 -/* - * Return the product of two integers modulo a third integer. - * The result is in the range 0 to q3 - 1 inclusive. - * q4 = (q1 * q2) mod q3. - */ -NUMBER * -qmulmod(NUMBER *q1, NUMBER *q2, NUMBER *q3) -{ - NUMBER *q; - - if (qisneg(q3) || qiszero(q3)) - math_error("Non-positive modulus"); - if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3)) - math_error("Non-integers for qmulmod"); - if (qiszero(q1) || qiszero(q2) || qisunit(q3)) - return qlink(&_qzero_); - q = qalloc(); - zmulmod(q1->num, q2->num, q3->num, &q->num); - return q; -} - - -/* - * Return the square of an integer modulo another integer. - * The result is in the range 0 to q2 - 1 inclusive. - * q2 = (q1^2) mod q2. - */ -NUMBER * -qsquaremod(NUMBER *q1, NUMBER *q2) -{ - NUMBER *q; - - if (qisneg(q2) || qiszero(q2)) - math_error("Non-positive modulus"); - if (qisfrac(q1) || qisfrac(q2)) - math_error("Non-integers for qsquaremod"); - if (qiszero(q1) || qisunit(q2)) - return qlink(&_qzero_); - if (qisunit(q1)) - return qlink(&_qone_); - q = qalloc(); - zsquaremod(q1->num, q2->num, &q->num); - return q; -} - - -/* - * Return the sum of two integers modulo a third integer. - * The result is in the range 0 to q3 - 1 inclusive. - * q4 = (q1 + q2) mod q3. - */ -NUMBER * -qaddmod(NUMBER *q1, NUMBER *q2, NUMBER *q3) -{ - NUMBER *q; - - if (qisneg(q3) || qiszero(q3)) - math_error("Non-positive modulus"); - if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3)) - math_error("Non-integers for qaddmod"); - q = qalloc(); - zaddmod(q1->num, q2->num, q3->num, &q->num); - return q; -} - - -/* - * Return the difference of two integers modulo a third integer. - * The result is in the range 0 to q3 - 1 inclusive. - * q4 = (q1 - q2) mod q3. - */ -NUMBER * -qsubmod(NUMBER *q1, NUMBER *q2, NUMBER *q3) -{ - NUMBER *q; - - if (qisneg(q3) || qiszero(q3)) - math_error("Non-positive modulus"); - if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3)) - math_error("Non-integers for qsubmod"); - if (q1 == q2) - return qlink(&_qzero_); - q = qalloc(); - zsubmod(q1->num, q2->num, q3->num, &q->num); - return q; -} - - -/* - * Return the negative of an integer modulo another integer. - * The result is in the range 0 to q2 - 1 inclusive. - * q2 = (-q1) mod q2. - */ -NUMBER * -qnegmod(NUMBER *q1, NUMBER *q2) -{ - NUMBER *q; - - if (qisneg(q2) || qiszero(q2)) - math_error("Non-positive modulus"); - if (qisfrac(q1) || qisfrac(q2)) - math_error("Non-integers for qnegmod"); - if (qiszero(q1) || qisunit(q2)) - return qlink(&_qzero_); - q = qalloc(); - znegmod(q1->num, q2->num, &q->num); - return q; -} -#endif - - /* * Return whether or not two integers are congruent modulo a third integer. * Returns TRUE if the numbers are not congruent, and FALSE if they are. @@ -426,7 +312,7 @@ qredcpower(NUMBER *q1, NUMBER *q2, NUMBER *q3) /* * Search for and return the REDC information for the specified number. * The information is cached into a local table so that future calls - * for this information will be quick. If the table fills up, then + * for this information will be quick. If the table fills up, then * the oldest cached entry is reused. * * given: @@ -521,5 +407,3 @@ freeredcdata(void) } } } - -/* END CODE */ diff --git a/qtrans.c b/qtrans.c index 3550d8c..4c50c17 100644 --- a/qtrans.c +++ b/qtrans.c @@ -112,9 +112,9 @@ qsincos(NUMBER *q, long bitnum, NUMBER **vs, NUMBER **vc) if (m > h) { zshift(cossum, -h, &qtmp1->num); zbitvalue(m - h, &qtmp1->den); - } - else + } else { zshift(cossum, - m, &qtmp1->num); + } zfree(cossum); *vc = qtmp1; h = zlowbit(sinsum); @@ -122,9 +122,9 @@ qsincos(NUMBER *q, long bitnum, NUMBER **vs, NUMBER **vc) if (m > h) { zshift(sinsum, -h, &qtmp2->num); zbitvalue(m - h, &qtmp2->den); - } - else + } else { zshift(sinsum, -m, &qtmp2->num); + } zfree(sinsum); *vs = qtmp2; return; @@ -378,8 +378,7 @@ qasin(NUMBER *q, NUMBER *epsilon) epsilon1 = qscale(epsilon, 1L); qtmp2 = qpi(epsilon1); qtmp1 = qscale(qtmp2, -1L); - } - else { + } else { epsilon1 = qscale(epsilon, -2L); qtmp1 = qalloc(); zsquare(q->num, &qtmp1->num); @@ -444,7 +443,7 @@ qacos(NUMBER *q, NUMBER *epsilon) /* * Calculate the arctangent function to the nearest or next to nearest - * multiple of epsilon. Algorithm uses + * multiple of epsilon. Algorithm uses * atan(x) = 2 * atan(x/(1 + sqrt(1+x^2))) * to reduce x to a small value and then * atan(x) = x - x^3/3 + ... @@ -528,9 +527,9 @@ qatan(NUMBER *q, NUMBER *epsilon) if (k) { zshift(sum, -k, &qtmp->num); zfree(sum); - } - else + } else { qtmp->num = sum; + } zbitvalue(m - 4 - k, &qtmp->den); res = qmappr(qtmp, epsilon, 24L); qfree(qtmp); @@ -842,9 +841,9 @@ qexprel(NUMBER *q, long bitnum) if (zrel(ztmp1, B) >= 0) { zshift(ztmp1, -m - 1, &sum); k++; - } - else + } else { zshift(ztmp1, -m, &sum); + } zfree(ztmp1); } zfree(B); @@ -929,7 +928,7 @@ qln(NUMBER *q, NUMBER *epsilon) zcopy(pow, &sum); /* pow is first term of sum */ zsquare(pow, &ztmp); - zshift(ztmp, -m, &mul); /* mul is now multiplier for powers */ + zshift(ztmp, -m, &mul); /* mul is now multiplier for powers */ zfree(ztmp); d = 1; @@ -957,8 +956,7 @@ qln(NUMBER *q, NUMBER *epsilon) if (k) { zshift(sum, -k, &qtmp->num); zfree(sum); - } - else { + } else { qtmp->num = sum; } zbitvalue(m - k - n, &qtmp->den); @@ -1003,8 +1001,7 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (zrel(q1->num, q1->den) < 0) { q1tmp = qinv(q1); q2tmp = qneg(q2); - } - else { + } else { q1tmp = qlink(q1); q2tmp = qlink(q2); } @@ -1031,8 +1028,7 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) tmp2 = qmul(tmp1, &_qlge_); m = qtoi(tmp2); } - } - else { + } else { if (m > 0) { tmp1 = itoq(m + 1); tmp2 = qmul(tmp1, q2tmp); @@ -1070,9 +1066,9 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) tmp2 = qexprel(tmp1, m - n + 3); qfree(tmp1); tmp1 = qinv(tmp2); - } - else + } else { tmp1 = qexprel(tmp2, m - n + 3) ; + } qfree(tmp2); tmp2 = qmappr(tmp1, epsilon, 24L); qfree(tmp1); @@ -1240,9 +1236,9 @@ qcoth(NUMBER *q, NUMBER *epsilon) tmp1 = qmul(&_qlge_, tmp2); k = qtoi(tmp1); qfree(tmp1); - } - else + } else { k = 2 * k; + } k = 4 - k - n; if (k < 4) k = 4; @@ -1333,9 +1329,9 @@ qcsch(NUMBER *q, NUMBER *epsilon) tmp2 = qmul(&_qlge_, tmp1); k = qtoi(tmp2); qfree(tmp2); - } - else + } else { k = 2 * qilog2(tmp1); + } if (k + n >= 1) { qfree(tmp1); return qlink(&_qzero_); @@ -1518,6 +1514,3 @@ qacoth(NUMBER *q, NUMBER *epsilon) qfree(tmp); return res; } - - -/* END CODE */ diff --git a/quickhash.c b/quickhash.c index 852ed25..075b402 100644 --- a/quickhash.c +++ b/quickhash.c @@ -19,10 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ */ /* @@ -39,7 +39,7 @@ * * The Fowler/Noll/Vo hash does a very good job in producing * a 32 bit hash from ASCII strings in a short amount of time. - * It is not bad for hashing calc data as well. So doing a + * It is not bad for hashing calc data as well. So doing a * quick and dirty job of hashing on a part of a calc value, * combined with using a reasonable hash function will result * acceptable associative array performance. @@ -80,14 +80,14 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val); * The basis of this hash algorithm was taken from an idea sent * as reviewer comments to the IEEE POSIX P1003.2 committee by: * - * Phong Vo (http://www.research.att.com/info/kpv/) - * Glenn Fowler (http://www.research.att.com/~gsf/) + * Phong Vo (http://www.research.att.com/info/kpv/) + * Glenn Fowler (http://www.research.att.com/~gsf/) * * In a subsequent ballot round: * - * Landon Curt Noll (http://reality.sgi.com/chongo/) + * Landon Curt Noll (http://reality.sgi.com/chongo/) * - * improved on their algorithm. Some people tried this hash + * improved on their algorithm. Some people tried this hash * and found that it worked rather well. In an EMail message * to Landon, they named it ``Fowler/Noll/Vo'' or the FNV hash. * @@ -95,7 +95,7 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val); * collision rate. The FNV speed allows one to quickly hash lots * of data while maintaining a reasonable collision rate. See: * - * http://reality.sgi.com/chongo/tech/comp/fnv/ + * http://reality.sgi.com/chongo/tech/comp/fnv/ * * for more details as well as other forms of the FNV hash. * @@ -313,7 +313,7 @@ randhash(RAND *r, QCKHASH val) * hash the RAND state */ if (!r->seeded) { - /* unseeded state hashes to V_RAND */ + /* unseeded state hashes to V_RAND */ return V_RAND+val; } else { /* hash control values */ diff --git a/sample/Makefile b/sample/Makefile index f83334a..b2d887c 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -22,7 +22,7 @@ # PERFORMANCE OF THIS SOFTWARE. # # Comments, suggestions, bug fixes and questions about these routines -# are welcome. Send EMail to the address given below. +# are welcome. Send EMail to the address given below. # # Happy bit twiddling, # @@ -131,7 +131,7 @@ DEBUG= -O # BSD NO_SHARED= # SYSV NO_SHARED= -dn # IRIX NO_SHARED= -non_shared -# disable NO_SHARED= +# disable NO_SHARED= # # If in doubt, use NO_SHARED= # @@ -153,7 +153,7 @@ RANLIB=: # a default here just in case you want to build from this directory. # # Normally certain files depend on the Makefile. If the Makefile is -# changed, then certain steps should be redone. If MAKE_FILE is +# changed, then certain steps should be redone. If MAKE_FILE is # set to Makefile, then these files will depend on Makefile. If # MAKE_FILE is empty, they they wont. # @@ -177,11 +177,11 @@ MAKE_FILE= Makefile # # By default, custom builtin functions may only be executed if calc # is given the -C option. This is because custom builtin functions -# may invoke non-standard or non-portable code. One may completely +# may invoke non-standard or non-portable code. One may completely # disable custom builtin functions by not compiling any of code # -# ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given -# ALLOW_CUSTOM= # disable custom even if -C is given +# ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given +# ALLOW_CUSTOM= # disable custom even if -C is given # # If in doubt, use ALLOW_CUSTOM= -DCUSTOM # @@ -308,14 +308,14 @@ many_random: many_random.o ../libcalc.a ## # -# File list generation. You can ignore this section. +# File list generation. You can ignore this section. # # # We will form the names of source files as if they were in a # sub-directory called calc/lib. # # NOTE: Due to bogus shells found on one common system we must have -# an non-emoty else clause for every if condition. *sigh* +# an non-emoty else clause for every if condition. *sigh* # ## @@ -351,7 +351,7 @@ depend: ${Q}mkdir skel ${Q}mkdir skel/sample -${Q}for i in ${C_SRC}; do \ - ${SED} -n '/^#[ ]*include[ ]*"/p' \ + ${SED} -n '/^#[ ]*include[ ]*"/p' \ "$$i" > "skel/sample/$$i"; \ done -${Q}for i in ${H_SRC} /dev/null; do \ diff --git a/sample/README_SAMPLE b/sample/README_SAMPLE index f66ef25..3ff9941 100644 --- a/sample/README_SAMPLE +++ b/sample/README_SAMPLE @@ -31,7 +31,7 @@ many_random Generate many (100000) sets random bits using the Blum-Blum-Shub generator that is used by the random() and srandom() builtin functions. - Output is one set per line. Unlike test_random, the seed is not + Output is one set per line. Unlike test_random, the seed is not printed. There is no leading 0x on numbers and there is no prefix strings. The only thing printed (normally) is ASCII hex chars and newlines. diff --git a/sample/many_random.c b/sample/many_random.c index 4ba29d6..5efc427 100644 --- a/sample/many_random.c +++ b/sample/many_random.c @@ -4,7 +4,7 @@ * usage: * many_random [[bits] seed_string] * - * seed_string something for which we can seed (def: default seed) + * seed_string something for which we can seed (def: default seed) * bits number of bits to generate */ @@ -93,7 +93,7 @@ main(int argc, char **argv) /* * reseed every so often - */ + */ for (j=0; j < RESEED; ++j) { /* diff --git a/sample/test_random.c b/sample/test_random.c index 8a5ffd7..b39f12c 100644 --- a/sample/test_random.c +++ b/sample/test_random.c @@ -4,7 +4,7 @@ * usage: * test_random [[bits] seed_string] * - * seed_string something for which we can seed (def: default seed) + * seed_string something for which we can seed (def: default seed) * bits number of bits to generate */ diff --git a/seed.c b/seed.c index 6c71637..3ea0126 100644 --- a/seed.c +++ b/seed.c @@ -4,7 +4,7 @@ * Generate a quasi-random seed based on system and process information. * * NOTE: This is not a good source of chaotic data. The lavarand - * system does a much better job of that. See: + * system does a much better job of that. See: * * http://lavarand.sgi.com/index.html * @@ -15,10 +15,10 @@ * provided that the above copyright, this permission notice and text * this comment, and the disclaimer below appear in all of the following: * - * supporting documentation - * source copies - * source works derived from this source - * binaries derived from this source or from derived source + * supporting documentation + * source copies + * source works derived from this source + * binaries derived from this source or from derived source * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO @@ -28,10 +28,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * Share and enjoy! :-) */ @@ -98,7 +98,7 @@ typedef struct s_hash64 hash64; * 0 hash value. The virgin value that we use below is the hash value * that we would get from following 32 ASCII characters: * - * chongo /\../\ + * chongo /\../\ * * Note that the \'s above are not back-slashing escape characters. * They are literal ASCII backslash 0x5c characters. @@ -158,27 +158,27 @@ hash_buf(char *buf, unsigned len) /* * FNV-1 - Fowler/Noll/Vo-1 64 bit hash * - * The basis of this hash algorithm was taken from an idea sent - * as reviewer comments to the IEEE POSIX P1003.2 committee by: - * - * Phong Vo (http://www.research.att.com/info/kpv/) - * Glenn Fowler (http://www.research.att.com/~gsf/) - * - * In a subsequent ballot round: - * - * Landon Curt Noll (http://reality.sgi.com/chongo/) - * - * improved on their algorithm. Some people tried this hash - * and found that it worked rather well. In an EMail message - * to Landon, they named it ``Fowler/Noll/Vo'' or the FNV hash. - * - * FNV hashes are architected to be fast while maintaining a low - * collision rate. The FNV speed allows one to quickly hash lots - * of data while maintaining a reasonable collision rate. See: - * - * http://reality.sgi.com/chongo/tech/comp/fnv/ - * - * for more details as well as other forms of the FNV hash. + * The basis of this hash algorithm was taken from an idea sent + * as reviewer comments to the IEEE POSIX P1003.2 committee by: + * + * Phong Vo (http://www.research.att.com/info/kpv/) + * Glenn Fowler (http://www.research.att.com/~gsf/) + * + * In a subsequent ballot round: + * + * Landon Curt Noll (http://reality.sgi.com/chongo/) + * + * improved on their algorithm. Some people tried this hash + * and found that it worked rather well. In an EMail message + * to Landon, they named it ``Fowler/Noll/Vo'' or the FNV hash. + * + * FNV hashes are architected to be fast while maintaining a low + * collision rate. The FNV speed allows one to quickly hash lots + * of data while maintaining a reasonable collision rate. See: + * + * http://reality.sgi.com/chongo/tech/comp/fnv/ + * + * for more details as well as other forms of the FNV hash. */ #if defined(HAVE_B64) /* hash each octet of the buffer */ @@ -250,7 +250,7 @@ hash_buf(char *buf, unsigned len) * Generate a quasi-random seed based on system and process information. * * NOTE: This is not a good source of chaotic data. The lavarand - * system does a much better job of that. See: + * system does a much better job of that. See: * * http://lavarand.sgi.com/index.html * @@ -258,7 +258,7 @@ hash_buf(char *buf, unsigned len) * If when porting this code to your system and something * won't compile, just remove that line or replace it with * some other system call. We don't have to have every call - * operating below. We only want to hash the resulting data. + * operating below. We only want to hash the resulting data. * * returns: * a pseudo-seed as a NUMBER over the range [0, 2^64) @@ -269,59 +269,59 @@ pseudo_seed(void) struct { /* data used for quasi-random seed */ #if defined(HAVE_GETTIME) # if defined(CLOCK_SGI_CYCLE) - struct timespec sgi_cycle; /* SGI hardware clock */ + struct timespec sgi_cycle; /* SGI hardware clock */ # endif /* CLOCK_SGI_CYCLE */ # if defined(CLOCK_REALTIME) struct timespec realtime; /* POSIX realtime clock */ # endif /* CLOCK_REALTIME */ #endif /* HAVE_GETTIME */ #if defined(HAVE_GETPRID) - prid_t getprid; /* project ID */ + prid_t getprid; /* project ID */ #endif /* HAVE_GETPRID */ #if defined(HAVE_URANDOM) int urandom_fd; /* open scriptor for /dev/urandom */ int urandom_ret; /* read() of /dev/random */ char urandom_pool[DEV_URANDOM_POOL]; /* /dev/urandom data pool */ #endif /* HAVE_URANDOM */ - struct timeval tp; /* time of day */ - pid_t getpid; /* process ID */ - pid_t getppid; /* parent process ID */ - uid_t getuid; /* real user ID */ - uid_t geteuid; /* effective user ID */ - gid_t getgid; /* real group ID */ - gid_t getegid; /* effective group ID */ - struct stat stat_dot; /* stat of "." */ - struct stat stat_dotdot; /* stat of ".." */ - struct stat stat_tmp; /* stat of "/tmp" */ + struct timeval tp; /* time of day */ + pid_t getpid; /* process ID */ + pid_t getppid; /* parent process ID */ + uid_t getuid; /* real user ID */ + uid_t geteuid; /* effective user ID */ + gid_t getgid; /* real group ID */ + gid_t getegid; /* effective group ID */ + struct stat stat_dot; /* stat of "." */ + struct stat stat_dotdot; /* stat of ".." */ + struct stat stat_tmp; /* stat of "/tmp" */ struct stat stat_root; /* stat of "/" */ - struct stat fstat_stdin; /* stat of stdin */ - struct stat fstat_stdout; /* stat of stdout */ - struct stat fstat_stderr; /* stat of stderr */ + struct stat fstat_stdin; /* stat of stdin */ + struct stat fstat_stdout; /* stat of stdout */ + struct stat fstat_stderr; /* stat of stderr */ #if defined(HAVE_USTAT) - struct ustat ustat_dot; /* usage stat of "." */ - struct ustat ustat_dotdot; /* usage stat of ".." */ - struct ustat ustat_tmp; /* usage stat of "/tmp" */ - struct ustat ustat_root; /* usage stat of "/" */ - struct ustat ustat_stdin; /* usage stat of stdin */ - struct ustat ustat_stdout; /* usage stat of stdout */ - struct ustat ustat_stderr; /* usage stat of stderr */ + struct ustat ustat_dot; /* usage stat of "." */ + struct ustat ustat_dotdot; /* usage stat of ".." */ + struct ustat ustat_tmp; /* usage stat of "/tmp" */ + struct ustat ustat_root; /* usage stat of "/" */ + struct ustat ustat_stdin; /* usage stat of stdin */ + struct ustat ustat_stdout; /* usage stat of stdout */ + struct ustat ustat_stderr; /* usage stat of stderr */ #endif /* HAVE_USTAT */ #if defined(HAVE_GETSID) - pid_t getsid; /* session ID */ + pid_t getsid; /* session ID */ #endif /* HAVE_GETSID */ #if defined(HAVE_GETPGID) - pid_t getpgid; /* process group ID */ + pid_t getpgid; /* process group ID */ #endif /* HAVE_GETPGID */ #if defined(HAVE_GETRUSAGE) - struct rusage rusage; /* resource utilization */ - struct rusage rusage_chld; /* resource utilization of children */ + struct rusage rusage; /* resource utilization */ + struct rusage rusage_chld; /* resource utilization of children */ #endif /* HAVE_GETRUSAGE */ - struct timeval tp2; /* time of day again */ + struct timeval tp2; /* time of day again */ struct tms times; /* process times */ time_t time; /* local time */ size_t size; /* size of this data structure */ jmp_buf env; /* setjmp() context */ - char *sdata_p; /* address of this structure */ + char *sdata_p; /* address of this structure */ } sdata; hash64 hash_val; /* fnv64 hash of sdata */ ZVALUE hash; /* hash_val as a ZVALUE */ @@ -331,7 +331,7 @@ pseudo_seed(void) * pick up process/system information * * NOTE: - * We do care (that much) if these calls fail. We do not + * We do care (that much) if these calls fail. We do not * need to process any data in the 'sdata' structure. */ #if defined(HAVE_GETTIME) diff --git a/shs.c b/shs.c index a6d5ded..a779956 100644 --- a/shs.c +++ b/shs.c @@ -2,29 +2,29 @@ * shs - old Secure Hash Standard * ************************************************************************** - * This version implements the old Secure Hash Algorithm specified by * + * This version implements the old Secure Hash Algorithm specified by * * (FIPS Pub 180). This version is kept for backward compatibility with * - * shs version 2.10.1. See the shs utility for the new standard. * + * shs version 2.10.1. See the shs utility for the new standard. * ************************************************************************** * * Written 2 September 1992, Peter C. Gutmann. * * This file was Modified/Re-written by: * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * @@ -43,7 +43,7 @@ * * In calc, we want to hash equal values to the same hash value. * For the most part, we will be hashing arrays of HALF's instead - * of strings. For this reason, the functions below do not byte + * of strings. For this reason, the functions below do not byte * swap on little endian machines automatically. Instead it is * the responsibility of the caller of the internal SHS function * to ensure that the values are already in the canonical 32 bit @@ -67,23 +67,23 @@ * f1: ((x&y) | (~x&z)) == (z ^ (x&(y^z))) * f3: ((x&y) | (x&z) | (y&z)) == ((x&y) | (z&(x|y))) */ -#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */ -#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */ -#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */ -#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */ +#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */ +#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */ +#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */ +#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */ /* The SHS Mysterious Constants */ -#define K1 0x5A827999L /* Rounds 0-19 */ -#define K2 0x6ED9EBA1L /* Rounds 20-39 */ -#define K3 0x8F1BBCDCL /* Rounds 40-59 */ -#define K4 0xCA62C1D6L /* Rounds 60-79 */ +#define K1 0x5A827999L /* Rounds 0-19 */ +#define K2 0x6ED9EBA1L /* Rounds 20-39 */ +#define K3 0x8F1BBCDCL /* Rounds 40-59 */ +#define K4 0xCA62C1D6L /* Rounds 60-79 */ /* SHS initial values */ -#define h0init 0x67452301L -#define h1init 0xEFCDAB89L -#define h2init 0x98BADCFEL -#define h3init 0x10325476L -#define h4init 0xC3D2E1F0L +#define h0init 0x67452301L +#define h1init 0xEFCDAB89L +#define h2init 0x98BADCFEL +#define h3init 0x10325476L +#define h4init 0xC3D2E1F0L /* 32-bit rotate left - kludged with shifts */ #define LEFT_ROT(X,n) (((X)<<(n)) | ((X)>>(32-(n)))) @@ -93,7 +93,7 @@ * 80-word expanded input array W, where the first 16 are copies of the input * data, and the remaining 64 are defined by * - * W[i] = W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3] + * W[i] = W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3] * * This implementation generates these values on the fly in a circular * buffer - thanks to Colin Plumb (colin@nyx10.cs.du.edu) for this @@ -102,13 +102,13 @@ #define exor(W,i) (W[i&15] ^= (W[(i-14)&15] ^ W[(i-8)&15] ^ W[(i-3)&15])) /* - * The prototype SHS sub-round. The fundamental sub-round is: + * The prototype SHS sub-round. The fundamental sub-round is: * - * a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data; - * b' = a; - * c' = LEFT_ROT(b,30); - * d' = c; - * e' = d; + * a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data; + * b' = a; + * c' = LEFT_ROT(b,30); + * d' = c; + * e' = d; * * but this is implemented by unrolling the loop 5 times and renaming the * variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration. @@ -345,7 +345,7 @@ shsUpdate(HASH *state, USB8 *buffer, USB32 count) * Next if we have more than 56 bytes, we will zero fill the remainder * of the chunk, transform and then zero fill the first 56 bytes. * If we have 56 or fewer bytes, we will zero fill out to the 56th - * chunk byte. Regardless, we wind up with 56 bytes data. + * chunk byte. Regardless, we wind up with 56 bytes data. * * Finally we append the 64 bit length on to the 56 bytes of data * remaining. This final chunk is transformed. @@ -380,8 +380,7 @@ shsFinal(HASH *state) for (i=0; i < SHS_CHUNKWORDS; ++i) { SWAP_B8_IN_B32(dig->data+i, dig->data+i); } - } - else { + } else { if (count % 4) { math_error("This should not happen in shsFinal"); /*NOTREACHED*/ @@ -697,13 +696,13 @@ shs_print(HASH *state) * form the hash value */ if (conf->calc_debug & CALCDBG_HASH_STATE) { - char buf[DEBUG_SIZE+1]; /* hash value buffer */ + char buf[DEBUG_SIZE+1]; /* hash value buffer */ /* * print numeric debug value * * NOTE: This value represents only the hash value as of - * the last full update or finalization. Thus it + * the last full update or finalization. Thus it * may NOT be the actual hash value. */ sprintf(buf, diff --git a/shs.h b/shs.h index a8ec954..8aa6be8 100644 --- a/shs.h +++ b/shs.h @@ -2,29 +2,29 @@ * shs - old Secure Hash Standard * ************************************************************************** - * This version implements the old Secure Hash Algorithm specified by * + * This version implements the old Secure Hash Algorithm specified by * * (FIPS Pub 180). This version is kept for backward compatibility with * - * shs version 2.10.1. See the shs utility for the new standard. * + * shs version 2.10.1. See the shs utility for the new standard. * ************************************************************************** * * Written 2 September 1992, Peter C. Gutmann. * * This file was Modified by: * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ diff --git a/shs1.c b/shs1.c index 9b9d718..58ba093 100644 --- a/shs1.c +++ b/shs1.c @@ -5,20 +5,20 @@ * * This file was Modified/Re-written by: * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -40,23 +40,23 @@ * f1: ((x&y) | (~x&z)) == (z ^ (x&(y^z))) * f3: ((x&y) | (x&z) | (y&z)) == ((x&y) | (z&(x|y))) */ -#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */ -#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */ -#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */ -#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */ +#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */ +#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */ +#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */ +#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */ /* The SHS1 Mysterious Constants */ -#define K1 0x5A827999L /* Rounds 0-19 */ -#define K2 0x6ED9EBA1L /* Rounds 20-39 */ -#define K3 0x8F1BBCDCL /* Rounds 40-59 */ -#define K4 0xCA62C1D6L /* Rounds 60-79 */ +#define K1 0x5A827999L /* Rounds 0-19 */ +#define K2 0x6ED9EBA1L /* Rounds 20-39 */ +#define K3 0x8F1BBCDCL /* Rounds 40-59 */ +#define K4 0xCA62C1D6L /* Rounds 60-79 */ /* SHS1 initial values */ -#define h0init 0x67452301L -#define h1init 0xEFCDAB89L -#define h2init 0x98BADCFEL -#define h3init 0x10325476L -#define h4init 0xC3D2E1F0L +#define h0init 0x67452301L +#define h1init 0xEFCDAB89L +#define h2init 0x98BADCFEL +#define h3init 0x10325476L +#define h4init 0xC3D2E1F0L /* 32-bit rotate left - kludged with shifts */ #define LEFT_ROT(X,n) (((X)<<(n)) | ((X)>>(32-(n)))) @@ -67,7 +67,7 @@ * 80-word expanded input array W, where the first 16 are copies of the input * data, and the remaining 64 are defined by * - * W[i] = LEFT_ROT(W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3], 1) + * W[i] = LEFT_ROT(W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3], 1) * * NOTE: The expanding function used in rounds 16 to 79 was changed from the * original SHA (in FIPS Pub 180) to one that also left circular shifted @@ -80,11 +80,11 @@ /* * The prototype SHS1 sub-round. The fundamental sub-round is: * - * a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data; - * b' = a; - * c' = LEFT_ROT(b,30); - * d' = c; - * e' = d; + * a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data; + * b' = a; + * c' = LEFT_ROT(b,30); + * d' = c; + * e' = d; * * but this is implemented by unrolling the loop 5 times and renaming the * variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration. @@ -319,7 +319,7 @@ shs1Update(HASH *state, USB8 *buffer, USB32 count) * Next if we have more than 56 bytes, we will zero fill the remainder * of the chunk, transform and then zero fill the first 56 bytes. * If we have 56 or fewer bytes, we will zero fill out to the 56th - * chunk byte. Regardless, we wind up with 56 bytes data. + * chunk byte. Regardless, we wind up with 56 bytes data. * * Finally we append the 64 bit length on to the 56 bytes of data * remaining. This final chunk is transformed. @@ -357,8 +357,7 @@ shs1Final(HASH *state) for (i=0; i < SHS1_CHUNKWORDS; ++i) { SWAP_B8_IN_B32(dig->data+i, dig->data+i); } - } - else { + } else { if (count % 4) { math_error("This should not happen in shs1Final"); /*NOTREACHED*/ @@ -673,13 +672,13 @@ shs1_print(HASH *state) * form the hash value */ if (conf->calc_debug & CALCDBG_HASH_STATE) { - char buf[DEBUG_SIZE+1]; /* hash value buffer */ + char buf[DEBUG_SIZE+1]; /* hash value buffer */ /* * print numeric debug value * * NOTE: This value represents only the hash value as of - * the last full update or finalization. Thus it + * the last full update or finalization. Thus it * may NOT be the actual hash value. */ sprintf(buf, diff --git a/shs1.h b/shs1.h index 8861385..94096f1 100644 --- a/shs1.h +++ b/shs1.h @@ -5,20 +5,20 @@ * * This file was Modified by: * - * Landon Curt Noll - * http://reality.sgi.com/chongo/ + * Landon Curt Noll + * http://reality.sgi.com/chongo/ * - * chongo /\../\ + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT + * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -48,7 +48,7 @@ * We will assume that bit count is a multiple of 8. */ typedef struct { - USB32 digest[SHS1_DIGESTWORDS]; /* message digest */ + USB32 digest[SHS1_DIGESTWORDS]; /* message digest */ USB32 countLo; /* 64 bit count: bits 3-34 */ USB32 countHi; /* 64 bit count: bits 35-63 */ USB32 datalen; /* length of data in data */ diff --git a/size.c b/size.c index e484517..3e8e860 100644 --- a/size.c +++ b/size.c @@ -118,7 +118,7 @@ zsize(ZVALUE z) /* * qsize - calculate memory footprint of a NUMBER (exlcuding overhead) * - * The numeric -1, - and 1 storage values are ignored. Denominator + * The numeric -1, - and 1 storage values are ignored. Denominator * parts of integers are ignored. * * given: @@ -142,7 +142,7 @@ qsize(NUMBER *q) /* * csize - calculate memory footprint of a COMPLEX (exlcuding overhead) * - * The numeric -1, - and 1 storage values are ignored. Denominator + * The numeric -1, - and 1 storage values are ignored. Denominator * parts of integers are ignored. Imaginary parts of pure reals * are ignored. * @@ -285,8 +285,8 @@ lsizeof(VALUE *vp) case V_HASH: /* ignore the unused part of the union */ s = (long)sizeof(HASH) + - vp->v_hash->unionsize - - (long)sizeof(vp->v_hash->h_union); + vp->v_hash->unionsize - + (long)sizeof(vp->v_hash->h_union); break; case V_BLOCK: s = vp->v_block->maxsize; diff --git a/string.c b/string.c index 8dcfefc..89d9afe 100644 --- a/string.c +++ b/string.c @@ -116,7 +116,7 @@ charstr(int ch) /* * Find a string with the specified name and return its number in the - * string list. The first string is numbered zero. Minus one is returned + * string list. The first string is numbered zero. Minus one is returned * if the string is not found. * * given: @@ -175,7 +175,7 @@ namestr(STRINGHEAD *hp, long n) /* * Useful routine to return the index of one string within another one * which has the format: "str1\000str2\000str3\000...strn\0\0". Index starts - * at one for the first string. Returns zero if the string being checked + * at one for the first string. Returns zero if the string being checked * is not contained in the formatted string. * * Be sure to use \000 instead of \0. ANSI-C compilers interpret "foo\0foo..." @@ -586,8 +586,7 @@ stringsegment(STRING *s1, long n1, long n2) if (n1 >= n2) { while (len-- > 0) *c++ = *c1--; - } - else { + } else { while (len-- > 0) *c++ = *c1++; } @@ -598,7 +597,7 @@ stringsegment(STRING *s1, long n1, long n2) /* * stringshift shifts s1 n bits to left if n > 0, -n to the right if n < 0; * octets in string considered to be in decreasing order of index, as in - * ... a_3 a_2 a_1 a_0. Returned string has same length as s1. + * ... a_3 a_2 a_1 a_0. Returned string has same length as s1. * Vacated bits are filled with '\0'; bits shifted off end are lost */ STRING * @@ -640,8 +639,7 @@ stringshift(STRING *s1, long n) *--c = ((unsigned char) *--c1 >> j) | ch; ch = (unsigned char) *c1 << k; } - } - else { + } else { while (i-- > 0) *c++ = '\0'; i = len - n; @@ -741,7 +739,7 @@ stringlowbit(STRING *s) unsigned char ch; long i; - for (i = s->s_len, c = s->s_str; i > 0 && *c == '\0'; i--, c++); + for (i = s->s_len, c = s->s_str; i > 0 && *c == '\0'; i--, c++); if (i == 0) return -1; i = (s->s_len - i) << 3; @@ -814,7 +812,7 @@ stringrel(STRING *s1, STRING *s2) /* * str with characters c0, c1, ... is considered as a bitstream, 8 bits * per character; within a character the bits ordered from low order to - * high order. For 0 <= i < 8 * length of str, stringbit returns 1 or 0 + * high order. For 0 <= i < 8 * length of str, stringbit returns 1 or 0 * according as the bit with index i is set or not set; other values of i * return -1. */ @@ -957,7 +955,7 @@ stringrsearch(STRING *s1, STRING *s2, long start, long end, ZVALUE *index) * String allocation routines */ -#define STRALLOC 100 +#define STRALLOC 100 static STRING *freeStr = NULL; @@ -1137,7 +1135,7 @@ sfree(STRING *s) static long stringconstcount = 0; static long stringconstavail = 0; -static STRING **stringconsttable; +static STRING **stringconsttable; #define STRCONSTALLOC 100 void @@ -1352,7 +1350,7 @@ showstrings(void) printf("Index Links Length String\n"); printf("----- ----- ------ ------\n"); sp = &_nullstring_; - printf(" 0 %5ld 0 \"\"\n", sp->s_links); + printf(" 0 %5ld 0 \"\"\n", sp->s_links); for (i = 0, k = 1, count = 1; i < blockcount; i++) { sp = firstStrs[i]; for (j = 0; j < STRALLOC; j++, k++, sp++) { @@ -1392,6 +1390,3 @@ showliterals(void) } printf("\nNumber: %ld\n", count); } - - -/* END CODE */ diff --git a/string.h b/string.h index cdb85c3..2d26ec7 100644 --- a/string.h +++ b/string.h @@ -6,7 +6,7 @@ #if !defined(__CALCSTRING_H__) -#define __CALCSTRING_H__ +#define __CALCSTRING_H__ #include "zmath.h" diff --git a/symbol.c b/symbol.c index 3019ad3..d0eb2dc 100644 --- a/symbol.c +++ b/symbol.c @@ -165,8 +165,8 @@ showglobals(void) if (sp->g_value.v_type != V_NUM) continue; if (count++ == 0) { - printf("\nName Digits Value\n"); - printf( "---- ------ -----\n"); + printf("\nName Digits Value\n"); + printf( "---- ------ -----\n"); } printf("%-8s", sp->g_name); if (sp->g_filescope != SCOPE_GLOBAL) @@ -193,10 +193,10 @@ showallglobals(void) for (hp = &globalhash[HASHSIZE-1]; hp >= globalhash; hp--) { for (sp = *hp; sp; sp = sp->g_next) { if (count++ == 0) { - printf("\nName Level Type\n"); - printf( "---- ----- -----\n"); + printf("\nName Level Type\n"); + printf( "---- ----- -----\n"); } - printf("%-8s%4d ", sp->g_name, sp->g_filescope); + printf("%-8s%4d ", sp->g_name, sp->g_filescope); printtype(&sp->g_value); printf("\n"); } @@ -211,7 +211,7 @@ static void printtype(VALUE *vp) { int type; - char *s; + char *s; type = vp->v_type; if (type < 0) { @@ -351,7 +351,7 @@ freeglobals(void) * more time. * * We could stop the loop with just hp >= globalhash, but stopping - * short and running the loop one last time manually helps make + * short and running the loop one last time manually helps make * code checkers such as insure happy. */ count = 0; @@ -408,7 +408,7 @@ resetscopes(void) /* * Enter a new file scope level so that newly defined static variables * will have the appropriate scope, and so that previously defined static - * variables will temporarily be unaccessible. This should only be called + * variables will temporarily be unaccessible. This should only be called * when the function scope level is zero. */ void @@ -531,8 +531,8 @@ showstatics(void) for (count = 0, stp = statictable; count < staticcount; count++) { sp = *stp++; if (count == 0) { - printf("\nName Scopes Type\n"); - printf( "---- ------ -----\n"); + printf("\nName Scopes Type\n"); + printf( "---- ------ -----\n"); } printf("%-8s", sp->g_name); printf("%3d", sp->g_filescope); @@ -564,7 +564,7 @@ unscope(void) * more time. * * We could stop the loop with just hp >= globalhash, but stopping - * short and running the loop one last time manually helps make + * short and running the loop one last time manually helps make * code checkers such as insure happy. */ for (hp = &globalhash[HASHSIZE-1]; hp > globalhash; hp--) { diff --git a/symbol.h b/symbol.h index 079f708..3263ecc 100644 --- a/symbol.h +++ b/symbol.h @@ -6,7 +6,7 @@ #if !defined(__SYMBOL_H__) -#define __SYMBOL_H__ +#define __SYMBOL_H__ #include "zmath.h" @@ -19,10 +19,10 @@ #define SYM_PARAM 1 /* parameter symbol */ #define SYM_LOCAL 2 /* local symbol */ #define SYM_GLOBAL 3 /* global symbol */ -#define SYM_STATIC 4 /* static symbol */ +#define SYM_STATIC 4 /* static symbol */ -#define SCOPE_GLOBAL 0 /* file scope level for global variables */ -#define SCOPE_STATIC 1 /* lowest file scope for static variables */ +#define SCOPE_GLOBAL 0 /* file scope level for global variables */ +#define SCOPE_STATIC 1 /* lowest file scope for static variables */ typedef struct global GLOBAL; diff --git a/token.c b/token.c index 141566b..7c5df66 100644 --- a/token.c +++ b/token.c @@ -401,8 +401,8 @@ eatstring(int quotechar) ch = 8 * ch + cch - '0'; } ch &= 0xff; - if (i > 0) - reread(); + if (i > 0) + reread(); break; } switch (ch) { @@ -474,7 +474,7 @@ eatstring(int quotechar) len = 0; } } - curtoken.t_strindex = addstring(str, totlen + len); + curtoken.t_strindex = addstring(str, totlen + len); if (str != buf) free(str); } diff --git a/token.h b/token.h index 32d69dd..80ab300 100644 --- a/token.h +++ b/token.h @@ -6,7 +6,7 @@ #if !defined(__TOKEN_H__) -#define __TOKEN_H__ +#define __TOKEN_H__ #include "zmath.h" @@ -67,8 +67,8 @@ #define T_POWEREQUALS 49 /* power equals "^=" or "**=" */ #define T_PERIOD 50 /* period "." */ #define T_IMAGINARY 51 /* numeric imaginary constant */ -#define T_AMPERSAND 52 /* ampersand "&" */ -#define T_QUESTIONMARK 53 /* question mark "?" */ +#define T_AMPERSAND 52 /* ampersand "&" */ +#define T_QUESTIONMARK 53 /* question mark "?" */ #define T_AT 54 /* at sign "@" */ #define T_DOLLAR 55 /* dollar sign "$" */ #define T_HASH 56 /* hash or pound sign "#" */ @@ -93,7 +93,7 @@ #define T_RETURN 107 /* return keyword */ #define T_LOCAL 108 /* local keyword */ #define T_GLOBAL 109 /* global keyword */ -#define T_STATIC 110 /* static keyword */ +#define T_STATIC 110 /* static keyword */ #define T_DO 111 /* do keyword */ #define T_FOR 112 /* for keyword */ #define T_SWITCH 113 /* switch keyword */ diff --git a/value.c b/value.c index 1aa0a8b..0a06701 100644 --- a/value.c +++ b/value.c @@ -1542,18 +1542,18 @@ sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) copyvalue(v1, vres); return; } - if (v2->v_type == V_NULL) + if (v2->v_type == V_NULL) { q = conf->epsilon; - else { + } else { if (v2->v_type != V_NUM || qiszero(v2->v_num)) { *vres = error_value(E_SQRT2); return; } q = v2->v_num; } - if (v3->v_type == V_NULL) + if (v3->v_type == V_NULL) { R = conf->sqrt; - else { + } else { if (v3->v_type != V_NUM || qisfrac(v3->v_num)) { *vres = error_value(E_SQRT3); return; @@ -2689,7 +2689,7 @@ userfunc(char *fname, VALUE *vp) /* * Print the value of a descriptor in one of several formats. * If flags contains PRINT_SHORT, then elements of arrays and lists - * will not be printed. If flags contains PRINT_UNAMBIG, then quotes + * will not be printed. If flags contains PRINT_UNAMBIG, then quotes * are placed around strings and the null value is explicitly printed. */ void @@ -2775,7 +2775,7 @@ printvalue(VALUE *vp, int flags) qfree(qtemp); break; case V_OPTR: - printf("o-ptr: %p", vp->v_octet); + printf("o-ptr: %p", vp->v_octet); break; case V_VPTR: printf("v-ptr: %p", vp->v_addr); diff --git a/value.h b/value.h index f20a757..d4411f3 100644 --- a/value.h +++ b/value.h @@ -8,7 +8,7 @@ #if !defined(__VALUE_H__) -#define __VALUE_H__ +#define __VALUE_H__ #include "cmath.h" @@ -28,9 +28,9 @@ * Flags to modify results from the printvalue routine. * These flags are OR'd together. */ -#define PRINT_NORMAL 0x00 /* print in normal manner */ -#define PRINT_SHORT 0x01 /* print in short format (no elements) */ -#define PRINT_UNAMBIG 0x02 /* print in non-ambiguous manner */ +#define PRINT_NORMAL 0x00 /* print in normal manner */ +#define PRINT_SHORT 0x01 /* print in short format (no elements) */ +#define PRINT_UNAMBIG 0x02 /* print in non-ambiguous manner */ /* @@ -40,10 +40,10 @@ typedef struct value VALUE; typedef struct object OBJECT; typedef struct matrix MATRIX; typedef struct list LIST; -typedef struct assoc ASSOC; -typedef long FILEID; -typedef struct rand RAND; -typedef struct random RANDOM; +typedef struct assoc ASSOC; +typedef long FILEID; +typedef struct rand RAND; +typedef struct random RANDOM; /* @@ -80,22 +80,22 @@ struct value { * For ease in referencing */ #define v_int v_union.vv_int -#define v_file v_union.vv_file +#define v_file v_union.vv_file #define v_num v_union.vv_num #define v_com v_union.vv_com #define v_addr v_union.vv_addr #define v_str v_union.vv_str #define v_mat v_union.vv_mat -#define v_list v_union.vv_list -#define v_assoc v_union.vv_assoc +#define v_list v_union.vv_list +#define v_assoc v_union.vv_assoc #define v_obj v_union.vv_obj -#define v_valid v_union.vv_int +#define v_valid v_union.vv_int #define v_rand v_union.vv_rand #define v_random v_union.vv_random #define v_config v_union.vv_config #define v_hash v_union.vv_hash -#define v_block v_union.vv_block -#define v_octet v_union.vv_octet +#define v_block v_union.vv_block +#define v_octet v_union.vv_octet #define v_nblock v_union.vv_nblock @@ -121,24 +121,24 @@ struct value { #define V_ADDR 4 /* address of variable value */ #define V_STR 5 /* address of string */ #define V_MAT 6 /* address of matrix structure */ -#define V_LIST 7 /* address of list structure */ -#define V_ASSOC 8 /* address of association structure */ +#define V_LIST 7 /* address of list structure */ +#define V_ASSOC 8 /* address of association structure */ #define V_OBJ 9 /* address of object structure */ -#define V_FILE 10 /* opened file id */ -#define V_RAND 11 /* address of additive 55 random state */ +#define V_FILE 10 /* opened file id */ +#define V_RAND 11 /* address of additive 55 random state */ #define V_RANDOM 12 /* address of Blum random state */ #define V_CONFIG 13 /* configuration state */ #define V_HASH 14 /* hash state */ -#define V_BLOCK 15 /* memory block */ +#define V_BLOCK 15 /* memory block */ #define V_OCTET 16 /* octet (unsigned char) */ #define V_NBLOCK 17 /* named memory block */ #define V_VPTR 18 /* value address as pointer */ #define V_OPTR 19 /* octet address as pointer */ #define V_SPTR 20 /* string address as pointer */ -#define V_NPTR 21 /* number address as pointer */ +#define V_NPTR 21 /* number address as pointer */ #define V_MAX 21 /* highest legal value */ -#define V_NOSUBTYPE 0 /* subtype has no meaning */ +#define V_NOSUBTYPE 0 /* subtype has no meaning */ #define V_NOASSIGNTO 1 /* protection status 1 */ #define V_NONEWVALUE 2 /* protection status 2 */ #define V_NONEWTYPE 4 /* protection status 4 */ @@ -160,7 +160,7 @@ struct value { #define TWOVAL(a,b) ((a) << 5 | (b)) /* for switch of two values */ -#define NULL_VALUE ((VALUE *) 0) +#define NULL_VALUE ((VALUE *) 0) /* @@ -333,7 +333,7 @@ extern LIST *listsegment(LIST *, long, long); * Associations are "indexed" by one or more arbitrary values, and are * stored in a hash table with their hash values for quick indexing. */ -typedef struct assocelem ASSOCELEM; +typedef struct assocelem ASSOCELEM; struct assocelem { ASSOCELEM *e_next; /* next element in list (or NULL) */ long e_dim; /* dimension of indexing for this element */ diff --git a/version.c b/version.c index 8da6309..9047438 100644 --- a/version.c +++ b/version.c @@ -18,7 +18,7 @@ static char *program; #define MAJOR_VER 2 /* major version */ #define MINOR_VER 11 /* minor version */ #define MAJOR_PATCH 0 /* patch level or 0 if no patch */ -#define MINOR_PATCH "9.4.5" /* test number or empty string if no patch */ +#define MINOR_PATCH "10" /* test number or empty string if no patch */ /* * calc version constants diff --git a/zfunc.c b/zfunc.c index fa5469e..c64a176 100644 --- a/zfunc.c +++ b/zfunc.c @@ -37,7 +37,7 @@ zfact(ZVALUE z, ZVALUE *dest) res = _one_; /* * Multiply numbers together, but squeeze out all powers of two. - * We will put them back in at the end. Also collect multiple + * We will put them back in at the end. Also collect multiple * numbers together until there is a risk of overflow. */ for (; n > 1; n--) { @@ -458,7 +458,7 @@ ztenpow(long power, ZVALUE *res) BOOL zmodinv(ZVALUE u, ZVALUE v, ZVALUE *res) { - FULL q1, q2, ui3, vi3, uh, vh, A, B, C, D, T; + FULL q1, q2, ui3, vi3, uh, vh, A, B, C, D, T; ZVALUE u2, u3, v2, v3, qz, tmp1, tmp2, tmp3; v.sign = 0; @@ -472,7 +472,7 @@ zmodinv(ZVALUE u, ZVALUE v, ZVALUE *res) /* * Loop here while the size of the numbers remain above - * the size of a HALF. Throughout this loop u3 >= v3. + * the size of a HALF. Throughout this loop u3 >= v3. */ while ((u3.len > 1) && !ziszero(v3)) { vh = 0; @@ -481,11 +481,11 @@ zmodinv(ZVALUE u, ZVALUE v, ZVALUE *res) if (v3.len == u3.len) vh = v3.v[v3.len - 1]; #else - uh = (((FULL) u3.v[u3.len - 1]) << BASEB) + u3.v[u3.len - 2]; - if ((v3.len + 1) >= u3.len) - vh = v3.v[v3.len - 1]; - if (v3.len == u3.len) - vh = (vh << BASEB) + v3.v[v3.len - 2]; + uh = (((FULL) u3.v[u3.len - 1]) << BASEB) + u3.v[u3.len - 2]; + if ((v3.len + 1) >= u3.len) + vh = v3.v[v3.len - 1]; + if (v3.len == u3.len) + vh = (vh << BASEB) + v3.v[v3.len - 2]; #endif A = 1; B = 0; @@ -611,61 +611,6 @@ zmodinv(ZVALUE u, ZVALUE v, ZVALUE *res) } -#if 0 -/* - * Approximate the quotient of two integers by another set of smaller - * integers. This uses continued fractions to determine the smaller set. - */ -void -zapprox(ZVALUE z1, ZVALUE z2, ZVALUE *res1, ZVALUE *res2) -{ - int sign; - ZVALUE u1, v1, u3, v3, q, t1, t2, t3; - - sign = ((z1.sign != 0) ^ (z2.sign != 0)); - z1.sign = 0; - z2.sign = 0; - v3 = z2; - u3 = z1; - u1 = _one_; - v1 = _zero_; - while (!ziszero(v3)) { - zdiv(u3, v3, &q, &t1, 0); - zmul(v1, q, &t2); - zsub(u1, t2, &t3); - zfree(q); - zfree(t2); - zfree(u1); - if ((u3.v != z1.v) && (u3.v != z2.v)) - zfree(u3); - u1 = v1; - u3 = v3; - v1 = t3; - v3 = t1; - } - if (!zisunit(u3)) { - math_error("Non-relativly prime numbers for approx"); - /*NOTREACHED*/ - } - if ((u3.v != z1.v) && (u3.v != z2.v)) - zfree(u3); - if ((v3.v != z1.v) && (v3.v != z2.v)) - zfree(v3); - zfree(v1); - zmul(u1, z1, &t1); - zsub(t1, _one_, &t2); - zfree(t1); - zquo(t2, z2, &t1, 0); - zfree(t2); - u1.sign = (BOOL)sign; - t1.sign = 0; - *res1 = t1; - *res2 = u1; -} -#endif - - - /* * Compute the greatest common divisor of a pair of integers. */ @@ -754,7 +699,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) b0 = A; m = 1; a0 = B; - if (m == 1) { /* a has one digit */ + if (m == 1) { /* a has one digit */ v = *a0; if (v > 1) { /* Euclid's algorithm */ b = b0 + n; @@ -784,8 +729,9 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) *a++ = (HALF) f; } if (f >>= BASEB) {len++; *a = (HALF) f;} + } else { + memcpy(gcd.v + o, b0, n * sizeof(HALF)); } - else memcpy(gcd.v + o, b0, n * sizeof(HALF)); gcd.len = len; gcd.sign = 0; freeh(A); @@ -795,7 +741,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) } u = B[n-1]; /* Bit count for b */ - k = (n - 1) * BASEB; + k = (n - 1) * BASEB; while (u >>= 1) k++; needw = TRUE; @@ -880,7 +826,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) m--; a0++; } - if (f) { /* a - g * b < 0 */ + if (f) { /* a - g * b < 0 */ while (m > 1 && a0[m-1] == BASE1) m--; *a0 = - *a0; a = a0; @@ -962,9 +908,12 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) *a++ = (HALF) f; f >>= BASEB; } - if (f) {len++; *a = (HALF) f;} + if (f) { + len++; *a = (HALF) f; + } + } else { + memcpy(gcd.v + o, b0, n * sizeof(HALF)); } - else memcpy(gcd.v + o, b0, n * sizeof(HALF)); gcd.len = len; gcd.sign = 0; freeh(A); @@ -1002,11 +951,11 @@ zrelprime(ZVALUE z1, ZVALUE z2) z1.sign = 0; z2.sign = 0; - if (ziseven(z1) && ziseven(z2)) /* false if both even */ + if (ziseven(z1) && ziseven(z2)) /* false if both even */ return FALSE; - if (zisunit(z1) || zisunit(z2)) /* true if either is a unit */ + if (zisunit(z1) || zisunit(z2)) /* true if either is a unit */ return TRUE; - if (ziszero(z1) || ziszero(z2)) /* false if either is zero */ + if (ziszero(z1) || ziszero(z2)) /* false if either is zero */ return FALSE; if (zistwo(z1) || zistwo(z2)) /* true if either is two */ return TRUE; @@ -1098,7 +1047,7 @@ zlog(ZVALUE z1, ZVALUE z2) worth = 1; zp = &squares[0]; *zp = z2; - while (((zp->len * 2) - 1) <= z1.len) { /* while square not too large */ + while (((zp->len * 2) - 1) <= z1.len) { /* while square not too large */ zsquare(*zp, zp + 1); zp++; worth *= 2; @@ -1116,7 +1065,7 @@ zlog(ZVALUE z1, ZVALUE z2) * more time. * * We could stop the loop with just zp >= squares, but stopping - * short and running the loop one last time manually helps make + * short and running the loop one last time manually helps make * code checkers such as insure happy. */ for (; zp > squares; zp--, worth /= 2) { @@ -1196,7 +1145,7 @@ zlog10(ZVALUE z) * more time. * * We could stop the loop with just zp >= _tenpowers_, but stopping - * short and running the loop one last time manually helps make + * short and running the loop one last time manually helps make * code checkers such as insure happy. */ for (; zp > _tenpowers_; zp--, worth /= 2) { @@ -1315,7 +1264,7 @@ zfacrem(ZVALUE z1, ZVALUE z2, ZVALUE *rem) worth = 1; zp = &squares[0]; *zp = z2; - while (((zp->len * 2) - 1) <= z1.len) { /* while square not too large */ + while (((zp->len * 2) - 1) <= z1.len) { /* while square not too large */ zsquare(*zp, &temp1); zdiv(z1, temp1, &temp2, &temp3, 0); if (!ziszero(temp3)) { @@ -1342,7 +1291,7 @@ zfacrem(ZVALUE z1, ZVALUE z2, ZVALUE *rem) * more time. * * We could stop the loop with just zp >= squares, but stopping - * short and running the loop one last time manually helps make + * short and running the loop one last time manually helps make * code checkers such as insure happy. */ for (; zp > squares; zp--, worth /= 2) { @@ -1450,7 +1399,7 @@ zdigits(ZVALUE z1) /* * Return the single digit at the specified decimal place of a number, - * where 0 means the rightmost digit. Example: zdigit(1234, 1) = 3. + * where 0 means the rightmost digit. Example: zdigit(1234, 1) = 3. */ long zdigit(ZVALUE z1, long n) @@ -1482,8 +1431,8 @@ zdigit(ZVALUE z1, long n) * z is to be a nonnegative integer * If z is the square of a integer stores at dest the square root of z; * otherwise stores at z an integer differing from the square root - * by less than 1. Returns the sign of the true square root minus - * the calculated integer. Type of rounding is determined by + * by less than 1. Returns the sign of the true square root minus + * the calculated integer. Type of rounding is determined by * rnd as follows: rnd = 0 gives round down, rnd = 1 * rounds up, rnd = 8 rounds to even integer, rnd = 9 rounds to odd * integer, rnd = 16 rounds to nearest integer. @@ -1535,8 +1484,7 @@ zsqrt(ZVALUE z, ZVALUE *dest, long rnd) f = A[1]; g = (FULL) A[0] << (j + BASEB); d = e = topbit = (FULL)1 << (k - 1); - } - else { + } else { if (j) f = (FULL) A[m-1] << (j + BASEB) | (FULL) A[m-2] << j | A[m-3] >> k; @@ -1609,8 +1557,7 @@ zsqrt(ZVALUE z, ZVALUE *dest, long rnd) A[m1 - 4] = (HALF)f; m = m1 - 2; k1 = k + 1; - } - else { + } else { A[m1 - 1] = 1; A[m1 - 2] = (HALF)(e >> (BASEB - 1)); A[m1 - 3] = ((HALF)(e << 1) | (HALF)(s > 0)); @@ -1667,9 +1614,9 @@ zsqrt(ZVALUE z, ZVALUE *dest, long rnd) a[1] |= 1; } *a = ((HALF)(x << 1) | (HALF)(u > 0)); - } - else + } else { *a = u; + } m--; if (*--a == u) { while (m > 1 && *--a == u) @@ -1742,9 +1689,9 @@ done: if (s == 0) { n++; *a = 1; } - } - else + } else { remsign = 1; + } sqrt.v = alloc(n); sqrt.len = n; sqrt.sign = 0; @@ -1802,7 +1749,7 @@ zroot(ZVALUE z1, ZVALUE z2, ZVALUE *dest) sival.ivalue = k - 1; k1.v = &sival.silow; /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name zroot`sival */ + /* ok to ignore on name zroot`sival */ k1.len = 1 + (sival.sihigh != 0); k1.sign = 0; z1.sign = 0; @@ -1903,5 +1850,3 @@ zissquare(ZVALUE z) zfree(tmp); return (n ? TRUE : FALSE); } - -/* END CODE */ diff --git a/zio.c b/zio.c index 3c46bb5..9e23ff1 100644 --- a/zio.c +++ b/zio.c @@ -12,14 +12,14 @@ #include "args.h" -#define OUTBUFSIZE 200 /* realloc size for output buffers */ +#define OUTBUFSIZE 200 /* realloc size for output buffers */ -#define PUTCHAR(ch) math_chr(ch) -#define PUTSTR(str) math_str(str) -#define PRINTF1(fmt, a1) math_fmt(fmt, a1) -#define PRINTF2(fmt, a1, a2) math_fmt(fmt, a1, a2) -#define PRINTF3(fmt, a1, a2, a3) math_fmt(fmt, a1, a2, a3) -#define PRINTF4(fmt, a1, a2, a3, a4) math_fmt(fmt, a1, a2, a3, a4) +#define PUTCHAR(ch) math_chr(ch) +#define PUTSTR(str) math_str(str) +#define PRINTF1(fmt, a1) math_fmt(fmt, a1) +#define PRINTF2(fmt, a1, a2) math_fmt(fmt, a1, a2) +#define PRINTF3(fmt, a1, a2, a3) math_fmt(fmt, a1, a2, a3) +#define PRINTF4(fmt, a1, a2, a3, a4) math_fmt(fmt, a1, a2, a3, a4) /* @@ -176,7 +176,7 @@ math_flush(void) /* * Divert further output so that it is saved into a string that will be * returned later when the diversion is completed. The current state of - * output is remembered for later restoration. Diversions can be nested. + * output is remembered for later restoration. Diversions can be nested. * Output diversion is only intended for saving output to "stdout". */ void @@ -314,9 +314,9 @@ math_setdigits(long newdigits) /* * Print an integer value as a hex number. * Width is the number of columns to print the number in, including the - * sign if required. If zero, no extra output is done. If positive, + * sign if required. If zero, no extra output is done. If positive, * leading spaces are typed if necessary. If negative, trailing spaces are - * typed if necessary. The special characters 0x appear to indicate the + * typed if necessary. The special characters 0x appear to indicate the * number is hex. */ /*ARGSUSED*/ @@ -457,7 +457,7 @@ zprinto(ZVALUE z, long width) num4 = (hp[-2] & 0xffffff); if (num1) { PRINTF4("0%lo%08lo%08lo%08lo", - (PRINT) num1, (PRINT) num2, + (PRINT) num1, (PRINT) num2, (PRINT) num3, (PRINT) num4); } else { PRINTF3("0%lo%08lo%08lo", @@ -532,10 +532,10 @@ zprinto(ZVALUE z, long width) * Decimals supplies number of decimal places to print, with a decimal * point at the right location, with zero meaning no decimal point. * Width is the number of columns to print the number in, including the - * decimal point and sign if required. If zero, no extra output is done. + * decimal point and sign if required. If zero, no extra output is done. * If positive, leading spaces are typed if necessary. If negative, trailing * spaces are typed if necessary. As examples of the effects of these values, - * (345,0,0) = "345", (345,2,0) = "3.45", (345,5,8) = " .00345". + * (345,0,0) = "345", (345,2,0) = "3.45", (345,5,8) = " .00345". * * given: * z number to be printed @@ -651,7 +651,7 @@ zprintval(ZVALUE z, long decimals, long width) /* * Read an integer value in decimal, hex, octal, or binary. * Hex numbers are indicated by a leading "0x", binary with a leading "0b", - * and octal by a leading "0". Periods are skipped over, but any other + * and octal by a leading "0". Periods are skipped over, but any other * extraneous character stops the scan. */ void diff --git a/zmath.c b/zmath.c index 058232c..6d4a984 100644 --- a/zmath.c +++ b/zmath.c @@ -120,8 +120,8 @@ HALF lowhalf[BASEB+1] = { 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, - 0x1FF, 0x3FF, 0x7FF, 0xFFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF + 0x1FF, 0x3FF, 0x7FF, 0xFFF, + 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF #if BASEB == 32 ,0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, @@ -400,7 +400,7 @@ zadd(ZVALUE z1, ZVALUE z2, ZVALUE *res) while (len--) { sival.ivalue = ((FULL) *p1++) + ((FULL) *p2++) + carry; /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name zadd`sival */ + /* ok to ignore on name zadd`sival */ *pd++ = sival.silow; carry = sival.sihigh; } @@ -470,7 +470,7 @@ zsub(ZVALUE z1, ZVALUE z2, ZVALUE *res) carry = 0; while (--len2 >= 0) { /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name zsub`sival */ + /* ok to ignore on name zsub`sival */ sival.ivalue = (BASE1 - ((FULL) *h1++)) + *h2++ + carry; *hd++ = (HALF)(BASE1 - sival.silow); carry = sival.sihigh; @@ -531,7 +531,7 @@ zmuli(ZVALUE z, long n, ZVALUE *res) carry = 0; while (len--) { /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name zmuli`sival */ + /* ok to ignore on name zmuli`sival */ sival.ivalue = ((FULL) *h1++) * low + carry; *sd++ = sival.silow; carry = sival.sihigh; @@ -755,7 +755,7 @@ done: while (m > 0 && A[m - 1] == 0) if (g > 0 && g < BASE) t = 1; else if (g == 0 && f == 0) - t = 0; + t = 0; } if (t) adjust = (t > 0); @@ -816,9 +816,9 @@ done: while (m > 0 && A[m - 1] == 0) val = rem->sign ? -1 : 1; if (a1[len - 1] == 0) len--; - if (len == 0) + if (len == 0) { *quo = _zero_; - else { + } else { quo->len = len; quo->v = alloc(len); memcpy(quo->v, a1, len * sizeof(HALF)); @@ -926,7 +926,7 @@ zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res) v |= B[1] << j; u = v - 1; w = x = 1; - while (u) { /* To find w = inverse of v modulo BASE */ + while (u) { /* To find w = inverse of v modulo BASE */ do { v <<= 1; x <<= 1; @@ -1318,8 +1318,7 @@ zxor(ZVALUE z1, ZVALUE z2, ZVALUE *res) j = z1.len; h1 = z2.v; h2 = z1.v; - } - else if (z1.len == z2.len) { + } else if (z1.len == z2.len) { while (len > 1 && z1.v[len-1] == z2.v[len-1]) len--; j = len; @@ -1353,8 +1352,7 @@ zandnot(ZVALUE z1, ZVALUE z2, ZVALUE *res) len--; j = len; k = 0; - } - else { + } else { j = z2.len; k = len - z2.len; } @@ -1505,41 +1503,6 @@ zhighbit(ZVALUE z) } -#if 0 -/* - * Reverse the bits of a particular range of bits of a number. - * - * This function returns an integer with bits a thru b swapped. - * That is, bit a is swapped with bit b, bit a+1 is swapped with b-1, - * and so on. - * - * As a special case, if the ending bit position is < 0, is it taken to - * mean the highest bit set. Thus zbitrev(0, -1, z, &res) will - * perform a complete bit reverse of the number 'z'. - * - * As a special case, if the starting bit position is < 0, is it taken to - * mean the lowest bit set. Thus zbitrev(-1, -1, z, &res) is the - * same as zbitrev(lowbit(z), highbit(z), z, &res). - * - * Note that the low order bit number is taken to be 0. Also, bitrev - * ignores the sign of the number. - * - * Bits beyond the highest bit are taken to be zero. Thus the calling - * bitrev(0, 100, _one_, &res) will result in a value of 2^100. - * - * given: - * low lowest bit to reverse, <0 => lowbit(z) - * high highest bit to reverse, <0 => highbit(z) - * z value to bit reverse - * res resulting bit reverse number - */ -void -zbitrev(long low, long high, ZVALUE z, ZVALUE *res) -{ -} -#endif - - /* * Return whether or not the specifed bit number is set in a number. * Rightmost bit of a number is bit 0. @@ -1857,7 +1820,7 @@ zshiftr(ZVALUE z, long n) * Utility routine to shift left. * * NOTE: The ZVALUE length is not adjusted. The bits in the upper - * HALF are simply tossed. You may want to use zshift() instead. + * HALF are simply tossed. You may want to use zshift() instead. */ void zshiftl(ZVALUE z, long n) diff --git a/zmath.h b/zmath.h index e280e36..5c0e66f 100644 --- a/zmath.h +++ b/zmath.h @@ -10,7 +10,7 @@ #if !defined(__ZMATH_H__) -#define __ZMATH_H__ +#define __ZMATH_H__ #include "alloc.h" @@ -31,10 +31,10 @@ #if !defined(TRUE) -#define TRUE ((BOOL) 1) /* booleans */ +#define TRUE ((BOOL) 1) /* booleans */ #endif #if !defined(FALSE) -#define FALSE ((BOOL) 0) +#define FALSE ((BOOL) 0) #endif @@ -89,17 +89,17 @@ typedef SB32 SFULL; /* signed FULL */ #define BASE ((FULL)1< /\../\ + * chongo /\../\ * * Note that the \'s above are not back-slashing escape characters. * They are literal ASCII backslash 0x5c characters. @@ -191,14 +191,14 @@ typedef SB32 LEN; /* unit of length storage */ /* * LEN storage size must be <= FULL storage size */ -#define MAXLEN ((LEN) 0x7fffffff >> 3) /* longest value allowed */ +#define MAXLEN ((LEN) 0x7fffffff >> 3) /* longest value allowed */ -#define MAXREDC 5 /* number of entries in REDC cache */ -#define SQ_ALG2 20 /* size for alternative squaring */ -#define MUL_ALG2 20 /* size for alternative multiply */ -#define POW_ALG2 40 /* size for using REDC for powers */ -#define REDC_ALG2 50 /* size for using alternative REDC */ +#define MAXREDC 5 /* number of entries in REDC cache */ +#define SQ_ALG2 20 /* size for alternative squaring */ +#define MUL_ALG2 20 /* size for alternative multiply */ +#define POW_ALG2 40 /* size for using REDC for powers */ +#define REDC_ALG2 50 /* size for using alternative REDC */ typedef union { @@ -220,10 +220,10 @@ typedef union { #if CALC_BYTE_ORDER == LITTLE_ENDIAN # define silow sis.Svalue1 /* low order half of full value */ -# define sihigh sis.Svalue2 /* high order half of full value */ +# define sihigh sis.Svalue2 /* high order half of full value */ #else # if CALC_BYTE_ORDER == BIG_ENDIAN -# define silow sis.Svalue2 /* low order half of full value */ +# define silow sis.Svalue2 /* low order half of full value */ # define sihigh sis.Svalue1 /* high order half of full value */ # else /\oo/\ CALC_BYTE_ORDER must be BIG_ENDIAN or LITTLE_ENDIAN /\oo/\ !!! @@ -349,11 +349,6 @@ extern void zlcmfact(ZVALUE z, ZVALUE *dest); /* * Misc misc functions. :-) */ -#if 0 -extern void zapprox(ZVALUE z1, ZVALUE z2, ZVALUE *res1, ZVALUE *res2); -extern void zmulmod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res); -extern void zsubmod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res); -#endif extern void zsquaremod(ZVALUE z1, ZVALUE z2, ZVALUE *res); extern void zminmod(ZVALUE z1, ZVALUE z2, ZVALUE *res); extern BOOL zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3); @@ -376,7 +371,7 @@ extern HALF *zalloctemp(LEN len); * calculations with more than one modulus at the same time. * Len of zero means the structure is not initialized. */ -typedef struct { +typedef struct { LEN len; /* number of words in binary modulus */ ZVALUE mod; /* modulus REDC is computing with */ ZVALUE inv; /* inverse of modulus in binary modulus */ @@ -441,15 +436,15 @@ extern void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res); /* * Some algorithms testing for values of a certain length. Macros such as * zistiny() do this well. In other cases algorthms require tests for values - * in comparison to a given power of 2. In the later case, zistiny() compares - * against a different power of 2 on a 64 bit machine. The macros below + * in comparison to a given power of 2. In the later case, zistiny() compares + * against a different power of 2 on a 64 bit machine. The macros below * provide a tests against powers of 2 that are independent of the work size. * - * zge16b(z) TRUE if abs(z) >= 2^16 - * zge24b(z) TRUE if abs(z) >= 2^24 - * zge31b(z) TRUE if abs(z) >= 2^31 - * zge32b(z) TRUE if abs(z) >= 2^32 - * zge64b(z) TRUE if abs(z) >= 2^64 + * zge16b(z) TRUE if abs(z) >= 2^16 + * zge24b(z) TRUE if abs(z) >= 2^24 + * zge31b(z) TRUE if abs(z) >= 2^31 + * zge32b(z) TRUE if abs(z) >= 2^32 + * zge64b(z) TRUE if abs(z) >= 2^64 */ #if BASEB == 32 @@ -504,11 +499,11 @@ extern void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res); */ #define ztolong(z) ((long)(ztoulong(z) & MAXLONG)) -#define zclearval(z) memset((z).v, 0, (z).len * sizeof(HALF)) -#define zcopyval(z1,z2) memcpy((z2).v, (z1).v, (z1).len * sizeof(HALF)) +#define zclearval(z) memset((z).v, 0, (z).len * sizeof(HALF)) +#define zcopyval(z1,z2) memcpy((z2).v, (z1).v, (z1).len * sizeof(HALF)) #define zquicktrim(z) {if (((z).len > 1) && ((z).v[(z).len-1] == 0)) \ (z).len--;} -#define zfree(z) freeh((z).v) +#define zfree(z) freeh((z).v) /* @@ -631,7 +626,7 @@ typedef struct { #else - /\../\ FULL_BITS must be 32 or 64 /\../\ !!! + /\../\ FULL_BITS must be 32 or 64 /\../\ !!! #endif diff --git a/zmod.c b/zmod.c index 176a0f1..a34fd74 100644 --- a/zmod.c +++ b/zmod.c @@ -5,7 +5,7 @@ * * Routines to do modulo arithmetic both normally and also using the REDC * algorithm given by Peter L. Montgomery in Mathematics of Computation, - * volume 44, number 170 (April, 1985). For multiple multiplies using + * volume 44, number 170 (April, 1985). For multiple multiplies using * the same large modulus, the REDC algorithm avoids the usual division * by the modulus, instead replacing it with two multiplies or else a * special algorithm. When these two multiplies or the special algorithm @@ -17,8 +17,8 @@ #include "zmath.h" -#define POWBITS 4 /* bits for power chunks (must divide BASEB) */ -#define POWNUMS (1< z3.len)) { - zmod(tmp, z3, res, 0); - zfree(tmp); - return; - } - sumdigit = tmp.v[tmp.len - 1]; - moddigit = z3.v[z3.len - 1]; - if ((tmp.len < z3.len) || (sumdigit < moddigit)) { - *res = tmp; - return; - } - if (sumdigit < 2 * moddigit) { - zsub(tmp, z3, res); - zfree(tmp); - return; - } - zmod(tmp, z2, res, 0); - zfree(tmp); -} - - -/* - * Subtract two numbers together and then mod the result with a third number. - * The two numbers to be subtract can be negative or out of modulo range. - * The result will be in the range 0 to the modulus - 1. - * - * given: - * z1 number to be subtracted from - * z2 number to be subtracted - * z3 number to take mod with - * res result - */ -void -zsubmod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res) -{ - if (ziszero(z3) || zisneg(z3)) { - math_error("Mod of non-positive integer"); - /*NOTREACHED*/ - } - if (ziszero(z2)) { - zmod(z1, z3, res, 0); - return; - } - if (ziszero(z1)) { - znegmod(z2, z3, res); - return; - } - if ((z1.sign == z2.sign) && (z1.len == z2.len) && - (z1.v[0] == z2.v[0]) && (zcmp(z1, z2) == 0)) { - *res = _zero_; - return; - } - z2.sign = !z2.sign; - zaddmod(z1, z2, z3, res); -} - - -/* - * Calculate the negative of a number modulo another number. - * The number to be negated can be negative or out of modulo range. - * The result will be in the range 0 to the modulus - 1. - * - * given: - * z1 number to take negative of - * z2 number to take mod with - * res result - */ -static void -znegmod(ZVALUE z1, ZVALUE z2, ZVALUE *res) -{ - int sign; - int cv; - - if (ziszero(z2) || zisneg(z2)) { - math_error("Mod of non-positive integer"); - /*NOTREACHED*/ - } - if (ziszero(z1) || zisunit(z2)) { - *res = _zero_; - return; - } - if (zistwo(z2)) { - if (z1.v[0] & 0x1) - *res = _one_; - else - *res = _zero_; - return; - } - - /* - * If the absolute value of the number is within the modulo range, - * then the result is just a copy or a subtraction. Otherwise go - * ahead and negate and reduce the result. - */ - sign = z1.sign; - z1.sign = 0; - cv = zrel(z1, z2); - if (cv == 0) { - *res = _zero_; - return; - } - if (cv < 0) { - if (sign) - zcopy(z1, res); - else - zsub(z2, z1, res); - return; - } - z1.sign = !sign; - zmod(z1, z2, res, 0); -} -#endif - - /* * Calculate the number congruent to the given number whose absolute * value is minimal. The number to be reduced can be negative or out of * modulo range. The result will be within the range -int((modulus-1)/2) - * to int(modulus/2) inclusive. For example, for modulus 7, numbers are + * to int(modulus/2) inclusive. For example, for modulus 7, numbers are * reduced to the range [-3, 3], and for modulus 8, numbers are reduced to * the range [-3, 4]. * @@ -477,8 +259,7 @@ zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3) */ if ((tmp1.sign == tmp2.sign) && ((tmp1.len < len) || (zrel(tmp1, z3) < 0)) && - ((tmp2.len < len) || (zrel(tmp2, z3) < 0))) - { + ((tmp2.len < len) || (zrel(tmp2, z3) < 0))) { if (tmp1.v != z1.v) zfree(tmp1); if (tmp2.v != z2.v) @@ -665,8 +446,8 @@ zmod6(ZVALUE z1, ZVALUE *res) * This calculates the result by examining the power POWBITS bits at a time, * using a small table of POWNUMS low powers to calculate powers for those bits, * and repeated squaring and multiplying by the partial powers to generate - * the complete power. If the power being raised to is high enough, then - * this uses the REDC algorithm to avoid doing many divisions. When using + * the complete power. If the power being raised to is high enough, then + * this uses the REDC algorithm to avoid doing many divisions. When using * REDC, multiple calls to this routine using the same modulus will be * slightly faster. */ @@ -747,8 +528,7 @@ zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res) /* * If modulus is large enough use zmod5 */ - if (z3.len >= conf->pow2) - { + if (z3.len >= conf->pow2) { if (havelastmod && zcmp(z3, *lastmod)) { zfree(*lastmod); zfree(*lastmodinv); @@ -867,10 +647,9 @@ zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res) /* * If the modulus is odd and small enough then use - * the REDC algorithm. The size where this is done is configurable. + * the REDC algorithm. The size where this is done is configurable. */ - if (z3.len < conf->redc2 && zisodd(z3)) - { + if (z3.len < conf->redc2 && zisodd(z3)) { if (powermodredc && zcmp(powermodredc->mod, z3)) { zredcfree(powermodredc); powermodredc = NULL; @@ -1045,7 +824,7 @@ zredcmodinv(ZVALUE z, ZVALUE *res) /* * Initialize the REDC algorithm for a particular modulus, * returning a pointer to a structure that is used for other - * REDC calls. An error is generated if the structure cannot + * REDC calls. An error is generated if the structure cannot * be allocated. The modulus must be odd and positive. * * given: @@ -1071,7 +850,7 @@ zredcalloc(ZVALUE z1) /* * Round up the binary modulus to the next power of two - * which is at a word boundary. Then the shift and modulo + * which is at a word boundary. Then the shift and modulo * operations mod the binary modulus can be done very cheaply. * Calculate the REDC format for the number 1 for future use. */ @@ -1111,7 +890,7 @@ zredcfree(REDC *rp) * The resulting number can be used for multiplying, adding, subtracting, * or comparing with any other such converted numbers, as if the numbers * were being calculated modulo the number which initialized the REDC - * information. When the final value is unconverted, the result is the + * information. When the final value is unconverted, the result is the * same as if the usual operations were done with the original numbers. * * given: @@ -1283,17 +1062,16 @@ zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res) if (len == 0) len = 1; res->len = len; - } - else { - /* Here 0 < z1 < 2^bitnum */ + } else { + /* Here 0 < z1 < 2^bitnum */ - /* - * First calculate the following: - * tmp2 = ((z1 * inv) % 2^bitnum. - * The mod operations can be done with no work since the bit - * number was selected as a multiple of the word size. Just - * reduce the sizes of the numbers as required. - */ + /* + * First calculate the following: + * tmp2 = ((z1 * inv) % 2^bitnum. + * The mod operations can be done with no work since the bit + * number was selected as a multiple of the word size. Just + * reduce the sizes of the numbers as required. + */ zmul(z1, rp->inv, &tmp2); if (tmp2.len > modlen) { h1 = tmp2.v + modlen; @@ -1303,14 +1081,14 @@ zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res) tmp2.len = len; } - /* - * Next calculate the following: - * res = (z1 + tmp2 * modulus) / 2^bitnum - * Since 0 < z1 < 2^bitnum and the division is always exact, - * the quotient can be evaluated by rounding up - * (tmp2 * modulus)/2^bitnum. This can be achieved by defining - * zp1 by an appropriate shift and then adding one. - */ + /* + * Next calculate the following: + * res = (z1 + tmp2 * modulus) / 2^bitnum + * Since 0 < z1 < 2^bitnum and the division is always exact, + * the quotient can be evaluated by rounding up + * (tmp2 * modulus)/2^bitnum. This can be achieved by defining + * zp1 by an appropriate shift and then adding one. + */ zmul(tmp2, rp->mod, &tmp1); zfree(tmp2); if (tmp1.len > modlen) { @@ -1318,9 +1096,9 @@ zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res) zp1.len = tmp1.len - modlen; zp1.sign = 0; zadd(zp1, _one_, res); - } - else + } else { *res = _one_; + } zfree(tmp1); } if (ztop.len) { @@ -1355,7 +1133,7 @@ zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res) * Multiply two numbers in REDC format together producing a result also * in REDC format. If the result is converted back to a normal number, * then the result is the same as the modulo'd multiplication of the - * original numbers before they were converted to REDC format. This + * original numbers before they were converted to REDC format. This * calculation is done in one of two ways, depending on the size of the * modulus. For large numbers, the REDC definition is used directly * which involves three multiplies overall. For small numbers, a @@ -1467,7 +1245,7 @@ zredcmul(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res) /* * The number is small enough to calculate by doing the O(N^2) REDC - * algorithm directly. This algorithm performs the multiplication and + * algorithm directly. This algorithm performs the multiplication and * the reduction at the same time. Notice the obscure facts that * only the lowest word of the inverse value is used, and that * there is no shifting of the partial products as there is in a @@ -1619,7 +1397,7 @@ zredcmul(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res) /* * Do a subtraction to reduce the result to a value less than - * the modulus. The REDC algorithm guarantees that a single subtract + * the modulus. The REDC algorithm guarantees that a single subtract * is all that is needed. Ignore any borrowing from the possible * highest word of the current result because that would affect * only the top digit value that was not stored and would become @@ -2033,9 +1811,9 @@ zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res) if (sign && !ziszero(ans)) { zsub(rp->mod, ans, res); zfree(ans); - } - else + } else { *res = ans; + } if (ztmp.len) zfree(ztmp); } diff --git a/zmul.c b/zmul.c index 67897c1..aa7c7a2 100644 --- a/zmul.c +++ b/zmul.c @@ -56,10 +56,10 @@ zmul(ZVALUE z1, ZVALUE z2, ZVALUE *res) /* * Allocate a temporary buffer for the recursion levels to use. * An array needs to be allocated large enough for all of the - * temporary results to fit in. This size is about twice the size + * temporary results to fit in. This size is about twice the size * of the largest original number, since each recursion level uses * the size of its given number, and whose size is 1/2 the size of - * the previous level. The sum of the infinite series is 2. + * the previous level. The sum of the infinite series is 2. * Add some extra words because of rounding when dividing by 2 * and also because of the extra word that each multiply needs. */ @@ -160,7 +160,7 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) /* * If the smaller number has only a few digits, then calculate * the result in the normal manner in order to avoid the overhead - * of the recursion for small numbers. The number of digits where + * of the recursion for small numbers. The number of digits where * the algorithm changes is settable from 2 to maxint. */ if (size2 < conf->mul2) { @@ -183,7 +183,7 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) len -= 4; sival.ivalue = ((FULL) *h1++) * digit + carry; /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name domul`sival */ + /* ok to ignore on name domul`sival */ *hd++ = sival.silow; carry = sival.sihigh; sival.ivalue = ((FULL) *h1++) * digit + carry; @@ -263,8 +263,8 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) /* * Need to multiply by a large number. * Allocate temporary space for calculations, and calculate the - * value for the shift. The shift value is 1/2 the size of the - * larger (first) number (rounded up). The amount of temporary + * value for the shift. The shift value is 1/2 the size of the + * larger (first) number (rounded up). The amount of temporary * space needed is twice the size of the shift, plus one more word * for the multiply to use. */ @@ -326,58 +326,58 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) * The insure tool also reports a problem at this position: * * [zmul.c:319] **COPY_BAD_RANGE** - * >> baseC = v2 + shift; + * >> baseC = v2 + shift; * * Copying pointer which is out-of-range: v2 + shift * * [[NOTE: line numbers may have changed]] * - * Pointer : 0x1400919cc + * Pointer : 0x1400919cc * Actual block : 0x140090c80 thru 0x140090def (368 bytes,92 elements) - * hp, allocated at: - * malloc() - * alloc() zmath.c, 221 - * zmul() zmul.c, 73 - * ztenpow() zfunc.c, 441 - * str2q() qio.c, 537 - * addnumber() const.c, 52 - * eatnumber() token.c, 594 - * gettoken() token.c, 319 - * getcallargs() codegen.c, 2358 + * hp, allocated at: + * malloc() + * alloc() zmath.c, 221 + * zmul() zmul.c, 73 + * ztenpow() zfunc.c, 441 + * str2q() qio.c, 537 + * addnumber() const.c, 52 + * eatnumber() token.c, 594 + * gettoken() token.c, 319 + * getcallargs() codegen.c, 2358 * * Stack trace where the error occurred: - * domul() zmul.c, 319 - * zmul() zmul.c, 74 - * ztenpow() zfunc.c, 441 - * str2q() qio.c, 537 - * addnumber() const.c, 52 - * eatnumber() token.c, 594 - * gettoken() token.c, 319 - * getcallargs() codegen.c, 2358 - * getidexpr() codegen.c, 1998 - * getterm() codegen.c, 1936 - * getincdecexpr() codegen.c, 1820 - * getreference() codegen.c, 1804 - * getshiftexpr() codegen.c, 1758 - * getandexpr() codegen.c, 1704 - * getorexpr() codegen.c, 1682 - * getproduct() codegen.c, 1654 - * getsum() codegen.c, 1626 - * getrelation() codegen.c, 1585 - * getandcond() codegen.c, 1556 - * getorcond() codegen.c, 1532 - * getaltcond() codegen.c, 1499 - * getassignment() codegen.c, 1442 - * getopassignment() codegen.c, 1352 - * getexprlist() codegen.c, 1318 - * getstatement() codegen.c, 921 - * evaluate() codegen.c, 219 - * getcommands() codegen.c, 165 - * main() calc.c, 321 + * domul() zmul.c, 319 + * zmul() zmul.c, 74 + * ztenpow() zfunc.c, 441 + * str2q() qio.c, 537 + * addnumber() const.c, 52 + * eatnumber() token.c, 594 + * gettoken() token.c, 319 + * getcallargs() codegen.c, 2358 + * getidexpr() codegen.c, 1998 + * getterm() codegen.c, 1936 + * getincdecexpr() codegen.c, 1820 + * getreference() codegen.c, 1804 + * getshiftexpr() codegen.c, 1758 + * getandexpr() codegen.c, 1704 + * getorexpr() codegen.c, 1682 + * getproduct() codegen.c, 1654 + * getsum() codegen.c, 1626 + * getrelation() codegen.c, 1585 + * getandcond() codegen.c, 1556 + * getorcond() codegen.c, 1532 + * getaltcond() codegen.c, 1499 + * getassignment() codegen.c, 1442 + * getopassignment() codegen.c, 1352 + * getexprlist() codegen.c, 1318 + * getstatement() codegen.c, 921 + * evaluate() codegen.c, 219 + * getcommands() codegen.c, 165 + * main() calc.c, 321 * * The final domul() call point is the next executable line below. */ - /* ok to ignore on name domul`baseC */ + /* ok to ignore on name domul`baseC */ baseC = v2 + shift; baseD = v2; baseAB = ans; @@ -464,11 +464,11 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) * Note: step (*) above can produce a result which is larger than * the final product will be, and this is where the extra word * needed in the product comes from. After the final subtraction is - * done, the result fits in the expected size. Using the extra word + * done, the result fits in the expected size. Using the extra word * is easier than suppressing the carries and borrows everywhere. * * Begin by forming the product (A-B)*(D-C) into a temporary - * location that we save until the final step. Do each subtraction + * location that we save until the final step. Do each subtraction * at positions 0 and S. Be very careful about the relative sizes * of the numbers since this result can be negative. For the first * step calculate the absolute difference of A and B into a temporary @@ -520,7 +520,7 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) } /* - * This completes the calculation of abs(A-B). For the next step + * This completes the calculation of abs(A-B). For the next step * calculate the absolute difference of D and C into a temporary * location at position S of the result. Negate the sign if C is * larger than D. @@ -535,8 +535,7 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) h2--; } } - if ((sizeC > sizeD) || ((sizeC == sizeD) && (*h1 > *h2))) - { + if ((sizeC > sizeD) || ((sizeC == sizeD) && (*h1 > *h2))) { neg = !neg; h1 = baseC; h2 = baseD; @@ -569,7 +568,7 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans) } /* - * This completes the calculation of abs(D-C). Now multiply + * This completes the calculation of abs(D-C). Now multiply * together abs(A-B) and abs(D-C) into a temporary location, * which is preserved until the final steps. */ @@ -738,7 +737,7 @@ zsquare(ZVALUE z, ZVALUE *res) /* * Allocate a temporary array if necessary for the recursion to use. * The array needs to be allocated large enough for all of the - * temporary results to fit in. This size is about 3 times the + * temporary results to fit in. This size is about 3 times the * size of the original number, since each recursion level uses 3/2 * of the size of its given number, and whose size is 1/2 the size * of the previous level. The sum of the infinite series is 3. @@ -886,7 +885,7 @@ dosquare(HALF *vp, LEN size, HALF *ans) digit = ((FULL) *hd); sival.ivalue = digit + digit + carry; /* ignore Saber-C warning #112 - get ushort from uint */ - /* ok to ignore on name dosquare`sival */ + /* ok to ignore on name dosquare`sival */ *hd++ = sival.silow; carry = sival.sihigh; } @@ -1046,8 +1045,7 @@ dosquare(HALF *vp, LEN size, HALF *ans) h2--; } } - if ((sizeA > sizeB) || ((sizeA == sizeB) && (*h1 > *h2))) - { + if ((sizeA > sizeB) || ((sizeA == sizeB) && (*h1 > *h2))) { h1 = baseA; h2 = baseB; sizeAB = sizeA; @@ -1155,5 +1153,3 @@ zalloctemp(LEN len) buflen = len; return hp; } - -/* END CODE */ diff --git a/zprime.c b/zprime.c index 926c2ff..9ff4655 100644 --- a/zprime.c +++ b/zprime.c @@ -90,10 +90,10 @@ static CONST unsigned char topbit[256] = { * We have enough table entries for a FULL that is 64 bits long. */ static CONST FULL isqrt_pow2[64] = { - 1, 1, 2, 2, 4, 5, 8, 11, /* 0 .. 7 */ + 1, 1, 2, 2, 4, 5, 8, 11, /* 0 .. 7 */ 16, 22, 32, 45, 64, 90, 128, 181, /* 8 .. 15 */ - 256, 362, 512, 724, 1024, 1448, 2048, 2896, /* 16 .. 23 */ - 4096, 5792, 8192, 11585, 16384, 23170, 32768, 46340, /* 24 .. 31 */ + 256, 362, 512, 724, 1024, 1448, 2048, 2896, /* 16 .. 23 */ + 4096, 5792, 8192, 11585, 16384, 23170, 32768, 46340, /* 24 .. 31 */ 65536, 92681, 131072, 185363, /* 32 .. 35 */ 262144, 370727, 524288, 741455, /* 36 .. 39 */ 1048576, 1482910, 2097152, 2965820, /* 40 .. 43 */ @@ -109,7 +109,7 @@ static CONST FULL isqrt_pow2[64] = { */ static FULL fsqrt(FULL v); /* quick square root of v */ static long pix(FULL x); /* pi of x */ -static FULL small_factor(ZVALUE n, FULL limit); /* factor or 0 */ +static FULL small_factor(ZVALUE n, FULL limit); /* factor or 0 */ /* @@ -136,7 +136,7 @@ zisprime(ZVALUE z) if (ziseven(z)) { /* * "2 is the greatest odd prime because it is the least even!" - * - Dr. Dan Jurca 1978 + * - Dr. Dan Jurca 1978 */ return zisabstwo(z); } @@ -159,7 +159,7 @@ zisprime(ZVALUE z) /* a number >=2^16 and < 2^32 */ for (isqr=fsqrt(n), tp=prime; (*tp <= isqr) && (n % *tp); ++tp) { } - return ((*tp <= isqr && *tp != 1) ? 0 : 1); + return ((*tp <= isqr && *tp != 1) ? 0 : 1); } @@ -306,7 +306,7 @@ zpprime(ZVALUE z) CONST unsigned char *j; /* current jump increment */ int tmp; - z.sign = 0; + z.sign = 0; /* ignore large values */ if (zge32b(z)) { @@ -890,7 +890,7 @@ zpfact(ZVALUE z, ZVALUE *dest) * * It is interesting to note that ptest(a,1,x) (for any x >= 0) of this * test will always return TRUE for a prime, and rarely return TRUE for - * a non-prime. The 1/4 is appears in practice to be a poor upper + * a non-prime. The 1/4 is appears in practice to be a poor upper * bound. Even so the only result that is EXACT and TRUE is when * this test returns FALSE for a non-prime. When ptest returns TRUE, * one cannot determine if the value in question is prime, or the value @@ -973,15 +973,13 @@ zprimetest(ZVALUE z, long count, ZVALUE skip) if (ziszero(skip)) { type = 0; zbase = _zero_; - } - else if (zisone(skip)) { + } else if (zisone(skip)) { type = 1; itoz(2, &zbase); limit = 1 << 16; if (!zge16b(z)) limit = ztolong(z); - } - else { + } else { type = 2; if (zrel(skip, z) >= 0 || zisneg(skip)) zmod(skip, z, &zbase, 0); @@ -1024,7 +1022,7 @@ zprimetest(ZVALUE z, long count, ZVALUE skip) zpowermod(zbase, z1, z, &z3); for (;;) { if (zisone(z3)) { - if (ij) { + if (ij) { /* number is definitely not prime */ zfree(z3); zfree(zm1); @@ -1082,15 +1080,13 @@ zredcprimetest(ZVALUE z, long count, ZVALUE skip) if (ziszero(skip)) { zbase = _zero_; type = 0; - } - else if (zisone(skip)) { + } else if (zisone(skip)) { itoz(2, &zbase); type = 1; limit = 1 << 16; if (!zge16b(z)) limit = ztolong(z); - } - else { + } else { zredcencode(rp, skip, &zbase); type = 2; } @@ -1147,7 +1143,7 @@ zredcprimetest(ZVALUE z, long count, ZVALUE skip) zredcpower(rp, zbase, z1, &z3); for (;;) { if (!zcmp(z3, rp->one)) { - if (ij) { + if (ij) { /* number is definitely not prime */ zfree(z3); zfree(zm1); @@ -1190,7 +1186,7 @@ zredcprimetest(ZVALUE z, long count, ZVALUE skip) /* * znextcand - find the next integer that passes ptest(). - * The signs of z and mod are ignored. Result is the least integer + * The signs of z and mod are ignored. Result is the least integer * greater than abs(z) congruent to res modulo abs(mod), or if there * is no such integer, zero. * @@ -1208,7 +1204,7 @@ znextcand(ZVALUE z, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *can ZVALUE tmp1; ZVALUE tmp2; - z.sign = 0; + z.sign = 0; mod.sign = 0; if (ziszero(mod)) { if (zrel(res, z) > 0 && zprimetest(res, count, skip)) { @@ -1269,7 +1265,7 @@ znextcand(ZVALUE z, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *can /* * zprevcand - find the nearest previous integer that passes ptest(). - * The signs of z and mod are ignored. Result is greatest positive integer + * The signs of z and mod are ignored. Result is greatest positive integer * less than abs(z) congruent to res modulo abs(mod), or if there * is no such integer, zero. * @@ -1287,7 +1283,7 @@ zprevcand(ZVALUE z, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *can ZVALUE tmp1; ZVALUE tmp2; - z.sign = 0; + z.sign = 0; mod.sign = 0; if (ziszero(mod)) { if (zispos(res)&&zrel(res, z)<0 && zprimetest(res,count,skip)) { diff --git a/zrand.c b/zrand.c index aaebb93..9c78e1e 100644 --- a/zrand.c +++ b/zrand.c @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -117,7 +117,7 @@ * * shuffle table - 256 entries of 64 bits used by the shuffle * part of the a55 generator and feed by the - * additive table. + * additive table. * * Casual direct use of the shuffle generator may be acceptable. If one * desires cryptographically strong random numbers, or if one is paranoid, @@ -131,7 +131,7 @@ * * rand() * - * Same as rand(0, 2^64). Print 64 bits. + * Same as rand(0, 2^64). Print 64 bits. * * rand(lim) (where 0 > lim) * @@ -318,7 +318,7 @@ * FOR THE PARANOID: * * The truly paranoid might suggest that my claims in the MAGIC NUMBERS - * section are a lie intended to entrap people. Well they are not, but + * section are a lie intended to entrap people. Well they are not, but * you need not take my word for it. * * The random numbers from the Rand Book of Random Numbers can be @@ -350,7 +350,7 @@ * so that srand(0) does the default action and randreseed64() remains * an 1-to-1 and onto map. Thus calling srand(0) with the randreseed64() * process would be the same as calling srand(4967126403401436567) without - * it. No extra security is gained or reduced by using the randreseed64() + * it. No extra security is gained or reduced by using the randreseed64() * process. The meaning of seeds are exchanged, but not lost or favored * (used by more than one input seed). */ @@ -374,7 +374,7 @@ static CONST RAND init_a55 = { #elif 2*FULL_BITS == SBITS {0, 0}, #else - /\../\ BASEB is assumed to be 16 or 32 /\../\ !!! + /\../\ BASEB is assumed to be 16 or 32 /\../\ !!! #endif 3, /* j */ 34, /* k */ @@ -488,7 +488,7 @@ static CONST RAND init_a55 = { SVAL(fa2bed49,9a7244cd), SVAL(847c40e5,213a970a), SVAL(c685f1a0,b28f5cd8), SVAL(7b097038,1d22ad26), SVAL(ce00b094,05b5d608), SVAL(a3572534,b519bc02), SVAL(74cbc38f,e7cd0932) - } + } }; /* @@ -528,7 +528,7 @@ static CONST FULL additive[SCNT] = { /* * Linear Congruential Constants * - * a = 6316878969928993981 = 0x57aa0ff473c0ccbd + * a = 6316878969928993981 = 0x57aa0ff473c0ccbd * c = 1363042948800878693 = 0x12ea805718e09865 * * These constants are used in the randreseed64(). See below. @@ -612,7 +612,7 @@ static void slotcp64(BITSTR *bitstr, FULL *src); * a is prime * * The choice of an adder 'c' is considered immaterial according (based - * in note v). Knuth suggests 'c==1' or 'c==a'. We elect to select 'c' + * in note v). Knuth suggests 'c==1' or 'c==a'. We elect to select 'c' * using the same process as we used to select 'a'. The choice is * 'immaterial' after all, and as long as: * @@ -626,10 +626,10 @@ static void slotcp64(BITSTR *bitstr, FULL *src); * then the adders and multipliers will be more independent. * * We will obtain the values 'a' and 'c for our generator from the - * Rand Book of Random Numbers. Because m=2^64 is 20 decimal digits long, - * we will search the Rand Book of Random Numbers 20 at a time. We will + * Rand Book of Random Numbers. Because m=2^64 is 20 decimal digits long, + * we will search the Rand Book of Random Numbers 20 at a time. We will * skip any of the 55 values that were used to initialize the additive 55 - * generators. The values obtained from the Rand Book of Random Numbers are: + * generators. The values obtained from the Rand Book of Random Numbers are: * * a = 6316878969928993981 * c = 1363042948800878693 @@ -663,7 +663,7 @@ static void slotcp64(BITSTR *bitstr, FULL *src); * * To determine which value maps back into 0, we let z = 0 and compute: * - * ((0-c) * minv(a,m)) % m ==> 10239951819489363767 + * ((0-c) * minv(a,m)) % m ==> 10239951819489363767 * * and thus we find that the congruence generator would also normally map: * @@ -676,11 +676,11 @@ static void slotcp64(BITSTR *bitstr, FULL *src); * * To repeat, this function converts a values into a seed value. With the * except of 'seed == 0', every value is mapped into a unique seed value. - * This mapping need not be complex, random or secure. All we attempt + * This mapping need not be complex, random or secure. All we attempt * to do here is to allow humans who pick small or successive seed values * to obtain reasonably different sequences from the generators below. * - * NOTE: This is NOT a pseudo random number generator. This function is + * NOTE: This is NOT a pseudo random number generator. This function is * intended to be used internally by sa55rand() and sshufrand(). */ static void @@ -802,8 +802,8 @@ randreseed64(ZVALUE seed, ZVALUE *res) * zsrand - seed the a55 generator * * given: - * pseed - ptr to seed of the generator or NULL - * pmat55 - additive 55 state table or NULL + * pseed - ptr to seed of the generator or NULL + * pmat55 - additive 55 state table or NULL * * returns: * previous a55 state @@ -863,7 +863,7 @@ zsrand(CONST ZVALUE *pseed, CONST MATRIX *pmat55) /* * clear buffered bits, initialize pointers */ - a55.seeded = 0; /* not seeded now */ + a55.seeded = 0; /* not seeded now */ a55.j = INIT_J-1; a55.k = INIT_K-1; a55.bits = 0; @@ -927,32 +927,32 @@ zsrand(CONST ZVALUE *pseed, CONST MATRIX *pmat55) /* * shuffle additive 55 table according to seed, if passed */ - if (pseed != NULL && zge64b(zscram)) { + if (pseed != NULL && zge64b(zscram)) { - /* prepare the seed for additive slot shuffling */ - zshiftr(zscram, 64); + /* prepare the seed for additive slot shuffling */ + zshiftr(zscram, 64); ztrim(&zscram); - /* shuffle additive table */ - for (i=A55-1; i > 0 && !zislezero(zscram); --i) { + /* shuffle additive table */ + for (i=A55-1; i > 0 && !zislezero(zscram); --i) { - /* determine what we will swap with */ - indx = zdivi(zscram, i+1, &ztmp); + /* determine what we will swap with */ + indx = zdivi(zscram, i+1, &ztmp); zfree(zscram); zscram = ztmp; - /* do nothing if swap with itself */ - if (indx == i) { - continue; - } + /* do nothing if swap with itself */ + if (indx == i) { + continue; + } - /* swap slot[i] with slot[indx] */ - SSWAP(a55, i, indx); - } - zfree(zscram); + /* swap slot[i] with slot[indx] */ + SSWAP(a55, i, indx); + } + zfree(zscram); } else if (pseed != NULL) { - zfree(zscram); - } + zfree(zscram); + } /* * load the shuffle table @@ -1044,7 +1044,7 @@ zsetrand(CONST RAND *state) * * given: * bitstr - most significant destination bit in a bit string - * src - low order FULL in a 64 bit slot + * src - low order FULL in a 64 bit slot * count - number of bits to transfer (must be 0 < count <= 64) * * returns: @@ -1134,7 +1134,7 @@ slotcp(BITSTR *bitstr, FULL *src, int count) * load the 2nd most significant HALF */ if (need > BASEB) { - /* fill up the 2nd most significant HALF */ + /* fill up the 2nd most significant HALF */ *dh-- = (HALF)(src[SLEN-1] >> (BASEB-dnxtbit)); need -= BASEB; } else if (need > 0) { @@ -1182,7 +1182,7 @@ slotcp(BITSTR *bitstr, FULL *src, int count) * At this point, only 32 bit FULLs are operating. */ if (need > BASEB) { - /* fill up the 2nd most significant HALF */ + /* fill up the 2nd most significant HALF */ *dh-- = (HALF)(src[0] >> (BASEB-dnxtbit)); /* no need todo: need -= BASEB, because we are nearly done */ } else if (need > 0) { @@ -1214,13 +1214,13 @@ slotcp(BITSTR *bitstr, FULL *src, int count) * * The src slot is 64 bits long and is stored as an array of FULLs. * When FULL_BITS is 64 this array is 1 FULL, otherwise FULL_BITS - * is 32 bits and the array is 2 FULLs. The most significant bit + * is 32 bits and the array is 2 FULLs. The most significant bit * in the array (highest bit in the last FULL of the array) is to * be transfered to the most significant bit in the destination. * * given: * bitstr - most significant destination bit in a bit string - * src - low order FULL in a 64 bit slot + * src - low order FULL in a 64 bit slot * * returns: * number of bits transfered @@ -1343,7 +1343,7 @@ zrandskip(long cnt) } #endif a55.bits -= cnt; - return; /* skip need satisfied */ + return; /* skip need satisfied */ } /* @@ -1649,7 +1649,7 @@ zrandrange(CONST ZVALUE low, CONST ZVALUE high, ZVALUE *res) * generate a random value between [0, diff) * * We will not fall into the trap of thinking that we can simply take - * a value mod 'range'. Consider the case where 'range' is '80' + * a value mod 'range'. Consider the case where 'range' is '80' * and we are given pseudo-random numbers [0,100). If we took them * mod 80, then the numbers [0,20) would be produced more frequently * because the numbers [81,100) mod 80 wrap back into [0,20). diff --git a/zrand.h b/zrand.h index ee59e9e..e61d4ce 100644 --- a/zrand.h +++ b/zrand.h @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -39,7 +39,7 @@ #if !defined(__ZRAND_H__) -#define __ZRAND_H__ +#define __ZRAND_H__ #include "value.h" @@ -95,7 +95,7 @@ * * NOTE: Due to a SunOS cc bug, don't put spaces in the SHVAL call! * - * SLOAD(s,i,z) - load table slot i from additive 55 state s with zvalue z + * SLOAD(s,i,z) - load table slot i from additive 55 state s with zvalue z * s: type RAND * i: type int, s.slot[i] slot index * z: type ZVALUE, what to load into s.slot[i] @@ -118,9 +118,9 @@ * SSHUF(s,t,k) - save slot[k] into shuffle entry t * s: type RAND * t: type int, s.shuf[t] entry index, what gets changed - * k: type int, s.slot[k] slot index, load into s.shuf[t] + * k: type int, s.slot[k] slot index, load into s.shuf[t] * - * SSWAP(s,j,k) - swap slot[j] with slot[k] + * SSWAP(s,j,k) - swap slot[j] with slot[k] * s: type RAND * j: type int, s.slot[j] slot index, goes into s.slot[k] * k: type int, s.slot[k] slot index, goes into s.slot[j] @@ -177,7 +177,7 @@ # endif #define SLOAD(s,i,z) {(s).slot[(i)<<1] = ztofull(z); \ (s).slot[1+((i)<<1)] = \ - (((z).len <= 2) ? (FULL)0 : \ + (((z).len <= 2) ? (FULL)0 : \ (((z).len == 3) ? (FULL)((z).v[2]) : \ ((FULL)((z).v[2]) + ((FULL)((z).v[3]) << BASEB)))); \ } @@ -214,7 +214,7 @@ #else - /\../\ FULL_BITS must be 32 or 64 /\../\ !!! + /\../\ FULL_BITS must be 32 or 64 /\../\ !!! #endif diff --git a/zrandom.c b/zrandom.c index 21fc3ec..8141077 100644 --- a/zrandom.c +++ b/zrandom.c @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -77,7 +77,7 @@ * no better way to predict the sequence than by tossing a coin * (as with TRULY random numbers) EVEN IF YOU KNOW THE MODULUS! * Furthermore, having a large chunk of output from the sequence - * does not help. The BITS THAT FOLLOW OR PRECEDE A SEQUENCE + * does not help. The BITS THAT FOLLOW OR PRECEDE A SEQUENCE * ARE UNPREDICTABLE! * * Of course the Blum modulus should have a long period. The default @@ -131,7 +131,7 @@ * The Blum generator is the best generator in this package. It * produces a cryptographically strong pseudo-random bit sequence. * Internally, a fixed number of bits are generated after each - * generator iteration. Any unused bits are saved for the next call + * generator iteration. Any unused bits are saved for the next call * to the generator. The Blum generator is not too slow, though * seeding the generator via srandom(seed,plen,qlen) can be slow. * Shortcuts and pre-defined generators have been provided for this reason. @@ -153,7 +153,7 @@ * * randombit(x) (where x > 0) * - * Same as random(0, 2^x). Print x bits. + * Same as random(0, 2^x). Print x bits. * * randombit(skip) (where skip < 0) * @@ -334,12 +334,12 @@ * * The follow calc script produces an equivalent effect: * - * n = n[newn]; (* n is new Blum modulus, see below *) + * n = n[newn]; (* n is new Blum modulus, see below *) * r = seed; * do { * last_r = r; * r = pmod(last_r, 2, n); - * } while (r > last_r); (* r is the new quadratic residue *) + * } while (r > last_r); (* r is the new quadratic residue *) * * 0 < seed < 2^32, 0 < newn <= 20: * -------------------------------- @@ -369,12 +369,12 @@ * * for an explination of how the lavarand random number generator works. * - * For a given newn, we select a given bit length. For 0 < newn <= 20, + * For a given newn, we select a given bit length. For 0 < newn <= 20, * the bit length selected was by: * * bitlen = 2^(int((newn-1)/4)+7) + small_random_value; * - * where small_random_value is also generated by lavarand. For + * where small_random_value is also generated by lavarand. For * 1 <= newn <= 16, small_random_value is a random value in [0,40). * For 17 < newn <= 20, small_random_value is a random value in [0,120). * Given two random integers generated by lavarand, we used the following @@ -411,122 +411,122 @@ * For a given 'newn' the Blum modulus 'n[newn]' (product of 2 Blum * (primes) and new quadratic residue 'r[newn]' is set as follows: * - * newn == 1: (Blum modulus bit length 130) + * newn == 1: (Blum modulus bit length 130) * n[ 1] = 0x5049440736fe328caf0db722d83de9361 * r[ 1] = 0xb226980f11d952e74e5dbb01a4cc42ec * - * newn == 2: (Blum modulus bit length 137) + * newn == 2: (Blum modulus bit length 137) * n[ 2] = 0x2c5348a2555dd374a18eb286ea9353443f1 * r[ 2] = 0x40f3d643446cd710e3e893616b21e3a218 * - * newn == 3: (Blum modulus bit length 147) + * newn == 3: (Blum modulus bit length 147) * n[ 3] = 0x9cfd959d6ce4e3a81f1e0f2ca661f11d001f1 * r[ 3] = 0xfae5b44d9b64ff5cea4f3e142de2a0d7d76a * - * newn == 4: (Blum modulus bit length 157) + * newn == 4: (Blum modulus bit length 157) * n[ 4] = 0x3070f9245c894ed75df12a1a2decc680dfcc0751 * r[ 4] = 0x20c2d8131b2bdca2c0af8aa220ddba4b984570 * - * newn == 5: (Blum modulus bit length 257) + * newn == 5: (Blum modulus bit length 257) * n[ 5] = 0x2109b1822db81a85b38f75aac680bc2fa5d3fe1118769a0108b99e5e799 * 166ef1 * r[ 5] = 0x5e9b890eae33b792e821a9605f5df6db234f7b7d1e70aeed0e6c77c859e * 2efa9 * - * newn == 6: (Blum modulus bit length 259) + * newn == 6: (Blum modulus bit length 259) * n[ 6] = 0xa7bfd9d7d9ada2c79f2dbf2185c6440263a38db775ee732dad85557f1e1 * ddf431 * r[ 6] = 0x5e94a02f88667154e097aedece1c925ce1f3495d2c98eccfc5dc2e80c94 * 04daf * - * newn == 7: (Blum modulus bit length 286) + * newn == 7: (Blum modulus bit length 286) * n[ 7] = 0x43d87de8f2399ef237801cd5628643fcff569d6b0dcf53ce52882e7f602 - * f9125cf9ec751 + * f9125cf9ec751 * r[ 7] = 0x13522d1ee014c7bfbe90767acced049d876aefcf18d4dd64f0b58c3992d - * 2e5098d25e6 + * 2e5098d25e6 * - * newn == 8: (Blum modulus bit length 294) + * newn == 8: (Blum modulus bit length 294) * n[ 8] = 0x5847126ca7eb4699b7f13c9ce7bdc91fed5bdbd2f99ad4a6c2b59cd9f0b - * c42e66a26742f11 + * c42e66a26742f11 * r[ 8] = 0x853016dca3269116b7e661fa3d344f9a28e9c9475597b4b8a35da929aae - * 95f3a489dc674 + * 95f3a489dc674 * - * newn == 9: (Blum modulus bit length 533) + * newn == 9: (Blum modulus bit length 533) * n[ 9] = 0x39e8be52322fd3218d923814e81b003d267bb0562157a3c1797b4f4a867 - * 52a84d895c3e08eb61c36a6ff096061c6fd0fdece0d62b16b66b980f95112 + * 52a84d895c3e08eb61c36a6ff096061c6fd0fdece0d62b16b66b980f95112 * 745db4ab27e3d1 * r[ 9] = 0xb458f8ad1e6bbab915bfc01508864b787343bc42a8aa82d9d2880107e3f - * d8357c0bd02de3222796b2545e5ab7d81309a89baedaa5d9e8e59f959601e + * d8357c0bd02de3222796b2545e5ab7d81309a89baedaa5d9e8e59f959601e * f2b87d4ed20d * * newn == 10: (Blum modulus bit length 537) * n[10] = 0x25f2435c9055666c23ef596882d7f98bd1448bf23b50e88250d3cc952c8 - * 1b3ba524a02fd38582de74511c4008d4957302abe36c6092ce222ef9c73cc + * 1b3ba524a02fd38582de74511c4008d4957302abe36c6092ce222ef9c73cc * 3cdc363b7e64b89 * r[10] = 0x66bb7e47b20e0c18401468787e2b707ca81ec9250df8cfc24b5ffbaaf2c - * f3008ed8b408d075d56f62c669fadc4f1751baf950d145f40ce23442aee59 + * f3008ed8b408d075d56f62c669fadc4f1751baf950d145f40ce23442aee59 * 4f5ad494cfc482 * * newn == 11: (Blum modulus bit length 542) * n[11] = 0x497864de82bdb3094217d56b874ecd7769a791ea5ec5446757f3f9b6286 - * e58704499daa2dd37a74925873cfa68f27533920ee1a9a729cf522014dab2 + * e58704499daa2dd37a74925873cfa68f27533920ee1a9a729cf522014dab2 * 2e1a530c546ee069 * r[11] = 0x8684881cb5e630264a4465ae3af8b69ce3163f806549a7732339eea2c54 - * d5c590f47fbcedfa07c1ef5628134d918fee5333fed9c094d65461d88b13a + * d5c590f47fbcedfa07c1ef5628134d918fee5333fed9c094d65461d88b13a * 0aded356e38b04 * * newn == 12: (Blum modulus bit length 549) * n[12] = 0x3457582ab3c0ccb15f08b8911665b18ca92bb7c2a12b4a1a66ee4251da1 - * 90b15934c94e315a1bf41e048c7c7ce812fdd25d653416557d3f09887efad + * 90b15934c94e315a1bf41e048c7c7ce812fdd25d653416557d3f09887efad * 2b7f66d151f14c7b99 * r[12] = 0xdf719bd1f648ed935870babd55490137758ca3b20add520da4c5e8cdcbf - * c4333a13f72a10b604eb7eeb07c573dd2c0208e736fe56ed081aa9488fbc4 + * c4333a13f72a10b604eb7eeb07c573dd2c0208e736fe56ed081aa9488fbc4 * 5227dd68e207b4a0 * * newn == 13: (Blum modulus bit length 1048) * n[13] = 0x1517c19166b7dd21b5af734ed03d833daf66d82959a553563f4345bd439 - * 510a7bda8ee0cb6bf6a94286bfd66e49e25678c1ee99ceec891da8b18e843 + * 510a7bda8ee0cb6bf6a94286bfd66e49e25678c1ee99ceec891da8b18e843 * 7575113aaf83c638c07137fdd3a76c3a49322a11b5a1a84c32d99cbb2b056 * 671589917ed14cc7f1b5915f6495dd1892b4ed7417d79a63cc8aaa503a208 * e3420cca200323314fc49 * r[13] = 0xd42e8e9a560d1263fa648b04f6a69b706d2bc4918c3317ddd162cb4be7a - * 5e3bbdd1564a4aadae9fd9f00548f730d5a68dc146f05216fe509f0b8f404 + * 5e3bbdd1564a4aadae9fd9f00548f730d5a68dc146f05216fe509f0b8f404 * 902692de080bbeda0a11f445ff063935ce78a67445eae5c9cea5a8f6b9883 * faeda1bbe5f1ad3ef6409600e2f67b92ed007aba432b567cc26cf3e965e20 * 722407bfe46b7736f5 * * newn == 14: (Blum modulus bit length 1054) * n[14] = 0x5e56a00e93c6f4e87479ac07b9d983d01f564618b314b4bfec7931eee85 - * eb909179161e23e78d32110560b22956b22f3bc7e4a034b0586e463fd40c6 + * eb909179161e23e78d32110560b22956b22f3bc7e4a034b0586e463fd40c6 * f01a33e30ede912acb86a0c1e03483c45f289a271d14bd52792d0a076fdfe * fe32159054b217092237f0767434b3db112fee83005b33f925bacb3185cc4 * 409a1abdef8c0fc116af01 * r[14] = 0xf7aa7cb67335096ef0c5d09b18f15415b9a564b609913f75f627fc6b0c5 - * b686c86563fe86134c5a0ea19d243350dfc6b9936ba1512abafb81a0a6856 + * b686c86563fe86134c5a0ea19d243350dfc6b9936ba1512abafb81a0a6856 * c9ae7816bf2073c0fb58d8138352b261a704b3ce64d69dee6339010186b98 * 3677c84167d4973444194649ad6d71f8fa8f1f1c313edfbbbb6b1b220913c * c8ea47a4db680ff9f190 * * newn == 15: (Blum modulus bit length 1055) * n[15] = 0x97dd840b9edfbcdb02c46c175ba81ca845352ebe470be6075326a26770c - * ab84bfc0f2e82aa95aac14f40de42a0590445b902c2b8ebb916753e72ab86 + * ab84bfc0f2e82aa95aac14f40de42a0590445b902c2b8ebb916753e72ab86 * c3278cccc1a783b3e962d81b80df03e4380a8fa08b0d86ed0caa515c196a5 * 30e49c558ddb53082310b1d0c7aee6f92b619798624ffe6c337299bc51ff5 * d2c721061e7597c8d97079 * r[15] = 0xb8220703b8c75869ab99f9b50025daa8d77ca6df8cef423ede521f55b1c - * 25d74fbf6d6cc31f5ef45e3b29660ef43797f226860a4aa1023dbe522b1fe + * 25d74fbf6d6cc31f5ef45e3b29660ef43797f226860a4aa1023dbe522b1fe * 6224d01eb77dee9ad97e8970e4a9e28e7391a6a70557fa0e46eca78866241 * ba3c126fc0c5469f8a2f65c33db95d1749d3f0381f401b9201e6abd43d98d * b92e808f0aaa6c3e2110 * * newn == 16: (Blum modulus bit length 1062) * n[16] = 0x456e348549b82fbb12b56f84c39f544cb89e43536ae8b2b497d426512c7 - * f3c9cc2311e0503928284391959e379587bc173e6bc51ba51c856ba557fee + * f3c9cc2311e0503928284391959e379587bc173e6bc51ba51c856ba557fee * 8dd69cee4bd40845bd34691046534d967e40fe15b6d7cf61e30e283c05be9 * 93c44b6a2ea8ade0f5578bd3f618336d9731fed1f1c5996a5828d4ca857ac * 2dc9bd36184183f6d84346e1 * r[16] = 0xb0d7dcb19fb27a07973e921a4a4b6dcd7895ae8fced828de8a81a3dbf25 - * 24def719225404bfd4977a1508c4bac0f3bc356e9d83b9404b5bf86f6d19f + * 24def719225404bfd4977a1508c4bac0f3bc356e9d83b9404b5bf86f6d19f * f75645dffc9c5cc153a41772670a5e1ae87a9521416e117a0c0d415fb15d2 * 454809bad45d6972f1ab367137e55ad0560d29ada9a2bcda8f4a70fbe04a1 * abe4a570605db87b4e8830 @@ -541,7 +541,7 @@ * 0974f0b3868ff772ab2ceaf77f328d7244c9ad30e11a2700a120a314aff74 * c7f14396e2a39cc14a9fa6922ca0fce40304166b249b574ffd9cbb927f766 * c9b150e970a8d1edc24ebf72b72051 - * r[17] = 0x53720b6eaf3bc3b8adf1dd665324c2d2fc5b2a62f32920c4e167537284d + * r[17] = 0x53720b6eaf3bc3b8adf1dd665324c2d2fc5b2a62f32920c4e167537284d * a802fc106be4b0399caf97519486f31e0fa45a3a677c6cb265c5551ba4a51 * 68a7ce3c29731a4e9345eac052ee1b84b7b3a82f906a67aaf7b35949fd7fc * 2f9f4fbc8c18689694c8d30810fff31ebee99b1cf029a33bd736750e7fe0a @@ -625,10 +625,10 @@ * * 1 <= newn <= 4 PC using ECM in a short amount of time * 5 <= newn <= 8 Workstation using MPQS in a short amount of time - * 8 <= newn <= 12 High end supercomputer or high parallel processor + * 8 <= newn <= 12 High end supercomputer or high parallel processor * using state of the art factoring over a long time - * 12 <= newn <= 16 Beyond Feb 1997 systems and factoring methods - * 17 <= newn <= 20 Well beyond Feb 1997 systems and factoring methods + * 12 <= newn <= 16 Beyond Feb 1997 systems and factoring methods + * 17 <= newn <= 20 Well beyond Feb 1997 systems and factoring methods * * See the section titled 'FOR THE PARANOID' for more details. * @@ -660,9 +660,9 @@ * * The follow calc script produces an equivalent effect: * - * p = nextcand(ip-2, trials, 0, 3, 4); (* find the 1st Blum prime *) - * q = nextcand(iq-2, trials, 0, 3, 4); (* find the 2nd Blum prime *) - * n = p * q; (* n is the new Blum modulus *) + * p = nextcand(ip-2, trials, 0, 3, 4); (* find the 1st Blum prime *) + * q = nextcand(iq-2, trials, 0, 3, 4); (* find the 2nd Blum prime *) + * n = p * q; (* n is the new Blum modulus *) * r = seed; * do { * last_r = r; @@ -693,9 +693,9 @@ * or in other words: * * (* trials, if omitted, is assumed to be 1 *) - * p = nextcand(ip-2, trials, 0, 3, 4); (* find the 1st Blum prime *) - * q = nextcand(iq-2, trials, 0, 3, 4); (* find the 2nd Blum prime *) - * n = p * q; (* n is the new Blum modulus *) + * p = nextcand(ip-2, trials, 0, 3, 4); (* find the 1st Blum prime *) + * q = nextcand(iq-2, trials, 0, 3, 4); (* find the 2nd Blum prime *) + * n = p * q; (* n is the new Blum modulus *) * r = default_residue; (* as used by the initial state *) * do { * last_r = r; @@ -751,7 +751,7 @@ * nextcand(value, 25, 0, 3, 4) * * The odds that a number returned by the above call is not prime is - * less than 1 in 4^25. For our purposes, this is sufficient as the + * less than 1 in 4^25. For our purposes, this is sufficient as the * chance of returning a composite is much smaller than the chance that * a hardware glitch will cause nextcand() to return a bogus result. * @@ -795,7 +795,7 @@ * * Taking some care to select a good initial residue helps eliminate cheap * search attacks. It is true that a subsequent residue could be one of the - * residues that we would first avoid. However such an occurrence will + * residues that we would first avoid. However such an occurrence will * happen after the generator is well underway and any such seed information * has been lost. * @@ -809,7 +809,7 @@ * * The size of default Blum modulus 'n=p*q' was taken to be > 2^259, or * 260 bits (79 digits) long. A modulus > 2^256 will generate 8 bits - * per crank of the generator. The period of this generator is long + * per crank of the generator. The period of this generator is long * enough to be reasonable, and the modulus is small enough to be fast. * * The default Blum modulus is not a secure modulus because it can @@ -871,7 +871,7 @@ * * These Blum primes were found after 1.81s of CPU time on a 195 Mhz IP28 * R10000 version 2.5 processor. The first Blum prime 'p' was 31716 higher - * than the initial search value 'ip'. The second Blum prime 'q' was 18762 + * than the initial search value 'ip'. The second Blum prime 'q' was 18762 * higher than the initial starting 'iq'. * * The product of the two Blum primes results in a 260 bit Blum modulus of: @@ -881,7 +881,7 @@ * The selection if the initial quadratic residue comes from the next * unused digits of the Rand Book of Random Numbers. Now the two initial * search values 'ip' and 'iq' used above needed the first 38 digits and - * the next 42 digits. Thus we will skip the first 38+42=80 digits + * the next 42 digits. Thus we will skip the first 38+42=80 digits * and begin to build in initial search value for a quadratic residue (most * significant digit first) from the Rand Book of Numbers digits until we * have a value whose square mod n > 4th power mod n. In other words, we @@ -925,7 +925,7 @@ * lambda(n) = lcm(2,2,fp,fq) = 2*fp*fq = ~2*(p/2)*(q/2) = ~n/2 * * The process above resulted in a default generator Blum modulus n > 2^259 - * with period of at least 2^258 bits. To be exact, the period of the + * with period of at least 2^258 bits. To be exact, the period of the * default Blum generator is: * * 0x79560c818ab57cf1b9ebc309f68746881adc15e79c05e476f741e5f904b9beb1a @@ -946,7 +946,7 @@ * The lengths of the two Blum probable primes 'p' and 'q' used to make up * the 20 Blum modului 'n=p*q' differ slightly to avoid certain * factorization attacks that work on numbers that are a perfect square, - * or where the two primes are nearly the same. I elected to have the + * or where the two primes are nearly the same. I elected to have the * sizes differ by up to 6% of the product size to avoid such attacks. * Clearly one does not want the size of the two factors to differ * by a large percentage: p=3 and q large would result in a easy @@ -963,7 +963,7 @@ * FOR THE PARANOID: * * The truly paranoid might suggest that my claims in the MAGIC NUMBERS - * section are a lie intended to entrap people. Well they are not, but + * section are a lie intended to entrap people. Well they are not, but * you need not take my word for it. * *** @@ -1030,7 +1030,7 @@ * pass before being considered a probable prime (must be >0, perhaps 25), and * where 'ip' is the initial search location for the Blum prime 'p', and * where 'iq' is the initial search location for the Blum prime 'q', and - * where 'ir' is the initial Blum quadratic residue generator. The 'ir' + * where 'ir' is the initial Blum quadratic residue generator. The 'ir' * value should be a random value in the range [2^(binsize*4/5), 2^(binsize-2)) * where 2^(binsize-1) < n=p*q <= 2^binsize. * @@ -1048,12 +1048,12 @@ * primes used in these special pre-defined generators are unknown. * * Not being able to factor 'n=p*q' into 'p' and 'q' does not directly - * improve the quality Blum generator. On the other hand, it does + * improve the quality Blum generator. On the other hand, it does * improve the security of it. * * I (Landon Curt Noll) did not keep the search values of these 20 special * pre-defined generators. While some of the smaller Blum moduli is - * within the range of some factoring methods, others are not. As of + * within the range of some factoring methods, others are not. As of * Feb 1997, the following is the estimate of what can factor the * pre-defined moduli: * @@ -2037,7 +2037,7 @@ zrandomskip(long cnt) /* buffer contains more bits than we need to toss */ blum.buffer >>= cnt; blum.bits -= cnt; - return; /* skip need satisfied */ + return; /* skip need satisfied */ } } @@ -2297,7 +2297,7 @@ zrandomrange(CONST ZVALUE low, CONST ZVALUE high, ZVALUE *res) * generate a random value between [0, diff) * * We will not fall into the trap of thinking that we can simply take - * a value mod 'range'. Consider the case where 'range' is '80' + * a value mod 'range'. Consider the case where 'range' is '80' * and we are given pseudo-random numbers [0,100). If we took them * mod 80, then the numbers [0,20) would be produced more frequently * because the numbers [81,100) mod 80 wrap back into [0,20). @@ -2507,7 +2507,7 @@ randomprint(CONST RANDOM *state, int flags) * This call is needed only by libcalc_call_me_last() to help clean up any * unneeded storage. * - * Do not call this function directly! Let libcalc_call_me_last() do it. + * Do not call this function directly! Let libcalc_call_me_last() do it. */ void random_libcalc_cleanup(void) diff --git a/zrandom.h b/zrandom.h index eba7da9..42aac53 100644 --- a/zrandom.h +++ b/zrandom.h @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. * * Prior to calc 2.9.3t9, these routines existed as a calc library called - * cryrand.cal. They have been rewritten in C for performance as well + * cryrand.cal. They have been rewritten in C for performance as well * as to make them available directly from libcalc.a. * * Comments, suggestions, bug fixes and questions about these routines - * are welcome. Send EMail to the address given below. + * are welcome. Send EMail to the address given below. * * Happy bit twiddling, * @@ -39,7 +39,7 @@ #if !defined(__ZRANDOM_H__) -#define __ZRANDOM_H__ +#define __ZRANDOM_H__ #include "value.h" @@ -54,7 +54,7 @@ * most this implies that a turn can yield no more than 15 bits when BASEB==16 * or 31 bits when BASEB==32. Should we deal with a excessively large * Blum modulus (>=2^16 bits long for BASEB==16, >=2^32 bits for BASEB==32) - * the higher order random bits will be tossed. This is not a loss as + * the higher order random bits will be tossed. This is not a loss as * regular sub-segments of the sequence are just as random. It only means * that excessively large Blum modulus values waste CPU time. */