From 74455508314bc2b007e812ec5f9429496b9fbd5f Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 12 Feb 2019 22:50:49 +0100 Subject: [PATCH] remote TABs in doc/ and test/ --- doc/apple2.sgml | 54 +- doc/apple2enh.sgml | 54 +- doc/ar65.sgml | 45 +- doc/atari2600.sgml | 16 +- doc/atari5200.sgml | 16 +- doc/atmos.sgml | 16 +- doc/c128.sgml | 16 +- doc/c16.sgml | 16 +- doc/c64.sgml | 16 +- doc/ca65.sgml | 788 ++++---- doc/cbm510.sgml | 16 +- doc/cbm610.sgml | 16 +- doc/chrcvt65.sgml | 16 +- doc/cl65.sgml | 38 +- doc/co65.sgml | 20 +- doc/coding.sgml | 58 +- doc/creativision.sgml | 16 +- doc/debugging.sgml | 8 +- doc/gamate.sgml | 16 +- doc/geos.sgml | 110 +- doc/grc65.sgml | 12 +- doc/ld65.sgml | 40 +- doc/library.sgml | 16 +- doc/lynx.sgml | 16 +- doc/nes.sgml | 19 +- doc/od65.sgml | 17 +- doc/osi.sgml | 16 +- doc/pet.sgml | 16 +- doc/plus4.sgml | 16 +- doc/sim65.sgml | 42 +- doc/smc.sgml | 12 +- doc/sp65.sgml | 16 +- doc/supervision.sgml | 16 +- doc/telestrat.sgml | 54 +- doc/using-make.sgml | 6 +- doc/vic20.sgml | 16 +- test/err/front.c | 66 +- test/misc/fields.c | 64 +- test/misc/limits.c | 6 +- test/misc/sitest.c | 2944 ++++++++++++++-------------- test/ref/8q.c | 48 +- test/ref/array.c | 74 +- test/ref/cc65070303.c | 10 +- test/ref/cc65090726.c | 22 +- test/ref/cc65090910.c | 2 +- test/ref/cc65090913.c | 2 +- test/ref/cf.c | 66 +- test/ref/charconst.c | 28 +- test/ref/charset.c | 128 +- test/ref/divmod.c | 36 +- test/ref/hanoi.c | 82 +- test/ref/incr.c | 44 +- test/ref/init.c | 58 +- test/ref/macro.c | 16 +- test/ref/paranoia.c | 3484 ++++++++++++++++----------------- test/ref/pointer2.c | 48 +- test/ref/sort.c | 64 +- test/ref/spill.c | 4 +- test/ref/stdarg.c | 118 +- test/ref/strptr.c | 114 +- test/ref/struct.c | 88 +- test/ref/switch.c | 252 +-- test/ref/switch2.c | 398 ++-- test/ref/varargs.c | 2 +- test/ref/wf1.c | 104 +- test/ref/yacc.c | 1078 +++++----- test/ref/yacc2.c | 228 +-- test/val/compare5.c | 6 +- test/val/cq22.c | 6 +- test/val/cq241.c | 6 +- test/val/cq243.c | 38 +- test/val/cq244.c | 6 +- test/val/cq25.c | 6 +- test/val/cq26.c | 6 +- test/val/cq4.c | 6 +- test/val/cq61.c | 6 +- test/val/cq626.c | 6 +- test/val/cq71.c | 6 +- test/val/cq714.c | 342 ++-- test/val/cq714b.c | 6 +- test/val/cq715.c | 6 +- test/val/cq72.c | 6 +- test/val/cq757.c | 4 +- test/val/cq7813.c | 6 +- test/val/cq81.c | 6 +- test/val/cq84.c | 10 +- test/val/cq85.c | 22 +- test/val/cq86.c | 6 +- test/val/cq88.c | 6 +- test/val/cq9.c | 4 +- test/val/lz4.c | 8 +- test/val/nestfor.c | 164 +- test/val/postincdec.c | 16 +- test/val/ptrfunc.c | 108 +- test/val/trampoline-params.c | 12 +- test/val/trampoline-varargs.c | 34 +- test/val/trampoline.c | 20 +- 97 files changed, 6118 insertions(+), 6125 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index ac5059902..648ee56db 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -32,7 +32,7 @@ more information. Binary format

The standard binary file format generated by the linker for the -Apple ][ target is an file. The default load address is $803. @@ -580,18 +580,18 @@ url="ca65.html" name="assembler manual">. ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike Windows which uses the file name's suffix (a.k.a. - extension) to specify the file type. For example, Specifying the File Type and Auxiliary Type There are two global variables provided that allow the file type @@ -603,7 +603,7 @@ url="ca65.html" name="assembler manual">. extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ - + The header file . Example A text file cannot be created with just the - standard C functions because they default to the binary type + standard C functions because they default to the binary type . } } - +

@@ -686,14 +686,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index d8d24ea32..d25aa7efe 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -32,7 +32,7 @@ more information. Binary format

The standard binary file format generated by the linker for the -enhanced Apple //e target is an file. The default load address is $803. @@ -586,18 +586,18 @@ url="ca65.html" name="assembler manual">. ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike Windows which uses the file name's suffix (a.k.a. - extension) to specify the file type. For example, Specifying the File Type and Auxiliary Type There are two global variables provided that allow the file type @@ -609,7 +609,7 @@ url="ca65.html" name="assembler manual">. extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ - + The header file . Example A text file cannot be created with just the - standard C functions because they default to the binary type + standard C functions because they default to the binary type . } } - +

@@ -692,14 +692,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/ar65.sgml b/doc/ar65.sgml index df4154539..900a0a92b 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -30,14 +30,14 @@ for the cc65 compiler. ar65 is part of this suite. The archiver is called as follows: - Usage: ar65 lib file|module ... - Operations are some of: - r Add modules - d Delete modules - t List library table - v Increase verbosity (put before other operation) - x Extract modules - V Print the archiver version + Usage: ar65 lib file|module ... + Operations are some of: + r Add modules + d Delete modules + t List library table + v Increase verbosity (put before other operation) + x Extract modules + V Print the archiver version You may add modules to a library using the - ar65 r mysubs.lib sub1.o sub2.o + ar65 r mysubs.lib sub1.o sub2.o This will add two modules to the library 'mysubs.lib' creating the @@ -62,7 +62,7 @@ sub2.o, they are replaced by the new ones. Modules names in the library are stored without the path, so, using - ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o + ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o will verbose add two modules named 'sub1.o' and 'sub2.o' to the library. @@ -73,7 +73,7 @@ give a path when naming the modules. Example: - ar65 d mysubs.lib sub1.o + ar65 d mysubs.lib sub1.o This will delete the module named 'sub1.o' from the library, printing an @@ -86,7 +86,7 @@ Any module names on the command line are ignored. Example: - ar65 tv mysubs.lib + ar65 tv mysubs.lib @@ -103,7 +103,7 @@ this is not a problem. Example for extracting a module from the library: - ar65 x mysubs.lib sub1.o + ar65 x mysubs.lib sub1.o @@ -131,17 +131,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - - - diff --git a/doc/atari2600.sgml b/doc/atari2600.sgml index 797b1e8be..36c06ad08 100644 --- a/doc/atari2600.sgml +++ b/doc/atari2600.sgml @@ -109,14 +109,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index e33c8a832..fedac4466 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -184,14 +184,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/atmos.sgml b/doc/atmos.sgml index ab7104f9d..3fd61abcf 100644 --- a/doc/atmos.sgml +++ b/doc/atmos.sgml @@ -279,14 +279,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c128.sgml b/doc/c128.sgml index 82c280ef0..1d8734fdf 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -397,14 +397,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c16.sgml b/doc/c16.sgml index 9f81c5115..462f98345 100644 --- a/doc/c16.sgml +++ b/doc/c16.sgml @@ -259,14 +259,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c64.sgml b/doc/c64.sgml index 37ac0c146..c11867051 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -481,14 +481,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 25c46c4c2..211039995 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -36,42 +36,42 @@ development: - The assembler must support macros. Macros are not essential, but they - make some things easier, especially when you use the assembler in the - backend of a compiler. - The assembler must support the newer 65C02 and 65816 CPUs. I have been - thinking about a 65816 backend for the C compiler, and even my old - a816 assembler had support for these CPUs, so this wasn't really a - problem. - The assembler must produce relocatable code. This is necessary for the - compiler support, and it is more convenient. - Conditional assembly must be supported. This is a must for bigger - projects written in assembler (like Elite128). - The assembler must support segments, and it must support more than - three segments (this is the count, most other assemblers support). - Having more than one code segments helps developing code for systems - with a divided ROM area (like the C64). - The linker must be able to resolve arbitrary expressions. It should - be able to get things like + The assembler must support macros. Macros are not essential, but they + make some things easier, especially when you use the assembler in the + backend of a compiler. + The assembler must support the newer 65C02 and 65816 CPUs. I have been + thinking about a 65816 backend for the C compiler, and even my old + a816 assembler had support for these CPUs, so this wasn't really a + problem. + The assembler must produce relocatable code. This is necessary for the + compiler support, and it is more convenient. + Conditional assembly must be supported. This is a must for bigger + projects written in assembler (like Elite128). + The assembler must support segments, and it must support more than + three segments (this is the count, most other assemblers support). + Having more than one code segments helps developing code for systems + with a divided ROM area (like the C64). + The linker must be able to resolve arbitrary expressions. It should + be able to get things like - .import S1, S2 - .export Special - Special = 2*S1 + S2/7 + .import S1, S2 + .export Special + Special = 2*S1 + S2/7 - right. - True lexical nesting for symbols. This is very convenient for larger - assembly projects. - "Cheap" local symbols without lexical nesting for those quick, late - night hacks. - I liked the idea of "options" as Anre Fachats .o65 format has it, so I - introduced the concept into the object file format use by the new cc65 - binutils. - The assembler will be a one pass assembler. There was no real need for - this decision, but I've written several multipass assemblers, and it - started to get boring. A one pass assembler needs much more elaborated - data structures, and because of that it's much more fun:-) - Non-GPLed code that may be used in any project without restrictions or - fear of "GPL infecting" other code. + right. + True lexical nesting for symbols. This is very convenient for larger + assembly projects. + "Cheap" local symbols without lexical nesting for those quick, late + night hacks. + I liked the idea of "options" as Anre Fachats .o65 format has it, so I + introduced the concept into the object file format use by the new cc65 + binutils. + The assembler will be a one pass assembler. There was no real need for + this decision, but I've written several multipass assemblers, and it + started to get boring. A one pass assembler needs much more elaborated + data structures, and because of that it's much more fun:-) + Non-GPLed code that may be used in any project without restrictions or + fear of "GPL infecting" other code.

@@ -151,7 +151,7 @@ Here is a description of all the command line options: Set the default for the CPU type. The option takes a parameter, which may be one of - 6502, 6502X, 65SC02, 65C02, 65816, sweet16, HuC6280, 4510 + 6502, 6502X, 65SC02, 65C02, 65816, sweet16, HuC6280, 4510

@@ -809,23 +809,23 @@ reference (use the n'th label in forward direction). An example will help to understand this: - : lda (ptr1),y ; #1 - cmp (ptr2),y - bne :+ ; -> #2 - tax - beq :+++ ; -> #4 - iny - bne :- ; -> #1 - inc ptr1+1 - inc ptr2+1 - bne :- ; -> #1 - - : bcs :+ ; #2 -> #3 - ldx #$FF - rts - - : ldx #$01 ; #3 - : rts ; #4 + : lda (ptr1),y ; #1 + cmp (ptr2),y + bne :+ ; -> #2 + tax + beq :+++ ; -> #4 + iny + bne :- ; -> #1 + inc ptr1+1 + inc ptr2+1 + bne :- ; -> #1 + + : bcs :+ ; #2 -> #3 + ldx #$FF + rts + + : ldx #$01 ; #3 + : rts ; #4 As you can see from the example, unnamed labels will make even short @@ -857,15 +857,15 @@ errors. Because of these problems, the general advice is, - .DEFINE two 2 - .DEFINE version "SOS V2.3" + .DEFINE two 2 + .DEFINE version "SOS V2.3" - four = two * two ; Ok - .byte version ; Ok + four = two * two ; Ok + .byte version ; Ok - .PROC ; Start local scope - two = 3 ; Will give "2 = 3" - invalid! - .ENDPROC + .PROC ; Start local scope + two = 3 ; Will give "2 = 3" - invalid! + .ENDPROC @@ -1241,17 +1241,17 @@ writable. Example: - ; Reverse Subtract with Accumulator - ; A = memory - A - .macro rsb param - .if .asize = 8 - eor #$ff - .else - eor #$ffff - .endif - sec - adc param - .endmacro + ; Reverse Subtract with Accumulator + ; A = memory - A + .macro rsb param + .if .asize = 8 + eor #$ff + .else + eor #$ffff + .endif + sec + adc param + .endmacro See also: @@ -1272,15 +1272,15 @@ writable. .macpack cpu - .if (.cpu .bitand CPU_ISET_65816) - phx - phy - .else - txa - pha - tya - pha - .endif + .if (.cpu .bitand CPU_ISET_65816) + phx + phy + .else + txa + pha + tya + pha + .endif @@ -1305,12 +1305,12 @@ writable. Example: - .macro foo arg1, arg2, arg3 - .if .paramcount <> 3 - .error "Too few parameters for macro foo" - .endif - ... - .endmacro + .macro foo arg1, arg2, arg3 + .if .paramcount <> 3 + .error "Too few parameters for macro foo" + .endif + ... + .endmacro See section . @@ -1417,7 +1417,7 @@ either a string or an expression. .endproc .proc bank_table - .addr banked_func_1 + .addr banked_func_1 .byte <.BANK (banked_func_1) .addr banked_func_2 @@ -1449,7 +1449,7 @@ either a string or an expression. As an example, the - .if .blank({arg}) + .if .blank({arg}) @@ -1465,13 +1465,13 @@ either a string or an expression. Example: - .include .concat ("myheader", ".", "inc") + .include .concat ("myheader", ".", "inc") This is the same as the command - .include "myheader.inc" + .include "myheader.inc" @@ -1483,7 +1483,7 @@ either a string or an expression. otherwise. As an example, the .IFCONST statement may be replaced by - .if .const(a + 3) + .if .const(a + 3) @@ -1513,7 +1513,7 @@ either a string or an expression. Example: - .macro makelabel arg1, arg2 + .macro makelabel arg1, arg2 .ident (.concat (arg1, arg2)): .endmacro @@ -1530,7 +1530,7 @@ either a string or an expression. Syntax: - .LEFT (<int expr>, <token list>) + .LEFT (<int expr>, <token list>) The first integer expression gives the number of tokens to extract from @@ -1545,16 +1545,16 @@ either a string or an expression. (immediate addressing mode), use something like this: - .macro ldax arg - ... - .if (.match (.left (1, {arg}), #)) + .macro ldax arg + ... + .if (.match (.left (1, {arg}), #)) - ; ldax called with immediate operand - ... + ; ldax called with immediate operand + ... - .endif - ... - .endmacro + .endif + ... + .endmacro See also the and - .MATCH(<token list #1>, <token list #2>) + .MATCH(<token list #1>, <token list #2>) Both token list may contain arbitrary tokens with the exception of the @@ -1617,16 +1617,16 @@ either a string or an expression. to check for this and print and error for invalid calls. - .macro asr arg + .macro asr arg - .if (.not .blank(arg)) .and (.not .match ({arg}, a)) - .error "Syntax error" - .endif + .if (.not .blank(arg)) .and (.not .match ({arg}, a)) + .error "Syntax error" + .endif - cmp #$80 ; Bit 7 into carry - lsr a ; Shift carry into bit 7 + cmp #$80 ; Bit 7 into carry + lsr a ; Shift carry into bit 7 - .endmacro + .endmacro The macro will only accept no arguments, or one argument that must be the @@ -1642,14 +1642,14 @@ either a string or an expression. The syntax is - .MAX (<value #1>, <value #2>) + .MAX (<value #1>, <value #2>) Example: ; Reserve space for the larger of two data blocks - savearea: .res .max (.sizeof (foo), .sizeof (bar)) + savearea: .res .max (.sizeof (foo), .sizeof (bar)) See: @@ -1663,7 +1663,7 @@ either a string or an expression. Syntax: - .MID (<int expr>, <int expr>, <token list>) + .MID (<int expr>, <int expr>, <token list>) The first integer expression gives the starting token in the list (the first @@ -1679,16 +1679,16 @@ either a string or an expression. (immediate addressing mode), use something like this: - .macro ldax arg - ... - .if (.match (.mid (0, 1, {arg}), #)) + .macro ldax arg + ... + .if (.match (.mid (0, 1, {arg}), #)) - ; ldax called with immediate operand - ... + ; ldax called with immediate operand + ... - .endif - ... - .endmacro + .endif + ... + .endmacro See also the and - .MIN (<value #1>, <value #2>) + .MIN (<value #1>, <value #2>) Example: ; Reserve space for some data, but 256 bytes maximum - savearea: .res .min (.sizeof (foo), 256) + savearea: .res .min (.sizeof (foo), 256) See: @@ -1724,7 +1724,7 @@ either a string or an expression. the statement may be replaced by - .if .referenced(a) + .if .referenced(a) See: @@ -1737,7 +1737,7 @@ either a string or an expression. Syntax: - .RIGHT (<int expr>, <token list>) + .RIGHT (<int expr>, <token list>) The first integer expression gives the number of tokens to extract from the @@ -1833,12 +1833,12 @@ either a string or an expression. Example: - .macro M Arg - ; Check if the argument string starts with '#' - .if (.strat (Arg, 0) = '#') - ... - .endif - .endmacro + .macro M Arg + ; Check if the argument string starts with '#' + .if (.strat (Arg, 0) = '#') + ... + .endif + .endmacro @@ -1873,10 +1873,10 @@ either a string or an expression. Example: - ; Emulate other assemblers: - .macro section name - .segment .string(name) - .endmacro + ; Emulate other assemblers: + .macro section name + .segment .string(name) + .endmacro @@ -1891,9 +1891,9 @@ either a string or an expression. a leading length byte. - .macro PString Arg - .byte .strlen(Arg), Arg - .endmacro + .macro PString Arg + .byte .strlen(Arg), Arg + .endmacro @@ -1913,15 +1913,15 @@ either a string or an expression. load instructions, the '#' token has to get stripped from the argument: - .macro ldax arg - .if (.match (.mid (0, 1, {arg}), #)) - ; ldax called with immediate operand - lda #<(.right (.tcount ({arg})-1, {arg})) - ldx #>(.right (.tcount ({arg})-1, {arg})) - .else - ... - .endif - .endmacro + .macro ldax arg + .if (.match (.mid (0, 1, {arg}), #)) + ; ldax called with immediate operand + lda #<(.right (.tcount ({arg})-1, {arg})) + ldx #>(.right (.tcount ({arg})-1, {arg})) + .else + ... + .endif + .endmacro @@ -1934,7 +1934,7 @@ either a string or an expression. The syntax is - .XMATCH(<token list #1>, <token list #2>) + .XMATCH(<token list #1>, <token list #2>) Both token list may contain arbitrary tokens with the exception of the @@ -1994,7 +1994,7 @@ Here's a list of all control commands and a description, what they do: Example: - .addr $0D00, $AF13, _Clear + .addr $0D00, $AF13, _Clear See: , - .align 256 + .align 256 Some unexpected behaviour might occur if there are multiple - Msg: .asciiz "Hello world" + Msg: .asciiz "Hello world" This will put the string "Hello world" followed by a binary zero into @@ -2099,7 +2099,7 @@ Here's a list of all control commands and a description, what they do: Example: - .assert * = $8000, error, "Code not at $8000" + .assert * = $8000, error, "Code not at $8000" The example assertion will check that the current location is at $8000, @@ -2131,7 +2131,7 @@ Here's a list of all control commands and a description, what they do: Example: - .autoimport + ; Switch on auto import + .autoimport + ; Switch on auto import .BANKBYTES

@@ -2145,17 +2145,17 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable - TableLookupBank: .bankbytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable + TableLookupBank: .bankbytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 - TableLookupBank: .byte ^TableItem0, ^TableItem1, ^TableItem2, ^TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupBank: .byte ^TableItem0, ^TableItem1, ^TableItem2, ^TableItem3 See also: , @@ -2169,7 +2169,7 @@ Here's a list of all control commands and a description, what they do: so this is a shortcut for - .segment "BSS" + .segment "BSS" See also the command. @@ -2183,8 +2183,8 @@ Here's a list of all control commands and a description, what they do: Example: - .byte "Hello " - .byt "world", $0D, $00 + .byte "Hello " + .byt "world", $0D, $00 @@ -2199,7 +2199,7 @@ Here's a list of all control commands and a description, what they do: Example: - .case - ; Identifiers are not case sensitive + .case - ; Identifiers are not case sensitive @@ -2224,7 +2224,7 @@ Here's a list of all control commands and a description, what they do: "CODE", so this is a shortcut for - .segment "CODE" + .segment "CODE" See also the command. @@ -2260,8 +2260,8 @@ Here's a list of all control commands and a description, what they do: Example: - .condes ModuleInit, constructor - .condes ModInit, 0, 16 + .condes ModuleInit, constructor + .condes ModInit, 0, 16 See the , - .constructor ModuleInit - .constructor ModInit, 16 + .constructor ModuleInit + .constructor ModInit, 16 See the and - .segment "DATA" + .segment "DATA" See also the command. @@ -2323,13 +2323,13 @@ Here's a list of all control commands and a description, what they do: Example: - .dbyt $1234, $4512 + .dbyt $1234, $4512 This will emit the bytes - $12 $34 $45 $12 + $12 $34 $45 $12 into the current segment in that order. @@ -2346,7 +2346,7 @@ Here's a list of all control commands and a description, what they do: Example: - .debuginfo + ; Generate debug info + .debuginfo + ; Generate debug info @@ -2387,7 +2387,7 @@ Here's a list of all control commands and a description, what they do: statement may be replaced by - .if .defined(a) + .if .defined(a) @@ -2404,7 +2404,7 @@ Here's a list of all control commands and a description, what they do: adc foo .endmacro - .if .definedmacro(add) + .if .definedmacro(add) add #$01 .else clc @@ -2434,8 +2434,8 @@ Here's a list of all control commands and a description, what they do: Example: - .destructor ModuleDone - .destructor ModDone, 16 + .destructor ModuleDone + .destructor ModDone, 16 See the and - .dword $12344512, $12FA489 + .dword $12344512, $12FA489 @@ -2595,13 +2595,13 @@ Here's a list of all control commands and a description, what they do: Example: - .if foo = 1 - ... - .elseif bar = 1 - ... - .else - .error "Must define foo or bar!" - .endif + .if foo = 1 + ... + .elseif bar = 1 + ... + .else + .error "Must define foo or bar!" + .endif See also: , @@ -2634,7 +2634,7 @@ Here's a list of all control commands and a description, what they do: Examples: - .export foo + .export foo .export bar: far .export foobar: far = foo * bar .export baz := foobar, zap: far = baz - bar @@ -2657,7 +2657,7 @@ Here's a list of all control commands and a description, what they do: Examples: - .exportzp foo, bar + .exportzp foo, bar .exportzp baz := $02 @@ -2672,7 +2672,7 @@ Here's a list of all control commands and a description, what they do: Example: - .faraddr DrawCircle, DrawRectangle, DrawHexagon + .faraddr DrawCircle, DrawRectangle, DrawHexagon See: @@ -2690,13 +2690,13 @@ Here's a list of all control commands and a description, what they do: Example: - .if foo = 1 - ... - .elseif bar = 1 - ... - .else - .fatal "Must define foo or bar!" - .endif + .if foo = 1 + ... + .elseif bar = 1 + ... + .else + .fatal "Must define foo or bar!" + .endif See also: , @@ -2713,7 +2713,7 @@ Here's a list of all control commands and a description, what they do: enabled it, so using - .FEATURE xxx + .FEATURE xxx will enable the feature until end of assembly is reached. @@ -2877,7 +2877,7 @@ Here's a list of all control commands and a description, what they do: assembler, the features - labels_without_colons, pc_assignment, loose_char_term + labels_without_colons, pc_assignment, loose_char_term may be helpful. They do not make ca65 completely compatible, so you may not @@ -2897,9 +2897,9 @@ Here's a list of all control commands and a description, what they do: The command is followed by one of the keywords - author - comment - compiler + author + comment + compiler a comma and a string. The option is written into the object file @@ -2910,9 +2910,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .fileopt comment, "Code stolen from my brother" - .fileopt compiler, "BASIC 2.0" - .fopt author, "J. R. User" + .fileopt comment, "Code stolen from my brother" + .fileopt compiler, "BASIC 2.0" + .fopt author, "J. R. User" @@ -2928,7 +2928,7 @@ Here's a list of all control commands and a description, what they do: Example: - .forceimport needthisone, needthistoo + .forceimport needthisone, needthistoo See: @@ -2945,7 +2945,7 @@ Here's a list of all control commands and a description, what they do: Example: - .global foo, bar + .global foo, bar @@ -2961,7 +2961,7 @@ Here's a list of all control commands and a description, what they do: Example: - .globalzp foo, bar + .globalzp foo, bar .HIBYTES

@@ -2974,14 +2974,14 @@ Here's a list of all control commands and a description, what they do: .lobytes $1234, $2345, $3456, $4567 - .hibytes $fedc, $edcb, $dcba, $cba9 + .hibytes $fedc, $edcb, $dcba, $cba9 which is equivalent to .byte $34, $45, $56, $67 - .byte $fe, $ed, $dc, $cb + .byte $fe, $ed, $dc, $cb Example: @@ -2989,15 +2989,15 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 See also: , @@ -3052,13 +3052,13 @@ Here's a list of all control commands and a description, what they do: Example: - .macro arg1, arg2 - .ifblank arg2 - lda #arg1 - .else - lda #arg2 - .endif - .endmacro + .macro arg1, arg2 + .ifblank arg2 + lda #arg1 + .else + lda #arg2 + .endif + .endmacro See also: @@ -3100,12 +3100,12 @@ Here's a list of all control commands and a description, what they do: Example: - .macro arg1, arg2 - lda #arg1 - .ifnblank arg2 - lda #arg2 - .endif - .endmacro + .macro arg1, arg2 + lda #arg1 + .ifnblank arg2 + lda #arg2 + .endif + .endmacro See also: @@ -3171,11 +3171,11 @@ Here's a list of all control commands and a description, what they do: Example: - .ifref ToHex ; If someone used this subroutine - ToHex: tay ; Define subroutine - lda HexTab,y - rts - .endif + .ifref ToHex ; If someone used this subroutine + ToHex: tay ; Define subroutine + lda HexTab,y + rts + .endif See also: @@ -3190,7 +3190,7 @@ Here's a list of all control commands and a description, what they do: Example: - .import foo + .import foo .import bar: zeropage @@ -3206,7 +3206,7 @@ Here's a list of all control commands and a description, what they do: Example: - .importzp foo, bar + .importzp foo, bar See: @@ -3224,14 +3224,14 @@ Here's a list of all control commands and a description, what they do: Example: - ; Include whole file - .incbin "sprites.dat" + ; Include whole file + .incbin "sprites.dat" - ; Include file starting at offset 256 - .incbin "music.dat", $100 + ; Include file starting at offset 256 + .incbin "music.dat", $100 - ; Read 100 bytes starting at offset 200 - .incbin "graphics.dat", 200, 100 + ; Read 100 bytes starting at offset 200 + .incbin "graphics.dat", 200, 100 @@ -3242,7 +3242,7 @@ Here's a list of all control commands and a description, what they do: Example: - .include "subs.inc" + .include "subs.inc" @@ -3267,8 +3267,8 @@ Here's a list of all control commands and a description, what they do: Example: - .interruptor IrqHandler - .interruptor Handler, 16 + .interruptor IrqHandler + .interruptor Handler, 16 See the command and the separate @@ -3284,12 +3284,12 @@ Here's a list of all control commands and a description, what they do: Example: - .if .not .ismnemonic(ina) - .macro ina - clc - adc #$01 - .endmacro - .endif + .if .not .ismnemonic(ina) + .macro ina + clc + adc #$01 + .endmacro + .endif @@ -3306,10 +3306,10 @@ Here's a list of all control commands and a description, what they do: Example: - .linecont + ; Allow line continuations + .linecont + ; Allow line continuations - lda \ - #$20 ; This is legal now + lda \ + #$20 ; This is legal now @@ -3327,7 +3327,7 @@ Here's a list of all control commands and a description, what they do: Example: - .list on ; Enable listing output + .list on ; Enable listing output @@ -3342,9 +3342,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .listbytes unlimited ; List all bytes - .listbytes 12 ; List the first 12 bytes - .incbin "data.bin" ; Include large binary file + .listbytes unlimited ; List all bytes + .listbytes 12 ; List the first 12 bytes + .incbin "data.bin" ; Include large binary file @@ -3358,14 +3358,14 @@ Here's a list of all control commands and a description, what they do: .lobytes $1234, $2345, $3456, $4567 - .hibytes $fedc, $edcb, $dcba, $cba9 + .hibytes $fedc, $edcb, $dcba, $cba9 which is equivalent to .byte $34, $45, $56, $67 - .byte $fe, $ed, $dc, $cb + .byte $fe, $ed, $dc, $cb Example: @@ -3373,15 +3373,15 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 See also: , @@ -3422,15 +3422,15 @@ Here's a list of all control commands and a description, what they do: Example: - .localchar '?' - - Clear: lda #$00 ; Global label - ?Loop: sta Mem,y ; Local label - dey - bne ?Loop ; Ok - rts - Sub: ... ; New global label - bne ?Loop ; ERROR: Unknown identifier! + .localchar '?' + + Clear: lda #$00 ; Global label + ?Loop: sta Mem,y ; Local label + dey + bne ?Loop ; Ok + rts + Sub: ... ; New global label + bne ?Loop ; ERROR: Unknown identifier! @@ -3454,10 +3454,10 @@ Here's a list of all control commands and a description, what they do: Example: - .macpack longbranch ; Include macro package + .macpack longbranch ; Include macro package - cmp #$20 ; Set condition codes - jne Label ; Jump long on condition + cmp #$20 ; Set condition codes + jne Label ; Jump long on condition Macro packages are explained in more detail in section - .macro ldax arg ; Define macro ldax + .macro ldax arg ; Define macro ldax lda arg ldx arg+1 @@ -3504,7 +3504,7 @@ Here's a list of all control commands and a description, what they do: Example: - .org $7FF ; Emit code starting at $7FF + .org $7FF ; Emit code starting at $7FF @@ -3517,7 +3517,7 @@ Here's a list of all control commands and a description, what they do: Example: - .out "This code was written by the codebuster(tm)" + .out "This code was written by the codebuster(tm)" See also: , @@ -3569,9 +3569,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .pagelength 66 ; Use 66 lines per listing page + .pagelength 66 ; Use 66 lines per listing page - .pagelength unlimited ; Unlimited page length + .pagelength unlimited ; Unlimited page length @@ -3634,15 +3634,15 @@ Here's a list of all control commands and a description, what they do: Example: - .proc Clear ; Define Clear subroutine, start new level - lda #$00 - L1: sta Mem,y ; L1 is local and does not cause a - ; duplicate symbol error if used in other - ; places - dey - bne L1 ; Reference local symbol - rts - .endproc ; Leave lexical level + .proc Clear ; Define Clear subroutine, start new level + lda #$00 + L1: sta Mem,y ; L1 is local and does not cause a + ; duplicate symbol error if used in other + ; places + dey + bne L1 ; Reference local symbol + rts + .endproc ; Leave lexical level See: / and - .macro Crypt Arg - .repeat .strlen(Arg), I - .byte .strat(Arg, I) ^ $55 - .endrep - .endmacro + .macro Crypt Arg + .repeat .strlen(Arg), I + .byte .strat(Arg, I) ^ $55 + .endrep + .endmacro See: @@ -3739,8 +3739,8 @@ Here's a list of all control commands and a description, what they do: Example: - ; Reserve 12 bytes of memory with value $AA - .res 12, $AA + ; Reserve 12 bytes of memory with value $AA + .res 12, $AA @@ -3750,7 +3750,7 @@ Here's a list of all control commands and a description, what they do: "RODATA", so this is a shortcut for - .segment "RODATA" + .segment "RODATA" The RODATA segment is a segment that is used by the compiler for @@ -3778,11 +3778,11 @@ Here's a list of all control commands and a description, what they do: Example: - .scope Error ; Start new scope named Error + .scope Error ; Start new scope named Error None = 0 ; No error File = 1 ; File error Parse = 2 ; Parse error - .endscope ; Close lexical level + .endscope ; Close lexical level ... lda #Error::File ; Use symbol from scope Error @@ -3825,10 +3825,10 @@ Here's a list of all control commands and a description, what they do: Examples: - .segment "ROM2" ; Switch to ROM2 segment - .segment "ZP2": zeropage ; New direct segment - .segment "ZP2" ; Ok, will use last attribute - .segment "ZP2": absolute ; Error, redecl mismatch + .segment "ROM2" ; Switch to ROM2 segment + .segment "ZP2": zeropage ; New direct segment + .segment "ZP2" ; Ok, will use last attribute + .segment "ZP2": absolute ; Error, redecl mismatch See: , - .smart ; Be smart - .smart - ; Stop being smart + .smart ; Be smart + .smart - ; Stop being smart See: , @@ -3959,17 +3959,17 @@ Here's a list of all control commands and a description, what they do: Example: - .macro jne target - .local L1 - .ifndef target - .warning "Forward jump in jne, cannot optimize!" - beq L1 - jmp target - L1: - .else - ... - .endif - .endmacro + .macro jne target + .local L1 + .ifndef target + .warning "Forward jump in jne, cannot optimize!" + beq L1 + jmp target + L1: + .else + ... + .endif + .endmacro See also: , @@ -3985,7 +3985,7 @@ Here's a list of all control commands and a description, what they do: Example: - .word $0D00, $AF13, _Clear + .word $0D00, $AF13, _Clear @@ -4306,41 +4306,41 @@ different: - Macros defined with may not - span more than a line. You may use line continuation (see ) to spread the definition over - more than one line for increased readability, but the macro itself - may not contain an end-of-line token. - - Macros defined with share - the name space with classic macros, but they are detected and replaced - at the scanner level. While classic macros may be used in every place, - where a mnemonic or other directive is allowed, style macros are allowed anywhere in a line. So - they are more versatile in some situations. - - style macros may take - parameters. While classic macros may have empty parameters, this is - not true for style macros. - For this macro type, the number of actual parameters must match - exactly the number of formal parameters. - - To make this possible, formal parameters are enclosed in braces when - defining the macro. If there are no parameters, the empty braces may - be omitted. - - Since style macros may not - contain end-of-line tokens, there are things that cannot be done. They - may not contain several processor instructions for example. So, while - some things may be done with both macro types, each type has special - usages. The types complement each other. - - Parentheses work differently from C macros. - The common practice of wrapping C macros in parentheses may cause - unintended problems here, such as accidentally implying an - indirect addressing mode. While the definition of a macro requires - parentheses around its argument list, when invoked they should not be - included. + Macros defined with may not + span more than a line. You may use line continuation (see ) to spread the definition over + more than one line for increased readability, but the macro itself + may not contain an end-of-line token. + + Macros defined with share + the name space with classic macros, but they are detected and replaced + at the scanner level. While classic macros may be used in every place, + where a mnemonic or other directive is allowed, style macros are allowed anywhere in a line. So + they are more versatile in some situations. + + style macros may take + parameters. While classic macros may have empty parameters, this is + not true for style macros. + For this macro type, the number of actual parameters must match + exactly the number of formal parameters. + + To make this possible, formal parameters are enclosed in braces when + defining the macro. If there are no parameters, the empty braces may + be omitted. + + Since style macros may not + contain end-of-line tokens, there are things that cannot be done. They + may not contain several processor instructions for example. So, while + some things may be done with both macro types, each type has special + usages. The types complement each other. + + Parentheses work differently from C macros. + The common practice of wrapping C macros in parentheses may cause + unintended problems here, such as accidentally implying an + indirect addressing mode. While the definition of a macro requires + parentheses around its argument list, when invoked they should not be + included. @@ -4484,14 +4484,14 @@ Currently defined macroes are: .macro add Arg ; add without carry - clc - adc Arg - .endmacro + clc + adc Arg + .endmacro .macro sub Arg ; subtract without borrow - sec - sbc Arg - .endmacro + sec + sbc Arg + .endmacro .macro bge Arg ; branch on greater-than or equal bcs Arg @@ -4531,14 +4531,14 @@ definition for the " - .macro jeq Target - .if .def(Target) .and ((*+2)-(Target) <= 127) - beq Target - .else - bne *+5 - jmp Target - .endif - .endmacro + .macro jeq Target + .if .def(Target) .and ((*+2)-(Target) <= 127) + beq Target + .else + bne *+5 + jmp Target + .endif + .endmacro All macros expand to a short branch, if the label is already defined (back @@ -4549,7 +4549,7 @@ jump to the actual branch target. The package defines the following macros: - jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc + jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc @@ -4980,14 +4980,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cbm510.sgml b/doc/cbm510.sgml index 600a1fe90..1ec0e05d4 100644 --- a/doc/cbm510.sgml +++ b/doc/cbm510.sgml @@ -322,14 +322,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cbm610.sgml b/doc/cbm610.sgml index 68b1060ad..37a445dd1 100644 --- a/doc/cbm610.sgml +++ b/doc/cbm610.sgml @@ -304,14 +304,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/chrcvt65.sgml b/doc/chrcvt65.sgml index 0a2fc2f76..a631a0004 100644 --- a/doc/chrcvt65.sgml +++ b/doc/chrcvt65.sgml @@ -102,14 +102,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cl65.sgml b/doc/cl65.sgml index c6761ed9e..0291f2eb3 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -236,14 +236,14 @@ package, it tries to be smart about several things. - If you don't give a target system on the command line, cl65 - defaults to the C64. + If you don't give a target system on the command line, cl65 + defaults to the C64. When linking, cl65 will supply the name of the library file for the target system to the linker; so, you don't have to do that. - If the final step is the linker, and the name of the output file was - not explicitly given, cl65 will use the name of the first input file + If the final step is the linker, and the name of the output file was + not explicitly given, cl65 will use the name of the first input file without the extension, provided that the name of that file has an extension. So, you don't need to give the executable name in most cases; just give the name of your "main" file as the first input file. @@ -284,24 +284,24 @@ assembler file (irq.s) will need the following separate steps to compile into an executable named morse: - cc65 -g -Oi -t c64 morse.c - ca65 -g morse.s - ca65 -g irq.s - ld65 -o morse -t c64 c64.o morse.o irq.o c64.lib + cc65 -g -Oi -t c64 morse.c + ca65 -g morse.s + ca65 -g irq.s + ld65 -o morse -t c64 c64.o morse.o irq.o c64.lib When using cl65, this is simplified to - cl65 -g -Oi morse.c irq.s + cl65 -g -Oi morse.c irq.s As a general rule, you may use cl65 instead of cc65 at most times, especially in makefiles to build object files directly from C files. Use - .c.o: - cl65 -g -Oi $< + .c.o: + cl65 -g -Oi $< to do this. @@ -323,14 +323,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/co65.sgml b/doc/co65.sgml index 06bdbe191..865aed2bb 100644 --- a/doc/co65.sgml +++ b/doc/co65.sgml @@ -285,7 +285,7 @@ segment. Use the assembler to generate an object file from the assembler output. - co65 --code-label _c64_hi c64-hi.tgi + co65 --code-label _c64_hi c64-hi.tgi ca65 c64-hi.s @@ -293,7 +293,7 @@ Next, change your C code to declare a variable that is actually the address of the driver: - extern void c64_hi[]; + extern void c64_hi[]; Instead of loading and unloading the driver, change the code to install and @@ -329,14 +329,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/coding.sgml b/doc/coding.sgml index 5897837c4..dc07c091a 100644 --- a/doc/coding.sgml +++ b/doc/coding.sgml @@ -127,17 +127,17 @@ and predecrement operators if you don't need the resulting value. That means, use - ... - ++i; - ... + ... + ++i; + ... instead of - ... - i++; - ... + ... + i++; + ... @@ -148,24 +148,24 @@ The compiler produces optimized code, if the value of a pointer is a constant. So, to access direct memory locations, use - #define VDC_STATUS 0xD601 - *(char*)VDC_STATUS = 0x01; + #define VDC_STATUS 0xD601 + *(char*)VDC_STATUS = 0x01; That will be translated to - lda #$01 - sta $D601 + lda #$01 + sta $D601 The constant value detection works also for struct pointers and arrays, if the subscript is a constant. So - #define VDC ((unsigned char*)0xD600) - #define STATUS 0x01 - VDC[STATUS] = 0x01; + #define VDC ((unsigned char*)0xD600) + #define STATUS 0x01 + VDC[STATUS] = 0x01; will also work. @@ -182,14 +182,14 @@ Initialization of local variables when declaring them gives shorter and faster code. So, use - int i = 1; + int i = 1; instead of - int i; - i = 1; + int i; + i = 1; But beware: To maximize your savings, don't mix uninitialized and initialized @@ -201,18 +201,18 @@ variables, you force the compiler to allocate space for the uninitialized variables each time, it parses an initialized one. So do this: - int i, j; - int a = 3; - int b = 0; + int i, j; + int a = 3; + int b = 0; instead of - int i; - int a = 3; - int j; - int b = 0; + int i; + int a = 3; + int j; + int b = 0; The latter will work, but will create larger and slower code. @@ -228,17 +228,17 @@ common cases. Don't use - char* a; - char b, c; - char b = *(a + c); + char* a; + char b, c; + char b = *(a + c); Use - char* a; - char b, c; - char b = a[c]; + char* a; + char b, c; + char b = a[c]; instead. diff --git a/doc/creativision.sgml b/doc/creativision.sgml index a701ae1ce..f7e5de8b1 100644 --- a/doc/creativision.sgml +++ b/doc/creativision.sgml @@ -168,14 +168,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/debugging.sgml b/doc/debugging.sgml index 7f2c3af5a..8b09db384 100644 --- a/doc/debugging.sgml +++ b/doc/debugging.sgml @@ -109,7 +109,7 @@ Load your program, then enter the monitor and use the " - ll "hello.lbl" + ll "hello.lbl" You will get lots of warnings and even a few errors. You may ignore safely all @@ -120,7 +120,7 @@ After loading the labels, they are used by VICE in the disassembler listing, and you may use them whereever you need to specify an address. Try - d ._main + d ._main as an example (note that VICE needs a leading dot before all labels, and that @@ -134,14 +134,14 @@ Load your program, then enter the monitor and use the " - sl hello.sym + sl hello.sym After loading the labels, they are used by Oricutron in the disassembler listing, and you may use them whereever you need to specify an address. Try - d ._main + d ._main as an example (note that VICE needs a leading dot before all labels, and that diff --git a/doc/gamate.sgml b/doc/gamate.sgml index e5e3acbdd..8e18ab76d 100644 --- a/doc/gamate.sgml +++ b/doc/gamate.sgml @@ -138,14 +138,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/geos.sgml b/doc/geos.sgml index eb8d74939..ec9d66b1a 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -68,19 +68,19 @@ programs. The software needed: . + can get it from: . . - The VICE package contains the . + The VICE package contains the . + object files from a PC to a 1541. There's also one important ability of this + tool - it automatically un-converts .cvt files into GEOS native format on + disk image files. Check out: . . + other Commodore IEC bus drives. It can be a replacement for Star Commander if + you only want to transfer files to a disk and unconvert using GEOS program for + this purpose. Check out: .

VICE and cc65 are portable - they run on variety of platforms - DOS, Win32 and UNIX. GEOSLib only @@ -387,7 +387,7 @@ and the number of rows to skip from the top if it. BitOtherClip

Similar to the previous one with some extension. File and Disk @@ -1452,9 +1452,9 @@ void example = { Which will be compiled to following string of bytes: _example: - .byte 3 - .word 3 - .byte 0 + .byte 3 + .word 3 + .byte 0 As you see this way it is possible to define data of any type in any order. You must remember to cast each member to proper type. @@ -1474,21 +1474,21 @@ just in the content. Here is how a single descriptor looks like: void myMenu = { - (char)top, (char)bottom, // this is the size of the menubox - (unsigned)left, (unsigned)right, // counting all items in the current descriptor - (char)number_of_items | type_of_menu, // number of following items ORed with - // type of this menu, it can be either - // HORIZONTAL or VERTICAL if you will have also bit 6 set then menu won't be closed - // after moving mouse pointer outside the menubox. You can have at most 31 items. + (char)top, (char)bottom, // this is the size of the menubox + (unsigned)left, (unsigned)right, // counting all items in the current descriptor + (char)number_of_items | type_of_menu, // number of following items ORed with + // type of this menu, it can be either + // HORIZONTAL or VERTICAL if you will have also bit 6 set then menu won't be closed + // after moving mouse pointer outside the menubox. You can have at most 31 items. This is followed by - ... - "menuitemname", (char)item_type, (unsigned)pointer, - "nextitemname", (char)item_type, (unsigned)pointer, - ... - "lastitemname", (char)item_type, (unsigned)pointer }; - // Note that there isn't ending const dlgBoxStr example = { - DB_DEFPOS (pattern_of_shadow), - ... // commands - DB_END }; + DB_DEFPOS (pattern_of_shadow), + ... // commands + DB_END }; And the own size and position would be: const dlgBoxStr example = { - DB_SETPOS (pattern, top, bottom, left, right) - ... // commands - DB_END }; + DB_SETPOS (pattern, top, bottom, left, right) + ... // commands + DB_END }; Commands @@ -1539,9 +1539,9 @@ The next element of the - ... - DB_ICON(OK, DBI_X_0, DBI_Y_0), - ... + ... + DB_ICON(OK, DBI_X_0, DBI_Y_0), + ... Note that the position is counted from top left corner of window, not entire screen and that the 'x' position is counted in cards (8-pixel) and not in pixels. This is also true for all following commands. @@ -1555,11 +1555,11 @@ where the address of the text is stored. This is useful for information windows is variable. Consider following: char text = "foo"; - ... - r15=(unsigned)text; // in code just before call to DoDlgBox - ... - DB_VARSTR (TXT_LN_X, TXT_LN_1_Y, &r15), - ... + ... + r15=(unsigned)text; // in code just before call to DoDlgBox + ... + DB_VARSTR (TXT_LN_X, TXT_LN_1_Y, &r15), + ... will cause the word ''foo'' to appear in the window, but you may store the pointer to any text in const graphicStr example = { - MOVEPENTO(0,0), - NEWPATTERN(0), - RECTANGLETO(319,199) - GSTR_END }; + MOVEPENTO(0,0), + NEWPATTERN(0), + RECTANGLETO(319,199) + GSTR_END }; InitRam table @@ -1623,17 +1623,17 @@ It is possible to intercept events and hook into the GEOS Kernal using vectors. void_func oldVector; void NewVectorHandler(void) { - // do something and at the end call the old vector routine - oldVector(); + // do something and at the end call the old vector routine + oldVector(); } void hook_into_system(void) { - oldVector = mouseVector; - mouseVector = NewVectorHandler; + oldVector = mouseVector; + mouseVector = NewVectorHandler; } void remove_hook(void) { - mouseVector = oldVector; + mouseVector = oldVector; }

@@ -1655,10 +1655,10 @@ That little example above intercepts - diff --git a/doc/grc65.sgml b/doc/grc65.sgml index fb90fe23f..aec112f6b 100644 --- a/doc/grc65.sgml +++ b/doc/grc65.sgml @@ -381,11 +381,11 @@ HEADER APPLICATION "MyFirstApp" "Class Name" "V1.0" ; file named MyFirstApp with the Class-string "Class Name V1.0" { ; Not all fields are required, default and current values will be used. - author "Maciej Witkowiak" ; always in quotes! - info "Information text" ; always in quotes! -; date yy mm dd hh ss ; always 5 fields! -; dostype seq ; can be: PRG, SEQ, USR (only all UPPER- or lower-case) -; structure seq ; can be: SEQ, VLIR (only UPPER- or lower-case) - mode c64only ; can be: any, 40only, 80only, c64only + author "Maciej Witkowiak" ; always in quotes! + info "Information text" ; always in quotes! +; date yy mm dd hh ss ; always 5 fields! +; dostype seq ; can be: PRG, SEQ, USR (only all UPPER- or lower-case) +; structure seq ; can be: SEQ, VLIR (only UPPER- or lower-case) + mode c64only ; can be: any, 40only, 80only, c64only } diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 0230b517f..9116eb442 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -24,21 +24,21 @@ It complements the features that are built into the ca65 macroassembler: - Accept any number of segments to form an executable module. + Accept any number of segments to form an executable module. - Resolve arbitrary expressions stored in the object files. + Resolve arbitrary expressions stored in the object files. - In case of errors, use the meta information stored in the object files - to produce helpful error messages. In case of undefined symbols, - expression range errors, or symbol type mismatches, ld65 is able to - tell you the exact location in the original assembler source, where - the symbol was referenced. + In case of errors, use the meta information stored in the object files + to produce helpful error messages. In case of undefined symbols, + expression range errors, or symbol type mismatches, ld65 is able to + tell you the exact location in the original assembler source, where + the symbol was referenced. - Flexible output. The output of ld65 is highly configurable by a config - file. Some more-common platforms are supported by default configurations - that may be activated by naming the target system. The output - generation was designed with different output formats in mind, so - adding other formats shouldn't be a great problem. + Flexible output. The output of ld65 is highly configurable by a config + file. Some more-common platforms are supported by default configurations + that may be activated by naming the target system. The output + generation was designed with different output formats in mind, so + adding other formats shouldn't be a great problem. @@ -1148,14 +1148,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/library.sgml b/doc/library.sgml index b2f880051..8800c5496 100644 --- a/doc/library.sgml +++ b/doc/library.sgml @@ -228,14 +228,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/lynx.sgml b/doc/lynx.sgml index de9951b9a..0eef70535 100644 --- a/doc/lynx.sgml +++ b/doc/lynx.sgml @@ -337,14 +337,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/nes.sgml b/doc/nes.sgml index 14fcac559..3f8f74183 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -179,17 +179,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - - - diff --git a/doc/od65.sgml b/doc/od65.sgml index aab7522d9..633f7b164 100644 --- a/doc/od65.sgml +++ b/doc/od65.sgml @@ -200,15 +200,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - diff --git a/doc/osi.sgml b/doc/osi.sgml index 081d7cfbb..eeaee4a97 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -217,14 +217,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/pet.sgml b/doc/pet.sgml index 61d6eb7a7..eb13d9fb9 100644 --- a/doc/pet.sgml +++ b/doc/pet.sgml @@ -242,14 +242,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/plus4.sgml b/doc/plus4.sgml index da9171a6f..11468bb33 100644 --- a/doc/plus4.sgml +++ b/doc/plus4.sgml @@ -260,14 +260,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 286c46c56..0739ea2f1 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -27,19 +27,19 @@ binary needs to be compiled with - Usage: sim65 [options] file [arguments] - Short options: - -h Help (this text) - -c Print amount of executed CPU cycles - -v Increase verbosity - -V Print the simulator version number - -x Exit simulator after cycles - - Long options: - --help Help (this text) - --cycles Print amount of executed CPU cycles - --verbose Increase verbosity - --version Print the simulator version number + Usage: sim65 [options] file [arguments] + Short options: + -h Help (this text) + -c Print amount of executed CPU cycles + -v Increase verbosity + -V Print the simulator version number + -x Exit simulator after cycles + + Long options: + --help Help (this text) + --cycles Print amount of executed CPU cycles + --verbose Increase verbosity + --version Print the simulator version number @@ -120,14 +120,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/smc.sgml b/doc/smc.sgml index aec0d3d0b..e277c5008 100644 --- a/doc/smc.sgml +++ b/doc/smc.sgml @@ -470,7 +470,7 @@ SMC instructions. Example: - SMC_OperateOnValue ASL, LoadMask ; shift mask to left + SMC_OperateOnValue ASL, LoadMask ; shift mask to left ... SMC LoadMask, { LDA #$20 } @@ -555,14 +555,14 @@ allowing reuse of some instructions. 5: SMC StoreAccuFirstSection, { sta SMC_AbsAdr, Y } 6: ... 7: RestoreCodeBranchBaseAdr: - 8: SMC FirstIncHighByte, { SMC_OperateOnHighByte inc, StoreAccuFirstSection } ; code will be overwritten to 'beq RestoreCode' (*) + 8: SMC FirstIncHighByte, { SMC_OperateOnHighByte inc, StoreAccuFirstSection } ; code will be overwritten to 'beq RestoreCode' (*) 9: ... -10: SMC_TransferOpcode FirstIncHighByte, OPC_BEQ , x ; change code marked above with (*) -11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative address to 'RestoreCode' +10: SMC_TransferOpcode FirstIncHighByte, OPC_BEQ , x ; change code marked above with (*) +11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative address to 'RestoreCode' 12: ... 13: restoreCode: -14: SMC_TransferOpcode FirstIncHighByte, OPC_INC_abs , x ; restore original code... -15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of address) +14: SMC_TransferOpcode FirstIncHighByte, OPC_INC_abs , x ; restore original code... +15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of address) 16: ... diff --git a/doc/sp65.sgml b/doc/sp65.sgml index 82b308025..255d7a552 100644 --- a/doc/sp65.sgml +++ b/doc/sp65.sgml @@ -403,14 +403,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 641a7e807..2570cfb9c 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -148,14 +148,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index 1f352607f..e52b183d0 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -16,8 +16,8 @@ An overview over the Telestrat (Telemon 2.4 & Telemon 3.x : http://orix.oric.org Overview

-This file contains an overview of the Telestrat runtime system as it comes -with the cc65 C compiler. It describes the memory layout, Telestrat-specific +This file contains an overview of the Telestrat runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Telestrat-specific header files, available drivers, and any pitfalls specific to that platform. Please note that Telestrat-specific functions are just mentioned here, they are @@ -27,13 +27,13 @@ more than one platform. Please see the function reference for more information. Oric Telestrat is the last Oric computer (Released in 1986, mainly in France). -This computer is an Atmos with extra hardware: RS232, cardridge(banking system), +This computer is an Atmos with extra hardware: RS232, cardridge(banking system), joysticks (2 ports) or mouse (on joystick port), FDC. Video chip, CPU, keyboard management, tape hardware are the same than Atmos. -Telestrat can start in Atmos mode with Atmos Cardridge (which is only the atmos -Basic 1.1 ROM). +Telestrat can start in Atmos mode with Atmos Cardridge (which is only the atmos +Basic 1.1 ROM). Telestrat can start in Sedoric (Atmos OS) and Atmos mode with Stratoric Cardridge. This Cardridge has 3 banks of 16KB of rom with: @@ -43,15 +43,15 @@ This Cardridge has 3 banks of 16KB of rom with: a Basic 1.0 ROM (Oric-1). -The main Telestrat's configuration is the Telemon/Hyperbasic Cardridge inserted +The main Telestrat's configuration is the Telemon/Hyperbasic Cardridge inserted with Stratsed in floppy drive. -Anyway, there is no way to load a tape file in Telemon/Hyperbasic mode without +Anyway, there is no way to load a tape file in Telemon/Hyperbasic mode without alternative program. There is also no software to write a Stratsed dsk file on PC. -This Telestrat target build an Orix binary file. But, in the future, it will be possible +This Telestrat target build an Orix binary file. But, in the future, it will be possible to build a Stratsed disk. Orix uses the same systems calls than Telemon mode. That is why if you need to do software for telestrat target, you have the choice to: @@ -74,12 +74,12 @@ name="here" url="http://orix.oric.org/orix-header/"> This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. -Stratsed (the Telestrat operating system) handles files management. Stratsed +Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. Stratsed vector are declared in asminc/telestrat.inc. -But, reverse engineering is required to find how theses vectors works. Please, note that +But, reverse engineering is required to find how theses vectors works. Please, note that Stratsed is located in overlay memory (bank 0) There is no tool to insert a binary in a Stratsed floppy disk. @@ -88,8 +88,8 @@ The only way to load a binary (for Telemon 2.4) is to: remove the 20 bytes header download -use Floppybuilder in OSDK to insert the binary with the tool (please read -FloppyBuilder manual to learn how to insert your binary and how to start Microdisc boot sector +use Floppybuilder in OSDK to insert the binary with the tool (please read +FloppyBuilder manual to learn how to insert your binary and how to start Microdisc boot sector when Telestrat starts) @@ -183,13 +183,13 @@ TGI drivers is available on Oric Telestrat with some functions: Extended memory drivers

-No extended memory drivers are currently available for the Telestrat. -This feature could be done because telestrat can manage RAM inserted in his -port cardridge. +No extended memory drivers are currently available for the Telestrat. +This feature could be done because telestrat can manage RAM inserted in his +port cardridge. Joystick drivers

-Telemon 2.4 & 3.0 manages joysticks but it had been handled yet. This means that +Telemon 2.4 & 3.0 manages joysticks but it had been handled yet. This means that joysticks driver could be written easily. Telemon 2.4 returns in keyboard buffer the direction of the joysticks. This means that @@ -197,12 +197,12 @@ if you get input from keyboard by conio cgetc function, you will get direction f Mouse drivers

-Telestrat manages also mouse, but it had been no handled yet in this version. +Telestrat manages also mouse, but it had been no handled yet in this version. Telestrat mouse is really difficult to find. RS232 device drivers

-Telestrat has a RS232 port, but it's not usable in cc65. It is possible to use +Telestrat has a RS232 port, but it's not usable in cc65. It is possible to use RS232 port with Telemon calls (see XSOUT primitive for example) Limitations

@@ -236,14 +236,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/using-make.sgml b/doc/using-make.sgml index 7986e1dc9..2758a340b 100644 --- a/doc/using-make.sgml +++ b/doc/using-make.sgml @@ -76,13 +76,13 @@ ifneq ($(MAKECMDGOALS),clean) endif %.o: %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< $(PROGRAM): $(SOURCES:.c=.o) - $(CC) $(LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ clean: - $(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map + $(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map - The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/test/err/front.c b/test/err/front.c index dde8d47ec..af59209b7 100644 --- a/test/err/front.c +++ b/test/err/front.c @@ -5,25 +5,25 @@ */ main() { - return 0; + return 0; } nested(a,b) { - if ((a<4 && b == 'r') - || (a == 1 && (b == 'h' || b == 'i')) - || (a == 2 && (b == 'o' || b == 'y')) - ) a=b; + if ((a<4 && b == 'r') + || (a == 1 && (b == 'h' || b == 'i')) + || (a == 2 && (b == 'o' || b == 'y')) + ) a=b; } /* type name scope */ -void s(struct D *d) {} /* this struct D differs from the one below */ +void s(struct D *d) {} /* this struct D differs from the one below */ typedef struct D D; struct D {int x, y;} Dy={0}; D Dz={1}; Dfunc(){ - D a; a.y=1; - s(&Dy); /* error */ + D a; a.y=1; + s(&Dy); /* error */ } /* qualifiers */ @@ -33,39 +33,39 @@ const int a, *x; int b, *y; volatile unsigned z; f() { - x = y; - z = z + z; /* should be 2 references to z's r-value */ + x = y; + z = z + z; /* should be 2 references to z's r-value */ } f1() { - x = &a; - x = &b; - y = &a; /* error */ - y = &b; + x = &a; + x = &b; + y = &a; /* error */ + y = &b; } f2(int **a, int **b) { - f(&x, &y); - **a = 0; - return **b; + f(&x, &y); + **a = 0; + return **b; } g(const int *p) { - g(&a); - g(&b); - return *p; + g(&a); + g(&b); + return *p; } h(int *p) { - f(&a); - f(&b); - return *p; + f(&a); + f(&b); + return *p; } h1(const int x, int y) { - h1(a,b); - h1(b,a); - return x + y; + h1(a,b); + h1(b,a); + return x + y; } h2() { - char *b; const void *p; - p = b; - b = p; /* error (incompatible pointer type) */ + char *b; const void *p; + p = b; + b = p; /* error (incompatible pointer type) */ } /* static naming */ @@ -120,14 +120,14 @@ extern int strcmp(const char*, const char*); extern void qsort(void*, int, int, int (*)(const void*, const void*)); extern int cmp(char**a, char**b) { return strcmp(*a,*b); } sort() { - int n; char *a[100]; - qsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp); + int n; char *a[100]; + qsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp); qsort(a, n, sizeof(char*), cmp); /* error (incompatible pointer type) */ } /* nasty calls */ onearg(){ - int a,b,c,d; - f( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) ); /* 1 argument */ + int a,b,c,d; + f( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) ); /* 1 argument */ } diff --git a/test/misc/fields.c b/test/misc/fields.c index 83bee82b7..acc561ce7 100644 --- a/test/misc/fields.c +++ b/test/misc/fields.c @@ -20,11 +20,11 @@ main() #ifdef REFCC #include struct foo { - int16_t a; - char b; - int16_t x : 12, y : 4; - int16_t zz : 1, : 0, : 4, z : 3; - char c; + int16_t a; + char b; + int16_t x : 12, y : 4; + int16_t zz : 1, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { uint16_t a:2, b:4, c:16;} y = { 7, 8, 9}; @@ -33,11 +33,11 @@ int16_t i = 8; #else struct foo { - int a; - char b; - int x : 12, y : 4; - int zz : 1, : 0, : 4, z : 3; - char c; + int a; + char b; + int x : 12, y : 4; + int zz : 1, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { unsigned int a:2, b:4, c:16;} y = { 7, 8, 9}; @@ -46,10 +46,10 @@ int i = 8; #else struct foo { - int a; - char b; - int x : 12, y : 4, : 0, : 4, z : 3; - char c; + int a; + char b; + int x : 12, y : 4, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { unsigned int a:2, b:4, c:32;} y = { 7, 8, 9}; @@ -63,32 +63,32 @@ f2(struct baz *p); main() { - printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); - printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); - x.y = i; - x.z = 070; - printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); - y.a = 2; - y.c = i; - printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); + printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); + printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); + x.y = i; + x.z = 070; + printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); + y.a = 2; + y.c = i; + printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); #ifdef CAST_STRUCT_PTR - f2((struct baz *)&x); + f2((struct baz *)&x); #else - f2(&x); + f2(&x); #endif - return 0; + return 0; } f1(struct baz *p) { - p->a = p->b = 0; - if (p->b) - printf("p->b != 0!\n"); - p->a = 0x3; p->b = 0xf; - printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b); + p->a = p->b = 0; + if (p->b) + printf("p->b != 0!\n"); + p->a = 0x3; p->b = 0xf; + printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b); } f2(struct baz *p) { - p->a = (i==0); - p->b = (f1(p),0); + p->a = (i==0); + p->b = (f1(p),0); } #endif diff --git a/test/misc/limits.c b/test/misc/limits.c index 613d6bd09..427c54d23 100644 --- a/test/misc/limits.c +++ b/test/misc/limits.c @@ -7,9 +7,9 @@ #include #include -#define SSHRT_MAX SHRT_MAX -#define SINT_MAX INT_MAX -#define SLONG_MAX LONG_MAX +#define SSHRT_MAX SHRT_MAX +#define SINT_MAX INT_MAX +#define SLONG_MAX LONG_MAX #define UCHAR_MIN 0 #define USHRT_MIN 0 diff --git a/test/misc/sitest.c b/test/misc/sitest.c index 9570f4989..3332c064e 100644 --- a/test/misc/sitest.c +++ b/test/misc/sitest.c @@ -5,29 +5,29 @@ */ /* - sitest -- exercise features of C99 and + sitest -- exercise features of C99 and - This source code has been placed into the PUBLIC DOMAIN by its author. + This source code has been placed into the PUBLIC DOMAIN by its author. - last edit: 1999/11/05 gwyn@arl.mil + last edit: 1999/11/05 gwyn@arl.mil - Tries to accommodate pre-C99 versions of . + Tries to accommodate pre-C99 versions of . - Takes advantage of __Q8_* symbols defined by a particular - implementation of , but doesn't require them. + Takes advantage of __Q8_* symbols defined by a particular + implementation of , but doesn't require them. - NOTE: This is not a thorough validation test of the facilities. + NOTE: This is not a thorough validation test of the facilities. */ #define NO_INTERNAL_WCHAR /*#define STANDALONE*/ -#include -#include /* for CHAR_BIT */ -#include -#include /* for ptrdiff_t */ -#include -#include +#include +#include /* for CHAR_BIT */ +#include +#include /* for ptrdiff_t */ +#include +#include #if !defined(STANDARD_C99) && !defined(STANDARD_CC65) @@ -41,15 +41,15 @@ #endif -#include /* embeds */ +#include /* embeds */ -#include /* for sig_atomic_t */ +#include /* for sig_atomic_t */ -#if defined(INTMAX_MAX) /* has C99 features */ -#include +#if defined(INTMAX_MAX) /* has C99 features */ +#include #endif -#include /* test idempotency */ +#include /* test idempotency */ #ifdef STANDALONE @@ -61,1531 +61,1531 @@ FILE *outfile=NULL; #endif -#if __STDC_VERSION__ >= 199901 -#ifndef __Q8_QT -#define __Q8_QT long long +#if __STDC_VERSION__ >= 199901 +#ifndef __Q8_QT +#define __Q8_QT long long #endif #endif -#ifdef PRIdMAX -#define HAVE_PRIdMAX -#ifndef __Q8_MT -#define __Q8_MT intmax_t +#ifdef PRIdMAX +#define HAVE_PRIdMAX +#ifndef __Q8_MT +#define __Q8_MT intmax_t #endif #else -#ifdef PRIdLEAST64 -#ifndef __Q8_MT -#define __Q8_MT int_least64_t +#ifdef PRIdLEAST64 +#ifndef __Q8_MT +#define __Q8_MT int_least64_t #endif -#define PRIdMAX PRIdLEAST64 +#define PRIdMAX PRIdLEAST64 #else -#ifndef __Q8_MT -#define __Q8_MT long +#ifndef __Q8_MT +#define __Q8_MT long #endif -#define PRIdMAX "ld" +#define PRIdMAX "ld" #endif #endif -#ifdef PRIuMAX -#define HAVE_PRIuMAX -#define U__Q8_MT uintmax_t +#ifdef PRIuMAX +#define HAVE_PRIuMAX +#define U__Q8_MT uintmax_t #else -#ifdef PRIuLEAST64 -#define U__Q8_MT uint_least64_t -#define PRIuMAX PRIuLEAST64 +#ifdef PRIuLEAST64 +#define U__Q8_MT uint_least64_t +#define PRIuMAX PRIuLEAST64 #else -#define U__Q8_MT unsigned long -#define PRIuMAX "lu" +#define U__Q8_MT unsigned long +#define PRIuMAX "lu" #endif #endif -#define STR_SUB(s) # s -#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ +#define STR_SUB(s) # s +#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ -#if defined(SCNo32) || defined(PRIo32) -static int32_t int32; +#if defined(SCNo32) || defined(PRIo32) +static int32_t int32; #endif -static int_least16_t intl16; -static uint_least16_t uintl16; -static uint_fast16_t uintf16; -static intmax_t intmax; -static uintmax_t uintmax; +static int_least16_t intl16; +static uint_least16_t uintl16; +static uint_fast16_t uintf16; +static intmax_t intmax; +static uintmax_t uintmax; int -main() { - int status = 0; /* exit status to be returned */ - - - /* features: */ - - printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); - printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ - printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); - printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); - printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); -#ifdef __Q8_QT - printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); +main() { + int status = 0; /* exit status to be returned */ + + + /* features: */ + + printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); + printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ + printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); + printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); + printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); +#ifdef __Q8_QT + printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); #else - printf("*** long long isn't defined ***\n"); -#endif - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); - printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); - printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); - printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); -#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 - printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); + printf("*** long long isn't defined ***\n"); +#endif + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); + printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); + printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); + printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); +#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 + printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); #else - printf("*** wint_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INT8_MAX - printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); - printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); -#endif -#ifdef INT9_MAX - printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); - printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); -#endif -#ifdef INT12_MAX - printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); - printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); -#endif -#ifdef INT16_MAX - printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); - printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); -#endif -#ifdef INT18_MAX - printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); - printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); -#endif -#ifdef INT24_MAX - printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); - printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); -#endif -#ifdef INT32_MAX - printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); - printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); -#endif -#ifdef INT36_MAX - printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); - printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); -#endif -#ifdef INT40_MAX - printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); - printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); -#endif -#ifdef INT48_MAX - printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); - printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); -#endif -#ifdef INT60_MAX - printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); - printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); -#endif -#ifdef INT64_MAX - printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); - printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); -#endif -#ifdef INT72_MAX - printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); - printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); -#endif -#ifdef INT128_MAX - printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); - printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); -#endif - printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); - printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); - printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); - printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); - printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); - printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); -#ifdef INT_LEAST64_MAX - printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); - printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); + printf("*** wint_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INT8_MAX + printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); + printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); +#endif +#ifdef INT9_MAX + printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); + printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); +#endif +#ifdef INT12_MAX + printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); + printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); +#endif +#ifdef INT16_MAX + printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); + printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); +#endif +#ifdef INT18_MAX + printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); + printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); +#endif +#ifdef INT24_MAX + printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); + printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); +#endif +#ifdef INT32_MAX + printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); + printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); +#endif +#ifdef INT36_MAX + printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); + printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); +#endif +#ifdef INT40_MAX + printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); + printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); +#endif +#ifdef INT48_MAX + printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); + printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); +#endif +#ifdef INT60_MAX + printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); + printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); +#endif +#ifdef INT64_MAX + printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); + printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); +#endif +#ifdef INT72_MAX + printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); + printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); +#endif +#ifdef INT128_MAX + printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); + printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); +#endif + printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); + printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); + printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); + printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); + printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); + printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); +#ifdef INT_LEAST64_MAX + printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); + printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); #else - printf("*** uint_least64_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INT_LEAST128_MAX - printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); - printf("sizeof(uint_least128_t)=%u\n", - (unsigned)sizeof(uint_least128_t)); -#endif - printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); - printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); - printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); - printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); - printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); - printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); -#ifdef INT_FAST64_MAX - printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); - printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); + printf("*** uint_least64_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INT_LEAST128_MAX + printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); + printf("sizeof(uint_least128_t)=%u\n", + (unsigned)sizeof(uint_least128_t)); +#endif + printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); + printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); + printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); + printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); + printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); + printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); +#ifdef INT_FAST64_MAX + printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); + printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); #else - printf("*** int_fast64_t isn't defined ***\n"); - status = EXIT_FAILURE; + printf("*** int_fast64_t isn't defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INT_FAST128_MAX - printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); - printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); +#ifdef INT_FAST128_MAX + printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); + printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); #endif -#if defined(INTPTR_MAX) - printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); -#if defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); +#if defined(INTPTR_MAX) + printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); +#if defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); #else - printf("*** intptr_t is defined but uintptr_t isn't ***\n"); - status = EXIT_FAILURE; + printf("*** intptr_t is defined but uintptr_t isn't ***\n"); + status = EXIT_FAILURE; #endif -#elif defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); - printf("*** uintptr_t is defined but intptr_t isn't ***\n"); - status = EXIT_FAILURE; +#elif defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); + printf("*** uintptr_t is defined but intptr_t isn't ***\n"); + status = EXIT_FAILURE; #else - printf("*** neither intptr_t nor uintptr_t is defined ***\n"); - status = EXIT_FAILURE; + printf("*** neither intptr_t nor uintptr_t is defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INTMAX_MAX - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); +#ifdef INTMAX_MAX + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); #else - printf("*** intmax_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif - -#ifdef INT8_MAX - printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); - printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); - printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); -#endif -#ifdef INT9_MAX - printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); - printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); - printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); -#endif -#ifdef INT12_MAX - printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); - printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); - printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); -#endif -#ifdef INT16_MAX - printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); - printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); - printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); -#endif -#ifdef INT18_MAX - printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); - printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); - printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); -#endif -#ifdef INT24_MAX - printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); - printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); - printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); -#endif -#ifdef INT32_MAX - printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); - printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); - printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); -#endif -#ifdef INT36_MAX - printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); - printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); - printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); -#endif -#ifdef INT40_MAX - printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); - printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); - printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); -#endif -#ifdef INT48_MAX - printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); - printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); - printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); -#endif -#ifdef INT60_MAX - printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); - printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); - printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); -#endif -#ifdef INT64_MAX - printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); - printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); - printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); -#endif -#ifdef INT72_MAX - printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); - printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); - printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); -#endif -#ifdef INT128_MAX - printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); - printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); - printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); -#endif - printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); - printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); - printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST8_MAX); - printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); - printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); - printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST16_MAX); - printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); - printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); - printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST32_MAX); -#ifdef INT_LEAST64_MAX - printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); - printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); - printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); -#endif -#ifdef INT_LEAST128_MAX - printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); - printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); - printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); -#endif - printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); - printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); - printf("UINT_FAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST8_MAX); - printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); - printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); - printf("UINT_FAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST16_MAX); - printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); - printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); - printf("UINT_FAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST32_MAX); -#ifdef INT_FAST64_MAX - printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); - printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); - printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); -#endif -#ifdef INT_FAST128_MAX - printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); - printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); - printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); -#endif -#ifdef INTPTR_MAX - printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); - printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); -#endif -#ifdef UINTPTR_MAX - printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); -#endif -#ifdef INTMAX_MAX - printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); - printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); - printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); -#endif -#ifdef PTRDIFF_MAX - printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); - printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); -#endif -#ifdef SIG_ATOMIC_MAX -#if SIG_ATOMIC_MIN < 0 - printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); + printf("*** intmax_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif + +#ifdef INT8_MAX + printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); + printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); + printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); +#endif +#ifdef INT9_MAX + printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); + printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); + printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); +#endif +#ifdef INT12_MAX + printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); + printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); + printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); +#endif +#ifdef INT16_MAX + printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); + printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); + printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); +#endif +#ifdef INT18_MAX + printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); + printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); + printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); +#endif +#ifdef INT24_MAX + printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); + printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); + printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); +#endif +#ifdef INT32_MAX + printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); + printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); + printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); +#endif +#ifdef INT36_MAX + printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); + printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); + printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); +#endif +#ifdef INT40_MAX + printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); + printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); + printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); +#endif +#ifdef INT48_MAX + printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); + printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); + printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); +#endif +#ifdef INT60_MAX + printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); + printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); + printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); +#endif +#ifdef INT64_MAX + printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); + printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); + printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); +#endif +#ifdef INT72_MAX + printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); + printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); + printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); +#endif +#ifdef INT128_MAX + printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); + printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); + printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); +#endif + printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); + printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); + printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST8_MAX); + printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); + printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); + printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST16_MAX); + printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); + printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); + printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST32_MAX); +#ifdef INT_LEAST64_MAX + printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); + printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); + printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); +#endif +#ifdef INT_LEAST128_MAX + printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); + printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); + printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); +#endif + printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); + printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); + printf("UINT_FAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST8_MAX); + printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); + printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); + printf("UINT_FAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST16_MAX); + printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); + printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); + printf("UINT_FAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST32_MAX); +#ifdef INT_FAST64_MAX + printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); + printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); + printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); +#endif +#ifdef INT_FAST128_MAX + printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); + printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); + printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); +#endif +#ifdef INTPTR_MAX + printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); + printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); +#endif +#ifdef UINTPTR_MAX + printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); +#endif +#ifdef INTMAX_MAX + printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); + printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); + printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); +#endif +#ifdef PTRDIFF_MAX + printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); + printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); +#endif +#ifdef SIG_ATOMIC_MAX +#if SIG_ATOMIC_MIN < 0 + printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); #else - printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); + printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); #endif #endif -#ifdef SIZE_MAX - printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); +#ifdef SIZE_MAX + printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); #endif -#ifdef WCHAR_MAX -#if WCHAR_MIN < 0 - printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); +#ifdef WCHAR_MAX +#if WCHAR_MIN < 0 + printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); #else - printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); + printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); #endif #endif -#ifdef WINT_MAX -#if WINT_MIN < 0 - printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); +#ifdef WINT_MAX +#if WINT_MIN < 0 + printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); #else - printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); -#endif -#endif - - /* - 7.18.4 Macros for integer constants - */ - - /* INTn_C for n=8 and 16 were at one point unimplementable - on most platforms, so they're treated as "optional": */ -#ifdef INT8_C - if ( INT8_C(-123) != -123 ) - printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT8_C(-123) - ); - if ( UINT8_C(123) != 123 ) - printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT8_C(123) - ); -#endif -#ifdef INT16_C - if ( INT16_C(-12345) != -12345 ) - printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT16_C(-12345) - ); - if ( UINT16_C(12345) != 12345 ) - printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT16_C(12345) - ); -#endif - if ( INT32_C(-123456789) != -123456789 ) - printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT32_C(-123456789) - ); - if ( UINT32_C(123456789) != 123456789 ) - printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT32_C(123456789) - ); -#ifdef INT_LEAST64_MAX - if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INT64_C(-1234567890123456789) - ); - if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINT64_C(1234567890123456789) - ); -#endif -#ifdef INTMAX_MAX - if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INTMAX_C(-1234567890123456789) - ); - if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINTMAX_C(1234567890123456789) - ); -#endif - - /* features: */ - -#if __STDC_VERSION__ >= 199901 - printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); -#endif - - /* - 7.8.1 Macros for format specifiers - */ - - { - /* scanf these strings */ - static const char in_dn[] = "Z119bZ"; - static const char in_dmo[] = "Z-0119bZ"; - static const char in_dspx[] = "Z \t\n +0X119bZ"; - static const char in_dsmx[] = "Z \t\n -0x119bZ"; - static const char in_dsn[] = "Z \t\n 119bZ"; - static const char in_dp[] = "Z+119bZ"; - static const char in_dpx[] = "Z+0X119bz"; - - /* sprintf into this */ - static char buffer[1024]; + printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); +#endif +#endif + + /* + 7.18.4 Macros for integer constants + */ + + /* INTn_C for n=8 and 16 were at one point unimplementable + on most platforms, so they're treated as "optional": */ +#ifdef INT8_C + if ( INT8_C(-123) != -123 ) + printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT8_C(-123) + ); + if ( UINT8_C(123) != 123 ) + printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT8_C(123) + ); +#endif +#ifdef INT16_C + if ( INT16_C(-12345) != -12345 ) + printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT16_C(-12345) + ); + if ( UINT16_C(12345) != 12345 ) + printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT16_C(12345) + ); +#endif + if ( INT32_C(-123456789) != -123456789 ) + printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT32_C(-123456789) + ); + if ( UINT32_C(123456789) != 123456789 ) + printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT32_C(123456789) + ); +#ifdef INT_LEAST64_MAX + if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INT64_C(-1234567890123456789) + ); + if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINT64_C(1234567890123456789) + ); +#endif +#ifdef INTMAX_MAX + if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INTMAX_C(-1234567890123456789) + ); + if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINTMAX_C(1234567890123456789) + ); +#endif + + /* features: */ + +#if __STDC_VERSION__ >= 199901 + printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); +#endif + + /* + 7.8.1 Macros for format specifiers + */ + + { + /* scanf these strings */ + static const char in_dn[] = "Z119bZ"; + static const char in_dmo[] = "Z-0119bZ"; + static const char in_dspx[] = "Z \t\n +0X119bZ"; + static const char in_dsmx[] = "Z \t\n -0x119bZ"; + static const char in_dsn[] = "Z \t\n 119bZ"; + static const char in_dp[] = "Z+119bZ"; + static const char in_dpx[] = "Z+0X119bz"; + + /* sprintf into this */ + static char buffer[1024]; #if 1 -#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( var != (exp) ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %" fs " ***\n", var \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ - -#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %s ***\n", buffer \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ +#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( var != (exp) ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %" fs " ***\n", var \ + ); \ + status = EXIT_FAILURE; \ + } \ + else /* for trailing semicolon */ + +#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %s ***\n", buffer \ + ); \ + status = EXIT_FAILURE; \ + } \ + else /* for trailing semicolon */ #else - -#define SCAN(buf,fs,var,exp) -#define PRINT(fs,var,exp) + +#define SCAN(buf,fs,var,exp) +#define PRINT(fs,var,exp) #endif - -#ifdef SCNo32 + +#ifdef SCNo32 - SCAN(in_dn, SCNo32, int32, 9); + SCAN(in_dn, SCNo32, int32, 9); #endif -#ifdef PRIo32 - PRINT(PRIo32, int32, 11); +#ifdef PRIo32 + PRINT(PRIo32, int32, 11); #endif - SCAN(in_dmo, SCNiLEAST16, intl16, -9); - SCAN(in_dspx, SCNdLEAST16, intl16, 0); - SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); - PRINT(PRIdLEAST16, intl16, -4507); - PRINT(PRIiLEAST16, intl16, -4507); - SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); - PRINT(PRIoLEAST16, uintl16, 10633); - PRINT(PRIuLEAST16, uintl16, 4507); - PRINT(PRIxLEAST16, uintl16, 119b); - PRINT(PRIXLEAST16, uintl16, 119B); - SCAN(in_dp, SCNxFAST16, uintf16, 4507); - PRINT(PRIxFAST16, uintf16, 119b); -#ifdef SCNdMAX - SCAN(in_dp, SCNdMAX, intmax, 119); + SCAN(in_dmo, SCNiLEAST16, intl16, -9); + SCAN(in_dspx, SCNdLEAST16, intl16, 0); + SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); + PRINT(PRIdLEAST16, intl16, -4507); + PRINT(PRIiLEAST16, intl16, -4507); + SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); + PRINT(PRIoLEAST16, uintl16, 10633); + PRINT(PRIuLEAST16, uintl16, 4507); + PRINT(PRIxLEAST16, uintl16, 119b); + PRINT(PRIXLEAST16, uintl16, 119B); + SCAN(in_dp, SCNxFAST16, uintf16, 4507); + PRINT(PRIxFAST16, uintf16, 119b); +#ifdef SCNdMAX + SCAN(in_dp, SCNdMAX, intmax, 119); #endif -#ifdef PRIiMAX - PRINT(PRIiMAX, intmax, 119); +#ifdef PRIiMAX + PRINT(PRIiMAX, intmax, 119); #endif -#ifdef SCNoMAX - SCAN(in_dpx, SCNoMAX, uintmax, 0); +#ifdef SCNoMAX + SCAN(in_dpx, SCNoMAX, uintmax, 0); #endif -#ifdef PRIxMAX - PRINT(PRIxMAX, uintmax, 0); +#ifdef PRIxMAX + PRINT(PRIxMAX, uintmax, 0); #endif - /* Obviously there should be a much larger battery of such tests. */ - } + /* Obviously there should be a much larger battery of such tests. */ + } -#if defined(INTMAX_MAX) /* has C99 features */ - /* - 7.8.2 Functions for greatest-width integer types - */ +#if defined(INTMAX_MAX) /* has C99 features */ + /* + 7.8.2 Functions for greatest-width integer types + */ - { - static struct - { - intmax_t input; - intmax_t expect; - } abs_data[] = - { -#ifdef INT8_MAX - { INT8_MAX, INT8_MAX, }, - { -INT8_MAX, INT8_MAX, }, - { UINT8_MAX, UINT8_MAX, }, + { + static struct + { + intmax_t input; + intmax_t expect; + } abs_data[] = + { +#ifdef INT8_MAX + { INT8_MAX, INT8_MAX, }, + { -INT8_MAX, INT8_MAX, }, + { UINT8_MAX, UINT8_MAX, }, #endif #if 0 -#ifdef INT16_MAX - { INT16_MAX, INT16_MAX, }, - { -INT16_MAX, INT16_MAX, }, - { UINT16_MAX, UINT16_MAX, }, -#endif -#ifdef INT32_MAX - { INT32_MAX, INT32_MAX, }, - { -INT32_MAX, INT32_MAX, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { UINT32_MAX, UINT32_MAX, }, -#endif -#endif -#ifdef INT64_MAX - { INT64_MAX, INT64_MAX, }, - { -INT64_MAX, INT64_MAX, }, -#endif - { INT_LEAST8_MAX, INT_LEAST8_MAX, }, - { -INT_LEAST8_MAX, INT_LEAST8_MAX, }, - { UINT_LEAST8_MAX, UINT_LEAST8_MAX, }, - { INT_LEAST16_MAX, INT_LEAST16_MAX, }, - { -INT_LEAST16_MAX, INT_LEAST16_MAX, }, - { UINT_LEAST16_MAX, UINT_LEAST16_MAX, }, - { INT_LEAST32_MAX, INT_LEAST32_MAX, }, - { -INT_LEAST32_MAX, INT_LEAST32_MAX, }, -#ifdef INT_LEAST64_MAX - { UINT_LEAST32_MAX, UINT_LEAST32_MAX, }, - { INT_LEAST64_MAX, INT_LEAST64_MAX, }, - { -INT_LEAST64_MAX, INT_LEAST64_MAX, }, -#endif - { INT_FAST8_MAX, INT_FAST8_MAX, }, - { -INT_FAST8_MAX, INT_FAST8_MAX, }, - { UINT_FAST8_MAX, UINT_FAST8_MAX, }, - { INT_FAST16_MAX, INT_FAST16_MAX, }, - { -INT_FAST16_MAX, INT_FAST16_MAX, }, - { UINT_FAST16_MAX, UINT_FAST16_MAX, }, - { INT_FAST32_MAX, INT_FAST32_MAX, }, - { -INT_FAST32_MAX, INT_FAST32_MAX, }, -#ifdef INT_FAST64_MAX - { UINT_FAST32_MAX, UINT_FAST32_MAX, }, - { INT_FAST64_MAX, INT_FAST64_MAX, }, - { -INT_FAST64_MAX, INT_FAST64_MAX, }, -#endif -#ifdef INTPTR_MAX - { INTPTR_MAX, INTPTR_MAX, }, - { -INTPTR_MAX, INTPTR_MAX, }, -#endif -#ifdef UINTPTR_MAX - { UINTPTR_MAX, UINTPTR_MAX, }, -#endif - { INTMAX_MAX, INTMAX_MAX, }, -#ifdef PTRDIFF_MAX - { PTRDIFF_MAX, PTRDIFF_MAX, }, -#endif -#ifdef SIG_ATOMIC_MAX - { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, -#if SIG_ATOMIC_MIN < 0 - { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, -#endif -#endif -#ifdef SIZE_MAX - { SIZE_MAX, SIZE_MAX, }, -#endif -#ifdef WCHAR_MAX - { WCHAR_MAX, WCHAR_MAX, }, -#if WCHAR_MIN < 0 - { -WCHAR_MAX, WCHAR_MAX, }, -#endif -#endif -#ifdef WINT_MAX - { WINT_MAX, WINT_MAX, }, -#if WINT_MIN < 0 - { -WINT_MAX, WINT_MAX, }, -#endif -#endif - { 127, 127, }, - { -127, 127, }, - { 128, 128, }, - { -127-1, 128, }, - { 255, 255, }, - { -256+1, 255, }, - { 256, 256, }, - { -256, 256, }, - { 32767, 32767, }, - { -32767, 32767, }, - { 32768, 32768, }, - { -32767-1, 32768, }, - { 65535, 65535, }, - { -65536+1, 65535, }, - { 65536, 65536, }, - { -65536, 65536, }, - { 2147483647, 2147483647, }, - { -2147483647, 2147483647, }, - { 2147483648, 2147483648, }, - { -2147483647-1, 2147483648, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { 4294967295, 4294967295, }, - { -4294967296+1, 4294967295, }, - { 4294967296, 4294967296, }, - { -4294967296, 4294967296, }, - { 9223372036854775807, 9223372036854775807, }, - { -9223372036854775807, 9223372036854775807, }, - { 1234567890123456789, 1234567890123456789, }, - { -1234567890123456789, 1234567890123456789, }, -#endif - { 1, 1, }, - { -1, 1, }, - { 2, 2, }, - { -2, 2, }, - { 10, 10, }, - { -10, 10, }, - { 16, 16, }, - { -16, 16, }, -#endif - /* Other test cases can be added here. */ - { 0, 0 /* terminates the list */ }, - }, *adp = abs_data; - - do { - if ( (intmax = imaxabs(adp->input)) != adp->expect ) - { - printf("*** imaxabs(%"PRIdMAX") failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", - adp->input, adp->expect, intmax - ); - status = EXIT_FAILURE; - } -// } while ( adp++->input != 0 ); - } while ( (adp++)->input != 0 ); - } - - { - imaxdiv_t result; - static struct - { - intmax_t numer; - intmax_t denom; - intmax_t exp_quot; - intmax_t exp_rem; - } div_data[] = - { - { 0, 1, 0, 0, }, +#ifdef INT16_MAX + { INT16_MAX, INT16_MAX, }, + { -INT16_MAX, INT16_MAX, }, + { UINT16_MAX, UINT16_MAX, }, +#endif +#ifdef INT32_MAX + { INT32_MAX, INT32_MAX, }, + { -INT32_MAX, INT32_MAX, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { UINT32_MAX, UINT32_MAX, }, +#endif +#endif +#ifdef INT64_MAX + { INT64_MAX, INT64_MAX, }, + { -INT64_MAX, INT64_MAX, }, +#endif + { INT_LEAST8_MAX, INT_LEAST8_MAX, }, + { -INT_LEAST8_MAX, INT_LEAST8_MAX, }, + { UINT_LEAST8_MAX, UINT_LEAST8_MAX, }, + { INT_LEAST16_MAX, INT_LEAST16_MAX, }, + { -INT_LEAST16_MAX, INT_LEAST16_MAX, }, + { UINT_LEAST16_MAX, UINT_LEAST16_MAX, }, + { INT_LEAST32_MAX, INT_LEAST32_MAX, }, + { -INT_LEAST32_MAX, INT_LEAST32_MAX, }, +#ifdef INT_LEAST64_MAX + { UINT_LEAST32_MAX, UINT_LEAST32_MAX, }, + { INT_LEAST64_MAX, INT_LEAST64_MAX, }, + { -INT_LEAST64_MAX, INT_LEAST64_MAX, }, +#endif + { INT_FAST8_MAX, INT_FAST8_MAX, }, + { -INT_FAST8_MAX, INT_FAST8_MAX, }, + { UINT_FAST8_MAX, UINT_FAST8_MAX, }, + { INT_FAST16_MAX, INT_FAST16_MAX, }, + { -INT_FAST16_MAX, INT_FAST16_MAX, }, + { UINT_FAST16_MAX, UINT_FAST16_MAX, }, + { INT_FAST32_MAX, INT_FAST32_MAX, }, + { -INT_FAST32_MAX, INT_FAST32_MAX, }, +#ifdef INT_FAST64_MAX + { UINT_FAST32_MAX, UINT_FAST32_MAX, }, + { INT_FAST64_MAX, INT_FAST64_MAX, }, + { -INT_FAST64_MAX, INT_FAST64_MAX, }, +#endif +#ifdef INTPTR_MAX + { INTPTR_MAX, INTPTR_MAX, }, + { -INTPTR_MAX, INTPTR_MAX, }, +#endif +#ifdef UINTPTR_MAX + { UINTPTR_MAX, UINTPTR_MAX, }, +#endif + { INTMAX_MAX, INTMAX_MAX, }, +#ifdef PTRDIFF_MAX + { PTRDIFF_MAX, PTRDIFF_MAX, }, +#endif +#ifdef SIG_ATOMIC_MAX + { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, +#if SIG_ATOMIC_MIN < 0 + { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, +#endif +#endif +#ifdef SIZE_MAX + { SIZE_MAX, SIZE_MAX, }, +#endif +#ifdef WCHAR_MAX + { WCHAR_MAX, WCHAR_MAX, }, +#if WCHAR_MIN < 0 + { -WCHAR_MAX, WCHAR_MAX, }, +#endif +#endif +#ifdef WINT_MAX + { WINT_MAX, WINT_MAX, }, +#if WINT_MIN < 0 + { -WINT_MAX, WINT_MAX, }, +#endif +#endif + { 127, 127, }, + { -127, 127, }, + { 128, 128, }, + { -127-1, 128, }, + { 255, 255, }, + { -256+1, 255, }, + { 256, 256, }, + { -256, 256, }, + { 32767, 32767, }, + { -32767, 32767, }, + { 32768, 32768, }, + { -32767-1, 32768, }, + { 65535, 65535, }, + { -65536+1, 65535, }, + { 65536, 65536, }, + { -65536, 65536, }, + { 2147483647, 2147483647, }, + { -2147483647, 2147483647, }, + { 2147483648, 2147483648, }, + { -2147483647-1, 2147483648, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { 4294967295, 4294967295, }, + { -4294967296+1, 4294967295, }, + { 4294967296, 4294967296, }, + { -4294967296, 4294967296, }, + { 9223372036854775807, 9223372036854775807, }, + { -9223372036854775807, 9223372036854775807, }, + { 1234567890123456789, 1234567890123456789, }, + { -1234567890123456789, 1234567890123456789, }, +#endif + { 1, 1, }, + { -1, 1, }, + { 2, 2, }, + { -2, 2, }, + { 10, 10, }, + { -10, 10, }, + { 16, 16, }, + { -16, 16, }, +#endif + /* Other test cases can be added here. */ + { 0, 0 /* terminates the list */ }, + }, *adp = abs_data; + + do { + if ( (intmax = imaxabs(adp->input)) != adp->expect ) + { + printf("*** imaxabs(%"PRIdMAX") failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", + adp->input, adp->expect, intmax + ); + status = EXIT_FAILURE; + } +// } while ( adp++->input != 0 ); + } while ( (adp++)->input != 0 ); + } + + { + imaxdiv_t result; + static struct + { + intmax_t numer; + intmax_t denom; + intmax_t exp_quot; + intmax_t exp_rem; + } div_data[] = + { + { 0, 1, 0, 0, }, #if 0 - { 0, -1, 0, 0, }, - { 0, 2, 0, 0, }, - { 0, -2, 0, 0, }, - { 0, 5, 0, 0, }, - { 0, -5, 0, 0, }, - { 1, 1, 1, 0, }, - { 1, -1, -1, 0, }, - { 1, 2, 0, 1, }, - { 1, -2, 0, 1, }, - { 1, 5, 0, 1, }, - { 1, -5, 0, 1, }, - { -1, 1, -1, 0, }, - { -1, -1, 1, 0, }, - { -1, 2, 0, -1, }, - { -1, -2, 0, -1, }, - { -1, 5, 0, -1, }, - { -1, -5, 0, -1, }, - { 2, 1, 2, 0, }, - { 2, -1, -2, 0, }, - { 2, 2, 1, 0, }, - { 2, -2, -1, 0, }, - { 2, 5, 0, 2, }, - { 2, -5, 0, 2, }, - { -2, 1, -2, 0, }, - { -2, -1, 2, 0, }, - { -2, 2, -1, 0, }, - { -2, -2, 1, 0, }, - { -2, 5, 0, -2, }, - { -2, -5, 0, -2, }, - { 17, 5, 3, 2, }, - { -17, -5, 3, -2, }, - { 17, -5, -3, 2, }, - { -17, 5, -3, -2, }, - { 2147483647, 1, 2147483647, 0, }, - { -2147483647, 1, -2147483647, 0, }, - { 2147483648, 1, 2147483648, 0, }, - { -2147483647-1, 1, -2147483647-1, 0, }, - { 2147483647, 2, 1073741823, 1, }, - { -2147483647, 2, -1073741823, -1, }, - { 2147483648, 2, 1073741824, 0, }, - { -2147483647-1, 2, -1073741824, 0, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { 4294967295, 1, 4294967295, 0, }, - { -4294967296+1, 1, -4294967296+1, 0, }, - { 4294967296, 1, 4294967296, 0, }, - { -4294967296, 1, -4294967296, 0, }, - { 4294967295, -1, -4294967296+1, 0, }, - { -4294967296+1, -1, 4294967295, 0, }, - { 4294967296, -1, -4294967296, 0, }, - { -4294967296, -1, 4294967296, 0, }, - { 4294967295, 2, 2147483647, 1, }, - { -4294967296+1, 2, -2147483647, -1, }, - { 4294967296, 2, 2147483648, 0, }, - { -4294967296, 2, -2147483647-1, 0, }, - { 4294967295, 2147483647, 2, 1, }, - { -4294967296+1, 2147483647, -2, -1, }, - { 4294967296, 2147483647, 2, 2, }, - { -4294967296, 2147483647, -2, -2, }, - { 4294967295, -2147483647, -2, 1, }, - { -4294967296+1, -2147483647, 2, -1, }, - { 4294967296, -2147483647, -2, 2, }, - { -4294967296, -2147483647, 2, -2, }, - { 4294967295, 2147483648, 1, 2147483647, }, - { -4294967296+1, 2147483648, -1, -2147483647, }, - { 4294967296, 2147483648, 2, 0, }, - { -4294967296, 2147483648, -2, 0, }, - { 4294967295, -2147483647-1, -1, 2147483647, }, - { -4294967296+1, -2147483647-1, 1, -2147483647,}, - { 4294967296, -2147483647-1, -2, 0, }, - { -4294967296, -2147483647-1, 2, 0, }, - { 9223372036854775807, 1, 9223372036854775807, 0, }, - { -9223372036854775807, 1, -9223372036854775807, 0, }, - { 9223372036854775807, 2, 4611686018427387903, 1, }, - { -9223372036854775807, 2, -4611686018427387903, -1, }, -#endif -#endif - /* There should be a much larger battery of such tests. */ - { 0, 0, 0, 0 }, /* 0 denom terminates the list */ - }, *ddp; + { 0, -1, 0, 0, }, + { 0, 2, 0, 0, }, + { 0, -2, 0, 0, }, + { 0, 5, 0, 0, }, + { 0, -5, 0, 0, }, + { 1, 1, 1, 0, }, + { 1, -1, -1, 0, }, + { 1, 2, 0, 1, }, + { 1, -2, 0, 1, }, + { 1, 5, 0, 1, }, + { 1, -5, 0, 1, }, + { -1, 1, -1, 0, }, + { -1, -1, 1, 0, }, + { -1, 2, 0, -1, }, + { -1, -2, 0, -1, }, + { -1, 5, 0, -1, }, + { -1, -5, 0, -1, }, + { 2, 1, 2, 0, }, + { 2, -1, -2, 0, }, + { 2, 2, 1, 0, }, + { 2, -2, -1, 0, }, + { 2, 5, 0, 2, }, + { 2, -5, 0, 2, }, + { -2, 1, -2, 0, }, + { -2, -1, 2, 0, }, + { -2, 2, -1, 0, }, + { -2, -2, 1, 0, }, + { -2, 5, 0, -2, }, + { -2, -5, 0, -2, }, + { 17, 5, 3, 2, }, + { -17, -5, 3, -2, }, + { 17, -5, -3, 2, }, + { -17, 5, -3, -2, }, + { 2147483647, 1, 2147483647, 0, }, + { -2147483647, 1, -2147483647, 0, }, + { 2147483648, 1, 2147483648, 0, }, + { -2147483647-1, 1, -2147483647-1, 0, }, + { 2147483647, 2, 1073741823, 1, }, + { -2147483647, 2, -1073741823, -1, }, + { 2147483648, 2, 1073741824, 0, }, + { -2147483647-1, 2, -1073741824, 0, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { 4294967295, 1, 4294967295, 0, }, + { -4294967296+1, 1, -4294967296+1, 0, }, + { 4294967296, 1, 4294967296, 0, }, + { -4294967296, 1, -4294967296, 0, }, + { 4294967295, -1, -4294967296+1, 0, }, + { -4294967296+1, -1, 4294967295, 0, }, + { 4294967296, -1, -4294967296, 0, }, + { -4294967296, -1, 4294967296, 0, }, + { 4294967295, 2, 2147483647, 1, }, + { -4294967296+1, 2, -2147483647, -1, }, + { 4294967296, 2, 2147483648, 0, }, + { -4294967296, 2, -2147483647-1, 0, }, + { 4294967295, 2147483647, 2, 1, }, + { -4294967296+1, 2147483647, -2, -1, }, + { 4294967296, 2147483647, 2, 2, }, + { -4294967296, 2147483647, -2, -2, }, + { 4294967295, -2147483647, -2, 1, }, + { -4294967296+1, -2147483647, 2, -1, }, + { 4294967296, -2147483647, -2, 2, }, + { -4294967296, -2147483647, 2, -2, }, + { 4294967295, 2147483648, 1, 2147483647, }, + { -4294967296+1, 2147483648, -1, -2147483647, }, + { 4294967296, 2147483648, 2, 0, }, + { -4294967296, 2147483648, -2, 0, }, + { 4294967295, -2147483647-1, -1, 2147483647, }, + { -4294967296+1, -2147483647-1, 1, -2147483647,}, + { 4294967296, -2147483647-1, -2, 0, }, + { -4294967296, -2147483647-1, 2, 0, }, + { 9223372036854775807, 1, 9223372036854775807, 0, }, + { -9223372036854775807, 1, -9223372036854775807, 0, }, + { 9223372036854775807, 2, 4611686018427387903, 1, }, + { -9223372036854775807, 2, -4611686018427387903, -1, }, +#endif +#endif + /* There should be a much larger battery of such tests. */ + { 0, 0, 0, 0 }, /* 0 denom terminates the list */ + }, *ddp; #if 0 - for ( ddp = div_data; ddp->denom != 0; ++ddp ) - if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot - != ddp->exp_quot || result.rem != ddp->exp_rem - ) { -// printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX -// ") failed; should be: (%"PRIdMAX",%"PRIdMAX -// "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", -// ddp->numer, ddp->denom, ddp->exp_quot, -// ddp->exp_rem, result.quot, result.rem -// ); - printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX - ") = (%"PRIdMAX",%"PRIdMAX - "), is: (%"PRIdMAX",%"PRIdMAX")\n", - ddp->numer, ddp->denom, ddp->exp_quot, - ddp->exp_rem, result.quot, result.rem - ); - status = EXIT_FAILURE; - } -#endif - } - - { - char *endptr; - wchar_t *wendptr; - static char saved[64]; /* holds copy of input string */ - static wchar_t wnptr[64]; /* holds wide copy of test string */ - static int warned; /* "warned for null endptr" flag */ - register int i; - static struct - { - char * nptr; - int base; - intmax_t exp_val; - int exp_len; - } str_data[] = - { - { "", 0, 0, 0, }, - { "", 2, 0, 0, }, - { "", 8, 0, 0, }, - { "", 9, 0, 0, }, - { "", 10, 0, 0, }, - { "", 16, 0, 0, }, - { "", 36, 0, 0, }, - { "0", 0, 0, 1, }, - { "0", 2, 0, 1, }, - { "0", 8, 0, 1, }, - { "0", 9, 0, 1, }, - { "0", 10, 0, 1, }, - { "0", 16, 0, 1, }, - { "0", 36, 0, 1, }, - { "+0", 0, 0, 2, }, - { "+0", 2, 0, 2, }, - { "+0", 8, 0, 2, }, - { "+0", 9, 0, 2, }, - { "+0", 10, 0, 2, }, - { "+0", 16, 0, 2, }, - { "+0", 36, 0, 2, }, - { "-0", 0, 0, 2, }, - { "-0", 2, 0, 2, }, - { "-0", 8, 0, 2, }, - { "-0", 9, 0, 2, }, - { "-0", 10, 0, 2, }, - { "-0", 16, 0, 2, }, - { "-0", 36, 0, 2, }, - { "Inf", 0, 0, 0, }, - { "Inf", 2, 0, 0, }, - { "Inf", 8, 0, 0, }, - { "Inf", 9, 0, 0, }, - { "Inf", 10, 0, 0, }, - { "Inf", 16, 0, 0, }, - { "Inf", 36, 24171, 3, }, - { "+Inf", 0, 0, 0, }, - { "+Inf", 2, 0, 0, }, - { "+Inf", 8, 0, 0, }, - { "+Inf", 9, 0, 0, }, - { "+Inf", 10, 0, 0, }, - { "+Inf", 16, 0, 0, }, - { "+Inf", 36, 24171, 4, }, - { "-Inf", 0, 0, 0, }, - { "-Inf", 2, 0, 0, }, - { "-Inf", 8, 0, 0, }, - { "-Inf", 9, 0, 0, }, - { "-Inf", 10, 0, 0, }, - { "-Inf", 16, 0, 0, }, - { "-Inf", 36, -24171, 4, }, - { "inf", 0, 0, 0, }, - { "inf", 2, 0, 0, }, - { "inf", 8, 0, 0, }, - { "inf", 9, 0, 0, }, - { "inf", 10, 0, 0, }, - { "inf", 16, 0, 0, }, - { "inf", 36, 24171, 3, }, - { "+inf", 0, 0, 0, }, - { "+inf", 2, 0, 0, }, - { "+inf", 8, 0, 0, }, - { "+inf", 9, 0, 0, }, - { "+inf", 10, 0, 0, }, - { "+inf", 16, 0, 0, }, - { "+inf", 36, 24171, 4, }, - { "-inf", 0, 0, 0, }, - { "-inf", 2, 0, 0, }, - { "-inf", 8, 0, 0, }, - { "-inf", 9, 0, 0, }, - { "-inf", 10, 0, 0, }, - { "-inf", 16, 0, 0, }, - { "-inf", 36, -24171, 4, }, - { "119b8Z", 0, 119, 3, }, - { "119bZ", 0, 119, 3, }, - { "-0119bZ", 0, -9, 4, }, - { " \t\n 0X119bZ", 0, 4507, 10, }, - { " \t\n +0X119bZ", 0, 4507, 11, }, - { " \t\n -0x119bZ", 0, -4507, 11, }, - { " \t\n 119bZ", 0, 119, 7, }, - { "+119bZ", 0, 119, 4, }, - { "+0X119bz", 0, 4507, 7, }, - { "119b8Z", 2, 3, 2, }, - { "119bZ", 2, 3, 2, }, - { "-0119bZ", 2, -3, 4, }, - { " \t\n 0X119bZ", 2, 0, 5, }, - { " \t\n +0X119bZ", 2, 0, 6, }, - { " \t\n -0x119bZ", 2, 0, 6, }, - { " \t\n 119bZ", 2, 3, 6, }, - { "+119bZ", 2, 3, 3, }, - { "+0X119bz", 2, 0, 2, }, - { "119b8Z", 8, 9, 2, }, - { "119bZ", 8, 9, 2, }, - { "-0119bZ", 8, -9, 4, }, - { " \t\n 0X119bZ", 8, 0, 5, }, - { " \t\n +0X119bZ", 8, 0, 6, }, - { " \t\n -0x119bZ", 8, 0, 6, }, - { " \t\n 119bZ", 8, 9, 6, }, - { "+119bZ", 8, 9, 3, }, - { "+0X119bz", 8, 0, 2, }, - { "119b8Z", 9, 10, 2, }, - { "119bZ", 9, 10, 2, }, - { "-0119bZ", 9, -10, 4, }, - { " \t\n 0X119bZ", 9, 0, 5, }, - { " \t\n +0X119bZ", 9, 0, 6, }, - { " \t\n -0x119bZ", 9, 0, 6, }, - { " \t\n 119bZ", 9, 10, 6, }, - { "+119bZ", 9, 10, 3, }, - { "+0X119bz", 9, 0, 2, }, - { "119b8Z", 10, 119, 3, }, - { "119bZ", 10, 119, 3, }, - { "-0119bZ", 10, -119, 5, }, - { " \t\n 0X119bZ", 10, 0, 5, }, - { " \t\n +0X119bZ", 10, 0, 6, }, - { " \t\n -0x119bZ", 10, 0, 6, }, - { " \t\n 119bZ", 10, 119, 7, }, - { "+119bZ", 10, 119, 4, }, - { "+0X119bz", 10, 0, 2, }, - { "119b8Z", 16, 72120, 5, }, - { "119bZ", 16, 4507, 4, }, - { "-0119bZ", 16, -4507, 6, }, - { " \t\n 0X119bZ", 16, 4507, 10, }, - { " \t\n +0X119bZ", 16, 4507, 11, }, - { " \t\n -0x119bZ", 16, -4507, 11, }, - { " \t\n 119bZ", 16, 4507,8, }, - { "+119bZ", 16, 4507, 5, }, - { "+0X119bz", 16, 4507, 7, }, - { "119b8Z", 36, 62580275, 6, }, - { "119bZ", 36, 1738367, 5, }, - { "-0119bZ", 36, -1738367, 7, }, - { " \t\n 0X119bZ", 36, 1997122175, 11, }, - { " \t\n +0X119bZ", 36, 1997122175, 12, }, - { " \t\n -0x119bZ", 36, -1997122175, 12, }, - { " \t\n 119bZ", 36, 1738367, 9, }, - { "+119bZ", 36, 1738367, 6, }, - { "+0X119bz", 36, 1997122175, 8, }, - /* There should be a much larger battery of such tests. */ - { "127", 0, 127, 3, }, - { "-127", 0, -127, 4, }, - { "128", 0, 128, 3, }, - { "-128", 0, -127-1, 4, }, - { "255", 0, 255, 3, }, - { "-255", 0, -255, 4, }, - { "256", 0, 256, 3, }, - { "-256", 0, -255-1, 4, }, - { "32767", 0, 32767, 5, }, - { "-32767", 0, -32767, 6, }, - { "32768", 0, 32768, 5, }, - { "-32768", 0, -32767-1, 6, }, - { "65535", 0, 65535, 5, }, - { "-65535", 0, -65536+1, 6, }, - { "65536", 0, 65536, 5, }, - { "-65536", 0, -65536, 6, }, - { "2147483647", 0, 2147483647, 10, }, - { "-2147483647", 0, -2147483647, 11, }, - { "2147483648", 0, 2147483648, 10, }, - { "-2147483648", 0, -2147483647-1, 11, }, - { "4294967295", 0, 4294967295, 10, }, - { "-4294967295", 0, -4294967296+1, 11, }, - { "4294967296", 0, 4294967296, 10, }, - { "-4294967296", 0, -4294967296, 11, }, - { "9223372036854775807", 0, 9223372036854775807, 19, }, - { "-9223372036854775807", 0, -9223372036854775807, 20, }, - { "1234567890123456789", 0, 1234567890123456789, 19, }, - { "-1234567890123456789", 0, -1234567890123456789, 20, }, - { "1", 0, 1, 1, }, - { "-1", 0, -1, 2, }, - { "2", 0, 2, 1, }, - { "-2", 0, -2, 2, }, - { "10", 0, 10, 2, }, - { "-10", 0, -10, 3, }, - { "16", 0, 16, 2, }, - { "-16", 0, -16, 3, }, - /* Other test cases can be added here. */ - { NULL, 0, 0, 0 }, /* terminates the list */ - }, *sdp; - - for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) - { - /* - 7.8.2.3 The strtoimax and strtoumax functions - */ - - strcpy(saved, sdp->nptr); - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* tests for null endptr */ - -#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoimax(%s,NULL,%d) failed; " - "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", - sdp->nptr, sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions - */ - - for ( i = 0; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - - /* tests for null endptr */ - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - } - - /* - 7.8.2.3 The strtoimax and strtoumax functions (continued) - */ - - if ( (intmax = strtoimax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** strtoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions (continued) - */ + for ( ddp = div_data; ddp->denom != 0; ++ddp ) + if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot + != ddp->exp_quot || result.rem != ddp->exp_rem + ) { +// printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX +// ") failed; should be: (%"PRIdMAX",%"PRIdMAX +// "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", +// ddp->numer, ddp->denom, ddp->exp_quot, +// ddp->exp_rem, result.quot, result.rem +// ); + printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX + ") = (%"PRIdMAX",%"PRIdMAX + "), is: (%"PRIdMAX",%"PRIdMAX")\n", + ddp->numer, ddp->denom, ddp->exp_quot, + ddp->exp_rem, result.quot, result.rem + ); + status = EXIT_FAILURE; + } +#endif + } + + { + char *endptr; + wchar_t *wendptr; + static char saved[64]; /* holds copy of input string */ + static wchar_t wnptr[64]; /* holds wide copy of test string */ + static int warned; /* "warned for null endptr" flag */ + register int i; + static struct + { + char * nptr; + int base; + intmax_t exp_val; + int exp_len; + } str_data[] = + { + { "", 0, 0, 0, }, + { "", 2, 0, 0, }, + { "", 8, 0, 0, }, + { "", 9, 0, 0, }, + { "", 10, 0, 0, }, + { "", 16, 0, 0, }, + { "", 36, 0, 0, }, + { "0", 0, 0, 1, }, + { "0", 2, 0, 1, }, + { "0", 8, 0, 1, }, + { "0", 9, 0, 1, }, + { "0", 10, 0, 1, }, + { "0", 16, 0, 1, }, + { "0", 36, 0, 1, }, + { "+0", 0, 0, 2, }, + { "+0", 2, 0, 2, }, + { "+0", 8, 0, 2, }, + { "+0", 9, 0, 2, }, + { "+0", 10, 0, 2, }, + { "+0", 16, 0, 2, }, + { "+0", 36, 0, 2, }, + { "-0", 0, 0, 2, }, + { "-0", 2, 0, 2, }, + { "-0", 8, 0, 2, }, + { "-0", 9, 0, 2, }, + { "-0", 10, 0, 2, }, + { "-0", 16, 0, 2, }, + { "-0", 36, 0, 2, }, + { "Inf", 0, 0, 0, }, + { "Inf", 2, 0, 0, }, + { "Inf", 8, 0, 0, }, + { "Inf", 9, 0, 0, }, + { "Inf", 10, 0, 0, }, + { "Inf", 16, 0, 0, }, + { "Inf", 36, 24171, 3, }, + { "+Inf", 0, 0, 0, }, + { "+Inf", 2, 0, 0, }, + { "+Inf", 8, 0, 0, }, + { "+Inf", 9, 0, 0, }, + { "+Inf", 10, 0, 0, }, + { "+Inf", 16, 0, 0, }, + { "+Inf", 36, 24171, 4, }, + { "-Inf", 0, 0, 0, }, + { "-Inf", 2, 0, 0, }, + { "-Inf", 8, 0, 0, }, + { "-Inf", 9, 0, 0, }, + { "-Inf", 10, 0, 0, }, + { "-Inf", 16, 0, 0, }, + { "-Inf", 36, -24171, 4, }, + { "inf", 0, 0, 0, }, + { "inf", 2, 0, 0, }, + { "inf", 8, 0, 0, }, + { "inf", 9, 0, 0, }, + { "inf", 10, 0, 0, }, + { "inf", 16, 0, 0, }, + { "inf", 36, 24171, 3, }, + { "+inf", 0, 0, 0, }, + { "+inf", 2, 0, 0, }, + { "+inf", 8, 0, 0, }, + { "+inf", 9, 0, 0, }, + { "+inf", 10, 0, 0, }, + { "+inf", 16, 0, 0, }, + { "+inf", 36, 24171, 4, }, + { "-inf", 0, 0, 0, }, + { "-inf", 2, 0, 0, }, + { "-inf", 8, 0, 0, }, + { "-inf", 9, 0, 0, }, + { "-inf", 10, 0, 0, }, + { "-inf", 16, 0, 0, }, + { "-inf", 36, -24171, 4, }, + { "119b8Z", 0, 119, 3, }, + { "119bZ", 0, 119, 3, }, + { "-0119bZ", 0, -9, 4, }, + { " \t\n 0X119bZ", 0, 4507, 10, }, + { " \t\n +0X119bZ", 0, 4507, 11, }, + { " \t\n -0x119bZ", 0, -4507, 11, }, + { " \t\n 119bZ", 0, 119, 7, }, + { "+119bZ", 0, 119, 4, }, + { "+0X119bz", 0, 4507, 7, }, + { "119b8Z", 2, 3, 2, }, + { "119bZ", 2, 3, 2, }, + { "-0119bZ", 2, -3, 4, }, + { " \t\n 0X119bZ", 2, 0, 5, }, + { " \t\n +0X119bZ", 2, 0, 6, }, + { " \t\n -0x119bZ", 2, 0, 6, }, + { " \t\n 119bZ", 2, 3, 6, }, + { "+119bZ", 2, 3, 3, }, + { "+0X119bz", 2, 0, 2, }, + { "119b8Z", 8, 9, 2, }, + { "119bZ", 8, 9, 2, }, + { "-0119bZ", 8, -9, 4, }, + { " \t\n 0X119bZ", 8, 0, 5, }, + { " \t\n +0X119bZ", 8, 0, 6, }, + { " \t\n -0x119bZ", 8, 0, 6, }, + { " \t\n 119bZ", 8, 9, 6, }, + { "+119bZ", 8, 9, 3, }, + { "+0X119bz", 8, 0, 2, }, + { "119b8Z", 9, 10, 2, }, + { "119bZ", 9, 10, 2, }, + { "-0119bZ", 9, -10, 4, }, + { " \t\n 0X119bZ", 9, 0, 5, }, + { " \t\n +0X119bZ", 9, 0, 6, }, + { " \t\n -0x119bZ", 9, 0, 6, }, + { " \t\n 119bZ", 9, 10, 6, }, + { "+119bZ", 9, 10, 3, }, + { "+0X119bz", 9, 0, 2, }, + { "119b8Z", 10, 119, 3, }, + { "119bZ", 10, 119, 3, }, + { "-0119bZ", 10, -119, 5, }, + { " \t\n 0X119bZ", 10, 0, 5, }, + { " \t\n +0X119bZ", 10, 0, 6, }, + { " \t\n -0x119bZ", 10, 0, 6, }, + { " \t\n 119bZ", 10, 119, 7, }, + { "+119bZ", 10, 119, 4, }, + { "+0X119bz", 10, 0, 2, }, + { "119b8Z", 16, 72120, 5, }, + { "119bZ", 16, 4507, 4, }, + { "-0119bZ", 16, -4507, 6, }, + { " \t\n 0X119bZ", 16, 4507, 10, }, + { " \t\n +0X119bZ", 16, 4507, 11, }, + { " \t\n -0x119bZ", 16, -4507, 11, }, + { " \t\n 119bZ", 16, 4507,8, }, + { "+119bZ", 16, 4507, 5, }, + { "+0X119bz", 16, 4507, 7, }, + { "119b8Z", 36, 62580275, 6, }, + { "119bZ", 36, 1738367, 5, }, + { "-0119bZ", 36, -1738367, 7, }, + { " \t\n 0X119bZ", 36, 1997122175, 11, }, + { " \t\n +0X119bZ", 36, 1997122175, 12, }, + { " \t\n -0x119bZ", 36, -1997122175, 12, }, + { " \t\n 119bZ", 36, 1738367, 9, }, + { "+119bZ", 36, 1738367, 6, }, + { "+0X119bz", 36, 1997122175, 8, }, + /* There should be a much larger battery of such tests. */ + { "127", 0, 127, 3, }, + { "-127", 0, -127, 4, }, + { "128", 0, 128, 3, }, + { "-128", 0, -127-1, 4, }, + { "255", 0, 255, 3, }, + { "-255", 0, -255, 4, }, + { "256", 0, 256, 3, }, + { "-256", 0, -255-1, 4, }, + { "32767", 0, 32767, 5, }, + { "-32767", 0, -32767, 6, }, + { "32768", 0, 32768, 5, }, + { "-32768", 0, -32767-1, 6, }, + { "65535", 0, 65535, 5, }, + { "-65535", 0, -65536+1, 6, }, + { "65536", 0, 65536, 5, }, + { "-65536", 0, -65536, 6, }, + { "2147483647", 0, 2147483647, 10, }, + { "-2147483647", 0, -2147483647, 11, }, + { "2147483648", 0, 2147483648, 10, }, + { "-2147483648", 0, -2147483647-1, 11, }, + { "4294967295", 0, 4294967295, 10, }, + { "-4294967295", 0, -4294967296+1, 11, }, + { "4294967296", 0, 4294967296, 10, }, + { "-4294967296", 0, -4294967296, 11, }, + { "9223372036854775807", 0, 9223372036854775807, 19, }, + { "-9223372036854775807", 0, -9223372036854775807, 20, }, + { "1234567890123456789", 0, 1234567890123456789, 19, }, + { "-1234567890123456789", 0, -1234567890123456789, 20, }, + { "1", 0, 1, 1, }, + { "-1", 0, -1, 2, }, + { "2", 0, 2, 1, }, + { "-2", 0, -2, 2, }, + { "10", 0, 10, 2, }, + { "-10", 0, -10, 3, }, + { "16", 0, 16, 2, }, + { "-16", 0, -16, 3, }, + /* Other test cases can be added here. */ + { NULL, 0, 0, 0 }, /* terminates the list */ + }, *sdp; + + for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) + { + /* + 7.8.2.3 The strtoimax and strtoumax functions + */ + + strcpy(saved, sdp->nptr); + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* tests for null endptr */ + +#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoimax(%s,NULL,%d) failed; " + "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", + sdp->nptr, sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions + */ + + for ( i = 0; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + + /* tests for null endptr */ + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + } + + /* + 7.8.2.3 The strtoimax and strtoumax functions (continued) + */ + + if ( (intmax = strtoimax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** strtoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions (continued) + */ #ifdef NO_INTERNAL_WCHAR - printf("NO_INTERNAL_WCHAR\n"); + printf("NO_INTERNAL_WCHAR\n"); #else - if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** wcstoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** wcstoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } #endif // NO_INTERNAL_WCHAR - } -#endif /* defined(INTMAX_MAX) */ + } +#endif /* defined(INTMAX_MAX) */ - if ( status != 0 ) - printf("sitest failed.\n"); + if ( status != 0 ) + printf("sitest failed.\n"); - return status; + return status; } #endif \ No newline at end of file diff --git a/test/ref/8q.c b/test/ref/8q.c index e8bd1ca2e..2055b5fd5 100644 --- a/test/ref/8q.c +++ b/test/ref/8q.c @@ -12,38 +12,38 @@ void print(void); int main(void) { - int i; - for (i = 0; i < 15; i++) - up[i] = down[i] = 1; - for (i = 0; i < 8; i++) - rows[i] = 1; - queens(0); - return 0; + int i; + for (i = 0; i < 15; i++) + up[i] = down[i] = 1; + for (i = 0; i < 8; i++) + rows[i] = 1; + queens(0); + return 0; } void queens(int c) { - int r; + int r; - for (r = 0; r < 8; r++) - if (rows[r] && up[r-c+7] && down[r+c]) { - rows[r] = up[r-c+7] = down[r+c] = 0; - x[c] = r; - if (c == 7) - print(); - else - queens(c + 1); - rows[r] = up[r-c+7] = down[r+c] = 1; - } + for (r = 0; r < 8; r++) + if (rows[r] && up[r-c+7] && down[r+c]) { + rows[r] = up[r-c+7] = down[r+c] = 0; + x[c] = r; + if (c == 7) + print(); + else + queens(c + 1); + rows[r] = up[r-c+7] = down[r+c] = 1; + } } void print(void) { - int k; + int k; - for (k = 0; k < 8; k++) { - printf("%c", x[k]+'1'); - if(k<7) printf(" "); - } - printf("\n"); + for (k = 0; k < 8; k++) { + printf("%c", x[k]+'1'); + if(k<7) printf(" "); + } + printf("\n"); } diff --git a/test/ref/array.c b/test/ref/array.c index 9d170aaa9..96bf22c3a 100644 --- a/test/ref/array.c +++ b/test/ref/array.c @@ -14,49 +14,49 @@ int g(int x[][4],int *y[]); int x[3][4], *y[3]; main() { - int z[3][4]; - int i, j, *p; - - for (i = 0; i < 3; i++) { - for (j = 0; j < 4; j++) - x[i][j] = 1000*i + j; - y[i] = x[i]; - } - f(); - for (i = 0; i < 3; i++) { - y[i] = p = &z[i][0]; - for (j = 0; j < 4; j++) - p[j] = x[i][j]; - } - g(z, y); - - return 0; + int z[3][4]; + int i, j, *p; + + for (i = 0; i < 3; i++) { + for (j = 0; j < 4; j++) + x[i][j] = 1000*i + j; + y[i] = x[i]; + } + f(); + for (i = 0; i < 3; i++) { + y[i] = p = &z[i][0]; + for (j = 0; j < 4; j++) + p[j] = x[i][j]; + } + g(z, y); + + return 0; } f() { - int i, j; - - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", x[i][j]); - printf("\n"); - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", y[i][j]); - printf("\n"); + int i, j; + + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", x[i][j]); + printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", y[i][j]); + printf("\n"); } g(x, y) int x[][4], *y[]; { - int i, j; - - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", x[i][j]); - printf("\n"); - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", y[i][j]); - printf("\n"); + int i, j; + + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", x[i][j]); + printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", y[i][j]); + printf("\n"); } diff --git a/test/ref/cc65070303.c b/test/ref/cc65070303.c index c0404dab8..6dbceeefc 100644 --- a/test/ref/cc65070303.c +++ b/test/ref/cc65070303.c @@ -9,17 +9,17 @@ typedef signed int TypA[3]; typedef struct TypB { - TypA Data[2]; + TypA Data[2]; } sTypB; sTypB Bs[10]; TypA * APtr; int main(int argc, char* argv[]) { - Bs[7].Data[1][2]=11; - APtr=&(Bs[7].Data[1]); - printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] ); - return 0; + Bs[7].Data[1][2]=11; + APtr=&(Bs[7].Data[1]); + printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] ); + return 0; } /* diff --git a/test/ref/cc65090726.c b/test/ref/cc65090726.c index b260f0afd..609594dc4 100644 --- a/test/ref/cc65090726.c +++ b/test/ref/cc65090726.c @@ -17,26 +17,26 @@ typedef RecordType *RecordPtr; void Proc3(RecordPtr *PtrParOut) { - /* whatever */ + /* whatever */ } void Proc1(RecordPtr PtrParIn) { #define NextRecord (*(PtrParIn->PtrComp)) - Proc3((RecordPtr *)NextRecord.PtrComp); - Proc3(&NextRecord.PtrComp); - Proc3(&PtrParIn->PtrComp->PtrComp); + Proc3((RecordPtr *)NextRecord.PtrComp); + Proc3(&NextRecord.PtrComp); + Proc3(&PtrParIn->PtrComp->PtrComp); #ifdef CAST_STRUCT_PTR - Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp); - Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp); - Proc3((RecordPtr *) NextRecord.PtrComp); + Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp); + Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp); + Proc3((RecordPtr *) NextRecord.PtrComp); #else - Proc3(PtrParIn->PtrComp->PtrComp); - Proc3((*(PtrParIn->PtrComp)).PtrComp); - Proc3(NextRecord.PtrComp); + Proc3(PtrParIn->PtrComp->PtrComp); + Proc3((*(PtrParIn->PtrComp)).PtrComp); + Proc3(NextRecord.PtrComp); #endif - + #undef NextRecord } diff --git a/test/ref/cc65090910.c b/test/ref/cc65090910.c index 6ac5d9dcb..d68c2b8e6 100644 --- a/test/ref/cc65090910.c +++ b/test/ref/cc65090910.c @@ -17,7 +17,7 @@ with compiler option -O but does _not_ show up with -Oi. unsigned htons(unsigned val) { - return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8); + return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8); } int main(void) diff --git a/test/ref/cc65090913.c b/test/ref/cc65090913.c index da6e37ef3..3a92dc6ec 100644 --- a/test/ref/cc65090913.c +++ b/test/ref/cc65090913.c @@ -25,7 +25,7 @@ int foo=0,bar=2; int main(void) { while(foo= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= 'a') && (i <= 'z')) + if ((i >= 'a') && (i <= 'z')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -101,19 +101,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("A-Z char:freq\n\n"); /* second round ... uppercase characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= 'A') && (i <= 'Z')) + if ((i >= 'A') && (i <= 'Z')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -121,19 +121,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("0-9 char:freq\n\n"); /* third round ... numbers */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= '0') && (i <= '9')) + if ((i >= '0') && (i <= '9')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -141,19 +141,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("isprint char:freq\n\n"); /* second last round ... remaining printable characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if(isprint(i)) + if(isprint(i)) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -161,30 +161,30 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("rest char:freq\n\n"); /* last round ... remaining non printable characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { if(i=='\n') { - printf("newline"); + printf("newline"); } else { - printf("%03o", i); + printf("%03o", i); } #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif - } + } } fclose(in); return 0; diff --git a/test/ref/charconst.c b/test/ref/charconst.c index 65ebc70be..1a2f5303d 100644 --- a/test/ref/charconst.c +++ b/test/ref/charconst.c @@ -14,23 +14,23 @@ void backslash(unsigned char c) switch (c) { - case 'b': - c = '\b'; - case 'f': - c = '\f'; - case 'n': - c = '\n'; - case 'r': - c = '\r'; - case 't': - c = '\t'; - case 'v': + case 'b': + c = '\b'; + case 'f': + c = '\f'; + case 'n': + c = '\n'; + case 'r': + c = '\r'; + case 't': + c = '\t'; + case 'v': #ifndef NO_BACKSLASH_V c = '\v'; #else c = 0x0b; #endif - } + } if(!isprint(c)) { @@ -54,7 +54,7 @@ void testbackslash(void) int main(void) { - testbackslash(); + testbackslash(); - return 0; + return 0; } diff --git a/test/ref/charset.c b/test/ref/charset.c index 59b7c4c54..8bd1675c8 100644 --- a/test/ref/charset.c +++ b/test/ref/charset.c @@ -12,82 +12,82 @@ /* this kind of line-continuation for strings doesnt work properly for cc65 */ const unsigned char characters[]={ - /*0123456789abcdef0123456789abcdef*/ - /* iso646-us control-characters */ - " " /* 00-1f */ - /* iso646-us printable characters */ - " !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */ - "0123456789" /* 30-39 0123456789 */ - ":;<=>?@" /* 3a-40 :;<=>?@ */ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */ - "[\\]^_`" /* 5b-60 [\]^_` */ - "abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */ - "{|}~ " /* 7b-7f {|}~ */ - /* iso8859-15 extended characters */ + /*0123456789abcdef0123456789abcdef*/ + /* iso646-us control-characters */ + " " /* 00-1f */ + /* iso646-us printable characters */ + " !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */ + "0123456789" /* 30-39 0123456789 */ + ":;<=>?@" /* 3a-40 :;<=>?@ */ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */ + "[\\]^_`" /* 5b-60 [\]^_` */ + "abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */ + "{|}~ " /* 7b-7f {|}~ */ + /* iso8859-15 extended characters */ }; #endif const unsigned char characters[]={ - /*0123456789abcdef0123456789abcdef*/ - /* iso646-us control-characters */ - /* 00-1f */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /* iso646-us printable characters */ - /* 20-2f !"#$%&'()*+,-./ */ - ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', - /* 30-39 0123456789 */ - '0','1','2','3','4','5','6','7','8','9', - /* 3a-40 :;<=>?@ */ - ':',';','<','=','>','?','@', - /* 41-5a A-Z */ - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - /* 5b-60 [\]^_` */ - '[','\\',']','^','_','`', - /* 61-7a a-z */ - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', - /* 7b-7f {|}~ */ - '{','|','}','~',' ' - /* iso8859-15 extended characters */ + /*0123456789abcdef0123456789abcdef*/ + /* iso646-us control-characters */ + /* 00-1f */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* iso646-us printable characters */ + /* 20-2f !"#$%&'()*+,-./ */ + ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', + /* 30-39 0123456789 */ + '0','1','2','3','4','5','6','7','8','9', + /* 3a-40 :;<=>?@ */ + ':',';','<','=','>','?','@', + /* 41-5a A-Z */ + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + /* 5b-60 [\]^_` */ + '[','\\',']','^','_','`', + /* 61-7a a-z */ + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', + /* 7b-7f {|}~ */ + '{','|','}','~',' ' + /* iso8859-15 extended characters */ }; void printchars(unsigned char a,unsigned char b){ - for(b++;a!=b;a++) + for(b++;a!=b;a++) /* printf("%02x ",a); */ /* printf("%02x ",characters[a]); */ - printf("%c",characters[a]); - printf("\n"); + printf("%c",characters[a]); + printf("\n"); } int main(void) { - printf("characters:\n\n"); - printchars(0x61,0x7a); - printchars(0x41,0x5a); - printf("numbers:\n\n"); - printchars(0x30,0x39); - printf("other:\n\n"); - printchars(0x20,0x2f); - /*printchars(0x3a,0x40);*/ - printchars(0x3a,0x3f); - /*printchars(0x5b,0x60);*/ - /*printchars(0x7b,0x7f);*/ - printf("\n\n"); - printf("slash: '%c'\n",'/'); - printf("backslash: '%c'\n",'\\'); - printf("curly braces open: '%c'\n",'{'); - printf("curly braces close: '%c'\n",'}'); - printf("square braces open: '%c'\n",'['); - printf("square braces close: '%c'\n",']'); - printf("underscore: '%c'\n",'_'); - printf("tilde: '%c'\n",'~'); - printf("pipe: '%c'\n",'|'); - printf("apostroph: '%c'\n",'\''); - printf("single quote '%c'\n",'`'); - printf("xor '%c'\n",'^'); - printf("at '%c'\n",'@'); + printf("characters:\n\n"); + printchars(0x61,0x7a); + printchars(0x41,0x5a); + printf("numbers:\n\n"); + printchars(0x30,0x39); + printf("other:\n\n"); + printchars(0x20,0x2f); + /*printchars(0x3a,0x40);*/ + printchars(0x3a,0x3f); + /*printchars(0x5b,0x60);*/ + /*printchars(0x7b,0x7f);*/ + printf("\n\n"); + printf("slash: '%c'\n",'/'); + printf("backslash: '%c'\n",'\\'); + printf("curly braces open: '%c'\n",'{'); + printf("curly braces close: '%c'\n",'}'); + printf("square braces open: '%c'\n",'['); + printf("square braces close: '%c'\n",']'); + printf("underscore: '%c'\n",'_'); + printf("tilde: '%c'\n",'~'); + printf("pipe: '%c'\n",'|'); + printf("apostroph: '%c'\n",'\''); + printf("single quote '%c'\n",'`'); + printf("xor '%c'\n",'^'); + printf("at '%c'\n",'@'); - return 0; + return 0; } diff --git a/test/ref/divmod.c b/test/ref/divmod.c index 8fcc951a6..e5535ebc4 100644 --- a/test/ref/divmod.c +++ b/test/ref/divmod.c @@ -8,31 +8,31 @@ void printc(signed char a,signed char b){ signed char x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); } void prints(short a,short b){ short x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); } void printl(long a,long b){ long x=a/b,y=a%b,z=a*b; - printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); + printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); } int main(void) { - printl( 3,-2); - printl(-3,-2); - printl(-3, 2); - printl( 3, 2); - printf("-\n"); - prints( 3,-2); - prints(-3,-2); - prints(-3, 2); - prints( 3, 2); - printf("-\n"); - printc( 3,-2); - printc(-3,-2); - printc(-3, 2); - printc( 3, 2); - return 0; + printl( 3,-2); + printl(-3,-2); + printl(-3, 2); + printl( 3, 2); + printf("-\n"); + prints( 3,-2); + prints(-3,-2); + prints(-3, 2); + prints( 3, 2); + printf("-\n"); + printc( 3,-2); + printc(-3,-2); + printc(-3, 2); + printc( 3, 2); + return 0; } diff --git a/test/ref/hanoi.c b/test/ref/hanoi.c index 234ac41e4..5198c5c61 100644 --- a/test/ref/hanoi.c +++ b/test/ref/hanoi.c @@ -11,8 +11,8 @@ ******************************************************************************* * Bug reports, patches, comments, suggestions should be sent to: * - * Ben Smith, Rick Grehan or Tom Yager - * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com + * Ben Smith, Rick Grehan or Tom Yager + * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com * ******************************************************************************* * Modification Log: @@ -38,53 +38,53 @@ void mov(unsigned char n,unsigned char f,unsigned char t) { char o; - if(n == 1) - { - num[f]--; - num[t]++; - } - else - { - o = (6-(f+t)); - mov(n-1,f,o); - mov(1,f,t); - mov(n-1,o,t); - } + if(n == 1) + { + num[f]--; + num[t]++; + } + else + { + o = (6-(f+t)); + mov(n-1,f,o); + mov(1,f,t); + mov(n-1,o,t); + } - #ifdef VERBOSE - printf("%2d: %2d %2d %2d %2d\n", - (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); - #endif + #ifdef VERBOSE + printf("%2d: %2d %2d %2d %2d\n", + (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); + #endif } int main(int argc,char **argv) { - #ifdef USECMDLINE - if (argc < 2) { - printf("Usage: %s [duration] [disks]\n", argv[0]); - exit(1); - } - else - { - if(argc > 1) duration = atoi(argv[1]); - if(argc > 2) disk = atoi(argv[2]); - } - #endif + #ifdef USECMDLINE + if (argc < 2) { + printf("Usage: %s [duration] [disks]\n", argv[0]); + exit(1); + } + else + { + if(argc > 1) duration = atoi(argv[1]); + if(argc > 2) disk = atoi(argv[2]); + } + #endif - printf("towers of hanoi\ndisks: %d\n\n",disk); + printf("towers of hanoi\ndisks: %d\n\n",disk); - num[1] = disk; + num[1] = disk; - #ifdef VERBOSE - printf("%2d: %2d %2d %2d %2d\n", - (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); - #endif + #ifdef VERBOSE + printf("%2d: %2d %2d %2d %2d\n", + (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); + #endif - while(num[3]codes[0]; p++) { - for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) - printf("%d ", p->codes[i]); - printf("%s\n", p->name); - } - h(); + int i; + + for ( ; p->codes[0]; p++) { + for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) + printf("%d ", p->codes[i]); + printf("%s\n", p->name); + } + h(); } h() { - int i; + int i; - for (i = 0; i < sizeof(words)/sizeof(Word); i++) - printf("%d %d %d %s\n", words[i].codes[0], - words[i].codes[1], words[i].codes[2], - &words[i].name[0]); + for (i = 0; i < sizeof(words)/sizeof(Word); i++) + printf("%d %d %d %s\n", words[i].codes[0], + words[i].codes[1], words[i].codes[2], + &words[i].name[0]); } diff --git a/test/ref/macro.c b/test/ref/macro.c index 1650b98db..c1346b939 100644 --- a/test/ref/macro.c +++ b/test/ref/macro.c @@ -14,17 +14,17 @@ unsigned long a=3; unsigned long _func(unsigned long x,unsigned long y) { - printf("x:%ld y:%ld\n",x,y); - return 0; + printf("x:%ld y:%ld\n",x,y); + return 0; } -#define func(x,y) _func(x,y) +#define func(x,y) _func(x,y) int main(void) { - fs= func( (fd/a) , func(2,0x0082c90f) ); - printf("fs:%ld\n",fs); - fs=_func( (fd/a) , _func(2,0x0082c90f) ); - printf("fs:%ld\n",fs); - return 0; + fs= func( (fd/a) , func(2,0x0082c90f) ); + printf("fs:%ld\n",fs); + fs=_func( (fd/a) , _func(2,0x0082c90f) ); + printf("fs:%ld\n",fs); + return 0; } diff --git a/test/ref/paranoia.c b/test/ref/paranoia.c index e4833bd16..1021264a5 100644 --- a/test/ref/paranoia.c +++ b/test/ref/paranoia.c @@ -18,39 +18,39 @@ main() #undef V9 #define NOPAUSE -/* A C version of Kahan's Floating Point Test "Paranoia" +/* A C version of Kahan's Floating Point Test "Paranoia" - Thos Sumner, UCSF, Feb. 1985 - David Gay, BTL, Jan. 1986 + Thos Sumner, UCSF, Feb. 1985 + David Gay, BTL, Jan. 1986 - This is a rewrite from the Pascal version by + This is a rewrite from the Pascal version by - B. A. Wichmann, 18 Jan. 1985 + B. A. Wichmann, 18 Jan. 1985 - (and does NOT exhibit good C programming style). + (and does NOT exhibit good C programming style). (C) Apr 19 1983 in BASIC version by: - Professor W. M. Kahan, - 567 Evans Hall - Electrical Engineering & Computer Science Dept. - University of California - Berkeley, California 94720 - USA + Professor W. M. Kahan, + 567 Evans Hall + Electrical Engineering & Computer Science Dept. + University of California + Berkeley, California 94720 + USA converted to Pascal by: - B. A. Wichmann - National Physical Laboratory - Teddington Middx - TW11 OLW - UK + B. A. Wichmann + National Physical Laboratory + Teddington Middx + TW11 OLW + UK converted to C by: - David M. Gay and Thos Sumner - AT&T Bell Labs Computer Center, Rm. U-76 - 600 Mountain Avenue University of California - Murray Hill, NJ 07974 San Francisco, CA 94143 - USA USA + David M. Gay and Thos Sumner + AT&T Bell Labs Computer Center, Rm. U-76 + 600 Mountain Avenue University of California + Murray Hill, NJ 07974 San Francisco, CA 94143 + USA USA with simultaneous corrections to the Pascal source (reflected in the Pascal source available over netlib). @@ -282,11 +282,11 @@ int NoTrials = 20; /*Number of tests for commutativity. */ #define True 1 /* Definitions for declared types - Guard == (Yes, No); - Rounding == (Chopped, Rounded, Other); - Message == packed array [1..40] of char; - Class == (Flaw, Defect, Serious, Failure); - */ + Guard == (Yes, No); + Rounding == (Chopped, Rounded, Other); + Message == packed array [1..40] of char; + Class == (Flaw, Defect, Serious, Failure); + */ #define Yes 1 #define No 0 #define Chopped 2 @@ -331,7 +331,7 @@ int M, N, N1; Guard GMult, GDiv, GAddSub; Rounding RMult, RDiv, RAddSub, RSqrt; int Break, Done, NotMonot, Monot, Anomaly, IEEE, - SqRWrng, UfNGrad; + SqRWrng, UfNGrad; /* Computed constants. */ /*U1 gap below 1.0, i.e, 1.0-U1 is next number below 1.0 */ /*U2 gap above 1.0, i.e, 1.0+U2 is next number above 1.0 */ @@ -340,1518 +340,1518 @@ int Break, Done, NotMonot, Monot, Anomaly, IEEE, void sigfpe(i) { - fpecount++; - printf("\n* * * FLOATING-POINT ERROR * * *\n"); - fflush(stdout); - if (sigsave) { + fpecount++; + printf("\n* * * FLOATING-POINT ERROR * * *\n"); + fflush(stdout); + if (sigsave) { #ifndef NOSIGNAL - signal(SIGFPE, sigsave); + signal(SIGFPE, sigsave); #endif - sigsave = 0; - longjmp(ovfl_buf, 1); - } - abort(); + sigsave = 0; + longjmp(ovfl_buf, 1); + } + abort(); } main() { #ifdef mc - char *out; - ieee_flags("set", "precision", "double", &out); + char *out; + ieee_flags("set", "precision", "double", &out); #endif - /* First two assignments use integer right-hand sides. */ - Zero = 0; - One = 1; - Two = One + One; - Three = Two + One; - Four = Three + One; - Five = Four + One; - Eight = Four + Four; - Nine = Three * Three; - TwentySeven = Nine * Three; - ThirtyTwo = Four * Eight; - TwoForty = Four * Five * Three * Four; - MinusOne = -One; - Half = One / Two; - OneAndHalf = One + Half; - ErrCnt[Failure] = 0; - ErrCnt[Serious] = 0; - ErrCnt[Defect] = 0; - ErrCnt[Flaw] = 0; - PageNo = 1; - /*=============================================*/ - Milestone = 0; - /*=============================================*/ + /* First two assignments use integer right-hand sides. */ + Zero = 0; + One = 1; + Two = One + One; + Three = Two + One; + Four = Three + One; + Five = Four + One; + Eight = Four + Four; + Nine = Three * Three; + TwentySeven = Nine * Three; + ThirtyTwo = Four * Eight; + TwoForty = Four * Five * Three * Four; + MinusOne = -One; + Half = One / Two; + OneAndHalf = One + Half; + ErrCnt[Failure] = 0; + ErrCnt[Serious] = 0; + ErrCnt[Defect] = 0; + ErrCnt[Flaw] = 0; + PageNo = 1; + /*=============================================*/ + Milestone = 0; + /*=============================================*/ #ifndef NOSIGNAL - signal(SIGFPE, sigfpe); + signal(SIGFPE, sigfpe); #endif - Instructions(); - Pause(); - Heading(); - Pause(); - Characteristics(); - Pause(); - History(); - Pause(); - /*=============================================*/ - Milestone = 7; - /*=============================================*/ - printf("Program is now RUNNING tests on small integers:\n"); - - TstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero) - && (One > Zero) && (One + One == Two), - "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2"); - Z = - Zero; - if (Z != 0.0) { - ErrCnt[Failure] = ErrCnt[Failure] + 1; - printf("Comparison alleges that -0.0 is Non-zero!\n"); - U1 = 0.001; - Radix = 1; - TstPtUf(); - } - TstCond (Failure, (Three == Two + One) && (Four == Three + One) - && (Four + Two * (- Two) == Zero) - && (Four - Three - One == Zero), - "3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0"); - TstCond (Failure, (MinusOne == (0 - One)) - && (MinusOne + One == Zero ) && (One + MinusOne == Zero) - && (MinusOne + FABS(One) == Zero) - && (MinusOne + MinusOne * MinusOne == Zero), - "-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0"); - TstCond (Failure, Half + MinusOne + Half == Zero, - "1/2 + (-1) + 1/2 != 0"); - /*=============================================*/ - /*SPLIT - part2(); - part3(); - part4(); - part5(); - part6(); - part7(); - part8(); - } + Instructions(); + Pause(); + Heading(); + Pause(); + Characteristics(); + Pause(); + History(); + Pause(); + /*=============================================*/ + Milestone = 7; + /*=============================================*/ + printf("Program is now RUNNING tests on small integers:\n"); + + TstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero) + && (One > Zero) && (One + One == Two), + "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2"); + Z = - Zero; + if (Z != 0.0) { + ErrCnt[Failure] = ErrCnt[Failure] + 1; + printf("Comparison alleges that -0.0 is Non-zero!\n"); + U1 = 0.001; + Radix = 1; + TstPtUf(); + } + TstCond (Failure, (Three == Two + One) && (Four == Three + One) + && (Four + Two * (- Two) == Zero) + && (Four - Three - One == Zero), + "3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0"); + TstCond (Failure, (MinusOne == (0 - One)) + && (MinusOne + One == Zero ) && (One + MinusOne == Zero) + && (MinusOne + FABS(One) == Zero) + && (MinusOne + MinusOne * MinusOne == Zero), + "-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0"); + TstCond (Failure, Half + MinusOne + Half == Zero, + "1/2 + (-1) + 1/2 != 0"); + /*=============================================*/ + /*SPLIT + part2(); + part3(); + part4(); + part5(); + part6(); + part7(); + part8(); + } #include "paranoia.h" part2(){ */ - Milestone = 10; - /*=============================================*/ - TstCond (Failure, (Nine == Three * Three) - && (TwentySeven == Nine * Three) && (Eight == Four + Four) - && (ThirtyTwo == Eight * Four) - && (ThirtyTwo - TwentySeven - Four - One == Zero), - "9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0"); - TstCond (Failure, (Five == Four + One) && - (TwoForty == Four * Five * Three * Four) - && (TwoForty / Three - Four * Four * Five == Zero) - && ( TwoForty / Four - Five * Three * Four == Zero) - && ( TwoForty / Five - Four * Three * Four == Zero), - "5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48"); - if (ErrCnt[Failure] == 0) { - printf("-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n"); - printf("\n"); - } - printf("Searching for Radix and Precision.\n"); - W = One; - do { - W = W + W; - Y = W + One; - Z = Y - W; - Y = Z - One; - } while (MinusOne + FABS(Y) < Zero); - /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/ - Precision = Zero; - Y = One; - do { - Radix = W + Y; - Y = Y + Y; - Radix = Radix - W; - } while ( Radix == Zero); - if (Radix < Two) Radix = One; - printf("Radix = %f .\n", Radix); - if (Radix != 1) { - W = One; - do { - Precision = Precision + One; - W = W * Radix; - Y = W + One; - } while ((Y - W) == One); - } - /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1 - ...*/ - U1 = One / W; - U2 = Radix * U1; - printf("Closest relative separation found is U1 = %.7e .\n\n", U1); - printf("Recalculating radix and precision\n "); - - /*save old values*/ - E0 = Radix; - E1 = U1; - E9 = U2; - E3 = Precision; - - X = Four / Three; - Third = X - One; - F6 = Half - Third; - X = F6 + F6; - X = FABS(X - Third); - if (X < U2) X = U2; - - /*... now X = (unknown no.) ulps of 1+...*/ - do { - U2 = X; - Y = Half * U2 + ThirtyTwo * U2 * U2; - Y = One + Y; - X = Y - One; - } while ( ! ((U2 <= X) || (X <= Zero))); - - /*... now U2 == 1 ulp of 1 + ... */ - X = Two / Three; - F6 = X - Half; - Third = F6 + F6; - X = Third - Half; - X = FABS(X + F6); - if (X < U1) X = U1; - - /*... now X == (unknown no.) ulps of 1 -... */ - do { - U1 = X; - Y = Half * U1 + ThirtyTwo * U1 * U1; - Y = Half - Y; - X = Half + Y; - Y = Half - X; - X = Half + Y; - } while ( ! ((U1 <= X) || (X <= Zero))); - /*... now U1 == 1 ulp of 1 - ... */ - if (U1 == E1) printf("confirms closest relative separation U1 .\n"); - else printf("gets better closest relative separation U1 = %.7e .\n", U1); - W = One / U1; - F9 = (Half - U1) + Half; - Radix = FLOOR(0.01 + U2 / U1); - if (Radix == E0) printf("Radix confirmed.\n"); - else printf("MYSTERY: recalculated Radix = %.7e .\n", Radix); - TstCond (Defect, Radix <= Eight + Eight, - "Radix is too big: roundoff problems"); - TstCond (Flaw, (Radix == Two) || (Radix == 10) - || (Radix == One), "Radix is not as good as 2 or 10"); - /*=============================================*/ - Milestone = 20; - /*=============================================*/ - TstCond (Failure, F9 - Half < Half, - "(1-U1)-1/2 < 1/2 is FALSE, prog. fails?"); - X = F9; - I = 1; - Y = X - Half; - Z = Y - Half; - TstCond (Failure, (X != One) - || (Z == Zero), "Comparison is fuzzy,X=1 but X-1/2-1/2 != 0"); - X = One + U2; - I = 0; - /*=============================================*/ - Milestone = 25; - /*=============================================*/ - /*... BMinusU2 = nextafter(Radix, 0) */ - BMinusU2 = Radix - One; - BMinusU2 = (BMinusU2 - U2) + One; - /* Purify Integers */ - if (Radix != One) { - X = - TwoForty * LOG(U1) / LOG(Radix); - Y = FLOOR(Half + X); - if (FABS(X - Y) * Four < One) X = Y; - Precision = X / TwoForty; - Y = FLOOR(Half + Precision); - if (FABS(Precision - Y) * TwoForty < Half) Precision = Y; - } - if ((Precision != FLOOR(Precision)) || (Radix == One)) { - printf("Precision cannot be characterized by an Integer number\n"); - printf("of significant digits but, by itself, this is a minor flaw.\n"); - } - if (Radix == One) - printf("logarithmic encoding has precision characterized solely by U1.\n"); - else printf("The number of significant digits of the Radix is %f .\n", - Precision); - TstCond (Serious, U2 * Nine * Nine * TwoForty < One, - "Precision worse than 5 decimal figures "); - /*=============================================*/ - Milestone = 30; - /*=============================================*/ - /* Test for extra-precise subepressions */ - X = FABS(((Four / Three - One) - One / Four) * Three - One / Four); - do { - Z2 = X; - X = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One; - } while ( ! ((Z2 <= X) || (X <= Zero))); - X = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four); - do { - Z1 = Z; - Z = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1)) - + One / Two)) + One / Two; - } while ( ! ((Z1 <= Z) || (Z <= Zero))); - do { - do { - Y1 = Y; - Y = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half - )) + Half; - } while ( ! ((Y1 <= Y) || (Y <= Zero))); - X1 = X; - X = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9; - } while ( ! ((X1 <= X) || (X <= Zero))); - if ((X1 != Y1) || (X1 != Z1)) { - BadCond(Serious, "Disagreements among the values X1, Y1, Z1,\n"); - printf("respectively %.7e, %.7e, %.7e,\n", X1, Y1, Z1); - printf("are symptoms of inconsistencies introduced\n"); - printf("by extra-precise evaluation of arithmetic subexpressions.\n"); - notify("Possibly some part of this"); - if ((X1 == U1) || (Y1 == U1) || (Z1 == U1)) printf( - "That feature is not tested further by this program.\n") ; - } - else { - if ((Z1 != U1) || (Z2 != U2)) { - if ((Z1 >= U1) || (Z2 >= U2)) { - BadCond(Failure, ""); - notify("Precision"); - printf("\tU1 = %.7e, Z1 - U1 = %.7e\n",U1,Z1-U1); - printf("\tU2 = %.7e, Z2 - U2 = %.7e\n",U2,Z2-U2); - } - else { - if ((Z1 <= Zero) || (Z2 <= Zero)) { - printf("Because of unusual Radix = %f", Radix); - printf(", or exact rational arithmetic a result\n"); - printf("Z1 = %.7e, or Z2 = %.7e ", Z1, Z2); - notify("of an\nextra-precision"); - } - if (Z1 != Z2 || Z1 > Zero) { - X = Z1 / U1; - Y = Z2 / U2; - if (Y > X) X = Y; - Q = - LOG(X); - printf("Some subexpressions appear to be calculated extra\n"); - printf("precisely with about %g extra B-digits, i.e.\n", - (Q / LOG(Radix))); - printf("roughly %g extra significant decimals.\n", - Q / LOG(10.)); - } - printf("That feature is not tested further by this program.\n"); - } - } - } - Pause(); - /*=============================================*/ - /*SPLIT - } + Milestone = 10; + /*=============================================*/ + TstCond (Failure, (Nine == Three * Three) + && (TwentySeven == Nine * Three) && (Eight == Four + Four) + && (ThirtyTwo == Eight * Four) + && (ThirtyTwo - TwentySeven - Four - One == Zero), + "9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0"); + TstCond (Failure, (Five == Four + One) && + (TwoForty == Four * Five * Three * Four) + && (TwoForty / Three - Four * Four * Five == Zero) + && ( TwoForty / Four - Five * Three * Four == Zero) + && ( TwoForty / Five - Four * Three * Four == Zero), + "5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48"); + if (ErrCnt[Failure] == 0) { + printf("-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n"); + printf("\n"); + } + printf("Searching for Radix and Precision.\n"); + W = One; + do { + W = W + W; + Y = W + One; + Z = Y - W; + Y = Z - One; + } while (MinusOne + FABS(Y) < Zero); + /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/ + Precision = Zero; + Y = One; + do { + Radix = W + Y; + Y = Y + Y; + Radix = Radix - W; + } while ( Radix == Zero); + if (Radix < Two) Radix = One; + printf("Radix = %f .\n", Radix); + if (Radix != 1) { + W = One; + do { + Precision = Precision + One; + W = W * Radix; + Y = W + One; + } while ((Y - W) == One); + } + /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1 + ...*/ + U1 = One / W; + U2 = Radix * U1; + printf("Closest relative separation found is U1 = %.7e .\n\n", U1); + printf("Recalculating radix and precision\n "); + + /*save old values*/ + E0 = Radix; + E1 = U1; + E9 = U2; + E3 = Precision; + + X = Four / Three; + Third = X - One; + F6 = Half - Third; + X = F6 + F6; + X = FABS(X - Third); + if (X < U2) X = U2; + + /*... now X = (unknown no.) ulps of 1+...*/ + do { + U2 = X; + Y = Half * U2 + ThirtyTwo * U2 * U2; + Y = One + Y; + X = Y - One; + } while ( ! ((U2 <= X) || (X <= Zero))); + + /*... now U2 == 1 ulp of 1 + ... */ + X = Two / Three; + F6 = X - Half; + Third = F6 + F6; + X = Third - Half; + X = FABS(X + F6); + if (X < U1) X = U1; + + /*... now X == (unknown no.) ulps of 1 -... */ + do { + U1 = X; + Y = Half * U1 + ThirtyTwo * U1 * U1; + Y = Half - Y; + X = Half + Y; + Y = Half - X; + X = Half + Y; + } while ( ! ((U1 <= X) || (X <= Zero))); + /*... now U1 == 1 ulp of 1 - ... */ + if (U1 == E1) printf("confirms closest relative separation U1 .\n"); + else printf("gets better closest relative separation U1 = %.7e .\n", U1); + W = One / U1; + F9 = (Half - U1) + Half; + Radix = FLOOR(0.01 + U2 / U1); + if (Radix == E0) printf("Radix confirmed.\n"); + else printf("MYSTERY: recalculated Radix = %.7e .\n", Radix); + TstCond (Defect, Radix <= Eight + Eight, + "Radix is too big: roundoff problems"); + TstCond (Flaw, (Radix == Two) || (Radix == 10) + || (Radix == One), "Radix is not as good as 2 or 10"); + /*=============================================*/ + Milestone = 20; + /*=============================================*/ + TstCond (Failure, F9 - Half < Half, + "(1-U1)-1/2 < 1/2 is FALSE, prog. fails?"); + X = F9; + I = 1; + Y = X - Half; + Z = Y - Half; + TstCond (Failure, (X != One) + || (Z == Zero), "Comparison is fuzzy,X=1 but X-1/2-1/2 != 0"); + X = One + U2; + I = 0; + /*=============================================*/ + Milestone = 25; + /*=============================================*/ + /*... BMinusU2 = nextafter(Radix, 0) */ + BMinusU2 = Radix - One; + BMinusU2 = (BMinusU2 - U2) + One; + /* Purify Integers */ + if (Radix != One) { + X = - TwoForty * LOG(U1) / LOG(Radix); + Y = FLOOR(Half + X); + if (FABS(X - Y) * Four < One) X = Y; + Precision = X / TwoForty; + Y = FLOOR(Half + Precision); + if (FABS(Precision - Y) * TwoForty < Half) Precision = Y; + } + if ((Precision != FLOOR(Precision)) || (Radix == One)) { + printf("Precision cannot be characterized by an Integer number\n"); + printf("of significant digits but, by itself, this is a minor flaw.\n"); + } + if (Radix == One) + printf("logarithmic encoding has precision characterized solely by U1.\n"); + else printf("The number of significant digits of the Radix is %f .\n", + Precision); + TstCond (Serious, U2 * Nine * Nine * TwoForty < One, + "Precision worse than 5 decimal figures "); + /*=============================================*/ + Milestone = 30; + /*=============================================*/ + /* Test for extra-precise subepressions */ + X = FABS(((Four / Three - One) - One / Four) * Three - One / Four); + do { + Z2 = X; + X = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One; + } while ( ! ((Z2 <= X) || (X <= Zero))); + X = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four); + do { + Z1 = Z; + Z = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1)) + + One / Two)) + One / Two; + } while ( ! ((Z1 <= Z) || (Z <= Zero))); + do { + do { + Y1 = Y; + Y = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half + )) + Half; + } while ( ! ((Y1 <= Y) || (Y <= Zero))); + X1 = X; + X = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9; + } while ( ! ((X1 <= X) || (X <= Zero))); + if ((X1 != Y1) || (X1 != Z1)) { + BadCond(Serious, "Disagreements among the values X1, Y1, Z1,\n"); + printf("respectively %.7e, %.7e, %.7e,\n", X1, Y1, Z1); + printf("are symptoms of inconsistencies introduced\n"); + printf("by extra-precise evaluation of arithmetic subexpressions.\n"); + notify("Possibly some part of this"); + if ((X1 == U1) || (Y1 == U1) || (Z1 == U1)) printf( + "That feature is not tested further by this program.\n") ; + } + else { + if ((Z1 != U1) || (Z2 != U2)) { + if ((Z1 >= U1) || (Z2 >= U2)) { + BadCond(Failure, ""); + notify("Precision"); + printf("\tU1 = %.7e, Z1 - U1 = %.7e\n",U1,Z1-U1); + printf("\tU2 = %.7e, Z2 - U2 = %.7e\n",U2,Z2-U2); + } + else { + if ((Z1 <= Zero) || (Z2 <= Zero)) { + printf("Because of unusual Radix = %f", Radix); + printf(", or exact rational arithmetic a result\n"); + printf("Z1 = %.7e, or Z2 = %.7e ", Z1, Z2); + notify("of an\nextra-precision"); + } + if (Z1 != Z2 || Z1 > Zero) { + X = Z1 / U1; + Y = Z2 / U2; + if (Y > X) X = Y; + Q = - LOG(X); + printf("Some subexpressions appear to be calculated extra\n"); + printf("precisely with about %g extra B-digits, i.e.\n", + (Q / LOG(Radix))); + printf("roughly %g extra significant decimals.\n", + Q / LOG(10.)); + } + printf("That feature is not tested further by this program.\n"); + } + } + } + Pause(); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part3(){ */ - Milestone = 35; - /*=============================================*/ - if (Radix >= Two) { - X = W / (Radix * Radix); - Y = X + One; - Z = Y - X; - T = Z + U2; - X = T - Z; - TstCond (Failure, X == U2, - "Subtraction is not normalized X=Y,X+Z != Y+Z!"); - if (X == U2) printf( - "Subtraction appears to be normalized, as it should be."); - } - printf("\nChecking for guard digit in *, /, and -.\n"); - Y = F9 * One; - Z = One * F9; - X = F9 - Half; - Y = (Y - Half) - X; - Z = (Z - Half) - X; - X = One + U2; - T = X * Radix; - R = Radix * X; - X = T - Radix; - X = X - Radix * U2; - T = R - Radix; - T = T - Radix * U2; - X = X * (Radix - One); - T = T * (Radix - One); - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes; - else { - GMult = No; - TstCond (Serious, False, - "* lacks a Guard Digit, so 1*X != X"); - } - Z = Radix * U2; - X = One + Z; - Y = FABS((X + Z) - X * X) - U2; - X = One - U2; - Z = FABS((X - U2) - X * X) - U1; - TstCond (Failure, (Y <= Zero) - && (Z <= Zero), "* gets too many final digits wrong.\n"); - Y = One - U2; - X = One + U2; - Z = One / Y; - Y = Z - X; - X = One / Three; - Z = Three / Nine; - X = X - Z; - T = Nine / TwentySeven; - Z = Z - T; - TstCond(Defect, X == Zero && Y == Zero && Z == Zero, - "Division lacks a Guard Digit, so error can exceed 1 ulp\nor 1/3 and 3/9 and 9/27 may disagree"); - Y = F9 / One; - X = F9 - Half; - Y = (Y - Half) - X; - X = One + U2; - T = X / One; - X = T - X; - if ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes; - else { - GDiv = No; - TstCond (Serious, False, - "Division lacks a Guard Digit, so X/1 != X"); - } - X = One / (One + U2); - Y = X - Half - Half; - TstCond (Serious, Y < Zero, - "Computed value of 1/1.000..1 >= 1"); - X = One - U2; - Y = One + Radix * U2; - Z = X * Radix; - T = Y * Radix; - R = Z / Radix; - StickyBit = T / Radix; - X = R - X; - Y = StickyBit - Y; - TstCond (Failure, X == Zero && Y == Zero, - "* and/or / gets too many last digits wrong"); - Y = One - U1; - X = One - F9; - Y = One - Y; - T = Radix - U2; - Z = Radix - BMinusU2; - T = Radix - T; - if ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes; - else { - GAddSub = No; - TstCond (Serious, False, - "- lacks Guard Digit, so cancellation is obscured"); - } - if (F9 != One && F9 - One >= Zero) { - BadCond(Serious, "comparison alleges (1-U1) < 1 although\n"); - printf(" subtraction yields (1-U1) - 1 = 0 , thereby vitiating\n"); - printf(" such precautions against division by zero as\n"); - printf(" ... if (X == 1.0) {.....} else {.../(X-1.0)...}\n"); - } - if (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf( - " *, /, and - appear to have guard digits, as they should.\n"); - /*=============================================*/ - Milestone = 40; - /*=============================================*/ - Pause(); - printf("Checking rounding on multiply, divide and add/subtract.\n"); - RMult = Other; - RDiv = Other; - RAddSub = Other; - RadixD2 = Radix / Two; - A1 = Two; - Done = False; - do { - AInvrse = Radix; - do { - X = AInvrse; - AInvrse = AInvrse / A1; - } while ( ! (FLOOR(AInvrse) != AInvrse)); - Done = (X == One) || (A1 > Three); - if (! Done) A1 = Nine + One; - } while ( ! (Done)); - if (X == One) A1 = Radix; - AInvrse = One / A1; - X = A1; - Y = AInvrse; - Done = False; - do { - Z = X * Y - Half; - TstCond (Failure, Z == Half, - "X * (1/X) differs from 1"); - Done = X == Radix; - X = Radix; - Y = One / X; - } while ( ! (Done)); - Y2 = One + U2; - Y1 = One - U2; - X = OneAndHalf - U2; - Y = OneAndHalf + U2; - Z = (X - U2) * Y2; - T = Y * Y1; - Z = Z - X; - T = T - X; - X = X * Y2; - Y = (Y + U2) * Y1; - X = X - OneAndHalf; - Y = Y - OneAndHalf; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) { - X = (OneAndHalf + U2) * Y2; - Y = OneAndHalf - U2 - U2; - Z = OneAndHalf + U2 + U2; - T = (OneAndHalf - U2) * Y1; - X = X - (Z + U2); - StickyBit = Y * Y1; - S = Z * Y2; - T = T - Y; - Y = (U2 - Y) + StickyBit; - Z = S - (Z + U2 + U2); - StickyBit = (Y2 + U2) * Y1; - Y1 = Y2 * Y1; - StickyBit = StickyBit - Y2; - Y1 = Y1 - Half; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) - && ( StickyBit == Zero) && (Y1 == Half)) { - RMult = Rounded; - printf("Multiplication appears to round correctly.\n"); - } - else if ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero) - && (T < Zero) && (StickyBit + U2 == Zero) - && (Y1 < Half)) { - RMult = Chopped; - printf("Multiplication appears to chop.\n"); - } - else printf("* is neither chopped nor correctly rounded.\n"); - if ((RMult == Rounded) && (GMult == No)) notify("Multiplication"); - } - else printf("* is neither chopped nor correctly rounded.\n"); - /*=============================================*/ - Milestone = 45; - /*=============================================*/ - Y2 = One + U2; - Y1 = One - U2; - Z = OneAndHalf + U2 + U2; - X = Z / Y2; - T = OneAndHalf - U2 - U2; - Y = (T - U2) / Y1; - Z = (Z + U2) / Y2; - X = X - OneAndHalf; - Y = Y - T; - T = T / Y1; - Z = Z - (OneAndHalf + U2); - T = (U2 - OneAndHalf) + T; - if (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) { - X = OneAndHalf / Y2; - Y = OneAndHalf - U2; - Z = OneAndHalf + U2; - X = X - Y; - T = OneAndHalf / Y1; - Y = Y / Y1; - T = T - (Z + U2); - Y = Y - Z; - Z = Z / Y2; - Y1 = (Y2 + U2) / Y2; - Z = Z - OneAndHalf; - Y2 = Y1 - Y2; - Y1 = (F9 - U1) / F9; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) - && (Y2 == Zero) && (Y2 == Zero) - && (Y1 - Half == F9 - Half )) { - RDiv = Rounded; - printf("Division appears to round correctly.\n"); - if (GDiv == No) notify("Division"); - } - else if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero) - && (Y2 < Zero) && (Y1 - Half < F9 - Half)) { - RDiv = Chopped; - printf("Division appears to chop.\n"); - } - } - if (RDiv == Other) printf("/ is neither chopped nor correctly rounded.\n"); - BInvrse = One / Radix; - TstCond (Failure, (BInvrse * Radix - Half == Half), - "Radix * ( 1 / Radix ) differs from 1"); - /*=============================================*/ - /*SPLIT - } + Milestone = 35; + /*=============================================*/ + if (Radix >= Two) { + X = W / (Radix * Radix); + Y = X + One; + Z = Y - X; + T = Z + U2; + X = T - Z; + TstCond (Failure, X == U2, + "Subtraction is not normalized X=Y,X+Z != Y+Z!"); + if (X == U2) printf( + "Subtraction appears to be normalized, as it should be."); + } + printf("\nChecking for guard digit in *, /, and -.\n"); + Y = F9 * One; + Z = One * F9; + X = F9 - Half; + Y = (Y - Half) - X; + Z = (Z - Half) - X; + X = One + U2; + T = X * Radix; + R = Radix * X; + X = T - Radix; + X = X - Radix * U2; + T = R - Radix; + T = T - Radix * U2; + X = X * (Radix - One); + T = T * (Radix - One); + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes; + else { + GMult = No; + TstCond (Serious, False, + "* lacks a Guard Digit, so 1*X != X"); + } + Z = Radix * U2; + X = One + Z; + Y = FABS((X + Z) - X * X) - U2; + X = One - U2; + Z = FABS((X - U2) - X * X) - U1; + TstCond (Failure, (Y <= Zero) + && (Z <= Zero), "* gets too many final digits wrong.\n"); + Y = One - U2; + X = One + U2; + Z = One / Y; + Y = Z - X; + X = One / Three; + Z = Three / Nine; + X = X - Z; + T = Nine / TwentySeven; + Z = Z - T; + TstCond(Defect, X == Zero && Y == Zero && Z == Zero, + "Division lacks a Guard Digit, so error can exceed 1 ulp\nor 1/3 and 3/9 and 9/27 may disagree"); + Y = F9 / One; + X = F9 - Half; + Y = (Y - Half) - X; + X = One + U2; + T = X / One; + X = T - X; + if ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes; + else { + GDiv = No; + TstCond (Serious, False, + "Division lacks a Guard Digit, so X/1 != X"); + } + X = One / (One + U2); + Y = X - Half - Half; + TstCond (Serious, Y < Zero, + "Computed value of 1/1.000..1 >= 1"); + X = One - U2; + Y = One + Radix * U2; + Z = X * Radix; + T = Y * Radix; + R = Z / Radix; + StickyBit = T / Radix; + X = R - X; + Y = StickyBit - Y; + TstCond (Failure, X == Zero && Y == Zero, + "* and/or / gets too many last digits wrong"); + Y = One - U1; + X = One - F9; + Y = One - Y; + T = Radix - U2; + Z = Radix - BMinusU2; + T = Radix - T; + if ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes; + else { + GAddSub = No; + TstCond (Serious, False, + "- lacks Guard Digit, so cancellation is obscured"); + } + if (F9 != One && F9 - One >= Zero) { + BadCond(Serious, "comparison alleges (1-U1) < 1 although\n"); + printf(" subtraction yields (1-U1) - 1 = 0 , thereby vitiating\n"); + printf(" such precautions against division by zero as\n"); + printf(" ... if (X == 1.0) {.....} else {.../(X-1.0)...}\n"); + } + if (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf( + " *, /, and - appear to have guard digits, as they should.\n"); + /*=============================================*/ + Milestone = 40; + /*=============================================*/ + Pause(); + printf("Checking rounding on multiply, divide and add/subtract.\n"); + RMult = Other; + RDiv = Other; + RAddSub = Other; + RadixD2 = Radix / Two; + A1 = Two; + Done = False; + do { + AInvrse = Radix; + do { + X = AInvrse; + AInvrse = AInvrse / A1; + } while ( ! (FLOOR(AInvrse) != AInvrse)); + Done = (X == One) || (A1 > Three); + if (! Done) A1 = Nine + One; + } while ( ! (Done)); + if (X == One) A1 = Radix; + AInvrse = One / A1; + X = A1; + Y = AInvrse; + Done = False; + do { + Z = X * Y - Half; + TstCond (Failure, Z == Half, + "X * (1/X) differs from 1"); + Done = X == Radix; + X = Radix; + Y = One / X; + } while ( ! (Done)); + Y2 = One + U2; + Y1 = One - U2; + X = OneAndHalf - U2; + Y = OneAndHalf + U2; + Z = (X - U2) * Y2; + T = Y * Y1; + Z = Z - X; + T = T - X; + X = X * Y2; + Y = (Y + U2) * Y1; + X = X - OneAndHalf; + Y = Y - OneAndHalf; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) { + X = (OneAndHalf + U2) * Y2; + Y = OneAndHalf - U2 - U2; + Z = OneAndHalf + U2 + U2; + T = (OneAndHalf - U2) * Y1; + X = X - (Z + U2); + StickyBit = Y * Y1; + S = Z * Y2; + T = T - Y; + Y = (U2 - Y) + StickyBit; + Z = S - (Z + U2 + U2); + StickyBit = (Y2 + U2) * Y1; + Y1 = Y2 * Y1; + StickyBit = StickyBit - Y2; + Y1 = Y1 - Half; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) + && ( StickyBit == Zero) && (Y1 == Half)) { + RMult = Rounded; + printf("Multiplication appears to round correctly.\n"); + } + else if ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero) + && (T < Zero) && (StickyBit + U2 == Zero) + && (Y1 < Half)) { + RMult = Chopped; + printf("Multiplication appears to chop.\n"); + } + else printf("* is neither chopped nor correctly rounded.\n"); + if ((RMult == Rounded) && (GMult == No)) notify("Multiplication"); + } + else printf("* is neither chopped nor correctly rounded.\n"); + /*=============================================*/ + Milestone = 45; + /*=============================================*/ + Y2 = One + U2; + Y1 = One - U2; + Z = OneAndHalf + U2 + U2; + X = Z / Y2; + T = OneAndHalf - U2 - U2; + Y = (T - U2) / Y1; + Z = (Z + U2) / Y2; + X = X - OneAndHalf; + Y = Y - T; + T = T / Y1; + Z = Z - (OneAndHalf + U2); + T = (U2 - OneAndHalf) + T; + if (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) { + X = OneAndHalf / Y2; + Y = OneAndHalf - U2; + Z = OneAndHalf + U2; + X = X - Y; + T = OneAndHalf / Y1; + Y = Y / Y1; + T = T - (Z + U2); + Y = Y - Z; + Z = Z / Y2; + Y1 = (Y2 + U2) / Y2; + Z = Z - OneAndHalf; + Y2 = Y1 - Y2; + Y1 = (F9 - U1) / F9; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) + && (Y2 == Zero) && (Y2 == Zero) + && (Y1 - Half == F9 - Half )) { + RDiv = Rounded; + printf("Division appears to round correctly.\n"); + if (GDiv == No) notify("Division"); + } + else if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero) + && (Y2 < Zero) && (Y1 - Half < F9 - Half)) { + RDiv = Chopped; + printf("Division appears to chop.\n"); + } + } + if (RDiv == Other) printf("/ is neither chopped nor correctly rounded.\n"); + BInvrse = One / Radix; + TstCond (Failure, (BInvrse * Radix - Half == Half), + "Radix * ( 1 / Radix ) differs from 1"); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part4(){ */ - Milestone = 50; - /*=============================================*/ - TstCond (Failure, ((F9 + U1) - Half == Half) - && ((BMinusU2 + U2 ) - One == Radix - One), - "Incomplete carry-propagation in Addition"); - X = One - U1 * U1; - Y = One + U2 * (One - U2); - Z = F9 - Half; - X = (X - Half) - Z; - Y = Y - One; - if ((X == Zero) && (Y == Zero)) { - RAddSub = Chopped; - printf("Add/Subtract appears to be chopped.\n"); - } - if (GAddSub == Yes) { - X = (Half + U2) * U2; - Y = (Half - U2) * U2; - X = One + X; - Y = One + Y; - X = (One + U2) - X; - Y = One - Y; - if ((X == Zero) && (Y == Zero)) { - X = (Half + U2) * U1; - Y = (Half - U2) * U1; - X = One - X; - Y = One - Y; - X = F9 - X; - Y = One - Y; - if ((X == Zero) && (Y == Zero)) { - RAddSub = Rounded; - printf("Addition/Subtraction appears to round correctly.\n"); - if (GAddSub == No) notify("Add/Subtract"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - S = One; - X = One + Half * (One + Half); - Y = (One + U2) * Half; - Z = X - Y; - T = Y - X; - StickyBit = Z + T; - if (StickyBit != Zero) { - S = Zero; - BadCond(Flaw, "(X - Y) + (Y - X) is non zero!\n"); - } - StickyBit = Zero; - if ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes) - && (RMult == Rounded) && (RDiv == Rounded) - && (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) { - printf("Checking for sticky bit.\n"); - X = (Half + U1) * U2; - Y = Half * U2; - Z = One + Y; - T = One + X; - if ((Z - One <= Zero) && (T - One >= U2)) { - Z = T + Y; - Y = Z - X; - if ((Z - T >= U2) && (Y - T == Zero)) { - X = (Half + U1) * U1; - Y = Half * U1; - Z = One - Y; - T = One - X; - if ((Z - One == Zero) && (T - F9 == Zero)) { - Z = (Half - U1) * U1; - T = F9 - Z; - Q = F9 - Y; - if ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) { - Z = (One + U2) * OneAndHalf; - T = (OneAndHalf + U2) - Z + U2; - X = One + Half / Radix; - Y = One + Radix * U2; - Z = X * Y; - if (T == Zero && X + Radix * U2 - Z == Zero) { - if (Radix != Two) { - X = Two + U2; - Y = X / Two; - if ((Y - One == Zero)) StickyBit = S; - } - else StickyBit = S; - } - } - } - } - } - } - if (StickyBit == One) printf("Sticky bit apparently used correctly.\n"); - else printf("Sticky bit used incorrectly or not at all.\n"); - TstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No || - RMult == Other || RDiv == Other || RAddSub == Other), - "lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below"); - /*=============================================*/ - Milestone = 60; - /*=============================================*/ - printf("\n"); - printf("Does Multiplication commute? "); - printf("Testing on %d random pairs.\n", NoTrials); - Random9 = SQRT(3.0); - Random1 = Third; - I = 1; - do { - X = Random(); - Y = Random(); - Z9 = Y * X; - Z = X * Y; - Z9 = Z - Z9; - I = I + 1; - } while ( ! ((I > NoTrials) || (Z9 != Zero))); - if (I == NoTrials) { - Random1 = One + Half / Three; - Random2 = (U2 + U1) + One; - Z = Random1 * Random2; - Y = Random2 * Random1; - Z9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half / - Three) * ((U2 + U1) + One); - } - if (! ((I == NoTrials) || (Z9 == Zero))) - BadCond(Defect, "X * Y == Y * X trial fails.\n"); - else printf(" No failures found in %d integer pairs.\n", NoTrials); - /*=============================================*/ - Milestone = 70; - /*=============================================*/ - printf("\nRunning test of square root(x).\n"); - TstCond (Failure, (Zero == SQRT(Zero)) - && (- Zero == SQRT(- Zero)) - && (One == SQRT(One)), "Square root of 0.0, -0.0 or 1.0 wrong"); - MinSqEr = Zero; - MaxSqEr = Zero; - J = Zero; - X = Radix; - OneUlp = U2; - SqXMinX (Serious); - X = BInvrse; - OneUlp = BInvrse * U1; - SqXMinX (Serious); - X = U1; - OneUlp = U1 * U1; - SqXMinX (Serious); - if (J != Zero) Pause(); - printf("Testing if sqrt(X * X) == X for %d Integers X.\n", NoTrials); - J = Zero; - X = Two; - Y = Radix; - if ((Radix != One)) do { - X = Y; - Y = Radix * Y; - } while ( ! ((Y - X >= NoTrials))); - OneUlp = X * U2; - I = 1; - while (I <= NoTrials) { - X = X + One; - SqXMinX (Defect); - if (J > Zero) break; - I = I + 1; - } - printf("Test for sqrt monotonicity.\n"); - I = - 1; - X = BMinusU2; - Y = Radix; - Z = Radix + Radix * U2; - NotMonot = False; - Monot = False; - while ( ! (NotMonot || Monot)) { - I = I + 1; - X = SQRT(X); - Q = SQRT(Y); - Z = SQRT(Z); - if ((X > Q) || (Q > Z)) NotMonot = True; - else { - Q = FLOOR(Q + Half); - if ((I > 0) || (Radix == Q * Q)) Monot = True; - else if (I > 0) { - if (I > 1) Monot = True; - else { - Y = Y * BInvrse; - X = Y - U1; - Z = Y + U1; - } - } - else { - Y = Q; - X = Y - U2; - Z = Y + U2; - } - } - } - if (Monot) printf("sqrt has passed a test for Monotonicity.\n"); - else { - BadCond(Defect, ""); - printf("sqrt(X) is non-monotonic for X near %.7e .\n", Y); - } - /*=============================================*/ - /*SPLIT - } + Milestone = 50; + /*=============================================*/ + TstCond (Failure, ((F9 + U1) - Half == Half) + && ((BMinusU2 + U2 ) - One == Radix - One), + "Incomplete carry-propagation in Addition"); + X = One - U1 * U1; + Y = One + U2 * (One - U2); + Z = F9 - Half; + X = (X - Half) - Z; + Y = Y - One; + if ((X == Zero) && (Y == Zero)) { + RAddSub = Chopped; + printf("Add/Subtract appears to be chopped.\n"); + } + if (GAddSub == Yes) { + X = (Half + U2) * U2; + Y = (Half - U2) * U2; + X = One + X; + Y = One + Y; + X = (One + U2) - X; + Y = One - Y; + if ((X == Zero) && (Y == Zero)) { + X = (Half + U2) * U1; + Y = (Half - U2) * U1; + X = One - X; + Y = One - Y; + X = F9 - X; + Y = One - Y; + if ((X == Zero) && (Y == Zero)) { + RAddSub = Rounded; + printf("Addition/Subtraction appears to round correctly.\n"); + if (GAddSub == No) notify("Add/Subtract"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + S = One; + X = One + Half * (One + Half); + Y = (One + U2) * Half; + Z = X - Y; + T = Y - X; + StickyBit = Z + T; + if (StickyBit != Zero) { + S = Zero; + BadCond(Flaw, "(X - Y) + (Y - X) is non zero!\n"); + } + StickyBit = Zero; + if ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes) + && (RMult == Rounded) && (RDiv == Rounded) + && (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) { + printf("Checking for sticky bit.\n"); + X = (Half + U1) * U2; + Y = Half * U2; + Z = One + Y; + T = One + X; + if ((Z - One <= Zero) && (T - One >= U2)) { + Z = T + Y; + Y = Z - X; + if ((Z - T >= U2) && (Y - T == Zero)) { + X = (Half + U1) * U1; + Y = Half * U1; + Z = One - Y; + T = One - X; + if ((Z - One == Zero) && (T - F9 == Zero)) { + Z = (Half - U1) * U1; + T = F9 - Z; + Q = F9 - Y; + if ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) { + Z = (One + U2) * OneAndHalf; + T = (OneAndHalf + U2) - Z + U2; + X = One + Half / Radix; + Y = One + Radix * U2; + Z = X * Y; + if (T == Zero && X + Radix * U2 - Z == Zero) { + if (Radix != Two) { + X = Two + U2; + Y = X / Two; + if ((Y - One == Zero)) StickyBit = S; + } + else StickyBit = S; + } + } + } + } + } + } + if (StickyBit == One) printf("Sticky bit apparently used correctly.\n"); + else printf("Sticky bit used incorrectly or not at all.\n"); + TstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No || + RMult == Other || RDiv == Other || RAddSub == Other), + "lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below"); + /*=============================================*/ + Milestone = 60; + /*=============================================*/ + printf("\n"); + printf("Does Multiplication commute? "); + printf("Testing on %d random pairs.\n", NoTrials); + Random9 = SQRT(3.0); + Random1 = Third; + I = 1; + do { + X = Random(); + Y = Random(); + Z9 = Y * X; + Z = X * Y; + Z9 = Z - Z9; + I = I + 1; + } while ( ! ((I > NoTrials) || (Z9 != Zero))); + if (I == NoTrials) { + Random1 = One + Half / Three; + Random2 = (U2 + U1) + One; + Z = Random1 * Random2; + Y = Random2 * Random1; + Z9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half / + Three) * ((U2 + U1) + One); + } + if (! ((I == NoTrials) || (Z9 == Zero))) + BadCond(Defect, "X * Y == Y * X trial fails.\n"); + else printf(" No failures found in %d integer pairs.\n", NoTrials); + /*=============================================*/ + Milestone = 70; + /*=============================================*/ + printf("\nRunning test of square root(x).\n"); + TstCond (Failure, (Zero == SQRT(Zero)) + && (- Zero == SQRT(- Zero)) + && (One == SQRT(One)), "Square root of 0.0, -0.0 or 1.0 wrong"); + MinSqEr = Zero; + MaxSqEr = Zero; + J = Zero; + X = Radix; + OneUlp = U2; + SqXMinX (Serious); + X = BInvrse; + OneUlp = BInvrse * U1; + SqXMinX (Serious); + X = U1; + OneUlp = U1 * U1; + SqXMinX (Serious); + if (J != Zero) Pause(); + printf("Testing if sqrt(X * X) == X for %d Integers X.\n", NoTrials); + J = Zero; + X = Two; + Y = Radix; + if ((Radix != One)) do { + X = Y; + Y = Radix * Y; + } while ( ! ((Y - X >= NoTrials))); + OneUlp = X * U2; + I = 1; + while (I <= NoTrials) { + X = X + One; + SqXMinX (Defect); + if (J > Zero) break; + I = I + 1; + } + printf("Test for sqrt monotonicity.\n"); + I = - 1; + X = BMinusU2; + Y = Radix; + Z = Radix + Radix * U2; + NotMonot = False; + Monot = False; + while ( ! (NotMonot || Monot)) { + I = I + 1; + X = SQRT(X); + Q = SQRT(Y); + Z = SQRT(Z); + if ((X > Q) || (Q > Z)) NotMonot = True; + else { + Q = FLOOR(Q + Half); + if ((I > 0) || (Radix == Q * Q)) Monot = True; + else if (I > 0) { + if (I > 1) Monot = True; + else { + Y = Y * BInvrse; + X = Y - U1; + Z = Y + U1; + } + } + else { + Y = Q; + X = Y - U2; + Z = Y + U2; + } + } + } + if (Monot) printf("sqrt has passed a test for Monotonicity.\n"); + else { + BadCond(Defect, ""); + printf("sqrt(X) is non-monotonic for X near %.7e .\n", Y); + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part5(){ */ - Milestone = 80; - /*=============================================*/ - MinSqEr = MinSqEr + Half; - MaxSqEr = MaxSqEr - Half; - Y = (SQRT(One + U2) - One) / U2; - SqEr = (Y - One) + U2 / Eight; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - SqEr = Y + U2 / Eight; - if (SqEr < MinSqEr) MinSqEr = SqEr; - Y = ((SQRT(F9) - U2) - (One - U2)) / U1; - SqEr = Y + U1 / Eight; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - SqEr = (Y + One) + U1 / Eight; - if (SqEr < MinSqEr) MinSqEr = SqEr; - OneUlp = U2; - X = OneUlp; - for( Indx = 1; Indx <= 3; ++Indx) { - Y = SQRT((X + U1 + X) + F9); - Y = ((Y - U2) - ((One - U2) + X)) / OneUlp; - Z = ((U1 - X) + F9) * Half * X * X / OneUlp; - SqEr = (Y + Half) + Z; - if (SqEr < MinSqEr) MinSqEr = SqEr; - SqEr = (Y - Half) + Z; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - if (((Indx == 1) || (Indx == 3))) - X = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp))); - else { - OneUlp = U1; - X = - OneUlp; - } - } - /*=============================================*/ - Milestone = 85; - /*=============================================*/ - SqRWrng = False; - Anomaly = False; - RSqrt = Other; /* ~dgh */ - if (Radix != One) { - printf("Testing whether sqrt is rounded or chopped.\n"); - D = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision))); - /* ... == Radix^(1 + fract) if (Precision == Integer + fract. */ - X = D / Radix; - Y = D / A1; - if ((X != FLOOR(X)) || (Y != FLOOR(Y))) { - Anomaly = True; - } - else { - X = Zero; - Z2 = X; - Y = One; - Y2 = Y; - Z1 = Radix - One; - FourD = Four * D; - do { - if (Y2 > Z2) { - Q = Radix; - Y1 = Y; - do { - X1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1); - Q = Y1; - Y1 = X1; - } while ( ! (X1 <= Zero)); - if (Q <= One) { - Z2 = Y2; - Z = Y; - } - } - Y = Y + Two; - X = X + Eight; - Y2 = Y2 + X; - if (Y2 >= FourD) Y2 = Y2 - FourD; - } while ( ! (Y >= D)); - X8 = FourD - Z2; - Q = (X8 + Z * Z) / FourD; - X8 = X8 / Eight; - if (Q != FLOOR(Q)) Anomaly = True; - else { - Break = False; - do { - X = Z1 * Z; - X = X - FLOOR(X / Radix) * Radix; - if (X == One) - Break = True; - else - Z1 = Z1 - One; - } while ( ! (Break || (Z1 <= Zero))); - if ((Z1 <= Zero) && (! Break)) Anomaly = True; - else { - if (Z1 > RadixD2) Z1 = Z1 - Radix; - do { - NewD(); - } while ( ! (U2 * D >= F9)); - if (D * Radix - D != W - D) Anomaly = True; - else { - Z2 = D; - I = 0; - Y = D + (One + Z) * Half; - X = D + Z + Q; - SR3750(); - Y = D + (One - Z) * Half + D; - X = D - Z + D; - X = X + Q + X; - SR3750(); - NewD(); - if (D - Z2 != W - Z2) Anomaly = True; - else { - Y = (D - Z2) + (Z2 + (One - Z) * Half); - X = (D - Z2) + (Z2 - Z + Q); - SR3750(); - Y = (One + Z) * Half; - X = Q; - SR3750(); - if (I == 0) Anomaly = True; - } - } - } - } - } - if ((I == 0) || Anomaly) { - BadCond(Failure, "Anomalous arithmetic with Integer < "); - printf("Radix^Precision = %.7e\n", W); - printf(" fails test whether sqrt rounds or chops.\n"); - SqRWrng = True; - } - } - if (! Anomaly) { - if (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) { - RSqrt = Rounded; - printf("Square root appears to be correctly rounded.\n"); - } - else { - if ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half) - || (MinSqEr + Radix < Half)) SqRWrng = True; - else { - RSqrt = Chopped; - printf("Square root appears to be chopped.\n"); - } - } - } - if (SqRWrng) { - printf("Square root is neither chopped nor correctly rounded.\n"); - printf("Observed errors run from %.7e ", MinSqEr - Half); - printf("to %.7e ulps.\n", Half + MaxSqEr); - TstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix, - "sqrt gets too many last digits wrong"); - } - /*=============================================*/ - Milestone = 90; - /*=============================================*/ - Pause(); - printf("Testing powers Z^i for small Integers Z and i.\n"); - N = 0; - /* ... test powers of zero. */ - I = 0; - Z = -Zero; - M = 3.0; - Break = False; - do { - X = One; - SR3980(); - if (I <= 10) { - I = 1023; - SR3980(); - } - if (Z == MinusOne) Break = True; - else { - Z = MinusOne; - PrintIfNPositive(); - N = 0; - /* .. if(-1)^N is invalid, replace MinusOne by One. */ - I = - 4; - } - } while ( ! Break); - PrintIfNPositive(); - N1 = N; - N = 0; - Z = A1; - M = FLOOR(Two * LOG(W) / LOG(A1)); - Break = False; - do { - X = Z; - I = 1; - SR3980(); - if (Z == AInvrse) Break = True; - else Z = AInvrse; - } while ( ! (Break)); - /*=============================================*/ - Milestone = 100; - /*=============================================*/ - /* Powers of Radix have been tested, */ - /* next try a few primes */ - M = NoTrials; - Z = Three; - do { - X = Z; - I = 1; - SR3980(); - do { - Z = Z + Two; - } while ( Three * FLOOR(Z / Three) == Z ); - } while ( Z < Eight * Three ); - if (N > 0) { - printf("Errors like this may invalidate financial calculations\n"); - printf("\tinvolving interest rates.\n"); - } - PrintIfNPositive(); - N += N1; - if (N == 0) printf("... no discrepancis found.\n"); - if (N > 0) Pause(); - else printf("\n"); - /*=============================================*/ - /*SPLIT - } + Milestone = 80; + /*=============================================*/ + MinSqEr = MinSqEr + Half; + MaxSqEr = MaxSqEr - Half; + Y = (SQRT(One + U2) - One) / U2; + SqEr = (Y - One) + U2 / Eight; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + SqEr = Y + U2 / Eight; + if (SqEr < MinSqEr) MinSqEr = SqEr; + Y = ((SQRT(F9) - U2) - (One - U2)) / U1; + SqEr = Y + U1 / Eight; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + SqEr = (Y + One) + U1 / Eight; + if (SqEr < MinSqEr) MinSqEr = SqEr; + OneUlp = U2; + X = OneUlp; + for( Indx = 1; Indx <= 3; ++Indx) { + Y = SQRT((X + U1 + X) + F9); + Y = ((Y - U2) - ((One - U2) + X)) / OneUlp; + Z = ((U1 - X) + F9) * Half * X * X / OneUlp; + SqEr = (Y + Half) + Z; + if (SqEr < MinSqEr) MinSqEr = SqEr; + SqEr = (Y - Half) + Z; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + if (((Indx == 1) || (Indx == 3))) + X = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp))); + else { + OneUlp = U1; + X = - OneUlp; + } + } + /*=============================================*/ + Milestone = 85; + /*=============================================*/ + SqRWrng = False; + Anomaly = False; + RSqrt = Other; /* ~dgh */ + if (Radix != One) { + printf("Testing whether sqrt is rounded or chopped.\n"); + D = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision))); + /* ... == Radix^(1 + fract) if (Precision == Integer + fract. */ + X = D / Radix; + Y = D / A1; + if ((X != FLOOR(X)) || (Y != FLOOR(Y))) { + Anomaly = True; + } + else { + X = Zero; + Z2 = X; + Y = One; + Y2 = Y; + Z1 = Radix - One; + FourD = Four * D; + do { + if (Y2 > Z2) { + Q = Radix; + Y1 = Y; + do { + X1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1); + Q = Y1; + Y1 = X1; + } while ( ! (X1 <= Zero)); + if (Q <= One) { + Z2 = Y2; + Z = Y; + } + } + Y = Y + Two; + X = X + Eight; + Y2 = Y2 + X; + if (Y2 >= FourD) Y2 = Y2 - FourD; + } while ( ! (Y >= D)); + X8 = FourD - Z2; + Q = (X8 + Z * Z) / FourD; + X8 = X8 / Eight; + if (Q != FLOOR(Q)) Anomaly = True; + else { + Break = False; + do { + X = Z1 * Z; + X = X - FLOOR(X / Radix) * Radix; + if (X == One) + Break = True; + else + Z1 = Z1 - One; + } while ( ! (Break || (Z1 <= Zero))); + if ((Z1 <= Zero) && (! Break)) Anomaly = True; + else { + if (Z1 > RadixD2) Z1 = Z1 - Radix; + do { + NewD(); + } while ( ! (U2 * D >= F9)); + if (D * Radix - D != W - D) Anomaly = True; + else { + Z2 = D; + I = 0; + Y = D + (One + Z) * Half; + X = D + Z + Q; + SR3750(); + Y = D + (One - Z) * Half + D; + X = D - Z + D; + X = X + Q + X; + SR3750(); + NewD(); + if (D - Z2 != W - Z2) Anomaly = True; + else { + Y = (D - Z2) + (Z2 + (One - Z) * Half); + X = (D - Z2) + (Z2 - Z + Q); + SR3750(); + Y = (One + Z) * Half; + X = Q; + SR3750(); + if (I == 0) Anomaly = True; + } + } + } + } + } + if ((I == 0) || Anomaly) { + BadCond(Failure, "Anomalous arithmetic with Integer < "); + printf("Radix^Precision = %.7e\n", W); + printf(" fails test whether sqrt rounds or chops.\n"); + SqRWrng = True; + } + } + if (! Anomaly) { + if (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) { + RSqrt = Rounded; + printf("Square root appears to be correctly rounded.\n"); + } + else { + if ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half) + || (MinSqEr + Radix < Half)) SqRWrng = True; + else { + RSqrt = Chopped; + printf("Square root appears to be chopped.\n"); + } + } + } + if (SqRWrng) { + printf("Square root is neither chopped nor correctly rounded.\n"); + printf("Observed errors run from %.7e ", MinSqEr - Half); + printf("to %.7e ulps.\n", Half + MaxSqEr); + TstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix, + "sqrt gets too many last digits wrong"); + } + /*=============================================*/ + Milestone = 90; + /*=============================================*/ + Pause(); + printf("Testing powers Z^i for small Integers Z and i.\n"); + N = 0; + /* ... test powers of zero. */ + I = 0; + Z = -Zero; + M = 3.0; + Break = False; + do { + X = One; + SR3980(); + if (I <= 10) { + I = 1023; + SR3980(); + } + if (Z == MinusOne) Break = True; + else { + Z = MinusOne; + PrintIfNPositive(); + N = 0; + /* .. if(-1)^N is invalid, replace MinusOne by One. */ + I = - 4; + } + } while ( ! Break); + PrintIfNPositive(); + N1 = N; + N = 0; + Z = A1; + M = FLOOR(Two * LOG(W) / LOG(A1)); + Break = False; + do { + X = Z; + I = 1; + SR3980(); + if (Z == AInvrse) Break = True; + else Z = AInvrse; + } while ( ! (Break)); + /*=============================================*/ + Milestone = 100; + /*=============================================*/ + /* Powers of Radix have been tested, */ + /* next try a few primes */ + M = NoTrials; + Z = Three; + do { + X = Z; + I = 1; + SR3980(); + do { + Z = Z + Two; + } while ( Three * FLOOR(Z / Three) == Z ); + } while ( Z < Eight * Three ); + if (N > 0) { + printf("Errors like this may invalidate financial calculations\n"); + printf("\tinvolving interest rates.\n"); + } + PrintIfNPositive(); + N += N1; + if (N == 0) printf("... no discrepancis found.\n"); + if (N > 0) Pause(); + else printf("\n"); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part6(){ */ - Milestone = 110; - /*=============================================*/ - printf("Seeking Underflow thresholds UfThold and E0.\n"); - D = U1; - if (Precision != FLOOR(Precision)) { - D = BInvrse; - X = Precision; - do { - D = D * BInvrse; - X = X - One; - } while ( X > Zero); - } - Y = One; - Z = D; - /* ... D is power of 1/Radix < 1. */ - do { - C = Y; - Y = Z; - Z = Y * Y; - } while ((Y > Z) && (Z + Z > Z)); - Y = C; - Z = Y * D; - do { - C = Y; - Y = Z; - Z = Y * D; - } while ((Y > Z) && (Z + Z > Z)); - if (Radix < Two) HInvrse = Two; - else HInvrse = Radix; - H = One / HInvrse; - /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */ - CInvrse = One / C; - E0 = C; - Z = E0 * H; - /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ - do { - Y = E0; - E0 = Z; - Z = E0 * H; - } while ((E0 > Z) && (Z + Z > Z)); - UfThold = E0; - E1 = Zero; - Q = Zero; - E9 = U2; - S = One + E9; - D = C * S; - if (D <= C) { - E9 = Radix * U2; - S = One + E9; - D = C * S; - if (D <= C) { - BadCond(Failure, "multiplication gets too many last digits wrong.\n"); - Underflow = E0; - Y1 = Zero; - PseudoZero = Z; - Pause(); - } - } - else { - Underflow = D; - PseudoZero = Underflow * H; - UfThold = Zero; - do { - Y1 = Underflow; - Underflow = PseudoZero; - if (E1 + E1 <= E1) { - Y2 = Underflow * HInvrse; - E1 = FABS(Y1 - Y2); - Q = Y1; - if ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1; - } - PseudoZero = PseudoZero * H; - } while ((Underflow > PseudoZero) - && (PseudoZero + PseudoZero > PseudoZero)); - } - /* Comment line 4530 .. 4560 */ - if (PseudoZero != Zero) { - printf("\n"); - Z = PseudoZero; - /* ... Test PseudoZero for "phoney- zero" violates */ - /* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero - ... */ - if (PseudoZero <= Zero) { - BadCond(Failure, "Positive expressions can underflow to an\n"); - printf("allegedly negative value\n"); - printf("PseudoZero that prints out as: %g .\n", PseudoZero); - X = - PseudoZero; - if (X <= Zero) { - printf("But -PseudoZero, which should be\n"); - printf("positive, isn't; it prints out as %g .\n", X); - } - } - else { - BadCond(Flaw, "Underflow can stick at an allegedly positive\n"); - printf("value PseudoZero that prints out as %g .\n", PseudoZero); - } - TstPtUf(); - } - /*=============================================*/ - Milestone = 120; - /*=============================================*/ - if (CInvrse * Y > CInvrse * Y1) { - S = H * S; - E0 = Underflow; - } - if (! ((E1 == Zero) || (E1 == E0))) { - BadCond(Defect, ""); - if (E1 < E0) { - printf("Products underflow at a higher"); - printf(" threshold than differences.\n"); - if (PseudoZero == Zero) - E0 = E1; - } - else { - printf("Difference underflows at a higher"); - printf(" threshold than products.\n"); - } - } - printf("Smallest strictly positive number found is E0 = %g .\n", E0); - Z = E0; - TstPtUf(); - Underflow = E0; - if (N == 1) Underflow = Y; - I = 4; - if (E1 == Zero) I = 3; - if (UfThold == Zero) I = I - 2; - UfNGrad = True; - switch (I) { - case 1: - UfThold = Underflow; - if ((CInvrse * Q) != ((CInvrse * Y) * S)) { - UfThold = Y; - BadCond(Failure, "Either accuracy deteriorates as numbers\n"); - printf("approach a threshold = %.17e\n", UfThold);; - printf(" coming down from %.17e\n", C); - printf(" or else multiplication gets too many last digits wrong.\n"); - } - Pause(); - break; - - case 2: - BadCond(Failure, "Underflow confuses Comparison, which alleges that\n"); - printf("Q == Y while denying that |Q - Y| == 0; these values\n"); - printf("print out as Q = %.17e, Y = %.17e .\n", Q, Y2); - printf ("|Q - Y| = %.17e .\n" , FABS(Q - Y2)); - UfThold = Q; - break; - - case 3: - X = X; - break; - - case 4: - if ((Q == UfThold) && (E1 == E0) - && (FABS( UfThold - E1 / E9) <= E1)) { - UfNGrad = False; - printf("Underflow is gradual; it incurs Absolute Error =\n"); - printf("(roundoff in UfThold) < E0.\n"); - Y = E0 * CInvrse; - Y = Y * (OneAndHalf + U2); - X = CInvrse * (One + U2); - Y = Y / X; - IEEE = (Y == E0); - } - } - if (UfNGrad) { - printf("\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) { - printf("Underflow / UfThold failed!\n"); - R = H + H; - } - else R = SQRT(Underflow / UfThold); - sigsave = 0; - if (R <= H) { - Z = R * UfThold; - X = Z * (One + R * H * (One + H)); - } - else { - Z = UfThold; - X = Z * (One + H * H * (One + H)); - } - if (! ((X == Z) || (X - Z != Zero))) { - BadCond(Flaw, ""); - printf("X = %.17e\n\tis not equal to Z = %.17e .\n", X, Z); - Z9 = X - Z; - printf("yet X - Z yields %.17e .\n", Z9); - printf(" Should this NOT signal Underflow, "); - printf("this is a SERIOUS DEFECT\nthat causes "); - printf("confusion when innocent statements like\n");; - printf(" if (X == Z) ... else"); - printf(" ... (f(X) - f(Z)) / (X - Z) ...\n"); - printf("encounter Division by Zero although actually\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) printf("X / Z fails!\n"); - else printf("X / Z = 1 + %g .\n", (X / Z - Half) - Half); - sigsave = 0; - } - } - printf("The Underflow threshold is %.17e, %s\n", UfThold, - " below which"); - printf("calculation may suffer larger Relative error than "); - printf("merely roundoff.\n"); - Y2 = U1 * U1; - Y = Y2 * Y2; - Y2 = Y * U1; - if (Y2 <= UfThold) { - if (Y > E0) { - BadCond(Defect, ""); - I = 5; - } - else { - BadCond(Serious, ""); - I = 4; - } - printf("Range is too narrow; U1^%d Underflows.\n", I); - } - /*=============================================*/ - /*SPLIT - } + Milestone = 110; + /*=============================================*/ + printf("Seeking Underflow thresholds UfThold and E0.\n"); + D = U1; + if (Precision != FLOOR(Precision)) { + D = BInvrse; + X = Precision; + do { + D = D * BInvrse; + X = X - One; + } while ( X > Zero); + } + Y = One; + Z = D; + /* ... D is power of 1/Radix < 1. */ + do { + C = Y; + Y = Z; + Z = Y * Y; + } while ((Y > Z) && (Z + Z > Z)); + Y = C; + Z = Y * D; + do { + C = Y; + Y = Z; + Z = Y * D; + } while ((Y > Z) && (Z + Z > Z)); + if (Radix < Two) HInvrse = Two; + else HInvrse = Radix; + H = One / HInvrse; + /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */ + CInvrse = One / C; + E0 = C; + Z = E0 * H; + /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ + do { + Y = E0; + E0 = Z; + Z = E0 * H; + } while ((E0 > Z) && (Z + Z > Z)); + UfThold = E0; + E1 = Zero; + Q = Zero; + E9 = U2; + S = One + E9; + D = C * S; + if (D <= C) { + E9 = Radix * U2; + S = One + E9; + D = C * S; + if (D <= C) { + BadCond(Failure, "multiplication gets too many last digits wrong.\n"); + Underflow = E0; + Y1 = Zero; + PseudoZero = Z; + Pause(); + } + } + else { + Underflow = D; + PseudoZero = Underflow * H; + UfThold = Zero; + do { + Y1 = Underflow; + Underflow = PseudoZero; + if (E1 + E1 <= E1) { + Y2 = Underflow * HInvrse; + E1 = FABS(Y1 - Y2); + Q = Y1; + if ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1; + } + PseudoZero = PseudoZero * H; + } while ((Underflow > PseudoZero) + && (PseudoZero + PseudoZero > PseudoZero)); + } + /* Comment line 4530 .. 4560 */ + if (PseudoZero != Zero) { + printf("\n"); + Z = PseudoZero; + /* ... Test PseudoZero for "phoney- zero" violates */ + /* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero + ... */ + if (PseudoZero <= Zero) { + BadCond(Failure, "Positive expressions can underflow to an\n"); + printf("allegedly negative value\n"); + printf("PseudoZero that prints out as: %g .\n", PseudoZero); + X = - PseudoZero; + if (X <= Zero) { + printf("But -PseudoZero, which should be\n"); + printf("positive, isn't; it prints out as %g .\n", X); + } + } + else { + BadCond(Flaw, "Underflow can stick at an allegedly positive\n"); + printf("value PseudoZero that prints out as %g .\n", PseudoZero); + } + TstPtUf(); + } + /*=============================================*/ + Milestone = 120; + /*=============================================*/ + if (CInvrse * Y > CInvrse * Y1) { + S = H * S; + E0 = Underflow; + } + if (! ((E1 == Zero) || (E1 == E0))) { + BadCond(Defect, ""); + if (E1 < E0) { + printf("Products underflow at a higher"); + printf(" threshold than differences.\n"); + if (PseudoZero == Zero) + E0 = E1; + } + else { + printf("Difference underflows at a higher"); + printf(" threshold than products.\n"); + } + } + printf("Smallest strictly positive number found is E0 = %g .\n", E0); + Z = E0; + TstPtUf(); + Underflow = E0; + if (N == 1) Underflow = Y; + I = 4; + if (E1 == Zero) I = 3; + if (UfThold == Zero) I = I - 2; + UfNGrad = True; + switch (I) { + case 1: + UfThold = Underflow; + if ((CInvrse * Q) != ((CInvrse * Y) * S)) { + UfThold = Y; + BadCond(Failure, "Either accuracy deteriorates as numbers\n"); + printf("approach a threshold = %.17e\n", UfThold);; + printf(" coming down from %.17e\n", C); + printf(" or else multiplication gets too many last digits wrong.\n"); + } + Pause(); + break; + + case 2: + BadCond(Failure, "Underflow confuses Comparison, which alleges that\n"); + printf("Q == Y while denying that |Q - Y| == 0; these values\n"); + printf("print out as Q = %.17e, Y = %.17e .\n", Q, Y2); + printf ("|Q - Y| = %.17e .\n" , FABS(Q - Y2)); + UfThold = Q; + break; + + case 3: + X = X; + break; + + case 4: + if ((Q == UfThold) && (E1 == E0) + && (FABS( UfThold - E1 / E9) <= E1)) { + UfNGrad = False; + printf("Underflow is gradual; it incurs Absolute Error =\n"); + printf("(roundoff in UfThold) < E0.\n"); + Y = E0 * CInvrse; + Y = Y * (OneAndHalf + U2); + X = CInvrse * (One + U2); + Y = Y / X; + IEEE = (Y == E0); + } + } + if (UfNGrad) { + printf("\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) { + printf("Underflow / UfThold failed!\n"); + R = H + H; + } + else R = SQRT(Underflow / UfThold); + sigsave = 0; + if (R <= H) { + Z = R * UfThold; + X = Z * (One + R * H * (One + H)); + } + else { + Z = UfThold; + X = Z * (One + H * H * (One + H)); + } + if (! ((X == Z) || (X - Z != Zero))) { + BadCond(Flaw, ""); + printf("X = %.17e\n\tis not equal to Z = %.17e .\n", X, Z); + Z9 = X - Z; + printf("yet X - Z yields %.17e .\n", Z9); + printf(" Should this NOT signal Underflow, "); + printf("this is a SERIOUS DEFECT\nthat causes "); + printf("confusion when innocent statements like\n");; + printf(" if (X == Z) ... else"); + printf(" ... (f(X) - f(Z)) / (X - Z) ...\n"); + printf("encounter Division by Zero although actually\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) printf("X / Z fails!\n"); + else printf("X / Z = 1 + %g .\n", (X / Z - Half) - Half); + sigsave = 0; + } + } + printf("The Underflow threshold is %.17e, %s\n", UfThold, + " below which"); + printf("calculation may suffer larger Relative error than "); + printf("merely roundoff.\n"); + Y2 = U1 * U1; + Y = Y2 * Y2; + Y2 = Y * U1; + if (Y2 <= UfThold) { + if (Y > E0) { + BadCond(Defect, ""); + I = 5; + } + else { + BadCond(Serious, ""); + I = 4; + } + printf("Range is too narrow; U1^%d Underflows.\n", I); + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part7(){ */ - Milestone = 130; - /*=============================================*/ - Y = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty; - Y2 = Y + Y; - printf("Since underflow occurs below the threshold\n"); - printf("UfThold = (%.17e) ^ (%.17e)\nonly underflow ", HInvrse, Y); - printf("should afflict the expression\n\t(%.17e) ^ (%.17e);\n", HInvrse, Y); - V9 = POW(HInvrse, Y2); - printf("actually calculating yields: %.17e .\n", V9); - if (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) { - BadCond(Serious, "this is not between 0 and underflow\n"); - printf(" threshold = %.17e .\n", UfThold); - } - else if (! (V9 > UfThold * (One + E9))) - printf("This computed value is O.K.\n"); - else { - BadCond(Defect, "this is not between 0 and underflow\n"); - printf(" threshold = %.17e .\n", UfThold); - } - /*=============================================*/ - Milestone = 140; - /*=============================================*/ - printf("\n"); - /* ...calculate Exp2 == exp(2) == 7.389056099... */ - X = Zero; - I = 2; - Y = Two * Three; - Q = Zero; - N = 0; - do { - Z = X; - I = I + 1; - Y = Y / (I + I); - R = Y + Q; - X = Z + R; - Q = (Z - X) + R; - } while(X > Z); - Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo); - X = Z * Z; - Exp2 = X * X; - X = F9; - Y = X - U1; - printf("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n", - Exp2); - for(I = 1;;) { - Z = X - BInvrse; - Z = (X + One) / (Z - (One - BInvrse)); - Q = POW(X, Z) - Exp2; - if (FABS(Q) > TwoForty * U2) { - N = 1; - V9 = (X - BInvrse) - (One - BInvrse); - BadCond(Defect, "Calculated"); - printf(" %.17e for\n", POW(X,Z)); - printf("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z); - printf("\tdiffers from correct value by %.17e .\n", Q); - printf("\tThis much error may spoil financial\n"); - printf("\tcalculations involving tiny interest rates.\n"); - break; - } - else { - Z = (Y - X) * Two + Y; - X = Y; - Y = Z; - Z = One + (X - F9)*(X - F9); - if (Z > One && I < NoTrials) I++; - else { - if (X > One) { - if (N == 0) - printf("Accuracy seems adequate.\n"); - break; - } - else { - X = One + U2; - Y = U2 + U2; - Y += X; - I = 1; - } - } - } - } - /*=============================================*/ - Milestone = 150; - /*=============================================*/ - printf("Testing powers Z^Q at four nearly extreme values.\n"); - N = 0; - Z = A1; - Q = FLOOR(Half - LOG(C) / LOG(A1)); - Break = False; - do { - X = CInvrse; - Y = POW(Z, Q); - IsYeqX(); - Q = - Q; - X = C; - Y = POW(Z, Q); - IsYeqX(); - if (Z < One) Break = True; - else Z = AInvrse; - } while ( ! (Break)); - PrintIfNPositive(); - if (N == 0) printf(" ... no discrepancies found.\n"); - printf("\n"); - - /*=============================================*/ - Milestone = 160; - /*=============================================*/ - Pause(); - printf("Searching for Overflow threshold:\n"); - printf("This may generate an error.\n"); - Y = - CInvrse; - V9 = HInvrse * Y; - sigsave = sigfpe; - if (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; } - do { - V = Y; - Y = V9; - V9 = HInvrse * Y; - } while(V9 < Y); - I = 1; + Milestone = 130; + /*=============================================*/ + Y = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty; + Y2 = Y + Y; + printf("Since underflow occurs below the threshold\n"); + printf("UfThold = (%.17e) ^ (%.17e)\nonly underflow ", HInvrse, Y); + printf("should afflict the expression\n\t(%.17e) ^ (%.17e);\n", HInvrse, Y); + V9 = POW(HInvrse, Y2); + printf("actually calculating yields: %.17e .\n", V9); + if (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) { + BadCond(Serious, "this is not between 0 and underflow\n"); + printf(" threshold = %.17e .\n", UfThold); + } + else if (! (V9 > UfThold * (One + E9))) + printf("This computed value is O.K.\n"); + else { + BadCond(Defect, "this is not between 0 and underflow\n"); + printf(" threshold = %.17e .\n", UfThold); + } + /*=============================================*/ + Milestone = 140; + /*=============================================*/ + printf("\n"); + /* ...calculate Exp2 == exp(2) == 7.389056099... */ + X = Zero; + I = 2; + Y = Two * Three; + Q = Zero; + N = 0; + do { + Z = X; + I = I + 1; + Y = Y / (I + I); + R = Y + Q; + X = Z + R; + Q = (Z - X) + R; + } while(X > Z); + Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo); + X = Z * Z; + Exp2 = X * X; + X = F9; + Y = X - U1; + printf("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n", + Exp2); + for(I = 1;;) { + Z = X - BInvrse; + Z = (X + One) / (Z - (One - BInvrse)); + Q = POW(X, Z) - Exp2; + if (FABS(Q) > TwoForty * U2) { + N = 1; + V9 = (X - BInvrse) - (One - BInvrse); + BadCond(Defect, "Calculated"); + printf(" %.17e for\n", POW(X,Z)); + printf("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z); + printf("\tdiffers from correct value by %.17e .\n", Q); + printf("\tThis much error may spoil financial\n"); + printf("\tcalculations involving tiny interest rates.\n"); + break; + } + else { + Z = (Y - X) * Two + Y; + X = Y; + Y = Z; + Z = One + (X - F9)*(X - F9); + if (Z > One && I < NoTrials) I++; + else { + if (X > One) { + if (N == 0) + printf("Accuracy seems adequate.\n"); + break; + } + else { + X = One + U2; + Y = U2 + U2; + Y += X; + I = 1; + } + } + } + } + /*=============================================*/ + Milestone = 150; + /*=============================================*/ + printf("Testing powers Z^Q at four nearly extreme values.\n"); + N = 0; + Z = A1; + Q = FLOOR(Half - LOG(C) / LOG(A1)); + Break = False; + do { + X = CInvrse; + Y = POW(Z, Q); + IsYeqX(); + Q = - Q; + X = C; + Y = POW(Z, Q); + IsYeqX(); + if (Z < One) Break = True; + else Z = AInvrse; + } while ( ! (Break)); + PrintIfNPositive(); + if (N == 0) printf(" ... no discrepancies found.\n"); + printf("\n"); + + /*=============================================*/ + Milestone = 160; + /*=============================================*/ + Pause(); + printf("Searching for Overflow threshold:\n"); + printf("This may generate an error.\n"); + Y = - CInvrse; + V9 = HInvrse * Y; + sigsave = sigfpe; + if (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; } + do { + V = Y; + Y = V9; + V9 = HInvrse * Y; + } while(V9 < Y); + I = 1; overflow: - sigsave = 0; - Z = V9; - printf("Can 'Z = -Y' overflow?\n"); - printf("Trying it on Y = %.17e .\n", Y); - V9 = - Y; - V0 = V9; - if (V - Y == V + V0) printf("Seems O.K.\n"); - else { - printf("finds a "); - BadCond(Flaw, "-(-Y) differs from Y.\n"); - } - if (Z != Y) { - BadCond(Serious, ""); - printf("overflow past %.17e\n\tshrinks to %.17e .\n", Y, Z); - } - if (I) { - Y = V * (HInvrse * U2 - HInvrse); - Z = Y + ((One - HInvrse) * U2) * V; - if (Z < V0) Y = Z; - if (Y < V0) V = Y; - if (V0 - V < V0) V = V0; - } - else { - V = Y * (HInvrse * U2 - HInvrse); - V = V + ((One - HInvrse) * U2) * Y; - } - printf("Overflow threshold is V = %.17e .\n", V); - if (I) printf("Overflow saturates at V0 = %.17e .\n", V0); - else printf("There is no saturation value because the system traps on overflow.\n"); - V9 = V * One; - printf("No Overflow should be signaled for V * 1 = %.17e\n", V9); - V9 = V / One; - printf(" nor for V / 1 = %.17e .\n", V9); - printf("Any overflow signal separating this * from the one\n"); - printf("above is a DEFECT.\n"); - /*=============================================*/ - Milestone = 170; - /*=============================================*/ - if (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) { - BadCond(Failure, "Comparisons involving "); - printf("+-%g, +-%g\nand +-%g are confused by Overflow.", - V, V0, UfThold); - } - /*=============================================*/ - Milestone = 175; - /*=============================================*/ - printf("\n"); - for(Indx = 1; Indx <= 3; ++Indx) { - switch (Indx) { - case 1: Z = UfThold; break; - case 2: Z = E0; break; - case 3: Z = PseudoZero; break; - } - if (Z != Zero) { - V9 = SQRT(Z); - Y = V9 * V9; - if (Y / (One - Radix * E9) < Z - || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */ - if (V9 > U1) BadCond(Serious, ""); - else BadCond(Defect, ""); - printf("Comparison alleges that what prints as Z = %.17e\n", Z); - printf(" is too far from sqrt(Z) ^ 2 = %.17e .\n", Y); - } - } - } - /*=============================================*/ - Milestone = 180; - /*=============================================*/ - for(Indx = 1; Indx <= 2; ++Indx) { - if (Indx == 1) Z = V; - else Z = V0; - V9 = SQRT(Z); - X = (One - Radix * E9) * V9; - V9 = V9 * X; - if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { - Y = V9; - if (X < W) BadCond(Serious, ""); - else BadCond(Defect, ""); - printf("Comparison alleges that Z = %17e\n", Z); - printf(" is too far from sqrt(Z) ^ 2 (%.17e) .\n", Y); - } - } - /*=============================================*/ - /*SPLIT - } + sigsave = 0; + Z = V9; + printf("Can 'Z = -Y' overflow?\n"); + printf("Trying it on Y = %.17e .\n", Y); + V9 = - Y; + V0 = V9; + if (V - Y == V + V0) printf("Seems O.K.\n"); + else { + printf("finds a "); + BadCond(Flaw, "-(-Y) differs from Y.\n"); + } + if (Z != Y) { + BadCond(Serious, ""); + printf("overflow past %.17e\n\tshrinks to %.17e .\n", Y, Z); + } + if (I) { + Y = V * (HInvrse * U2 - HInvrse); + Z = Y + ((One - HInvrse) * U2) * V; + if (Z < V0) Y = Z; + if (Y < V0) V = Y; + if (V0 - V < V0) V = V0; + } + else { + V = Y * (HInvrse * U2 - HInvrse); + V = V + ((One - HInvrse) * U2) * Y; + } + printf("Overflow threshold is V = %.17e .\n", V); + if (I) printf("Overflow saturates at V0 = %.17e .\n", V0); + else printf("There is no saturation value because the system traps on overflow.\n"); + V9 = V * One; + printf("No Overflow should be signaled for V * 1 = %.17e\n", V9); + V9 = V / One; + printf(" nor for V / 1 = %.17e .\n", V9); + printf("Any overflow signal separating this * from the one\n"); + printf("above is a DEFECT.\n"); + /*=============================================*/ + Milestone = 170; + /*=============================================*/ + if (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) { + BadCond(Failure, "Comparisons involving "); + printf("+-%g, +-%g\nand +-%g are confused by Overflow.", + V, V0, UfThold); + } + /*=============================================*/ + Milestone = 175; + /*=============================================*/ + printf("\n"); + for(Indx = 1; Indx <= 3; ++Indx) { + switch (Indx) { + case 1: Z = UfThold; break; + case 2: Z = E0; break; + case 3: Z = PseudoZero; break; + } + if (Z != Zero) { + V9 = SQRT(Z); + Y = V9 * V9; + if (Y / (One - Radix * E9) < Z + || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */ + if (V9 > U1) BadCond(Serious, ""); + else BadCond(Defect, ""); + printf("Comparison alleges that what prints as Z = %.17e\n", Z); + printf(" is too far from sqrt(Z) ^ 2 = %.17e .\n", Y); + } + } + } + /*=============================================*/ + Milestone = 180; + /*=============================================*/ + for(Indx = 1; Indx <= 2; ++Indx) { + if (Indx == 1) Z = V; + else Z = V0; + V9 = SQRT(Z); + X = (One - Radix * E9) * V9; + V9 = V9 * X; + if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { + Y = V9; + if (X < W) BadCond(Serious, ""); + else BadCond(Defect, ""); + printf("Comparison alleges that Z = %17e\n", Z); + printf(" is too far from sqrt(Z) ^ 2 (%.17e) .\n", Y); + } + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part8(){ */ - Milestone = 190; - /*=============================================*/ - Pause(); - X = UfThold * V; - Y = Radix * Radix; - if (X*Y < One || X > Y) { - if (X * Y < U1 || X > Y/U1) BadCond(Defect, "Badly"); - else BadCond(Flaw, ""); - - printf(" unbalanced range; UfThold * V = %.17e\n\t%s\n", - X, "is too far from 1.\n"); - } - /*=============================================*/ - Milestone = 200; - /*=============================================*/ - for (Indx = 1; Indx <= 5; ++Indx) { - X = F9; - switch (Indx) { - case 2: X = One + U2; break; - case 3: X = V; break; - case 4: X = UfThold; break; - case 5: X = Radix; - } - Y = X; - sigsave = sigfpe; - if (setjmp(ovfl_buf)) - printf(" X / X traps when X = %g\n", X); - else { - V9 = (Y / X - Half) - Half; - if (V9 == Zero) continue; - if (V9 == - U1 && Indx < 5) BadCond(Flaw, ""); - else BadCond(Serious, ""); - printf(" X / X differs from 1 when X = %.17e\n", X); - printf(" instead, X / X - 1/2 - 1/2 = %.17e .\n", V9); - } - sigsave = 0; - } - /*=============================================*/ - Milestone = 210; - /*=============================================*/ - MyZero = Zero; - printf("\n"); - printf("What message and/or values does Division by Zero produce?\n") ; + Milestone = 190; + /*=============================================*/ + Pause(); + X = UfThold * V; + Y = Radix * Radix; + if (X*Y < One || X > Y) { + if (X * Y < U1 || X > Y/U1) BadCond(Defect, "Badly"); + else BadCond(Flaw, ""); + + printf(" unbalanced range; UfThold * V = %.17e\n\t%s\n", + X, "is too far from 1.\n"); + } + /*=============================================*/ + Milestone = 200; + /*=============================================*/ + for (Indx = 1; Indx <= 5; ++Indx) { + X = F9; + switch (Indx) { + case 2: X = One + U2; break; + case 3: X = V; break; + case 4: X = UfThold; break; + case 5: X = Radix; + } + Y = X; + sigsave = sigfpe; + if (setjmp(ovfl_buf)) + printf(" X / X traps when X = %g\n", X); + else { + V9 = (Y / X - Half) - Half; + if (V9 == Zero) continue; + if (V9 == - U1 && Indx < 5) BadCond(Flaw, ""); + else BadCond(Serious, ""); + printf(" X / X differs from 1 when X = %.17e\n", X); + printf(" instead, X / X - 1/2 - 1/2 = %.17e .\n", V9); + } + sigsave = 0; + } + /*=============================================*/ + Milestone = 210; + /*=============================================*/ + MyZero = Zero; + printf("\n"); + printf("What message and/or values does Division by Zero produce?\n") ; #ifndef NOPAUSE - printf("This can interupt your program. You can "); - printf("skip this part if you wish.\n"); - printf("Do you wish to compute 1 / 0? "); - fflush(stdout); - read (KEYBOARD, ch, 8); - if ((ch[0] == 'Y') || (ch[0] == 'y')) { + printf("This can interupt your program. You can "); + printf("skip this part if you wish.\n"); + printf("Do you wish to compute 1 / 0? "); + fflush(stdout); + read (KEYBOARD, ch, 8); + if ((ch[0] == 'Y') || (ch[0] == 'y')) { #endif - sigsave = sigfpe; - printf(" Trying to compute 1 / 0 produces ..."); - if (!setjmp(ovfl_buf)) printf(" %.7e .\n", One / MyZero); - sigsave = 0; + sigsave = sigfpe; + printf(" Trying to compute 1 / 0 produces ..."); + if (!setjmp(ovfl_buf)) printf(" %.7e .\n", One / MyZero); + sigsave = 0; #ifndef NOPAUSE - } - else printf("O.K.\n"); - printf("\nDo you wish to compute 0 / 0? "); - fflush(stdout); - read (KEYBOARD, ch, 80); - if ((ch[0] == 'Y') || (ch[0] == 'y')) { + } + else printf("O.K.\n"); + printf("\nDo you wish to compute 0 / 0? "); + fflush(stdout); + read (KEYBOARD, ch, 80); + if ((ch[0] == 'Y') || (ch[0] == 'y')) { #endif - sigsave = sigfpe; - printf("\n Trying to compute 0 / 0 produces ..."); - if (!setjmp(ovfl_buf)) printf(" %.7e .\n", Zero / MyZero); - sigsave = 0; + sigsave = sigfpe; + printf("\n Trying to compute 0 / 0 produces ..."); + if (!setjmp(ovfl_buf)) printf(" %.7e .\n", Zero / MyZero); + sigsave = 0; #ifndef NOPAUSE - } - else printf("O.K.\n"); + } + else printf("O.K.\n"); #endif - /*=============================================*/ - Milestone = 220; - /*=============================================*/ - Pause(); - printf("\n"); - { - static char *msg[] = { - "FAILUREs encountered =", - "SERIOUS DEFECTs discovered =", - "DEFECTs discovered =", - "FLAWs discovered =" }; - int i; - for(i = 0; i < 4; i++) if (ErrCnt[i]) - printf("The number of %-29s %d.\n", - msg[i], ErrCnt[i]); - } - printf("\n"); - if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect] - + ErrCnt[Flaw]) > 0) { - if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[ - Defect] == 0) && (ErrCnt[Flaw] > 0)) { - printf("The arithmetic diagnosed seems "); - printf("Satisfactory though flawed.\n"); - } - if ((ErrCnt[Failure] + ErrCnt[Serious] == 0) - && ( ErrCnt[Defect] > 0)) { - printf("The arithmetic diagnosed may be Acceptable\n"); - printf("despite inconvenient Defects.\n"); - } - if ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) { - printf("The arithmetic diagnosed has "); - printf("unacceptable Serious Defects.\n"); - } - if (ErrCnt[Failure] > 0) { - printf("Potentially fatal FAILURE may have spoiled this"); - printf(" program's subsequent diagnoses.\n"); - } - } - else { - printf("No failures, defects nor flaws have been discovered.\n"); - if (! ((RMult == Rounded) && (RDiv == Rounded) - && (RAddSub == Rounded) && (RSqrt == Rounded))) - printf("The arithmetic diagnosed seems Satisfactory.\n"); - else { - if (StickyBit >= One && - (Radix - Two) * (Radix - Nine - One) == Zero) { - printf("Rounding appears to conform to "); - printf("the proposed IEEE standard P"); - if ((Radix == Two) && - ((Precision - Four * Three * Two) * - ( Precision - TwentySeven - - TwentySeven + One) == Zero)) - printf("754"); - else printf("854"); - if (IEEE) printf(".\n"); - else { - printf(",\nexcept for possibly Double Rounding"); - printf(" during Gradual Underflow.\n"); - } - } - printf("The arithmetic diagnosed appears to be Excellent!\n"); - } - } - if (fpecount) - printf("\nA total of %d floating point exceptions were registered.\n", - fpecount); - printf("END OF TEST.\n"); - return 0; - } + /*=============================================*/ + Milestone = 220; + /*=============================================*/ + Pause(); + printf("\n"); + { + static char *msg[] = { + "FAILUREs encountered =", + "SERIOUS DEFECTs discovered =", + "DEFECTs discovered =", + "FLAWs discovered =" }; + int i; + for(i = 0; i < 4; i++) if (ErrCnt[i]) + printf("The number of %-29s %d.\n", + msg[i], ErrCnt[i]); + } + printf("\n"); + if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect] + + ErrCnt[Flaw]) > 0) { + if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[ + Defect] == 0) && (ErrCnt[Flaw] > 0)) { + printf("The arithmetic diagnosed seems "); + printf("Satisfactory though flawed.\n"); + } + if ((ErrCnt[Failure] + ErrCnt[Serious] == 0) + && ( ErrCnt[Defect] > 0)) { + printf("The arithmetic diagnosed may be Acceptable\n"); + printf("despite inconvenient Defects.\n"); + } + if ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) { + printf("The arithmetic diagnosed has "); + printf("unacceptable Serious Defects.\n"); + } + if (ErrCnt[Failure] > 0) { + printf("Potentially fatal FAILURE may have spoiled this"); + printf(" program's subsequent diagnoses.\n"); + } + } + else { + printf("No failures, defects nor flaws have been discovered.\n"); + if (! ((RMult == Rounded) && (RDiv == Rounded) + && (RAddSub == Rounded) && (RSqrt == Rounded))) + printf("The arithmetic diagnosed seems Satisfactory.\n"); + else { + if (StickyBit >= One && + (Radix - Two) * (Radix - Nine - One) == Zero) { + printf("Rounding appears to conform to "); + printf("the proposed IEEE standard P"); + if ((Radix == Two) && + ((Precision - Four * Three * Two) * + ( Precision - TwentySeven - + TwentySeven + One) == Zero)) + printf("754"); + else printf("854"); + if (IEEE) printf(".\n"); + else { + printf(",\nexcept for possibly Double Rounding"); + printf(" during Gradual Underflow.\n"); + } + } + printf("The arithmetic diagnosed appears to be Excellent!\n"); + } + } + if (fpecount) + printf("\nA total of %d floating point exceptions were registered.\n", + fpecount); + printf("END OF TEST.\n"); + return 0; + } /*SPLIT subs.c #include "paranoia.h" @@ -1868,17 +1868,17 @@ FLOAT X; Pause() { #ifndef NOPAUSE - char ch[8]; + char ch[8]; - printf("\nTo continue, press RETURN"); - fflush(stdout); - read(KEYBOARD, ch, 8); + printf("\nTo continue, press RETURN"); + fflush(stdout); + read(KEYBOARD, ch, 8); #endif - printf("\nDiagnosis resumes after milestone Number %d", Milestone); - printf(" Page: %d\n\n", PageNo); - ++Milestone; - ++PageNo; - } + printf("\nDiagnosis resumes after milestone Number %d", Milestone); + printf(" Page: %d\n\n", PageNo); + ++Milestone; + ++PageNo; + } /* TstCond */ @@ -1891,11 +1891,11 @@ BadCond(K, T) int K; char *T; { - static char *msg[] = { "FAILURE", "SERIOUS DEFECT", "DEFECT", "FLAW" }; + static char *msg[] = { "FAILURE", "SERIOUS DEFECT", "DEFECT", "FLAW" }; - ErrCnt [K] = ErrCnt [K] + 1; - printf("%s: %s", msg[K], T); - } + ErrCnt [K] = ErrCnt [K] + 1; + printf("%s: %s", msg[K], T); + } /* Random */ /* Random computes @@ -1906,174 +1906,174 @@ char *T; FLOAT Random() { - FLOAT X, Y; + FLOAT X, Y; - X = Random1 + Random9; - Y = X * X; - Y = Y * Y; - X = X * Y; - Y = X - FLOOR(X); - Random1 = Y + X * 0.000005; - return(Random1); - } + X = Random1 + Random9; + Y = X * X; + Y = Y * Y; + X = X * Y; + Y = X - FLOOR(X); + Random1 = Y + X * 0.000005; + return(Random1); + } /* SqXMinX */ SqXMinX (ErrKind) int ErrKind; { - FLOAT XA, XB; - - XB = X * BInvrse; - XA = X - XB; - SqEr = ((SQRT(X * X) - XB) - XA) / OneUlp; - if (SqEr != Zero) { - if (SqEr < MinSqEr) MinSqEr = SqEr; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - J = J + 1.0; - BadCond(ErrKind, "\n"); - printf("sqrt( %.17e) - %.17e = %.17e\n", X * X, X, OneUlp * SqEr); - printf("\tinstead of correct value 0 .\n"); - } - } + FLOAT XA, XB; + + XB = X * BInvrse; + XA = X - XB; + SqEr = ((SQRT(X * X) - XB) - XA) / OneUlp; + if (SqEr != Zero) { + if (SqEr < MinSqEr) MinSqEr = SqEr; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + J = J + 1.0; + BadCond(ErrKind, "\n"); + printf("sqrt( %.17e) - %.17e = %.17e\n", X * X, X, OneUlp * SqEr); + printf("\tinstead of correct value 0 .\n"); + } + } /* NewD */ NewD() { - X = Z1 * Q; - X = FLOOR(Half - X / Radix) * Radix + X; - Q = (Q - X * Z) / Radix + X * X * (D / Radix); - Z = Z - Two * X * D; - if (Z <= Zero) { - Z = - Z; - Z1 = - Z1; - } - D = Radix * D; - } + X = Z1 * Q; + X = FLOOR(Half - X / Radix) * Radix + X; + Q = (Q - X * Z) / Radix + X * X * (D / Radix); + Z = Z - Two * X * D; + if (Z <= Zero) { + Z = - Z; + Z1 = - Z1; + } + D = Radix * D; + } /* SR3750 */ SR3750() { - if (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) { - I = I + 1; - X2 = SQRT(X * D); - Y2 = (X2 - Z2) - (Y - Z2); - X2 = X8 / (Y - Half); - X2 = X2 - Half * X2 * X2; - SqEr = (Y2 + Half) + (Half - X2); - if (SqEr < MinSqEr) MinSqEr = SqEr; - SqEr = Y2 - X2; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - } - } + if (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) { + I = I + 1; + X2 = SQRT(X * D); + Y2 = (X2 - Z2) - (Y - Z2); + X2 = X8 / (Y - Half); + X2 = X2 - Half * X2 * X2; + SqEr = (Y2 + Half) + (Half - X2); + if (SqEr < MinSqEr) MinSqEr = SqEr; + SqEr = Y2 - X2; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + } + } /* IsYeqX */ IsYeqX() { - if (Y != X) { - if (N <= 0) { - if (Z == Zero && Q <= Zero) - printf("WARNING: computing\n"); - else BadCond(Defect, "computing\n"); - printf("\t(%.17e) ^ (%.17e)\n", Z, Q); - printf("\tyielded %.17e;\n", Y); - printf("\twhich compared unequal to correct %.17e ;\n", - X); - printf("\t\tthey differ by %.17e .\n", Y - X); - } - N = N + 1; /* ... count discrepancies. */ - } - } + if (Y != X) { + if (N <= 0) { + if (Z == Zero && Q <= Zero) + printf("WARNING: computing\n"); + else BadCond(Defect, "computing\n"); + printf("\t(%.17e) ^ (%.17e)\n", Z, Q); + printf("\tyielded %.17e;\n", Y); + printf("\twhich compared unequal to correct %.17e ;\n", + X); + printf("\t\tthey differ by %.17e .\n", Y - X); + } + N = N + 1; /* ... count discrepancies. */ + } + } /* SR3980 */ SR3980() { - do { - Q = (FLOAT) I; - Y = POW(Z, Q); - IsYeqX(); - if (++I > M) break; - X = Z * X; - } while ( X < W ); - } + do { + Q = (FLOAT) I; + Y = POW(Z, Q); + IsYeqX(); + if (++I > M) break; + X = Z * X; + } while ( X < W ); + } /* PrintIfNPositive */ PrintIfNPositive() { - if (N > 0) printf("Similar discrepancies have occurred %d times.\n", N); - } + if (N > 0) printf("Similar discrepancies have occurred %d times.\n", N); + } /* TstPtUf */ TstPtUf() { - N = 0; - if (Z != Zero) { - printf("Since comparison denies Z = 0, evaluating "); - printf("(Z + Z) / Z should be safe.\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) goto very_serious; - Q9 = (Z + Z) / Z; - printf("What the machine gets for (Z + Z) / Z is %.17e .\n", - Q9); - if (FABS(Q9 - Two) < Radix * U2) { - printf("This is O.K., provided Over/Underflow"); - printf(" has NOT just been signaled.\n"); - } - else { - if ((Q9 < One) || (Q9 > Two)) { + N = 0; + if (Z != Zero) { + printf("Since comparison denies Z = 0, evaluating "); + printf("(Z + Z) / Z should be safe.\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) goto very_serious; + Q9 = (Z + Z) / Z; + printf("What the machine gets for (Z + Z) / Z is %.17e .\n", + Q9); + if (FABS(Q9 - Two) < Radix * U2) { + printf("This is O.K., provided Over/Underflow"); + printf(" has NOT just been signaled.\n"); + } + else { + if ((Q9 < One) || (Q9 > Two)) { very_serious: - N = 1; - ErrCnt [Serious] = ErrCnt [Serious] + 1; - printf("This is a VERY SERIOUS DEFECT!\n"); - } - else { - N = 1; - ErrCnt [Defect] = ErrCnt [Defect] + 1; - printf("This is a DEFECT!\n"); - } - } - sigsave = 0; - V9 = Z * One; - Random1 = V9; - V9 = One * Z; - Random2 = V9; - V9 = Z / One; - if ((Z == Random1) && (Z == Random2) && (Z == V9)) { - if (N > 0) Pause(); - } - else { - N = 1; - BadCond(Defect, "What prints as Z = "); - printf("%.17e\n\tcompares different from ", Z); - if (Z != Random1) printf("Z * 1 = %.17e ", Random1); - if (! ((Z == Random2) - || (Random2 == Random1))) - printf("1 * Z == %g\n", Random2); - if (! (Z == V9)) printf("Z / 1 = %.17e\n", V9); - if (Random2 != Random1) { - ErrCnt [Defect] = ErrCnt [Defect] + 1; - BadCond(Defect, "Multiplication does not commute!\n"); - printf("\tComparison alleges that 1 * Z = %.17e\n", - Random2); - printf("\tdiffers from Z * 1 = %.17e\n", Random1); - } - Pause(); - } - } - } + N = 1; + ErrCnt [Serious] = ErrCnt [Serious] + 1; + printf("This is a VERY SERIOUS DEFECT!\n"); + } + else { + N = 1; + ErrCnt [Defect] = ErrCnt [Defect] + 1; + printf("This is a DEFECT!\n"); + } + } + sigsave = 0; + V9 = Z * One; + Random1 = V9; + V9 = One * Z; + Random2 = V9; + V9 = Z / One; + if ((Z == Random1) && (Z == Random2) && (Z == V9)) { + if (N > 0) Pause(); + } + else { + N = 1; + BadCond(Defect, "What prints as Z = "); + printf("%.17e\n\tcompares different from ", Z); + if (Z != Random1) printf("Z * 1 = %.17e ", Random1); + if (! ((Z == Random2) + || (Random2 == Random1))) + printf("1 * Z == %g\n", Random2); + if (! (Z == V9)) printf("Z / 1 = %.17e\n", V9); + if (Random2 != Random1) { + ErrCnt [Defect] = ErrCnt [Defect] + 1; + BadCond(Defect, "Multiplication does not commute!\n"); + printf("\tComparison alleges that 1 * Z = %.17e\n", + Random2); + printf("\tdiffers from Z * 1 = %.17e\n", Random1); + } + Pause(); + } + } + } notify(s) char *s; { - printf("%s test appears to be inconsistent...\n", s); - printf(" PLEASE NOTIFY KARPINKSI!\n"); - } + printf("%s test appears to be inconsistent...\n", s); + printf(" PLEASE NOTIFY KARPINKSI!\n"); + } /*SPLIT msgs.c */ @@ -2086,134 +2086,134 @@ char **s; Instructions() { static char *instr[] = { - "Lest this program stop prematurely, i.e. before displaying\n", - " 'END OF TEST',\n", - "try to persuade the computer NOT to terminate execution when an", - "error like Over/Underflow or Division by Zero occurs, but rather", - "to persevere with a surrogate value after, perhaps, displaying some", - "warning. If persuasion avails naught, don't despair but run this", - "program anyway to see how many milestones it passes, and then", - "amend it to make further progress.\n", - "Answer questions with Y, y, N or n (unless otherwise indicated).\n", - 0}; - - msglist(instr); - } + "Lest this program stop prematurely, i.e. before displaying\n", + " 'END OF TEST',\n", + "try to persuade the computer NOT to terminate execution when an", + "error like Over/Underflow or Division by Zero occurs, but rather", + "to persevere with a surrogate value after, perhaps, displaying some", + "warning. If persuasion avails naught, don't despair but run this", + "program anyway to see how many milestones it passes, and then", + "amend it to make further progress.\n", + "Answer questions with Y, y, N or n (unless otherwise indicated).\n", + 0}; + + msglist(instr); + } /* Heading */ Heading() { static char *head[] = { - "Users are invited to help debug and augment this program so it will", - "cope with unanticipated and newly uncovered arithmetic pathologies.\n", - "Please send suggestions and interesting results to", - "\tRichard Karpinski", - "\tComputer Center U-76", - "\tUniversity of California", - "\tSan Francisco, CA 94143-0704, USA\n", - "In doing so, please include the following information:", + "Users are invited to help debug and augment this program so it will", + "cope with unanticipated and newly uncovered arithmetic pathologies.\n", + "Please send suggestions and interesting results to", + "\tRichard Karpinski", + "\tComputer Center U-76", + "\tUniversity of California", + "\tSan Francisco, CA 94143-0704, USA\n", + "In doing so, please include the following information:", #ifdef Single - "\tPrecision:\tsingle;", + "\tPrecision:\tsingle;", #else - "\tPrecision:\tdouble;", + "\tPrecision:\tdouble;", #endif - "\tVersion:\t10 February 1989;", - "\tComputer:\n", - "\tCompiler:\n", - "\tOptimization level:\n", - "\tOther relevant compiler options:", - 0}; + "\tVersion:\t10 February 1989;", + "\tComputer:\n", + "\tCompiler:\n", + "\tOptimization level:\n", + "\tOther relevant compiler options:", + 0}; - msglist(head); - } + msglist(head); + } /* Characteristics */ Characteristics() { - static char *chars[] = { - "Running this program should reveal these characteristics:", - " Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...", - " Precision = number of significant digits carried.", - " U2 = Radix/Radix^Precision = One Ulp", - "\t(OneUlpnit in the Last Place) of 1.000xxx .", - " U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .", - " Adequacy of guard digits for Mult., Div. and Subt.", - " Whether arithmetic is chopped, correctly rounded, or something else", - "\tfor Mult., Div., Add/Subt. and Sqrt.", - " Whether a Sticky Bit used correctly for rounding.", - " UnderflowThreshold = an underflow threshold.", - " E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.", - " V = an overflow threshold, roughly.", - " V0 tells, roughly, whether Infinity is represented.", - " Comparisions are checked for consistency with subtraction", - "\tand for contamination with pseudo-zeros.", - " Sqrt is tested. Y^X is not tested.", - " Extra-precise subexpressions are revealed but NOT YET tested.", - " Decimal-Binary conversion is NOT YET tested for accuracy.", - 0}; - - msglist(chars); - } + static char *chars[] = { + "Running this program should reveal these characteristics:", + " Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...", + " Precision = number of significant digits carried.", + " U2 = Radix/Radix^Precision = One Ulp", + "\t(OneUlpnit in the Last Place) of 1.000xxx .", + " U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .", + " Adequacy of guard digits for Mult., Div. and Subt.", + " Whether arithmetic is chopped, correctly rounded, or something else", + "\tfor Mult., Div., Add/Subt. and Sqrt.", + " Whether a Sticky Bit used correctly for rounding.", + " UnderflowThreshold = an underflow threshold.", + " E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.", + " V = an overflow threshold, roughly.", + " V0 tells, roughly, whether Infinity is represented.", + " Comparisions are checked for consistency with subtraction", + "\tand for contamination with pseudo-zeros.", + " Sqrt is tested. Y^X is not tested.", + " Extra-precise subexpressions are revealed but NOT YET tested.", + " Decimal-Binary conversion is NOT YET tested for accuracy.", + 0}; + + msglist(chars); + } History() { /* History */ /* Converted from Brian Wichmann's Pascal version to C by Thos Sumner, - with further massaging by David M. Gay. */ + with further massaging by David M. Gay. */ static char *hist[] = { - "The program attempts to discriminate among", - " FLAWs, like lack of a sticky bit,", - " Serious DEFECTs, like lack of a guard digit, and", - " FAILUREs, like 2+2 == 5 .", - "Failures may confound subsequent diagnoses.\n", - "The diagnostic capabilities of this program go beyond an earlier", - "program called 'MACHAR', which can be found at the end of the", - "book 'Software Manual for the Elementary Functions' (1980) by", - "W. J. Cody and W. Waite. Although both programs try to discover", - "the Radix, Precision and range (over/underflow thresholds)", - "of the arithmetic, this program tries to cope with a wider variety", - "of pathologies, and to say how well the arithmetic is implemented.", - "\nThe program is based upon a conventional radix representation for", - "floating-point numbers, but also allows logarithmic encoding", - "as used by certain early WANG machines.\n", - "BASIC version of this program (C) 1983 by Prof. W. M. Kahan;", - "see source comments for more history.", - 0}; - - msglist(hist); - } + "The program attempts to discriminate among", + " FLAWs, like lack of a sticky bit,", + " Serious DEFECTs, like lack of a guard digit, and", + " FAILUREs, like 2+2 == 5 .", + "Failures may confound subsequent diagnoses.\n", + "The diagnostic capabilities of this program go beyond an earlier", + "program called 'MACHAR', which can be found at the end of the", + "book 'Software Manual for the Elementary Functions' (1980) by", + "W. J. Cody and W. Waite. Although both programs try to discover", + "the Radix, Precision and range (over/underflow thresholds)", + "of the arithmetic, this program tries to cope with a wider variety", + "of pathologies, and to say how well the arithmetic is implemented.", + "\nThe program is based upon a conventional radix representation for", + "floating-point numbers, but also allows logarithmic encoding", + "as used by certain early WANG machines.\n", + "BASIC version of this program (C) 1983 by Prof. W. M. Kahan;", + "see source comments for more history.", + 0}; + + msglist(hist); + } double pow(x, y) /* return x ^ y (exponentiation) */ double x, y; { - extern double exp(), frexp(), ldexp(), log(), modf(); - double xy, ye; - long i; - int ex, ey = 0, flip = 0; - - if (!y) return 1.0; - - if ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x)); - - if (y < 0.) { y = -y; flip = 1; } - y = modf(y, &ye); - if (y) xy = exp(y * log(x)); - else xy = 1.0; - /* next several lines assume >= 32 bit integers */ - x = frexp(x, &ex); - if (i = ye) for(;;) { - if (i & 1) { xy *= x; ey += ex; } - if (!(i >>= 1)) break; - x *= x; - ex *= 2; - if (x < .5) { x *= 2.; ex -= 1; } - } - if (flip) { xy = 1. / xy; ey = -ey; } - return ldexp(xy, ey); + extern double exp(), frexp(), ldexp(), log(), modf(); + double xy, ye; + long i; + int ex, ey = 0, flip = 0; + + if (!y) return 1.0; + + if ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x)); + + if (y < 0.) { y = -y; flip = 1; } + y = modf(y, &ye); + if (y) xy = exp(y * log(x)); + else xy = 1.0; + /* next several lines assume >= 32 bit integers */ + x = frexp(x, &ex); + if (i = ye) for(;;) { + if (i & 1) { xy *= x; ey += ex; } + if (!(i >>= 1)) break; + x *= x; + ex *= 2; + if (x < .5) { x *= 2.; ex -= 1; } + } + if (flip) { xy = 1. / xy; ey = -ey; } + return ldexp(xy, ey); } #endif /* NO_FLOATS */ diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c index 29f9e3de4..cfa384268 100644 --- a/test/ref/pointer2.c +++ b/test/ref/pointer2.c @@ -16,15 +16,15 @@ char i1[]; void test1(void) { int a; - a=sizeof(i1[0]); - printf("%04x - ",a); - if(sizeof(i1[0])==sizeof(char)) { - /* gcc gives size of element */ - printf("sizeof(i1[0]) gives size of element\n"); - } - if(sizeof(i1[0])==sizeof(char*)) { - printf("sizeof(i1[0]) gives size of pointer to element\n"); - } + a=sizeof(i1[0]); + printf("%04x - ",a); + if(sizeof(i1[0])==sizeof(char)) { + /* gcc gives size of element */ + printf("sizeof(i1[0]) gives size of element\n"); + } + if(sizeof(i1[0])==sizeof(char*)) { + printf("sizeof(i1[0]) gives size of pointer to element\n"); + } } /* @@ -40,14 +40,14 @@ char *t4={"abcde"}; void test2(void) { char c1,c2,c3,c4; int i,e=0; - for(i=0;i<5;i++){ - c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; -/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ - printf("%c %c %c %c\n",c1,c2,c3,c4); - if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; - } - if(e) printf("test2 failed.\n"); - else printf("test2 ok.\n"); + for(i=0;i<5;i++){ + c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; +/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ + printf("%c %c %c %c\n",c1,c2,c3,c4); + if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; + } + if(e) printf("test2 failed.\n"); + else printf("test2 ok.\n"); } /* @@ -74,7 +74,7 @@ A3 a3[] = { #endif void test3a(A3 *list, int number){ - printf("%s %d\n",list->name,number); + printf("%s %d\n",list->name,number); } static void test31(void) @@ -103,10 +103,10 @@ static void test30(void) */ int main(void) { - test1(); - test2(); - test30(); - test31(); -/* test32(); */ - return 0; + test1(); + test2(); + test30(); + test31(); +/* test32(); */ + return 0; } diff --git a/test/ref/sort.c b/test/ref/sort.c index 5db5cf01b..b4dee8734 100644 --- a/test/ref/sort.c +++ b/test/ref/sort.c @@ -14,62 +14,62 @@ int *xx; exchange(int *x,int *y) { int t; - printf("exchange(%d,%d)\n", x - xx, y - xx); - t = *x; *x = *y; *y = t; + printf("exchange(%d,%d)\n", x - xx, y - xx); + t = *x; *x = *y; *y = t; } /* partition - partition a[i..j] */ int partition(int a[], int i, int j) { int v, k; - j++; - k = i; - v = a[k]; - while (i < j) { - i++; while (a[i] < v) i++; - j--; while (a[j] > v) j--; - if (i < j) exchange(&a[i], &a[j]); - } - exchange(&a[k], &a[j]); - return j; + j++; + k = i; + v = a[k]; + while (i < j) { + i++; while (a[i] < v) i++; + j--; while (a[j] > v) j--; + if (i < j) exchange(&a[i], &a[j]); + } + exchange(&a[k], &a[j]); + return j; } /* quick - quicksort a[lb..ub] */ void quick(int a[], int lb, int ub) { int k; - if (lb >= ub) - return; - k = partition(a, lb, ub); - quick(a, lb, k - 1); - quick(a, k + 1, ub); + if (lb >= ub) + return; + k = partition(a, lb, ub); + quick(a, lb, k - 1); + quick(a, k + 1, ub); } /* sort - sort a[0..n-1] into increasing order */ sort(int a[], int n) { - quick(xx = a, 0, --n); + quick(xx = a, 0, --n); } /* putd - output decimal number */ void putd(int n) { - if (n < 0) { - putchar('-'); - n = -n; - } - if (n/10) - putd(n/10); - putchar(n%10 + '0'); + if (n < 0) { + putchar('-'); + n = -n; + } + if (n/10) + putd(n/10); + putchar(n%10 + '0'); } int main(void) { - int i; + int i; - sort(in, (sizeof in)/(sizeof in[0])); - for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) { - putd(in[i]); - putchar('\n'); - } + sort(in, (sizeof in)/(sizeof in[0])); + for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) { + putd(in[i]); + putchar('\n'); + } - return 0; + return 0; } diff --git a/test/ref/spill.c b/test/ref/spill.c index 56b03d6a7..316928ab3 100644 --- a/test/ref/spill.c +++ b/test/ref/spill.c @@ -51,6 +51,6 @@ int j, k, m, n; #endif f5(){ - x=A[k*m]*A[j*m]+B[k*n]*B[j*n]; - x=A[k*m]*B[j*n]-B[k*n]*A[j*m]; + x=A[k*m]*A[j*m]+B[k*n]*B[j*n]; + x=A[k*m]*B[j*n]-B[k*n]*A[j*m]; } diff --git a/test/ref/stdarg.c b/test/ref/stdarg.c index 295a2ccad..b88fcaafe 100644 --- a/test/ref/stdarg.c +++ b/test/ref/stdarg.c @@ -10,15 +10,15 @@ #ifndef NO_FUNCS_TAKE_STRUCTS struct node { - int a[4]; + int a[4]; } x = { #ifdef NO_SLOPPY_STRUCT_INIT - { + { #endif - 1,2,3,4 + 1,2,3,4 #ifdef NO_SLOPPY_STRUCT_INIT - } + } #endif }; #endif @@ -27,68 +27,68 @@ print(char *fmt, ...); main() { - print("test 1\n"); - print("test %s\n", "2"); - print("test %d%c", 3, '\n'); - print("%s%s %w%c", "te", "st", 4, '\n'); + print("test 1\n"); + print("test %s\n", "2"); + print("test %d%c", 3, '\n'); + print("%s%s %w%c", "te", "st", 4, '\n'); #ifdef NO_FLOATS - print("%s%s %f%c", "te", "st", (signed long) 5, '\n'); - #else - print("%s%s %f%c", "te", "st", 5.0, '\n'); + print("%s%s %f%c", "te", "st", (signed long) 5, '\n'); + #else + print("%s%s %f%c", "te", "st", 5.0, '\n'); #endif - #ifndef NO_FUNCS_TAKE_STRUCTS + #ifndef NO_FUNCS_TAKE_STRUCTS print("%b %b %b %b %b %b\n", x, x, x, x, x, x); - #endif - return 0; + #endif + return 0; } print(char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - for (; *fmt; fmt++) - { - if (*fmt == '%') - switch (*++fmt) { + va_list ap; + va_start(ap, fmt); + for (; *fmt; fmt++) + { + if (*fmt == '%') + switch (*++fmt) { case 'b': { - #ifdef NO_FUNCS_TAKE_STRUCTS - printf("(1 2 3 4)"); - #else - struct node x = - va_arg( - ap, - struct node - ); - printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]); - #endif + #ifdef NO_FUNCS_TAKE_STRUCTS + printf("(1 2 3 4)"); + #else + struct node x = + va_arg( + ap, + struct node + ); + printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]); + #endif break; } - case 'c': - /* printf("%c", va_arg(ap, char)); */ - printf("%c", va_arg(ap, int)); - break; - case 'd': - printf("%d", va_arg(ap, int)); - break; - case 'w': - /* printf("%x", va_arg(ap, short)); */ - printf("%x", va_arg(ap, int)); - break; - case 's': - printf("%s", va_arg(ap, char *)); - break; - case 'f': - #ifdef NO_FLOATS - printf("%ld.000000", va_arg(ap, signed long)); - #else - printf("%f", va_arg(ap, double)); - #endif - break; - default: - printf("%c", *fmt); - break; - } - else - printf("%c", *fmt); - } - va_end(ap); + case 'c': + /* printf("%c", va_arg(ap, char)); */ + printf("%c", va_arg(ap, int)); + break; + case 'd': + printf("%d", va_arg(ap, int)); + break; + case 'w': + /* printf("%x", va_arg(ap, short)); */ + printf("%x", va_arg(ap, int)); + break; + case 's': + printf("%s", va_arg(ap, char *)); + break; + case 'f': + #ifdef NO_FLOATS + printf("%ld.000000", va_arg(ap, signed long)); + #else + printf("%f", va_arg(ap, double)); + #endif + break; + default: + printf("%c", *fmt); + break; + } + else + printf("%c", *fmt); + } + va_end(ap); } diff --git a/test/ref/strptr.c b/test/ref/strptr.c index 8bfa983a8..152c1bb48 100644 --- a/test/ref/strptr.c +++ b/test/ref/strptr.c @@ -24,7 +24,7 @@ FILE *outfile=NULL; #else #endif - + #include #include #include @@ -34,18 +34,18 @@ FILE *outfile=NULL; struct Xdirent { - char d_name[XNAME_MAX+1]; - unsigned short d_off; - unsigned short d_reclen; - unsigned char d_type; - unsigned char d_namlen; + char d_name[XNAME_MAX+1]; + unsigned short d_off; + unsigned short d_reclen; + unsigned char d_type; + unsigned char d_namlen; }; typedef struct { - unsigned char fd; - unsigned short off; - char name[XNAME_MAX+1]; + unsigned char fd; + unsigned short off; + char name[XNAME_MAX+1]; } XDIR; unsigned char b1[4]; @@ -61,51 +61,51 @@ static struct Xdirent entry; unsigned char fd; static unsigned char ch; - entry.d_off=dir->off; - - /* basic line-link / file-length */ - memcpy(buffer,b1,4); - - dir->off=dir->off+4; - entry.d_reclen=254*(buffer[2]+(buffer[3]<<8)); - - /* read file entry */ - memcpy(buffer,b2,0x10); - - dir->off=dir->off+i; - - printf("Xreaddir: '%s'\n",buffer); - - /* skip until either quote (file) or b (blocks free => end) */ - i=0;ii=0; - while(i==0){ - temp=buffer[ii];ii++; - if(ii>16){ - /* something went wrong...this shouldnt happen! */ - return(NULL); - } - else if(temp=='\"') i++; - else if(temp=='b') { - /* "blocks free" */ - return(NULL); - } - } - printf("Xreaddir: '%s'\n",buffer); - - /* process file entry */ - - i=0; temp=buffer[ii];ii++; - while(temp!='\"'){ - entry.d_name[i]=temp; - i++; - temp=buffer[ii];ii++; - } - entry.d_name[i]=0; - entry.d_namlen=i; - - /* set type flag */ - - return(&entry); + entry.d_off=dir->off; + + /* basic line-link / file-length */ + memcpy(buffer,b1,4); + + dir->off=dir->off+4; + entry.d_reclen=254*(buffer[2]+(buffer[3]<<8)); + + /* read file entry */ + memcpy(buffer,b2,0x10); + + dir->off=dir->off+i; + + printf("Xreaddir: '%s'\n",buffer); + + /* skip until either quote (file) or b (blocks free => end) */ + i=0;ii=0; + while(i==0){ + temp=buffer[ii];ii++; + if(ii>16){ + /* something went wrong...this shouldnt happen! */ + return(NULL); + } + else if(temp=='\"') i++; + else if(temp=='b') { + /* "blocks free" */ + return(NULL); + } + } + printf("Xreaddir: '%s'\n",buffer); + + /* process file entry */ + + i=0; temp=buffer[ii];ii++; + while(temp!='\"'){ + entry.d_name[i]=temp; + i++; + temp=buffer[ii];ii++; + } + entry.d_name[i]=0; + entry.d_namlen=i; + + /* set type flag */ + + return(&entry); } int main(void) @@ -113,16 +113,16 @@ int main(void) char mydirname[XNAME_MAX+1]="."; XDIR mydir; struct Xdirent *mydirent; - + printf("start\n"); if((mydirent=Xreaddir(&mydir))==NULL) { - printf("NULL\n"); + printf("NULL\n"); } else { - printf("=%s\n",mydirent->d_name); + printf("=%s\n",mydirent->d_name); } printf("done\n"); diff --git a/test/ref/struct.c b/test/ref/struct.c index a0f181e96..15fae62fc 100644 --- a/test/ref/struct.c +++ b/test/ref/struct.c @@ -74,8 +74,8 @@ void makepoint(point *p,int x, int y) { /* make a rectangle from two points */ void makerect(rect *d,point p1, point p2) { rect r; - r.pt1 = p1; - r.pt2 = p2; + r.pt1 = p1; + r.pt2 = p2; canonrect(d,r); } @@ -97,53 +97,53 @@ odd(struct odd y) { /* add two points */ point addpoint(point p1, point p2) { - p1.x += p2.x; - p1.y += p2.y; - return p1; + p1.x += p2.x; + p1.y += p2.y; + return p1; } /* canonicalize rectangle coordinates */ rect canonrect(rect r) { - rect temp; + rect temp; - temp.pt1.x = min(r.pt1.x, r.pt2.x); - temp.pt1.y = min(r.pt1.y, r.pt2.y); - temp.pt2.x = max(r.pt1.x, r.pt2.x); - temp.pt2.y = max(r.pt1.y, r.pt2.y); - return temp; + temp.pt1.x = min(r.pt1.x, r.pt2.x); + temp.pt1.y = min(r.pt1.y, r.pt2.y); + temp.pt2.x = max(r.pt1.x, r.pt2.x); + temp.pt2.y = max(r.pt1.y, r.pt2.y); + return temp; } /* make a point from x and y components */ point makepoint(int x, int y) { - point p; + point p; - p.x = x; - p.y = y; - return p; + p.x = x; + p.y = y; + return p; } /* make a rectangle from two points */ rect makerect(point p1, point p2) { - rect r; + rect r; - r.pt1 = p1; - r.pt2 = p2; - return canonrect(r); + r.pt1 = p1; + r.pt2 = p2; + return canonrect(r); } struct odd {char a[3]; } y = { #ifdef NO_SLOPPY_STRUCT_INIT - { + { #endif - 'a', 'b', 0 + 'a', 'b', 0 #ifdef NO_SLOPPY_STRUCT_INIT - } + } #endif }; odd(struct odd y) { - struct odd x - = y; + struct odd x + = y; printf("%s\n\r", x.a); } @@ -157,8 +157,8 @@ int ptinrect(point *p, rect *r) { } #else int ptinrect(point p, rect r) { - return p.x >= r.pt1.x && p.x < r.pt2.x - && p.y >= r.pt1.y && p.y < r.pt2.y; + return p.x >= r.pt1.x && p.x < r.pt2.x + && p.y >= r.pt1.y && p.y < r.pt2.y; } #endif @@ -212,9 +212,9 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 }; #else if (ptinrect(x, screen) == 0) #endif - { + { printf("not "); - } + } printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y, screen.pt2.x, screen.pt2.y); } @@ -240,24 +240,24 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 }; #endif rect screen = - makerect( - addpoint(maxpt, makepoint(-10, -10)), - addpoint(origin, makepoint(10, 10)) - ); - - test1(); - - for (i = 0; i < sizeof pts/sizeof pts[0]; i++) { - printf("(%d,%d) is ", pts[i].x, - (x = makepoint(pts[i].x, pts[i].y)).y); - if (ptinrect(x, screen) == 0) - printf("not "); + makerect( + addpoint(maxpt, makepoint(-10, -10)), + addpoint(origin, makepoint(10, 10)) + ); + + test1(); + + for (i = 0; i < sizeof pts/sizeof pts[0]; i++) { + printf("(%d,%d) is ", pts[i].x, + (x = makepoint(pts[i].x, pts[i].y)).y); + if (ptinrect(x, screen) == 0) + printf("not "); printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y, - screen.pt2.x, screen.pt2.y); - } - odd(y); + screen.pt2.x, screen.pt2.y); + } + odd(y); - return 0; + return 0; } #endif /* FUNCS_RETURN_STRUCTS */ diff --git a/test/ref/switch.c b/test/ref/switch.c index 0821d29ee..dc7fdc8ce 100644 --- a/test/ref/switch.c +++ b/test/ref/switch.c @@ -18,9 +18,9 @@ limit(); big( # ifdef ASSUME_32BIT_UNSIGNED - unsigned + unsigned # else - unsigned long + unsigned long # endif x); @@ -28,28 +28,28 @@ x); main() { - testbackslash(); - f(); - g(); - h(); - testbig(); /* ! broken long int compare (?) */ - limit(); /* ! broken long int compare (?) */ - - return 0; + testbackslash(); + f(); + g(); + h(); + testbig(); /* ! broken long int compare (?) */ + limit(); /* ! broken long int compare (?) */ + + return 0; } testbig() { - #ifdef ASSUME_32BIT_INT - int i; - #else - signed long i; - #endif - /* 2341234 2341234 2341234 */ - for (i = 0x1000000; i&0x7000000; i += 0x1000000) { -/* printf("i = 0x%lx\n", i); */ - big(i); - } + #ifdef ASSUME_32BIT_INT + int i; + #else + signed long i; + #endif + /* 2341234 2341234 2341234 */ + for (i = 0x1000000; i&0x7000000; i += 0x1000000) { +/* printf("i = 0x%lx\n", i); */ + big(i); + } } #ifdef NO_LOCAL_STRING_INIT @@ -69,93 +69,93 @@ testbackslash() #else for (s = "bfnrtvx"; *s; s++) { #endif - printf("%c = %c\n", *s, backslash(*s)); + printf("%c = %c\n", *s, backslash(*s)); } } backslash(c) { - switch (c) + switch (c) { - case 'b': - return 'b'; - case 'f': - return 'f'; - case 'n': - return 'n'; - case 'r': - return 'r'; - case 't': - return 't'; - case 'v': + case 'b': + return 'b'; + case 'f': + return 'f'; + case 'n': + return 'n'; + case 'r': + return 'r'; + case 't': + return 't'; + case 'v': return 'v'; - } + } - return 'x'; + return 'x'; } f() { - int i, x = 0, y; - - printf("f:\n"); - for (i = 0; i <= 20; i++) { - y = i; - switch (i) { - case 1: x = i; break; - case 2: x = i; break; - case 7: x = i; break; - case 8: x = i; break; - case 9: x = i; break; - case 16: x = i; break; - case 17: x = i; break; - case 18: x = i; break; - case 19: x = i; break; - case 20: x = i; break; - } - printf("x = %d\n", x); - } + int i, x = 0, y; + + printf("f:\n"); + for (i = 0; i <= 20; i++) { + y = i; + switch (i) { + case 1: x = i; break; + case 2: x = i; break; + case 7: x = i; break; + case 8: x = i; break; + case 9: x = i; break; + case 16: x = i; break; + case 17: x = i; break; + case 18: x = i; break; + case 19: x = i; break; + case 20: x = i; break; + } + printf("x = %d\n", x); + } } g() { - int i; - - printf("g:\n"); - for (i = 1; i <= 10; i++) - switch (i) { - case 1: case 2: printf("1 %d\n", i); break; - case 3: case 4: case 5: printf("2 %d\n", i); break; - case 6: case 7: case 8: printf("3 %d\n", i); - default: - printf("d %d\n", i); break; - case 1001: case 1002: case 1003: case 1004: - printf("5 %d\n", i); break; - case 3001: case 3002: case 3003: case 3004: - printf("6 %d\n", i); break; - } + int i; + + printf("g:\n"); + for (i = 1; i <= 10; i++) + switch (i) { + case 1: case 2: printf("1 %d\n", i); break; + case 3: case 4: case 5: printf("2 %d\n", i); break; + case 6: case 7: case 8: printf("3 %d\n", i); + default: + printf("d %d\n", i); break; + case 1001: case 1002: case 1003: case 1004: + printf("5 %d\n", i); break; + case 3001: case 3002: case 3003: case 3004: + printf("6 %d\n", i); break; + } } h() { - int i, n=0; - - printf("h:\n"); - for (i = 1; i <= 500; i++) - switch (i) { - default: n++; continue; - case 128: printf("i = %d\n", i); break; - case 16: printf("i = %d\n", i); break; - case 8: printf("i = %d\n", i); break; - case 120: printf("i = %d\n", i); break; - case 280: printf("i = %d\n", i); break; - case 264: printf("i = %d\n", i); break; - case 248: printf("i = %d\n", i); break; - case 272: printf("i = %d\n", i); break; - case 304: printf("i = %d\n", i); break; - case 296: printf("i = %d\n", i); break; - case 288: printf("i = %d\n", i); break; - case 312: printf("i = %d\n", i); break; - } - printf("%d defaults\n", n); + int i, n=0; + + printf("h:\n"); + for (i = 1; i <= 500; i++) + switch (i) { + default: n++; continue; + case 128: printf("i = %d\n", i); break; + case 16: printf("i = %d\n", i); break; + case 8: printf("i = %d\n", i); break; + case 120: printf("i = %d\n", i); break; + case 280: printf("i = %d\n", i); break; + case 264: printf("i = %d\n", i); break; + case 248: printf("i = %d\n", i); break; + case 272: printf("i = %d\n", i); break; + case 304: printf("i = %d\n", i); break; + case 296: printf("i = %d\n", i); break; + case 288: printf("i = %d\n", i); break; + case 312: printf("i = %d\n", i); break; + } + printf("%d defaults\n", n); } #ifdef NO_OLD_FUNC_DECL @@ -165,9 +165,9 @@ h() #endif # ifdef ASSUME_32BIT_UNSIGNED - unsigned + unsigned # else - unsigned long + unsigned long # endif #ifdef NO_OLD_FUNC_DECL @@ -176,42 +176,42 @@ h() x; { #endif -/* printf("x = 0x%x\n", x); */ - - switch(x&0x6000000){ - case -1: - case -2: - case 0x0000000: - printf("x = 0x%lx\n", x); break; - case 0x2000000: - printf("x = 0x%lx\n", x); break; - case 0x4000000: - printf("x = 0x%lx\n", x); break; - default: - printf("x = 0x%lx (default)\n", x); break; - } +/* printf("x = 0x%x\n", x); */ + + switch(x&0x6000000){ + case -1: + case -2: + case 0x0000000: + printf("x = 0x%lx\n", x); break; + case 0x2000000: + printf("x = 0x%lx\n", x); break; + case 0x4000000: + printf("x = 0x%lx\n", x); break; + default: + printf("x = 0x%lx (default)\n", x); break; + } } limit() { - int i; - - for (i = INT_MIN; i <= INT_MIN+5; i++) -/* for (i = INT_MIN; i < INT_MIN+6; i++) */ - switch (i) { - case INT_MIN: printf("0\n"); break; - case INT_MIN+1: printf("1\n"); break; - case INT_MIN+2: printf("2\n"); break; - case INT_MIN+3: printf("3\n"); break; - case INT_MIN+4: printf("4\n"); break; - default: printf("5\n"); break; - } - for (i = INT_MAX; i >= INT_MAX-5; i--) - switch (i) { - case INT_MAX: printf("0\n"); break; - case INT_MAX-1: printf("1\n"); break; - case INT_MAX-2: printf("2\n"); break; - case INT_MAX-3: printf("3\n"); break; - case INT_MAX-4: printf("4\n"); break; - default: printf("5\n"); break; - } + int i; + + for (i = INT_MIN; i <= INT_MIN+5; i++) +/* for (i = INT_MIN; i < INT_MIN+6; i++) */ + switch (i) { + case INT_MIN: printf("0\n"); break; + case INT_MIN+1: printf("1\n"); break; + case INT_MIN+2: printf("2\n"); break; + case INT_MIN+3: printf("3\n"); break; + case INT_MIN+4: printf("4\n"); break; + default: printf("5\n"); break; + } + for (i = INT_MAX; i >= INT_MAX-5; i--) + switch (i) { + case INT_MAX: printf("0\n"); break; + case INT_MAX-1: printf("1\n"); break; + case INT_MAX-2: printf("2\n"); break; + case INT_MAX-3: printf("3\n"); break; + case INT_MAX-4: printf("4\n"); break; + default: printf("5\n"); break; + } } diff --git a/test/ref/switch2.c b/test/ref/switch2.c index 7a9bcecd7..7884f3722 100644 --- a/test/ref/switch2.c +++ b/test/ref/switch2.c @@ -9,31 +9,31 @@ #include void testlimits(int i) { - printf("%d:",i); + printf("%d:",i); - switch(i) { - case -1: /* works */ - /* case 0xffff: */ /* 'range error' (-1) */ + switch(i) { + case -1: /* works */ + /* case 0xffff: */ /* 'range error' (-1) */ - printf("-1\n"); - break; - /* max int */ + printf("-1\n"); + break; + /* max int */ -/* case 0x7fff: */ /* works */ - case 32767: /* works */ - /* case 32768: */ /* 'range error' (correct for that one!) */ +/* case 0x7fff: */ /* works */ + case 32767: /* works */ + /* case 32768: */ /* 'range error' (correct for that one!) */ - printf("max\n"); - break; - /* min int */ + printf("max\n"); + break; + /* min int */ - case -32768: /* 'warning. constant is long' */ - /* case 0x8000: */ /* 'range error' */ - /* case -32769: */ /* 'range error' (correct for that one!) */ - printf("min\n"); - break; - } - printf("\n"); + case -32768: /* 'warning. constant is long' */ + /* case 0x8000: */ /* 'range error' */ + /* case -32769: */ /* 'range error' (correct for that one!) */ + printf("min\n"); + break; + } + printf("\n"); } void testdefault1(unsigned char i) { @@ -45,9 +45,9 @@ signed char k; #else char k; #endif - + #else - + #ifdef UNSIGNED_CHARS signed char k; #else @@ -56,89 +56,89 @@ char k; #endif - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - /* gcc warning: case label value exceeds maximum value for type */ - /* cc65 error: range error */ + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + /* gcc warning: case label value exceeds maximum value for type */ + /* cc65 error: range error */ - /* - case 170: - break; - */ - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + /* + case 170: + break; + */ + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } void testdefault2(unsigned char i) { @@ -150,9 +150,9 @@ char k; #else unsigned char k; #endif - + #else - + #ifdef UNSIGNED_CHARS char k; #else @@ -161,102 +161,102 @@ unsigned char k; #endif - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ - case 170: - break; - - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + case 170: + break; + + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } int main(void) { - testlimits(32767); - testlimits(-32768); - testlimits(-1); - - testdefault1(1); - testdefault1(2); - testdefault1(3); - testdefault1(4); - - testdefault2(1); - testdefault2(2); - testdefault2(3); - testdefault2(4); + testlimits(32767); + testlimits(-32768); + testlimits(-1); + + testdefault1(1); + testdefault1(2); + testdefault1(3); + testdefault1(4); + + testdefault2(1); + testdefault2(2); + testdefault2(3); + testdefault2(4); - return 0; + return 0; } diff --git a/test/ref/varargs.c b/test/ref/varargs.c index 3d61fdbd0..c3e89aaa5 100644 --- a/test/ref/varargs.c +++ b/test/ref/varargs.c @@ -86,7 +86,7 @@ static char string[0x100]; va_start(ap,format); vsprintf(string,format,ap); - printf("fd:%d,format:%s,string:%s\n",fd,format,string); + printf("fd:%d,format:%s,string:%s\n",fd,format,string); va_end(ap); } diff --git a/test/ref/wf1.c b/test/ref/wf1.c index 0539d8398..1c3bfbd37 100644 --- a/test/ref/wf1.c +++ b/test/ref/wf1.c @@ -16,12 +16,12 @@ FILE *in; struct node { - int count; /* frequency count */ - struct node *left; /* left subtree */ - struct node *right; /* right subtree */ - char *word; /* word itself */ + int count; /* frequency count */ + struct node *left; /* left subtree */ + struct node *right; /* right subtree */ + char *word; /* word itself */ } words[MAXWORDS]; -int next; /* index of next free entry in words */ +int next; /* index of next free entry in words */ /*struct node *lookup();*/ @@ -38,14 +38,14 @@ struct node *lookup(char *word, struct node **p); int isletter(char c); -/* err - print error message s and die */ +/* err - print error message s and die */ #ifndef NO_OLD_FUNC_DECL err(s) char *s; { #else int err(char *s) { #endif - printf("? %s\n", s); - exit(1); + printf("? %s\n", s); + exit(1); } /* getword - get next input word into buf, return 0 on EOF */ @@ -55,25 +55,25 @@ int getword(buf) char *buf; int getword(char *buf) #endif { - char *s; - int c; + char *s; + int c; while (((c = getchar()) != -1) && (isletter(c) == 0)) - ; + ; for (s = buf; (c = isletter(c)); c = getchar()) - *s++ = c; - *s = 0; - if (s > buf) - return 1; - return 0; + *s++ = c; + *s = 0; + if (s > buf) + return 1; + return 0; } /* isletter - return folded version of c if it is a letter, 0 otherwise */ int isletter(char c) { - if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A'; - if ((c >= 'a') && (c <= 'z')) return c; - return 0; + if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A'; + if ((c >= 'a') && (c <= 'z')) return c; + return 0; } /* lookup - lookup word in tree; install if necessary */ @@ -84,27 +84,27 @@ char *word; struct node **p; struct node *lookup(char *word, struct node **p) #endif { - int cond; -/* char *malloc(); */ - - if (*p) { - cond = strcmp(word, (*p)->word); - if (cond < 0) - return lookup(word, &(*p)->left); - else if (cond > 0) - return lookup(word, &(*p)->right); - else - return *p; - } - if (next >= MAXWORDS) - err("out of node storage"); - words[next].count = 0; - words[next].left = words[next].right = 0; - words[next].word = malloc(strlen(word) + 1); - if (words[next].word == 0) - err("out of word storage"); - strcpy(words[next].word, word); - return *p = &words[next++]; + int cond; +/* char *malloc(); */ + + if (*p) { + cond = strcmp(word, (*p)->word); + if (cond < 0) + return lookup(word, &(*p)->left); + else if (cond > 0) + return lookup(word, &(*p)->right); + else + return *p; + } + if (next >= MAXWORDS) + err("out of node storage"); + words[next].count = 0; + words[next].left = words[next].right = 0; + words[next].word = malloc(strlen(word) + 1); + if (words[next].word == 0) + err("out of word storage"); + strcpy(words[next].word, word); + return *p = &words[next++]; } /* tprint - print tree */ @@ -113,28 +113,28 @@ void tprint(tree) struct node *tree; { #else void tprint(struct node *tree) { #endif - if (tree) { - tprint(tree->left); - printf("%d:%s\n", tree->count, tree->word); - tprint(tree->right); - } + if (tree) { + tprint(tree->left); + printf("%d:%s\n", tree->count, tree->word); + tprint(tree->right); + } } int main(void) { - struct node *root; - char word[20]; + struct node *root; + char word[20]; in = fopen("wf1.in","rb"); if (in == NULL) { return EXIT_FAILURE; } - root = 0; - next = 0; - while (getword(word)) - lookup(word, &root)->count++; - tprint(root); + root = 0; + next = 0; + while (getword(word)) + lookup(word, &root)->count++; + tprint(root); fclose(in); return 0; diff --git a/test/ref/yacc.c b/test/ref/yacc.c index ab72e24c0..f2c3e2a58 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -72,9 +72,9 @@ int yytchar; extern int yylineno; struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; struct yysvf *yyestate; extern struct yysvf yysvec[], *yybgin; @@ -96,18 +96,18 @@ yyback(int *p,int m); #ifdef YYDEBUG void printchar(char *name,int ch) { - if((ch==YYNEWLINE)) - { - fprintf(yyout," %s=YYNEWLINE\n",name); - } - else if((ch<0)||(ch>0xf0)||(!isprint(ch))) - { - fprintf(yyout," %s=%04x\n",name,ch &0xffff); - } - else - { - fprintf(yyout," %s='%c'\n",name,ch); - } + if((ch==YYNEWLINE)) + { + fprintf(yyout," %s=YYNEWLINE\n",name); + } + else if((ch<0)||(ch>0xf0)||(!isprint(ch))) + { + fprintf(yyout," %s=%04x\n",name,ch &0xffff); + } + else + { + fprintf(yyout," %s='%c'\n",name,ch); + } } #endif @@ -117,148 +117,148 @@ int nstr; extern int yyprevious; #ifdef YYDEBUG - fprintf(yyout,"yylex()\n"); + fprintf(yyout,"yylex()\n"); #endif - while((nstr = yylook()) >= 0) - { + while((nstr = yylook()) >= 0) + { #ifdef YYDEBUG - fprintf(yyout,"yylex: nstr=%d\n",nstr); + fprintf(yyout,"yylex: nstr=%d\n",nstr); #endif yyfussy: - switch(nstr) - { - case 0: - if(yywrap()) return(0); - break; - case 1: - return ID; - break; - case 2: - return CON; - break; - case 3: - ; - break; - case 4: - return yytext[0]; - break; - case -1: - break; - default: - fprintf(yyout,"yylex: bad switch yylook %d\n",nstr); - } - - } - + switch(nstr) + { + case 0: + if(yywrap()) return(0); + break; + case 1: + return ID; + break; + case 2: + return CON; + break; + case 3: + ; + break; + case 4: + return yytext[0]; + break; + case -1: + break; + default: + fprintf(yyout,"yylex: bad switch yylook %d\n",nstr); + } + + } + #ifdef YYDEBUG - fprintf(yyout,"yylex: return 0\n"); + fprintf(yyout,"yylex: return 0\n"); #endif - return(0); + return(0); } /* end of yylex */ int yyvstop[] = { - 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 + 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 }; # define YYTYPE char struct yywork { - YYTYPE verify, advance; + YYTYPE verify, advance; } yycrank[] = { - {0,0}, {0,0}, {1,3}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {1,4}, {1,3}, - {0,0}, {0,0}, {0,0}, {0,0}, - - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,3}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,4}, {1,3}, + {0,0}, {0,0}, {0,0}, {0,0}, + + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {1,5}, {5,7}, {5,7}, - {5,7}, {5,7}, {5,7}, {5,7}, - {5,7}, {5,7}, {5,7}, {5,7}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {1,5}, {5,7}, {5,7}, + {5,7}, {5,7}, {5,7}, {5,7}, + {5,7}, {5,7}, {5,7}, {5,7}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0x40 */ - {0,0}, {0,0}, {1,6}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,6}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {0,0}, {0,0}, - {0,0}, {0,0}, {6,8}, {0,0}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {6,8}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, /* 0x80 */ - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {0,0}, {0,0}, #ifdef CHARSETHACK - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0xc0 */ - {0,0}, {0,0}, {1,6}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,6}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {0,0}, {0,0}, {0,0}, #endif - {0,0} + {0,0} }; /* struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; */ struct yysvf yysvec[] = { - {0, 0, 0}, - {yycrank+-1, 0, 0}, - {yycrank+0, yysvec+1, 0}, - {yycrank+0, 0, yyvstop+1}, - {yycrank+0, 0, yyvstop+3}, - {yycrank+2, 0, yyvstop+6}, - {yycrank+19, 0, yyvstop+9}, - {yycrank+0, yysvec+5, yyvstop+12}, - {yycrank+0, yysvec+6, yyvstop+14}, - {0, 0, 0} + {0, 0, 0}, + {yycrank+-1, 0, 0}, + {yycrank+0, yysvec+1, 0}, + {yycrank+0, 0, yyvstop+1}, + {yycrank+0, 0, yyvstop+3}, + {yycrank+2, 0, yyvstop+6}, + {yycrank+19, 0, yyvstop+9}, + {yycrank+0, yysvec+5, yyvstop+12}, + {yycrank+0, yysvec+6, yyvstop+14}, + {0, 0, 0} }; /* 0x8d */ /* struct yywork *yytop = yycrank+141; */ @@ -268,66 +268,66 @@ struct yywork *yytop = yycrank+255; struct yysvf *yybgin = yysvec+1; /* - WARNING: this table contains one entry per character - in the execution character set and must match it. + WARNING: this table contains one entry per character + in the execution character set and must match it. */ char yymatch[] = { - 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , #ifdef CHARSETHACK - 01 ,011 ,012 ,01 ,01 ,012 ,01 ,01 , + 01 ,011 ,012 ,01 ,01 ,012 ,01 ,01 , #else - 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , + 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , #endif - 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - 011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , - '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 , + '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , + '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 , /* 0x40 (ascii) @A... (petscii) @a... */ - 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,'A' , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,'A' , /* 0x60 (ascii) @a... */ - 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , #ifdef CHARSETHACK /* 0x80 */ - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0xc0 (petcii) @A... */ - 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , + 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, #endif - 0 + 0 }; char yyextra[] = { - 0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0 }; -/* ncform 4.1 83/08/11 */ +/* ncform 4.1 83/08/11 */ int yylineno =1; # define YYU(x) x @@ -344,26 +344,26 @@ unsigned char testbreak=0; yylook() { - register struct yysvf *yystate, **lsp; - register struct yywork *yyt; - struct yysvf *yyz; - int yych; - struct yywork *yyr; + register struct yysvf *yystate, **lsp; + register struct yywork *yyt; + struct yysvf *yyz; + int yych; + struct yywork *yyr; /* # ifdef LEXDEBUG - int debug; + int debug; # endif */ - - char *yylastch; - - /* start off machines */ + + char *yylastch; + + /* start off machines */ /* # ifdef LEXDEBUG - debug = 1; + debug = 1; # else - debug = 0; + debug = 0; # endif */ @@ -372,298 +372,298 @@ yylook() # else #define debug 0 #endif - + #ifdef YYDEBUG - fprintf(yyout,"yylook()\n"); -# endif - - if (!yymorfg) - yylastch = yytext; - else - { - yymorfg=0; - yylastch = yytext+yyleng; - } + fprintf(yyout,"yylook()\n"); +# endif + + if (!yymorfg) + yylastch = yytext; + else + { + yymorfg=0; + yylastch = yytext+yyleng; + } #ifdef YYDEBUG - fprintf(yyout,"yylook: yymorfg=%d\n",yymorfg); + fprintf(yyout,"yylook: yymorfg=%d\n",yymorfg); # endif - - for(;;) - { + + for(;;) + { #ifdef YYDEBUG - fprintf(yyout,"yylook: (outer loop)"); - printchar("yyprevious",yyprevious); + fprintf(yyout,"yylook: (outer loop)"); + printchar("yyprevious",yyprevious); # endif - lsp = yylstate; - yyestate = yystate = yybgin; - if (yyprevious==YYNEWLINE) yystate++; + lsp = yylstate; + yyestate = yystate = yybgin; + if (yyprevious==YYNEWLINE) yystate++; - testbreak=0; - - for (;;) - { + testbreak=0; + + for (;;) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: (inner loop) state %d\n",yystate-yysvec-1); -# endif - if(testbreak==5) - { - fprintf(yyout,"yylook: error, aborted after 5 loops\n"); - exit(0); - } - testbreak++; - - yyt = yystate->yystoff; - -/* fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); */ - - - if(yyt == yycrank) - { /* may not be any transitions */ - yyz = yystate->yyother; - if(yyz == 0)break; - if(yyz->yystoff == yycrank)break; - } - *yylastch++ = yych = input(); + fprintf(yyout,"yylook: (inner loop) state %d\n",yystate-yysvec-1); +# endif + if(testbreak==5) + { + fprintf(yyout,"yylook: error, aborted after 5 loops\n"); + exit(0); + } + testbreak++; + + yyt = yystate->yystoff; + +/* fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); */ + + + if(yyt == yycrank) + { /* may not be any transitions */ + yyz = yystate->yyother; + if(yyz == 0)break; + if(yyz->yystoff == yycrank)break; + } + *yylastch++ = yych = input(); # ifdef LEXDEBUG - fprintf(yyout,"yylook: input "); - printchar("yych",yych); + fprintf(yyout,"yylook: input "); + printchar("yych",yych); # endif - - tryagain: + + tryagain: # ifdef LEXDEBUG -/* fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); */ - fprintf(yyout,"yylook: tryagain\n"); -# endif - yyr = yyt; - -/* fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ - - if ( yyt > yycrank) - { - yyt = yyr + yych; - if (yyt <= yytop && yyt->verify+yysvec == yystate) - { - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - { +/* fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); */ + fprintf(yyout,"yylook: tryagain\n"); +# endif + yyr = yyt; + +/* fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ + + if ( yyt > yycrank) + { + yyt = yyr + yych; + if (yyt <= yytop && yyt->verify+yysvec == yystate) + { + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (1) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (1) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG - fprintf(yyout,"yylook: continue (1)\n"); + fprintf(yyout,"yylook: continue (1)\n"); # endif - goto contin; - } + goto contin; + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: ( yyt > yycrank)\n"); + fprintf(yyout,"yylook: ( yyt > yycrank)\n"); # endif - } + } # ifdef YYOPTIM - else if(yyt < yycrank) /* r < yycrank */ - { - yyt = yyr = yycrank+(yycrank-yyt); + else if(yyt < yycrank) /* r < yycrank */ + { + yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG - fprintf(yyout,"yylook: compressed state\n"); + fprintf(yyout,"yylook: compressed state\n"); # endif - yyt = yyt + yych; - if(yyt <= yytop && yyt->verify+yysvec == yystate) - { + yyt = yyt + yych; + if(yyt <= yytop && yyt->verify+yysvec == yystate) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: (1)\n"); + fprintf(yyout,"yylook: (1)\n"); # endif - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - { + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (2) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (2) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG - fprintf(yyout,"yylook: continue (2)\n"); + fprintf(yyout,"yylook: continue (2)\n"); # endif - goto contin; - - } + goto contin; + + } # ifdef LEXDEBUG /* - fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); - fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); - fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); + fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); + fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); + fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ # endif - yyt = yyr + YYU(yymatch[yych]); + yyt = yyr + YYU(yymatch[yych]); # ifdef LEXDEBUG /* - fprintf(yyout,"yylook: yyt offs: %02x <= yytop offs: %02x\n",yyt-yycrank,yytop-yycrank); - fprintf(yyout,"yylook: yyt->verify=%04x yysvec=%04x (yyt->verify+yysvec)=%04x == yystate=%04x\n",yyt->verify,yysvec,(yyt->verify+yysvec),yystate); + fprintf(yyout,"yylook: yyt offs: %02x <= yytop offs: %02x\n",yyt-yycrank,yytop-yycrank); + fprintf(yyout,"yylook: yyt->verify=%04x yysvec=%04x (yyt->verify+yysvec)=%04x == yystate=%04x\n",yyt->verify,yysvec,(yyt->verify+yysvec),yystate); */ - fprintf(yyout,"yylook: try fall back character\n"); + fprintf(yyout,"yylook: try fall back character\n"); # endif - if(yyt <= yytop && yyt->verify+yysvec == yystate) - { + if(yyt <= yytop && yyt->verify+yysvec == yystate) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: (2a)\n"); + fprintf(yyout,"yylook: (2a)\n"); # endif - - if(yyt->advance+yysvec == YYLERR) /* error transition */ - { + + if(yyt->advance+yysvec == YYLERR) /* error transition */ + { # ifdef LEXDEBUG -/* cc65 compiles this ?! fprintf(yyout,"yylook: unput (3) ",); */ - fprintf(yyout,"yylook: unput (3) "); - printchar("*yylastch",*yylastch); -# endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; +/* cc65 compiles this ?! fprintf(yyout,"yylook: unput (3) ",); */ + fprintf(yyout,"yylook: unput (3) "); + printchar("*yylastch",*yylastch); +# endif + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG -/* fprintf(yyout,"yylook: yyt offs: %02x yyt->advance=%d\n",yyt-yycrank,yyt->advance); */ - fprintf(yyout,"yylook: continue (3)\n"); +/* fprintf(yyout,"yylook: yyt offs: %02x yyt->advance=%d\n",yyt-yycrank,yyt->advance); */ + fprintf(yyout,"yylook: continue (3)\n"); # endif - goto contin; - - } + goto contin; + + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: (2)\n"); + fprintf(yyout,"yylook: (2)\n"); # endif - } - if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank) - { + } + if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: fall back to state %d\n",yystate-yysvec-1); + fprintf(yyout,"yylook: fall back to state %d\n",yystate-yysvec-1); # endif - goto tryagain; - } + goto tryagain; + } # endif - else - { + else + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (4) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (4) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - contin: + unput(*--yylastch); + break; + } + contin: # ifdef LEXDEBUG - fprintf(yyout,"yylook: contin state=%d\n",yystate-yysvec-1); + fprintf(yyout,"yylook: contin state=%d\n",yystate-yysvec-1); # endif - ; - } + ; + } # ifdef LEXDEBUG - if (lsp == yylstate) - { - fprintf(yyout,"yylook: stopped (end)\n"); - } - else - { - fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); - } -# endif - while (lsp-- > yylstate) - { - *yylastch-- = 0; - if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0) - { - yyolsp = lsp; - if(yyextra[*yyfnd]) /* must backup */ - { - while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate) - { - lsp--; + if (lsp == yylstate) + { + fprintf(yyout,"yylook: stopped (end)\n"); + } + else + { + fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); + } +# endif + while (lsp-- > yylstate) + { + *yylastch-- = 0; + if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0) + { + yyolsp = lsp; + if(yyextra[*yyfnd]) /* must backup */ + { + while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate) + { + lsp--; # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (5) "); - printchar("*yylastch",*yylastch); -# endif - unput(*yylastch--); - } - } - yyprevious = YYU(*yylastch); - yylsp = lsp; - yyleng = yylastch-yytext+1; - yytext[yyleng] = 0; + fprintf(yyout,"yylook: unput (5) "); + printchar("*yylastch",*yylastch); +# endif + unput(*yylastch--); + } + } + yyprevious = YYU(*yylastch); + yylsp = lsp; + yyleng = yylastch-yytext+1; + yytext[yyleng] = 0; # ifdef LEXDEBUG - fprintf(yyout,"yylook: match action %d\n",*yyfnd); - fprintf(yyout,"yylook: done loops: %d\n",testbreak); -# endif - return(*yyfnd++); - } - unput(*yylastch); - } - if (yytext[0] == 0 /* && feof(yyin) */) - { - yysptr=yysbuf; + fprintf(yyout,"yylook: match action %d\n",*yyfnd); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); +# endif + return(*yyfnd++); + } + unput(*yylastch); + } + if (yytext[0] == 0 /* && feof(yyin) */) + { + yysptr=yysbuf; # ifdef LEXDEBUG - fprintf(yyout,"yylook: done loops: %d\n",testbreak); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); # endif - return(0); - } - yyprevious = yytext[0] = input(); + return(0); + } + yyprevious = yytext[0] = input(); # ifdef LEXDEBUG - fprintf(yyout,"yylook: input "); - printchar("yyprevious",yyprevious); + fprintf(yyout,"yylook: input "); + printchar("yyprevious",yyprevious); # endif - if (yyprevious>0) - output(yyprevious); - yylastch=yytext; + if (yyprevious>0) + output(yyprevious); + yylastch=yytext; # ifdef LEXDEBUG -/* if(debug)putchar('\n'); */ +/* if(debug)putchar('\n'); */ # endif - } + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: done loops: %d\n",testbreak); - fprintf(yyout,"yylook: return \n"); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); + fprintf(yyout,"yylook: return \n"); # endif } - + yyback(p, m) - int *p; + int *p; { - if (p==0) return(0); - while (*p) - { - if (*p++ == m) - { - return(1); - } - } - return(0); + if (p==0) return(0); + while (*p) + { + if (*p++ == m) + { + return(1); + } + } + return(0); } - /* the following are only used in the lex library */ + /* the following are only used in the lex library */ yyinput() { - int out=input(); - + int out=input(); + #ifdef YYDEBUG - fprintf(yyout,"yylook: input "); - printchar("out",out); -#endif - return(out); + fprintf(yyout,"yylook: input "); + printchar("out",out); +#endif + return(out); } yyoutput(c) int c; { - output(c); + output(c); } yyunput(c) int c; { - unput(c); + unput(c); } main() @@ -689,8 +689,8 @@ char *s; short yyexca[] = { -1, 1, - 0, -1, - -2, 0, + 0, -1, + -2, 0, }; # define YYNPROD 15 @@ -762,7 +762,7 @@ short yydef[]= # define YYACCEPT return(0) # define YYABORT return(1) -/* parser for yacc output */ +/* parser for yacc output */ #ifdef YYDEBUG int yydebug = 1; /* 1 for debugging */ @@ -776,231 +776,231 @@ short yyerrflag = 0; /* error recovery flag */ yyparse() { - short yys[YYMAXDEPTH]; - short yyj, yym; - register YYSTYPE *yypvt; - register short yystate, *yyps, yyn; - register YYSTYPE *yypv; - register short *yyxi; - - yystate = 0; - yychar = -1; - yynerrs = 0; - yyerrflag = 0; - yyps= &yys[-1]; - yypv= &yyv[-1]; + short yys[YYMAXDEPTH]; + short yyj, yym; + register YYSTYPE *yypvt; + register short yystate, *yyps, yyn; + register YYSTYPE *yypv; + register short *yyxi; + + yystate = 0; + yychar = -1; + yynerrs = 0; + yyerrflag = 0; + yyps= &yys[-1]; + yypv= &yyv[-1]; yystack: /* put a state and value onto the stack */ #ifdef YYDEBUG - printf("yyparse: yystack\n"); + printf("yyparse: yystack\n"); #endif #ifdef YYDEBUG - printf("yyparse: yystate=%d, ", yystate); - printchar("yychar",yychar); + printf("yyparse: yystate=%d, ", yystate); + printchar("yychar",yychar); #endif - if( ++yyps> &yys[YYMAXDEPTH] ) - { - yyerror( "yyparse: yacc stack overflow" ); - return(1); - } - *yyps = yystate; - ++yypv; - *yypv = yyval; + if( ++yyps> &yys[YYMAXDEPTH] ) + { + yyerror( "yyparse: yacc stack overflow" ); + return(1); + } + *yyps = yystate; + ++yypv; + *yypv = yyval; yynewstate: #ifdef YYDEBUG - printf("yyparse: yynewstate\n"); + printf("yyparse: yynewstate\n"); #endif - yyn = yypact[yystate]; + yyn = yypact[yystate]; - if( yyn<= YYFLAG ) goto yydefault; /* simple state */ + if( yyn<= YYFLAG ) goto yydefault; /* simple state */ #ifdef YYDEBUG - printf("yyparse: yynewstate (1)\n"); + printf("yyparse: yynewstate (1)\n"); #endif - - if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; + + if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; #ifdef YYDEBUG - - printf("yyparse: yynewstate yyn=%d ",yyn); - printchar("yychar",yychar); + + printf("yyparse: yynewstate yyn=%d ",yyn); + printchar("yychar",yychar); #endif - - if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; + + if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; #ifdef YYDEBUG - printf("yyparse: yynewstate (2)\n"); + printf("yyparse: yynewstate (2)\n"); #endif - - if( yychk[ yyn=yyact[ yyn ] ] == yychar ) /* valid shift */ - { - yychar = -1; - yyval = yylval; - yystate = yyn; + + if( yychk[ yyn=yyact[ yyn ] ] == yychar ) /* valid shift */ + { + yychar = -1; + yyval = yylval; + yystate = yyn; #ifdef YYDEBUG - printf("yyparse: yynewstate (3)\n"); + printf("yyparse: yynewstate (3)\n"); #endif - if( yyerrflag > 0 ) --yyerrflag; - goto yystack; - } + if( yyerrflag > 0 ) --yyerrflag; + goto yystack; + } yydefault: #ifdef YYDEBUG - printf("yyparse: yydefault yystate=%d\n",yystate); + printf("yyparse: yydefault yystate=%d\n",yystate); #endif - /* default state action */ + /* default state action */ - if( (yyn=yydef[yystate]) == -2 ) - { - if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; - /* look through exception table */ + if( (yyn=yydef[yystate]) == -2 ) + { + if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; + /* look through exception table */ - for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ + for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ - while( *(yyxi+=2) >= 0 ) - { - if( *yyxi == yychar ) break; - } - if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ - } + while( *(yyxi+=2) >= 0 ) + { + if( *yyxi == yychar ) break; + } + if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ + } #ifdef YYDEBUG - printf("yyparse: yyn=%d yyerrflag=%d\n",yyn,yyerrflag); + printf("yyparse: yyn=%d yyerrflag=%d\n",yyn,yyerrflag); #endif - - if( yyn == 0 ) /* error */ - { - /* error ... attempt to resume parsing */ + + if( yyn == 0 ) /* error */ + { + /* error ... attempt to resume parsing */ - switch( yyerrflag ){ - case 0: /* brand new error */ + switch( yyerrflag ){ + case 0: /* brand new error */ - yyerror( "yyparse: syntax error" ); - yyerrlab: - ++yynerrs; + yyerror( "yyparse: syntax error" ); + yyerrlab: + ++yynerrs; - case 1: - case 2: /* incompletely recovered error ... try again */ + case 1: + case 2: /* incompletely recovered error ... try again */ - yyerrflag = 3; + yyerrflag = 3; - /* find a state where "error" is a legal shift action */ + /* find a state where "error" is a legal shift action */ - while ( yyps >= yys ) { - yyn = yypact[*yyps] + YYERRCODE; - if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ - yystate = yyact[yyn]; /* simulate a shift of "error" */ - goto yystack; - } - yyn = yypact[*yyps]; + while ( yyps >= yys ) { + yyn = yypact[*yyps] + YYERRCODE; + if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ + yystate = yyact[yyn]; /* simulate a shift of "error" */ + goto yystack; + } + yyn = yypact[*yyps]; - /* the current yyps has no shift onn "error", pop stack */ + /* the current yyps has no shift onn "error", pop stack */ #ifdef YYDEBUG - printf("yyparse: error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); + printf("yyparse: error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); #endif - --yyps; - --yypv; - } + --yyps; + --yypv; + } - /* there is no state on the stack with an error shift ... abort */ + /* there is no state on the stack with an error shift ... abort */ - yyabort: - return(1); + yyabort: + return(1); - case 3: /* no shift yet; clobber input char */ + case 3: /* no shift yet; clobber input char */ #ifdef YYDEBUG - printf("yyparse: error recovery discards char "); - printchar("yychar",yychar); + printf("yyparse: error recovery discards char "); + printchar("yychar",yychar); #endif - if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ - yychar = -1; - goto yynewstate; /* try again in the same state */ + if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ + yychar = -1; + goto yynewstate; /* try again in the same state */ - } + } - } + } - /* reduction by production yyn */ + /* reduction by production yyn */ #ifdef YYDEBUG - printf("yyparse: reduce %d\n",yyn); + printf("yyparse: reduce %d\n",yyn); #endif - yyps -= yyr2[yyn]; - yypvt = yypv; - yypv -= yyr2[yyn]; - yyval = yypv[1]; - yym=yyn; - /* consult goto table to find next state */ - yyn = yyr1[yyn]; - yyj = yypgo[yyn] + *yyps + 1; - if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; - - switch(yym) - { - case 4: - { - yyerrok; - } - break; - case 5: - { - printf("[STORE]\n"); - } - break; - case 6: - { - printf("[ADD]\n"); - } - break; - case 7: - { - printf("[NEG]\n[ADD]\n"); - } - break; - case 8: - { - printf("[MUL]\n"); - } - break; - case 9: - { - printf("[DIV]\n"); - } - break; - case 10: - { - printf("[NEG]\n"); - } - break; - case 12: - { - printf("[LOAD]\n"); - } - break; - case 13: - { - printf("[PUSH %s]\n", yytext); - } - break; - case 14: - { - printf("[%s]\n", yytext); - } - break; - } - - goto yystack; /* stack new state and value */ + yyps -= yyr2[yyn]; + yypvt = yypv; + yypv -= yyr2[yyn]; + yyval = yypv[1]; + yym=yyn; + /* consult goto table to find next state */ + yyn = yyr1[yyn]; + yyj = yypgo[yyn] + *yyps + 1; + if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; + + switch(yym) + { + case 4: + { + yyerrok; + } + break; + case 5: + { + printf("[STORE]\n"); + } + break; + case 6: + { + printf("[ADD]\n"); + } + break; + case 7: + { + printf("[NEG]\n[ADD]\n"); + } + break; + case 8: + { + printf("[MUL]\n"); + } + break; + case 9: + { + printf("[DIV]\n"); + } + break; + case 10: + { + printf("[NEG]\n"); + } + break; + case 12: + { + printf("[LOAD]\n"); + } + break; + case 13: + { + printf("[PUSH %s]\n", yytext); + } + break; + case 14: + { + printf("[%s]\n", yytext); + } + break; + } + + goto yystack; /* stack new state and value */ } - + int yywrap() { - return 1; + return 1; } diff --git a/test/ref/yacc2.c b/test/ref/yacc2.c index 78d654ded..3b4819c55 100644 --- a/test/ref/yacc2.c +++ b/test/ref/yacc2.c @@ -10,105 +10,105 @@ # define YYTYPE char struct yywork { - YYTYPE verify, advance; + YYTYPE verify, advance; } yycrank[] = { - {0,0}, {0,0}, {1,3}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {1,4}, {1,3}, - {0,0}, {0,0}, {0,0}, {0,0}, - - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,3}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,4}, {1,3}, + {0,0}, {0,0}, {0,0}, {0,0}, + + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {1,5}, {5,7}, {5,7}, - {5,7}, {5,7}, {5,7}, {5,7}, - {5,7}, {5,7}, {5,7}, {5,7}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {1,5}, {5,7}, {5,7}, + {5,7}, {5,7}, {5,7}, {5,7}, + {5,7}, {5,7}, {5,7}, {5,7}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0x40 */ - {0,0}, {0,0}, {1,6}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,6}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {0,0}, {0,0}, - {0,0}, {0,0}, {6,8}, {0,0}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {6,8}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, /* 0x80 */ - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {0,0}, {0,0}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {0,0}, {0,0}, #ifdef CHARSETHACK - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0xc0 */ - {0,0}, {0,0}, {1,6}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {6,8}, {6,8}, {6,8}, - {6,8}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,6}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {6,8}, {6,8}, {6,8}, + {6,8}, {0,0}, {0,0}, {0,0}, #endif - {0,0} + {0,0} }; struct yywork *yytop = yycrank+255; int yyvstop[] = { - 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 + 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 }; struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; struct yysvf yysvec[] = { - {0, 0, 0}, - {yycrank+-1, 0, 0}, - {yycrank+0, yysvec+1, 0}, - {yycrank+0, 0, yyvstop+1}, - {yycrank+0, 0, yyvstop+3}, - {yycrank+2, 0, yyvstop+6}, - {yycrank+19, 0, yyvstop+9}, - {yycrank+0, yysvec+5, yyvstop+12}, - {yycrank+0, yysvec+6, yyvstop+14}, - {0, 0, 0} + {0, 0, 0}, + {yycrank+-1, 0, 0}, + {yycrank+0, yysvec+1, 0}, + {yycrank+0, 0, yyvstop+1}, + {yycrank+0, 0, yyvstop+3}, + {yycrank+2, 0, yyvstop+6}, + {yycrank+19, 0, yyvstop+9}, + {yycrank+0, yysvec+5, yyvstop+12}, + {yycrank+0, yysvec+6, yyvstop+14}, + {0, 0, 0} }; #if 0 @@ -116,7 +116,7 @@ struct yysvf yysvec[] = // *yylastch++ = yych = input(); void subtest1(void) { - *yylastch++ = yych = input(); + *yylastch++ = yych = input(); } #endif @@ -125,26 +125,26 @@ static int bog=1234; #if 0 void bogus(void) { - bog*=0x1234; + bog*=0x1234; } #else -#define bogus() bog+=0x1234 +#define bogus() bog+=0x1234 #endif #if 1 // yyt = yyt + yych; void subtest2(void) { - register struct yywork *yyt; - int yych; + register struct yywork *yyt; + int yych; - yyt=yycrank; - yych=10; + yyt=yycrank; + yych=10; - bogus(); - yyt = yyt + yych; + bogus(); + yyt = yyt + yych; - printf("yyt: %d %d\n",yyt->verify,yyt->advance); + printf("yyt: %d %d\n",yyt->verify,yyt->advance); } #endif @@ -152,21 +152,21 @@ void subtest2(void) // if(yyt <= yytop && yyt->verify+yysvec == yystate) void subtest3(void) { - register struct yywork *yyt; - register struct yysvf *yystate; - - yyt=yycrank; - yystate=yysvec; - - bogus(); - if(yyt <= yytop && yyt->verify+yysvec == yystate) - { - printf("if ok %d %d\n",yyt->verify,yyt->advance); - } - else - { - printf("if not ok %d %d\n",yyt->verify,yyt->advance); - } + register struct yywork *yyt; + register struct yysvf *yystate; + + yyt=yycrank; + yystate=yysvec; + + bogus(); + if(yyt <= yytop && yyt->verify+yysvec == yystate) + { + printf("if ok %d %d\n",yyt->verify,yyt->advance); + } + else + { + printf("if not ok %d %d\n",yyt->verify,yyt->advance); + } } #endif @@ -179,19 +179,19 @@ short yyr2[]= // yyps -= yyr2[yyn]; void subtest4(void) { - register short *yyps, yyn; + register short *yyps, yyn; - yyps=0x8004; - yyn=0; + yyps=0x8004; + yyn=0; - while(yyn<14) - { - bogus(); - yyps -= yyr2[yyn]; + while(yyn<14) + { + bogus(); + yyps -= yyr2[yyn]; - yyn++; - } - printf("yyps: %04x\n",yyps); + yyn++; + } + printf("yyps: %04x\n",yyps); } #if 1 @@ -199,21 +199,21 @@ void subtest4(void) int yylookret=10; yylook() { - yylookret--; - return yylookret; + yylookret--; + return yylookret; } // while((nstr = yylook()) >= 0) void subtest5(void) { - int nstr; - - bogus(); - while((nstr = yylook()) >= 0) - { - printf("nstr: %04x\n",nstr); - bogus(); - } + int nstr; + + bogus(); + while((nstr = yylook()) >= 0) + { + printf("nstr: %04x\n",nstr); + bogus(); + } } #endif diff --git a/test/val/compare5.c b/test/val/compare5.c index 9e0c97a63..f1d94d537 100644 --- a/test/val/compare5.c +++ b/test/val/compare5.c @@ -288,17 +288,17 @@ void c_minus1(void) printf("(long0 != -1)\n"); if(long0 != -1) { - failures++; + failures++; } printf("(long0 > 0)\n"); if(long0 > 0) { - failures++; + failures++; } printf("(long1 < 0)\n"); if(long1 < 0) { - failures++; + failures++; } /* if(long1 < 2) diff --git a/test/val/cq22.c b/test/val/cq22.c index bcd1570c8..015b7bf77 100644 --- a/test/val/cq22.c +++ b/test/val/cq22.c @@ -101,9 +101,9 @@ int s22(struct defs *pd0) #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s22(pd0); @@ -125,7 +125,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq241.c b/test/val/cq241.c index 76f437e0c..1f66a378c 100644 --- a/test/val/cq241.c +++ b/test/val/cq241.c @@ -243,9 +243,9 @@ int s241(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s241(pd0); @@ -267,7 +267,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq243.c b/test/val/cq243.c index 676c73182..aaec9a8ea 100644 --- a/test/val/cq243.c +++ b/test/val/cq243.c @@ -176,21 +176,21 @@ int s243(struct defs *pd0) { by a more failproof version if( - '\0' != 0 || - '\01' != 1 || - '\02' != 2 || - '\03' != 3 || - '\04' != 4 || - '\05' != 5 || - '\06' != 6 || - '\07' != 7 || - '\10' != 8 || - '\17' != 15 || - '\20' != 16 || - '\77' != 63 || - '\100' != 64 || - '\177' != 127 - ) + '\0' != 0 || + '\01' != 1 || + '\02' != 2 || + '\03' != 3 || + '\04' != 4 || + '\05' != 5 || + '\06' != 6 || + '\07' != 7 || + '\10' != 8 || + '\17' != 15 || + '\20' != 16 || + '\77' != 63 || + '\100' != 64 || + '\177' != 127 + ) */ if( ('0' != '\60') || @@ -201,7 +201,7 @@ int s243(struct defs *pd0) { ('z' != '\172') ) - { + { rc = rc+8; if(pd0->flgd != 0) { @@ -221,9 +221,9 @@ int s243(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s243(pd0); @@ -245,7 +245,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq244.c b/test/val/cq244.c index bedf51e95..9f4704f36 100644 --- a/test/val/cq244.c +++ b/test/val/cq244.c @@ -116,9 +116,9 @@ s244(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s244(pd0); @@ -140,7 +140,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq25.c b/test/val/cq25.c index 9cb2f61c8..bfdade957 100644 --- a/test/val/cq25.c +++ b/test/val/cq25.c @@ -128,9 +128,9 @@ int s25(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s25(pd0); @@ -152,7 +152,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq26.c b/test/val/cq26.c index 399f0a45e..239411f1c 100644 --- a/test/val/cq26.c +++ b/test/val/cq26.c @@ -171,9 +171,9 @@ s26(struct defs *pd0) { *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -197,7 +197,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq4.c b/test/val/cq4.c index 8a8125c52..a8b6b1d52 100644 --- a/test/val/cq4.c +++ b/test/val/cq4.c @@ -317,9 +317,9 @@ setev(){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -344,7 +344,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq61.c b/test/val/cq61.c index 3dcca6454..fc4d1d95f 100644 --- a/test/val/cq61.c +++ b/test/val/cq61.c @@ -140,9 +140,9 @@ simply discarded. */ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -167,7 +167,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq626.c b/test/val/cq626.c index 166d3a95b..a8b05c8f2 100644 --- a/test/val/cq626.c +++ b/test/val/cq626.c @@ -291,9 +291,9 @@ int s626(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -318,7 +318,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq71.c b/test/val/cq71.c index 7bf0d9e1e..f7167c728 100644 --- a/test/val/cq71.c +++ b/test/val/cq71.c @@ -194,9 +194,9 @@ int *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -221,7 +221,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq714.c b/test/val/cq714.c index f4c58801f..d7a878033 100644 --- a/test/val/cq714.c +++ b/test/val/cq714.c @@ -1507,175 +1507,175 @@ initial (5,2) | (5,2) | (12,10) } #ifdef NO_FLOATS - fl = 5; cr = 2; - fl /= cr; - if(fl != 2){ - lrc = 232; - if(prlc) printf(f,lrc); - } - fl = 5; sr = 2; - fl /= sr; - if(fl != 2){ - lrc = 233; - if(prlc) printf(f,lrc); - } - fl = 5; ir = 2; - fl /= ir; - if(fl != 2){ - lrc = 234; - if(prlc) printf(f,lrc); - } - fl = 5; lr = 2; - fl /= lr; - if(fl != 2){ - lrc = 235; - if(prlc) printf(f,lrc); - } - fl = 5; ur = 2; - fl /= ur; - if(fl != 2){ - lrc = 236; - if(prlc) printf(f,lrc); - } - fl = 5; fr = 2; - fl /= fr; - if(fl != 2){ - lrc = 237; - if(prlc) printf(f,lrc); - } - fl = 5; dr = 2; - fl /= dr; - if(fl != 2){ - lrc = 238; - if(prlc) printf(f,lrc); - } - dl = 5; cr = 2; - dl /= cr; - if(dl != 2){ - lrc = 239; - if(prlc) printf(f,lrc); - } - dl = 5; sr = 2; - dl /= sr; - if(dl != 2){ - lrc = 240; - if(prlc) printf(f,lrc); - } - dl = 5; ir = 2; - dl /= ir; - if(dl != 2){ - lrc = 241; - if(prlc) printf(f,lrc); - } - dl = 5; lr = 2; - dl /= lr; - if(dl != 2){ - lrc = 242; - if(prlc) printf(f,lrc); - } - dl = 5; ur = 2; - dl /= ur; - if(dl != 2){ - lrc = 243; - if(prlc) printf(f,lrc); - } - dl = 5; fr = 2; - dl /= fr; - if(dl != 2){ - lrc = 244; - if(prlc) printf(f,lrc); - } - dl = 5; dr = 2; - dl /= dr; - if(dl != 2){ - lrc = 245; - if(prlc) printf(f,lrc); - } + fl = 5; cr = 2; + fl /= cr; + if(fl != 2){ + lrc = 232; + if(prlc) printf(f,lrc); + } + fl = 5; sr = 2; + fl /= sr; + if(fl != 2){ + lrc = 233; + if(prlc) printf(f,lrc); + } + fl = 5; ir = 2; + fl /= ir; + if(fl != 2){ + lrc = 234; + if(prlc) printf(f,lrc); + } + fl = 5; lr = 2; + fl /= lr; + if(fl != 2){ + lrc = 235; + if(prlc) printf(f,lrc); + } + fl = 5; ur = 2; + fl /= ur; + if(fl != 2){ + lrc = 236; + if(prlc) printf(f,lrc); + } + fl = 5; fr = 2; + fl /= fr; + if(fl != 2){ + lrc = 237; + if(prlc) printf(f,lrc); + } + fl = 5; dr = 2; + fl /= dr; + if(fl != 2){ + lrc = 238; + if(prlc) printf(f,lrc); + } + dl = 5; cr = 2; + dl /= cr; + if(dl != 2){ + lrc = 239; + if(prlc) printf(f,lrc); + } + dl = 5; sr = 2; + dl /= sr; + if(dl != 2){ + lrc = 240; + if(prlc) printf(f,lrc); + } + dl = 5; ir = 2; + dl /= ir; + if(dl != 2){ + lrc = 241; + if(prlc) printf(f,lrc); + } + dl = 5; lr = 2; + dl /= lr; + if(dl != 2){ + lrc = 242; + if(prlc) printf(f,lrc); + } + dl = 5; ur = 2; + dl /= ur; + if(dl != 2){ + lrc = 243; + if(prlc) printf(f,lrc); + } + dl = 5; fr = 2; + dl /= fr; + if(dl != 2){ + lrc = 244; + if(prlc) printf(f,lrc); + } + dl = 5; dr = 2; + dl /= dr; + if(dl != 2){ + lrc = 245; + if(prlc) printf(f,lrc); + } #else - fl = 5; cr = 2; - fl /= cr; - if(fl != 2.5){ - lrc = 232; - if(prlc) printf(f,lrc); - } - fl = 5; sr = 2; - fl /= sr; - if(fl != 2.5){ - lrc = 233; - if(prlc) printf(f,lrc); - } - fl = 5; ir = 2; - fl /= ir; - if(fl != 2.5){ - lrc = 234; - if(prlc) printf(f,lrc); - } - fl = 5; lr = 2; - fl /= lr; - if(fl != 2.5){ - lrc = 235; - if(prlc) printf(f,lrc); - } - fl = 5; ur = 2; - fl /= ur; - if(fl != 2.5){ - lrc = 236; - if(prlc) printf(f,lrc); - } - fl = 5; fr = 2; - fl /= fr; - if(fl != 2.5){ - lrc = 237; - if(prlc) printf(f,lrc); - } - fl = 5; dr = 2; - fl /= dr; - if(fl != 2.5){ - lrc = 238; - if(prlc) printf(f,lrc); - } - dl = 5; cr = 2; - dl /= cr; - if(dl != 2.5){ - lrc = 239; - if(prlc) printf(f,lrc); - } - dl = 5; sr = 2; - dl /= sr; - if(dl != 2.5){ - lrc = 240; - if(prlc) printf(f,lrc); - } - dl = 5; ir = 2; - dl /= ir; - if(dl != 2.5){ - lrc = 241; - if(prlc) printf(f,lrc); - } - dl = 5; lr = 2; - dl /= lr; - if(dl != 2.5){ - lrc = 242; - if(prlc) printf(f,lrc); - } - dl = 5; ur = 2; - dl /= ur; - if(dl != 2.5){ - lrc = 243; - if(prlc) printf(f,lrc); - } - dl = 5; fr = 2; - dl /= fr; - if(dl != 2.5){ - lrc = 244; - if(prlc) printf(f,lrc); - } - dl = 5; dr = 2; - dl /= dr; - if(dl != 2.5){ - lrc = 245; - if(prlc) printf(f,lrc); - } + fl = 5; cr = 2; + fl /= cr; + if(fl != 2.5){ + lrc = 232; + if(prlc) printf(f,lrc); + } + fl = 5; sr = 2; + fl /= sr; + if(fl != 2.5){ + lrc = 233; + if(prlc) printf(f,lrc); + } + fl = 5; ir = 2; + fl /= ir; + if(fl != 2.5){ + lrc = 234; + if(prlc) printf(f,lrc); + } + fl = 5; lr = 2; + fl /= lr; + if(fl != 2.5){ + lrc = 235; + if(prlc) printf(f,lrc); + } + fl = 5; ur = 2; + fl /= ur; + if(fl != 2.5){ + lrc = 236; + if(prlc) printf(f,lrc); + } + fl = 5; fr = 2; + fl /= fr; + if(fl != 2.5){ + lrc = 237; + if(prlc) printf(f,lrc); + } + fl = 5; dr = 2; + fl /= dr; + if(fl != 2.5){ + lrc = 238; + if(prlc) printf(f,lrc); + } + dl = 5; cr = 2; + dl /= cr; + if(dl != 2.5){ + lrc = 239; + if(prlc) printf(f,lrc); + } + dl = 5; sr = 2; + dl /= sr; + if(dl != 2.5){ + lrc = 240; + if(prlc) printf(f,lrc); + } + dl = 5; ir = 2; + dl /= ir; + if(dl != 2.5){ + lrc = 241; + if(prlc) printf(f,lrc); + } + dl = 5; lr = 2; + dl /= lr; + if(dl != 2.5){ + lrc = 242; + if(prlc) printf(f,lrc); + } + dl = 5; ur = 2; + dl /= ur; + if(dl != 2.5){ + lrc = 243; + if(prlc) printf(f,lrc); + } + dl = 5; fr = 2; + dl /= fr; + if(dl != 2.5){ + lrc = 244; + if(prlc) printf(f,lrc); + } + dl = 5; dr = 2; + dl /= dr; + if(dl != 2.5){ + lrc = 245; + if(prlc) printf(f,lrc); + } #endif cl = 5; cr = 2; cl %= cr; @@ -1750,9 +1750,9 @@ initial (5,2) | (5,2) | (12,10) *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s714(pd0); @@ -1776,7 +1776,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq714b.c b/test/val/cq714b.c index b4908f4cb..9538281b8 100644 --- a/test/val/cq714b.c +++ b/test/val/cq714b.c @@ -971,9 +971,9 @@ initial (5,2) | (5,2) | (12,10) *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s714(pd0); @@ -997,7 +997,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq715.c b/test/val/cq715.c index fec9c6170..0fe864159 100644 --- a/test/val/cq715.c +++ b/test/val/cq715.c @@ -105,9 +105,9 @@ int x, y, z; *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -132,7 +132,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq72.c b/test/val/cq72.c index 2f956e59d..421177a0b 100644 --- a/test/val/cq72.c +++ b/test/val/cq72.c @@ -299,9 +299,9 @@ int s72(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -326,7 +326,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq757.c b/test/val/cq757.c index 60b588555..cf28f79e3 100644 --- a/test/val/cq757.c +++ b/test/val/cq757.c @@ -289,9 +289,9 @@ int s757(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); diff --git a/test/val/cq7813.c b/test/val/cq7813.c index 0e743abcd..9d4308a3e 100644 --- a/test/val/cq7813.c +++ b/test/val/cq7813.c @@ -336,9 +336,9 @@ int s7813(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s7813(pd0); @@ -362,7 +362,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq81.c b/test/val/cq81.c index 0271cae5d..85e1ac1d6 100644 --- a/test/val/cq81.c +++ b/test/val/cq81.c @@ -682,9 +682,9 @@ test is unreliable. */ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s81(pd0); @@ -708,7 +708,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq84.c b/test/val/cq84.c index d37c82f29..64429e300 100644 --- a/test/val/cq84.c +++ b/test/val/cq84.c @@ -101,13 +101,13 @@ int s84(struct defs *pd0){ if(pd0->flgd != 0) printf(s84er,2); rc = rc+2; } - #else + #else pfi = glork; if((*pfi)(4) != 4){ if(pd0->flgd != 0) printf(s84er,2); rc = rc+2; } - #endif + #endif /* Float fa[17] declares an array of floating point numbers, and *afp[17] declares an array of pointers @@ -223,9 +223,9 @@ return x;} *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s84(pd0); @@ -249,7 +249,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq85.c b/test/val/cq85.c index 15b055b20..49423e7de 100644 --- a/test/val/cq85.c +++ b/test/val/cq85.c @@ -118,10 +118,10 @@ int s85(struct defs *pd0){ #ifdef NO_FLOATS "signed", "signed", - #else + #else "float", "double" - #endif + #endif }; static char aln[] = " alignment: "; @@ -205,12 +205,12 @@ int s85(struct defs *pd0){ if(pd0->flgm != 0) printf("Sign extension in fields\n"); } else{ - #ifdef NO_BITFIELDS - if(pd0->flgd != 0) printf("NO_BITFIELDS\n"); - #else - if(pd0->flgd != 0) printf(s85er,2); - rc = rc+2; - #endif + #ifdef NO_BITFIELDS + if(pd0->flgd != 0) printf("NO_BITFIELDS\n"); + #else + if(pd0->flgd != 0) printf(s85er,2); + rc = rc+2; + #endif } } @@ -268,9 +268,9 @@ int one(); *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s85(pd0); @@ -294,7 +294,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq86.c b/test/val/cq86.c index 9f2409e7a..9c850662a 100644 --- a/test/val/cq86.c +++ b/test/val/cq86.c @@ -183,9 +183,9 @@ int *metricp; *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s86(pd0); @@ -209,7 +209,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq88.c b/test/val/cq88.c index a15f75110..ef742824e 100644 --- a/test/val/cq88.c +++ b/test/val/cq88.c @@ -139,9 +139,9 @@ int s88(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s88(pd0); @@ -165,7 +165,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq9.c b/test/val/cq9.c index 228ac9e77..c0f1f45ff 100644 --- a/test/val/cq9.c +++ b/test/val/cq9.c @@ -109,9 +109,9 @@ int s9(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s9(pd0); diff --git a/test/val/lz4.c b/test/val/lz4.c index dceefbfcc..6fe72e72d 100644 --- a/test/val/lz4.c +++ b/test/val/lz4.c @@ -660,10 +660,10 @@ static unsigned char buf[18830]; int main() { - unsigned long cksum = adler32(0, NULL, 0); + unsigned long cksum = adler32(0, NULL, 0); - decompress_lz4(compressed, buf, 18830); - cksum = adler32(cksum, buf, 18830); + decompress_lz4(compressed, buf, 18830); + cksum = adler32(cksum, buf, 18830); - return cksum == 0xf748269d ? 0 : 1; + return cksum == 0xf748269d ? 0 : 1; } diff --git a/test/val/nestfor.c b/test/val/nestfor.c index 735da21de..09f9d093d 100644 --- a/test/val/nestfor.c +++ b/test/val/nestfor.c @@ -21,10 +21,10 @@ unsigned char uchar1 = 0; void dput(unsigned char val) { - /*PORTB = val; - PORTA = 0x01; - PORTA = 0x00; - */ + /*PORTB = val; + PORTA = 0x01; + PORTA = 0x00; + */ } void done() @@ -35,104 +35,104 @@ void done() /* both loops use the loop variable inside the inner loop */ void for1(void) { - unsigned char i, j; - - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(i); - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + unsigned char i, j; + + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(i); + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* only the outer loop's variable is used inside, inner can be optimized into a repeat-loop */ void for2(void) { - unsigned char i, j; - - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(i); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + unsigned char i, j; + + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(i); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* only the inner loop's variable is used inside */ void for3(void) { - unsigned char i, j; - - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + unsigned char i, j; + + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* neither loop variable used inside the loops */ void for4(void) { - unsigned char i, j; - - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(uchar0); - dput(uchar1); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + unsigned char i, j; + + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(uchar0); + dput(uchar1); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* like for1 but different condition in inner loop */ void for5(void) { - unsigned char i, j; - - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 10; j >= 5; j--) { - uchar1++; - dput(i); - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 18) - failures++; + unsigned char i, j; + + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 10; j >= 5; j--) { + uchar1++; + dput(i); + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 18) + failures++; } int main(void) diff --git a/test/val/postincdec.c b/test/val/postincdec.c index 6d3e9593c..9a4f06183 100644 --- a/test/val/postincdec.c +++ b/test/val/postincdec.c @@ -10,14 +10,14 @@ static unsigned char val, array[2]; int main() { - val = 0; - array[0] = array[1] = 10; + val = 0; + array[0] = array[1] = 10; - array[val++] = 2; - array[val++] = 2; - --val; - array[val--] = 0; - array[val--] = 0; + array[val++] = 2; + array[val++] = 2; + --val; + array[val--] = 0; + array[val--] = 0; - return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; + return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; } diff --git a/test/val/ptrfunc.c b/test/val/ptrfunc.c index 55503e176..4aa23b77b 100644 --- a/test/val/ptrfunc.c +++ b/test/val/ptrfunc.c @@ -50,33 +50,33 @@ void done() void call0(void) { - uchar0++; + uchar0++; } void call1(void) { - uchar1++; + uchar1++; } unsigned char call2(void) { - return uchar0 + 9; + return uchar0 + 9; } void docall0(void) { - pfunc = call0; - (pfunc)(); - if(uchar0 != 1) - failures++; + pfunc = call0; + (pfunc)(); + if(uchar0 != 1) + failures++; } void docall1() { - unsigned char i; - for(i = 0; i < 3; i++) { - (*p1func)(); - } + unsigned char i; + for(i = 0; i < 3; i++) { + (*p1func)(); + } } #ifdef NO_IMPLICIT_FUNCPTR_CONV @@ -85,53 +85,53 @@ void docall2( void(*pf)(void) ) void docall2( void(*pf)() ) #endif { - unsigned char i; - for(i = 0; i < 2; i++) { - pf(); - } + unsigned char i; + for(i = 0; i < 2; i++) { + pf(); + } } int main(void) { docall0(); - p1func = call1; - docall1(); - if(uchar1 != 3) - failures++; - if(uchar0 != 1) - failures++; - - p1func = call0; - docall1(); - if(uchar1 != 3) - failures++; - if(uchar0 != 4) - failures++; - - docall2(call0); - if(uchar1 != 3) - failures++; - if(uchar0 != 6) - failures++; - - docall2(call1); - if(uchar1 != 5) - failures++; - if(uchar0 != 6) - failures++; - - pcfunc = call2; - uchar2 = (*pcfunc)(); - if(uchar2 != 15) - failures++; - - uchar2 += (pcfunc)(); - uchar2 += pcfunc(); - - success = failures; - done(); - printf("failures: %d\n",failures); - - return failures; + p1func = call1; + docall1(); + if(uchar1 != 3) + failures++; + if(uchar0 != 1) + failures++; + + p1func = call0; + docall1(); + if(uchar1 != 3) + failures++; + if(uchar0 != 4) + failures++; + + docall2(call0); + if(uchar1 != 3) + failures++; + if(uchar0 != 6) + failures++; + + docall2(call1); + if(uchar1 != 5) + failures++; + if(uchar0 != 6) + failures++; + + pcfunc = call2; + uchar2 = (*pcfunc)(); + if(uchar2 != 15) + failures++; + + uchar2 += (pcfunc)(); + uchar2 += pcfunc(); + + success = failures; + done(); + printf("failures: %d\n",failures); + + return failures; } diff --git a/test/val/trampoline-params.c b/test/val/trampoline-params.c index 890e43e5f..c05d8c06d 100644 --- a/test/val/trampoline-params.c +++ b/test/val/trampoline-params.c @@ -10,9 +10,9 @@ static unsigned char flag; static void trampoline_set() { - asm("ldy tmp4"); - asm("sty %v", flag); - asm("jsr callptr4"); + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); } #pragma wrapped-call(push, trampoline_set, 4) @@ -21,12 +21,12 @@ long adder(long in); long adder(long in) { - return in + 7; + return in + 7; } int main() { - flag = 0; + flag = 0; - return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; + return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; } diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c index d154a3da0..e2db839c8 100644 --- a/test/val/trampoline-varargs.c +++ b/test/val/trampoline-varargs.c @@ -10,14 +10,14 @@ static unsigned char flag; static void trampoline_set() { - // The Y register is used for variadics - save and restore - asm("sty tmp3"); + // The Y register is used for variadics - save and restore + asm("sty tmp3"); - asm("ldy tmp4"); - asm("sty %v", flag); + asm("ldy tmp4"); + asm("sty %v", flag); - asm("ldy tmp3"); - asm("jsr callptr4"); + asm("ldy tmp3"); + asm("jsr callptr4"); } #pragma wrapped-call(push, trampoline_set, 4) @@ -26,23 +26,23 @@ unsigned adder(unsigned char num, ...); unsigned adder(unsigned char num, ...) { - unsigned char i; - unsigned sum = 0; - va_list ap; - va_start(ap, num); + unsigned char i; + unsigned sum = 0; + va_list ap; + va_start(ap, num); - for (i = 0; i < num; i++) { - sum += va_arg(ap, unsigned); - } + for (i = 0; i < num; i++) { + sum += va_arg(ap, unsigned); + } - va_end(ap); + va_end(ap); - return sum; + return sum; } int main() { - flag = 0; + flag = 0; - return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; + return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; } diff --git a/test/val/trampoline.c b/test/val/trampoline.c index 63741b590..b2010f6f3 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -8,14 +8,14 @@ static unsigned char flag; static void trampoline_set() { - asm("ldy tmp4"); - asm("sty %v", flag); - asm("jsr callptr4"); + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); } void trampoline_inc() { - asm("inc %v", flag); - asm("jsr callptr4"); + asm("inc %v", flag); + asm("jsr callptr4"); } void func3() { @@ -25,7 +25,7 @@ void func3() { #pragma wrapped-call(push, trampoline_inc, 0) void func2() { - func3(); + func3(); } #pragma wrapped-call(push, trampoline_set, 4) @@ -36,14 +36,14 @@ void func1(void); #pragma wrapped-call(pop) void func1() { - func2(); + func2(); } int main(void) { - flag = 0; + flag = 0; - func1(); + func1(); - return flag == 5 ? 0 : 1; + return flag == 5 ? 0 : 1; } -- 2.39.5