From 60cf64612c1d0a94c15eed3243ef869356e81d79 Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 5 Feb 2013 13:22:36 +0100 Subject: tests2: move into tests --- tests2/00_assignment.c | 18 -- tests2/00_assignment.expect | 3 - tests2/01_comment.c | 14 - tests2/01_comment.expect | 5 - tests2/02_printf.c | 18 -- tests2/02_printf.expect | 15 - tests2/03_struct.c | 31 -- tests2/03_struct.expect | 6 - tests2/04_for.c | 15 - tests2/04_for.expect | 10 - tests2/05_array.c | 21 -- tests2/05_array.expect | 10 - tests2/06_case.c | 29 -- tests2/06_case.expect | 8 - tests2/07_function.c | 30 -- tests2/07_function.expect | 4 - tests2/08_while.c | 24 -- tests2/08_while.expect | 11 - tests2/09_do_while.c | 24 -- tests2/09_do_while.expect | 11 - tests2/10_pointer.c | 40 --- tests2/10_pointer.expect | 8 - tests2/11_precedence.c | 40 --- tests2/11_precedence.expect | 15 - tests2/12_hashdefine.c | 14 - tests2/12_hashdefine.expect | 2 - tests2/13_integer_literals.c | 20 -- tests2/13_integer_literals.expect | 5 - tests2/14_if.c | 21 -- tests2/14_if.expect | 2 - tests2/15_recursion.c | 21 -- tests2/15_recursion.expect | 10 - tests2/16_nesting.c | 21 -- tests2/16_nesting.expect | 18 -- tests2/17_enum.c | 29 -- tests2/17_enum.expect | 3 - tests2/18_include.c | 12 - tests2/18_include.expect | 3 - tests2/18_include.h | 1 - tests2/19_pointer_arithmetic.c | 28 -- tests2/19_pointer_arithmetic.expect | 3 - tests2/20_pointer_comparison.c | 24 -- tests2/20_pointer_comparison.expect | 6 - tests2/21_char_array.c | 33 -- tests2/21_char_array.expect | 7 - tests2/22_floating_point.c | 50 --- tests2/22_floating_point.expect | 16 - tests2/23_type_coercion.c | 54 ---- tests2/23_type_coercion.expect | 12 - tests2/24_math_library.c | 28 -- tests2/24_math_library.expect | 18 -- tests2/25_quicksort.c | 83 ----- tests2/25_quicksort.expect | 2 - tests2/26_character_constants.c | 17 - tests2/26_character_constants.expect | 8 - tests2/27_sizeof.c | 16 - tests2/27_sizeof.expect | 3 - tests2/28_strings.c | 46 --- tests2/28_strings.expect | 19 -- tests2/29_array_address.c | 13 - tests2/29_array_address.expect | 1 - tests2/30_hanoi.c | 122 -------- tests2/30_hanoi.expect | 71 ----- tests2/31_args.c | 14 - tests2/31_args.expect | 7 - tests2/32_led.c | 266 ---------------- tests2/32_led.expect | 4 - tests2/33_ternary_op.c | 15 - tests2/33_ternary_op.expect | 10 - tests2/34_array_assignment.c | 23 -- tests2/34_array_assignment.expect | 2 - tests2/35_sizeof.c | 14 - tests2/35_sizeof.expect | 2 - tests2/36_array_initialisers.c | 21 -- tests2/36_array_initialisers.expect | 20 -- tests2/37_sprintf.c | 17 - tests2/37_sprintf.expect | 20 -- tests2/38_multiple_array_index.c | 32 -- tests2/38_multiple_array_index.expect | 4 - tests2/39_typedef.c | 31 -- tests2/39_typedef.expect | 3 - tests2/40_stdio.c | 52 ---- tests2/40_stdio.expect | 27 -- tests2/41_hashif.c | 85 ----- tests2/41_hashif.expect | 6 - tests2/42_function_pointer.c | 18 -- tests2/42_function_pointer.expect | 2 - tests2/43_void_param.c | 15 - tests2/43_void_param.expect | 1 - tests2/44_scoped_declarations.c | 17 - tests2/44_scoped_declarations.expect | 1 - tests2/45_empty_for.c | 18 -- tests2/45_empty_for.expect | 10 - tests2/46_grep.c | 564 ---------------------------------- tests2/47_switch_return.c | 24 -- tests2/47_switch_return.expect | 4 - tests2/48_nested_break.c | 26 -- tests2/48_nested_break.expect | 1 - tests2/49_bracket_evaluation.c | 23 -- tests2/49_bracket_evaluation.expect | 1 - tests2/50_logical_second_arg.c | 29 -- tests2/50_logical_second_arg.expect | 20 -- tests2/51_static.c | 30 -- tests2/51_static.expect | 8 - tests2/52_unnamed_enum.c | 27 -- tests2/52_unnamed_enum.expect | 9 - tests2/54_goto.c | 56 ---- tests2/54_goto.expect | 8 - tests2/55_lshift_type.c | 52 ---- tests2/55_lshift_type.expect | 1 - tests2/LICENSE | 37 --- tests2/Makefile | 103 ------- 112 files changed, 3052 deletions(-) delete mode 100644 tests2/00_assignment.c delete mode 100644 tests2/00_assignment.expect delete mode 100644 tests2/01_comment.c delete mode 100644 tests2/01_comment.expect delete mode 100644 tests2/02_printf.c delete mode 100644 tests2/02_printf.expect delete mode 100644 tests2/03_struct.c delete mode 100644 tests2/03_struct.expect delete mode 100644 tests2/04_for.c delete mode 100644 tests2/04_for.expect delete mode 100644 tests2/05_array.c delete mode 100644 tests2/05_array.expect delete mode 100644 tests2/06_case.c delete mode 100644 tests2/06_case.expect delete mode 100644 tests2/07_function.c delete mode 100644 tests2/07_function.expect delete mode 100644 tests2/08_while.c delete mode 100644 tests2/08_while.expect delete mode 100644 tests2/09_do_while.c delete mode 100644 tests2/09_do_while.expect delete mode 100644 tests2/10_pointer.c delete mode 100644 tests2/10_pointer.expect delete mode 100644 tests2/11_precedence.c delete mode 100644 tests2/11_precedence.expect delete mode 100644 tests2/12_hashdefine.c delete mode 100644 tests2/12_hashdefine.expect delete mode 100644 tests2/13_integer_literals.c delete mode 100644 tests2/13_integer_literals.expect delete mode 100644 tests2/14_if.c delete mode 100644 tests2/14_if.expect delete mode 100644 tests2/15_recursion.c delete mode 100644 tests2/15_recursion.expect delete mode 100644 tests2/16_nesting.c delete mode 100644 tests2/16_nesting.expect delete mode 100644 tests2/17_enum.c delete mode 100644 tests2/17_enum.expect delete mode 100644 tests2/18_include.c delete mode 100644 tests2/18_include.expect delete mode 100644 tests2/18_include.h delete mode 100644 tests2/19_pointer_arithmetic.c delete mode 100644 tests2/19_pointer_arithmetic.expect delete mode 100644 tests2/20_pointer_comparison.c delete mode 100644 tests2/20_pointer_comparison.expect delete mode 100644 tests2/21_char_array.c delete mode 100644 tests2/21_char_array.expect delete mode 100644 tests2/22_floating_point.c delete mode 100644 tests2/22_floating_point.expect delete mode 100644 tests2/23_type_coercion.c delete mode 100644 tests2/23_type_coercion.expect delete mode 100644 tests2/24_math_library.c delete mode 100644 tests2/24_math_library.expect delete mode 100644 tests2/25_quicksort.c delete mode 100644 tests2/25_quicksort.expect delete mode 100644 tests2/26_character_constants.c delete mode 100644 tests2/26_character_constants.expect delete mode 100644 tests2/27_sizeof.c delete mode 100644 tests2/27_sizeof.expect delete mode 100644 tests2/28_strings.c delete mode 100644 tests2/28_strings.expect delete mode 100644 tests2/29_array_address.c delete mode 100644 tests2/29_array_address.expect delete mode 100644 tests2/30_hanoi.c delete mode 100644 tests2/30_hanoi.expect delete mode 100644 tests2/31_args.c delete mode 100644 tests2/31_args.expect delete mode 100644 tests2/32_led.c delete mode 100644 tests2/32_led.expect delete mode 100644 tests2/33_ternary_op.c delete mode 100644 tests2/33_ternary_op.expect delete mode 100644 tests2/34_array_assignment.c delete mode 100644 tests2/34_array_assignment.expect delete mode 100644 tests2/35_sizeof.c delete mode 100644 tests2/35_sizeof.expect delete mode 100644 tests2/36_array_initialisers.c delete mode 100644 tests2/36_array_initialisers.expect delete mode 100644 tests2/37_sprintf.c delete mode 100644 tests2/37_sprintf.expect delete mode 100644 tests2/38_multiple_array_index.c delete mode 100644 tests2/38_multiple_array_index.expect delete mode 100644 tests2/39_typedef.c delete mode 100644 tests2/39_typedef.expect delete mode 100644 tests2/40_stdio.c delete mode 100644 tests2/40_stdio.expect delete mode 100644 tests2/41_hashif.c delete mode 100644 tests2/41_hashif.expect delete mode 100644 tests2/42_function_pointer.c delete mode 100644 tests2/42_function_pointer.expect delete mode 100644 tests2/43_void_param.c delete mode 100644 tests2/43_void_param.expect delete mode 100644 tests2/44_scoped_declarations.c delete mode 100644 tests2/44_scoped_declarations.expect delete mode 100644 tests2/45_empty_for.c delete mode 100644 tests2/45_empty_for.expect delete mode 100644 tests2/46_grep.c delete mode 100644 tests2/47_switch_return.c delete mode 100644 tests2/47_switch_return.expect delete mode 100644 tests2/48_nested_break.c delete mode 100644 tests2/48_nested_break.expect delete mode 100644 tests2/49_bracket_evaluation.c delete mode 100644 tests2/49_bracket_evaluation.expect delete mode 100644 tests2/50_logical_second_arg.c delete mode 100644 tests2/50_logical_second_arg.expect delete mode 100644 tests2/51_static.c delete mode 100644 tests2/51_static.expect delete mode 100644 tests2/52_unnamed_enum.c delete mode 100644 tests2/52_unnamed_enum.expect delete mode 100644 tests2/54_goto.c delete mode 100644 tests2/54_goto.expect delete mode 100644 tests2/55_lshift_type.c delete mode 100644 tests2/55_lshift_type.expect delete mode 100644 tests2/LICENSE delete mode 100644 tests2/Makefile (limited to 'tests2') diff --git a/tests2/00_assignment.c b/tests2/00_assignment.c deleted file mode 100644 index c96109f..0000000 --- a/tests2/00_assignment.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int main() -{ - int a; - a = 42; - printf("%d\n", a); - - int b = 64; - printf("%d\n", b); - - int c = 12, d = 34; - printf("%d, %d\n", c, d); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/00_assignment.expect b/tests2/00_assignment.expect deleted file mode 100644 index d4407f3..0000000 --- a/tests2/00_assignment.expect +++ /dev/null @@ -1,3 +0,0 @@ -42 -64 -12, 34 diff --git a/tests2/01_comment.c b/tests2/01_comment.c deleted file mode 100644 index a2e6bc6..0000000 --- a/tests2/01_comment.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int main() -{ - printf("Hello\n"); - printf("Hello\n"); /* this is a comment */ printf("Hello\n"); - printf("Hello\n"); - // this is also a comment sayhello(); - printf("Hello\n"); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/01_comment.expect b/tests2/01_comment.expect deleted file mode 100644 index b1387ad..0000000 --- a/tests2/01_comment.expect +++ /dev/null @@ -1,5 +0,0 @@ -Hello -Hello -Hello -Hello -Hello diff --git a/tests2/02_printf.c b/tests2/02_printf.c deleted file mode 100644 index 4c34dd8..0000000 --- a/tests2/02_printf.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int main() -{ - printf("Hello world\n"); - - int Count; - for (Count = -5; Count <= 5; Count++) - printf("Count = %d\n", Count); - - printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there"); - printf("Character 'A' is '%c'\n", 65); - printf("Character 'a' is '%c'\n", 'a'); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/02_printf.expect b/tests2/02_printf.expect deleted file mode 100644 index f67a0f6..0000000 --- a/tests2/02_printf.expect +++ /dev/null @@ -1,15 +0,0 @@ -Hello world -Count = -5 -Count = -4 -Count = -3 -Count = -2 -Count = -1 -Count = 0 -Count = 1 -Count = 2 -Count = 3 -Count = 4 -Count = 5 -String 'hello', 'there' is 'hello', 'there' -Character 'A' is 'A' -Character 'a' is 'a' diff --git a/tests2/03_struct.c b/tests2/03_struct.c deleted file mode 100644 index df0d3e7..0000000 --- a/tests2/03_struct.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -struct fred -{ - int boris; - int natasha; -}; - -void main() -{ - struct fred bloggs; - - bloggs.boris = 12; - bloggs.natasha = 34; - - printf("%d\n", bloggs.boris); - printf("%d\n", bloggs.natasha); - - struct fred jones[2]; - jones[0].boris = 12; - jones[0].natasha = 34; - jones[1].boris = 56; - jones[1].natasha = 78; - - printf("%d\n", jones[0].boris); - printf("%d\n", jones[0].natasha); - printf("%d\n", jones[1].boris); - printf("%d\n", jones[1].natasha); - - return 0; -} diff --git a/tests2/03_struct.expect b/tests2/03_struct.expect deleted file mode 100644 index ecbf589..0000000 --- a/tests2/03_struct.expect +++ /dev/null @@ -1,6 +0,0 @@ -12 -34 -12 -34 -56 -78 diff --git a/tests2/04_for.c b/tests2/04_for.c deleted file mode 100644 index 312fed8..0000000 --- a/tests2/04_for.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int main() -{ - int Count; - - for (Count = 1; Count <= 10; Count++) - { - printf("%d\n", Count); - } - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/04_for.expect b/tests2/04_for.expect deleted file mode 100644 index f00c965..0000000 --- a/tests2/04_for.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/tests2/05_array.c b/tests2/05_array.c deleted file mode 100644 index c218f31..0000000 --- a/tests2/05_array.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int main() -{ - int Count; - int Array[10]; - - for (Count = 1; Count <= 10; Count++) - { - Array[Count-1] = Count * Count; - } - - for (Count = 0; Count < 10; Count++) - { - printf("%d\n", Array[Count]); - } - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/05_array.expect b/tests2/05_array.expect deleted file mode 100644 index bc7257c..0000000 --- a/tests2/05_array.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -4 -9 -16 -25 -36 -49 -64 -81 -100 diff --git a/tests2/06_case.c b/tests2/06_case.c deleted file mode 100644 index c0191e2..0000000 --- a/tests2/06_case.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -int main() -{ - int Count; - - for (Count = 0; Count < 4; Count++) - { - printf("%d\n", Count); - switch (Count) - { - case 1: - printf("%d\n", 1); - break; - - case 2: - printf("%d\n", 2); - break; - - default: - printf("%d\n", 0); - break; - } - } - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/06_case.expect b/tests2/06_case.expect deleted file mode 100644 index fab2c20..0000000 --- a/tests2/06_case.expect +++ /dev/null @@ -1,8 +0,0 @@ -0 -0 -1 -1 -2 -2 -3 -0 diff --git a/tests2/07_function.c b/tests2/07_function.c deleted file mode 100644 index 0477ce1..0000000 --- a/tests2/07_function.c +++ /dev/null @@ -1,30 +0,0 @@ -#include - -int myfunc(int x) -{ - return x * x; -} - -void vfunc(int a) -{ - printf("a=%d\n", a); -} - -void qfunc() -{ - printf("qfunc()\n"); -} - -int main() -{ - printf("%d\n", myfunc(3)); - printf("%d\n", myfunc(4)); - - vfunc(1234); - - qfunc(); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/07_function.expect b/tests2/07_function.expect deleted file mode 100644 index 8ffb0a7..0000000 --- a/tests2/07_function.expect +++ /dev/null @@ -1,4 +0,0 @@ -9 -16 -a=1234 -qfunc() diff --git a/tests2/08_while.c b/tests2/08_while.c deleted file mode 100644 index 602ffc7..0000000 --- a/tests2/08_while.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int main() -{ - int a; - int p; - int t; - - a = 1; - p = 0; - t = 0; - - while (a < 100) - { - printf("%d\n", a); - t = a; - a = t + p; - p = t; - } - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/08_while.expect b/tests2/08_while.expect deleted file mode 100644 index 702d4c0..0000000 --- a/tests2/08_while.expect +++ /dev/null @@ -1,11 +0,0 @@ -1 -1 -2 -3 -5 -8 -13 -21 -34 -55 -89 diff --git a/tests2/09_do_while.c b/tests2/09_do_while.c deleted file mode 100644 index 1d3315d..0000000 --- a/tests2/09_do_while.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int main() -{ - int a; - int p; - int t; - - a = 1; - p = 0; - t = 0; - - do - { - printf("%d\n", a); - t = a; - a = t + p; - p = t; - } while (a < 100); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/09_do_while.expect b/tests2/09_do_while.expect deleted file mode 100644 index 702d4c0..0000000 --- a/tests2/09_do_while.expect +++ /dev/null @@ -1,11 +0,0 @@ -1 -1 -2 -3 -5 -8 -13 -21 -34 -55 -89 diff --git a/tests2/10_pointer.c b/tests2/10_pointer.c deleted file mode 100644 index 0177f4d..0000000 --- a/tests2/10_pointer.c +++ /dev/null @@ -1,40 +0,0 @@ -#include - -struct ziggy -{ - int a; - int b; - int c; -} bolshevic; - -int main() -{ - int a; - int *b; - int c; - - a = 42; - b = &a; - printf("a = %d\n", *b); - - bolshevic.a = 12; - bolshevic.b = 34; - bolshevic.c = 56; - - printf("bolshevic.a = %d\n", bolshevic.a); - printf("bolshevic.b = %d\n", bolshevic.b); - printf("bolshevic.c = %d\n", bolshevic.c); - - struct ziggy *tsar = &bolshevic; - - printf("tsar->a = %d\n", tsar->a); - printf("tsar->b = %d\n", tsar->b); - printf("tsar->c = %d\n", tsar->c); - - b = &(bolshevic.b); - printf("bolshevic.b = %d\n", *b); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/10_pointer.expect b/tests2/10_pointer.expect deleted file mode 100644 index 1e3c473..0000000 --- a/tests2/10_pointer.expect +++ /dev/null @@ -1,8 +0,0 @@ -a = 42 -bolshevic.a = 12 -bolshevic.b = 34 -bolshevic.c = 56 -tsar->a = 12 -tsar->b = 34 -tsar->c = 56 -bolshevic.b = 34 diff --git a/tests2/11_precedence.c b/tests2/11_precedence.c deleted file mode 100644 index db2049d..0000000 --- a/tests2/11_precedence.c +++ /dev/null @@ -1,40 +0,0 @@ -#include - -int main() -{ - int a; - int b; - int c; - int d; - int e; - int f; - int x; - int y; - - a = 12; - b = 34; - c = 56; - d = 78; - e = 0; - f = 1; - - printf("%d\n", c + d); - printf("%d\n", (y = c + d)); - printf("%d\n", e || e && f); - printf("%d\n", e || f && f); - printf("%d\n", e && e || f); - printf("%d\n", e && f || f); - printf("%d\n", a && f | f); - printf("%d\n", a | b ^ c & d); - printf("%d, %d\n", a == a, a == b); - printf("%d, %d\n", a != a, a != b); - printf("%d\n", a != b && c != d); - printf("%d\n", a + b * c / f); - printf("%d\n", a + b * c / f); - printf("%d\n", (4 << 4)); - printf("%d\n", (64 >> 4)); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/11_precedence.expect b/tests2/11_precedence.expect deleted file mode 100644 index b692396..0000000 --- a/tests2/11_precedence.expect +++ /dev/null @@ -1,15 +0,0 @@ -134 -134 -0 -1 -1 -1 -1 -46 -1, 0 -0, 1 -1 -1916 -1916 -64 -4 diff --git a/tests2/12_hashdefine.c b/tests2/12_hashdefine.c deleted file mode 100644 index 5c521e0..0000000 --- a/tests2/12_hashdefine.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#define FRED 12 -#define BLOGGS(x) (12*(x)) - -int main() -{ - printf("%d\n", FRED); - printf("%d, %d, %d\n", BLOGGS(1), BLOGGS(2), BLOGGS(3)); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/12_hashdefine.expect b/tests2/12_hashdefine.expect deleted file mode 100644 index 99f2ed5..0000000 --- a/tests2/12_hashdefine.expect +++ /dev/null @@ -1,2 +0,0 @@ -12 -12, 24, 36 diff --git a/tests2/13_integer_literals.c b/tests2/13_integer_literals.c deleted file mode 100644 index 7cee98b..0000000 --- a/tests2/13_integer_literals.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -int main() -{ - int a = 24680; - int b = 01234567; - int c = 0x2468ac; - int d = 0x2468AC; - int e = 0b010101010101; - - printf("%d\n", a); - printf("%d\n", b); - printf("%d\n", c); - printf("%d\n", d); - printf("%d\n", e); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/13_integer_literals.expect b/tests2/13_integer_literals.expect deleted file mode 100644 index f5aca06..0000000 --- a/tests2/13_integer_literals.expect +++ /dev/null @@ -1,5 +0,0 @@ -24680 -342391 -2386092 -2386092 -1365 diff --git a/tests2/14_if.c b/tests2/14_if.c deleted file mode 100644 index 2bd2550..0000000 --- a/tests2/14_if.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int main() -{ - int a = 1; - - if (a) - printf("a is true\n"); - else - printf("a is false\n"); - - int b = 0; - if (b) - printf("b is true\n"); - else - printf("b is false\n"); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : diff --git a/tests2/14_if.expect b/tests2/14_if.expect deleted file mode 100644 index c32c415..0000000 --- a/tests2/14_if.expect +++ /dev/null @@ -1,2 +0,0 @@ -a is true -b is false diff --git a/tests2/15_recursion.c b/tests2/15_recursion.c deleted file mode 100644 index f79a00d..0000000 --- a/tests2/15_recursion.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int factorial(int i) -{ - if (i < 2) - return i; - else - return i * factorial(i - 1); -} - -int main() -{ - int Count; - - for (Count = 1; Count <= 10; Count++) - printf("%d\n", factorial(Count)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/15_recursion.expect b/tests2/15_recursion.expect deleted file mode 100644 index db47b28..0000000 --- a/tests2/15_recursion.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -6 -24 -120 -720 -5040 -40320 -362880 -3628800 diff --git a/tests2/16_nesting.c b/tests2/16_nesting.c deleted file mode 100644 index 2b72cc0..0000000 --- a/tests2/16_nesting.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int main() -{ - int x, y, z; - - for (x = 0; x < 2; x++) - { - for (y = 0; y < 3; y++) - { - for (z = 0; z < 3; z++) - { - printf("%d %d %d\n", x, y, z); - } - } - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/16_nesting.expect b/tests2/16_nesting.expect deleted file mode 100644 index 625ee13..0000000 --- a/tests2/16_nesting.expect +++ /dev/null @@ -1,18 +0,0 @@ -0 0 0 -0 0 1 -0 0 2 -0 1 0 -0 1 1 -0 1 2 -0 2 0 -0 2 1 -0 2 2 -1 0 0 -1 0 1 -1 0 2 -1 1 0 -1 1 1 -1 1 2 -1 2 0 -1 2 1 -1 2 2 diff --git a/tests2/17_enum.c b/tests2/17_enum.c deleted file mode 100644 index 0853c42..0000000 --- a/tests2/17_enum.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -enum fred -{ - a, - b, - c, - d, - e = 54, - f = 73, - g, - h -}; - -int main() -{ - enum fred frod; - - printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h); - /* printf("%d\n", frod); */ - frod = 12; - printf("%d\n", frod); - frod = e; - printf("%d\n", frod); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/17_enum.expect b/tests2/17_enum.expect deleted file mode 100644 index bef4be6..0000000 --- a/tests2/17_enum.expect +++ /dev/null @@ -1,3 +0,0 @@ -0 1 2 3 54 73 74 75 -12 -54 diff --git a/tests2/18_include.c b/tests2/18_include.c deleted file mode 100644 index dbae3aa..0000000 --- a/tests2/18_include.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -int main() -{ - printf("including\n"); -#include "18_include.h" - printf("done\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/18_include.expect b/tests2/18_include.expect deleted file mode 100644 index 87729df..0000000 --- a/tests2/18_include.expect +++ /dev/null @@ -1,3 +0,0 @@ -including -included -done diff --git a/tests2/18_include.h b/tests2/18_include.h deleted file mode 100644 index 01f894d..0000000 --- a/tests2/18_include.h +++ /dev/null @@ -1 +0,0 @@ -printf("included\n"); diff --git a/tests2/19_pointer_arithmetic.c b/tests2/19_pointer_arithmetic.c deleted file mode 100644 index aff65e5..0000000 --- a/tests2/19_pointer_arithmetic.c +++ /dev/null @@ -1,28 +0,0 @@ -#include - -int main() -{ - int a; - int *b; - int *c; - - a = 42; - b = &a; - c = NULL; - - printf("%d\n", *b); - - if (b == NULL) - printf("b is NULL\n"); - else - printf("b is not NULL\n"); - - if (c == NULL) - printf("c is NULL\n"); - else - printf("c is not NULL\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/19_pointer_arithmetic.expect b/tests2/19_pointer_arithmetic.expect deleted file mode 100644 index 0cf781b..0000000 --- a/tests2/19_pointer_arithmetic.expect +++ /dev/null @@ -1,3 +0,0 @@ -42 -b is not NULL -c is NULL diff --git a/tests2/20_pointer_comparison.c b/tests2/20_pointer_comparison.c deleted file mode 100644 index 825f778..0000000 --- a/tests2/20_pointer_comparison.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int main() -{ - int a; - int b; - int *d; - int *e; - d = &a; - e = &b; - a = 12; - b = 34; - printf("%d\n", *d); - printf("%d\n", *e); - printf("%d\n", d == e); - printf("%d\n", d != e); - d = e; - printf("%d\n", d == e); - printf("%d\n", d != e); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/20_pointer_comparison.expect b/tests2/20_pointer_comparison.expect deleted file mode 100644 index 5d1e5f5..0000000 --- a/tests2/20_pointer_comparison.expect +++ /dev/null @@ -1,6 +0,0 @@ -12 -34 -0 -1 -1 -0 diff --git a/tests2/21_char_array.c b/tests2/21_char_array.c deleted file mode 100644 index f22f527..0000000 --- a/tests2/21_char_array.c +++ /dev/null @@ -1,33 +0,0 @@ -#include - -int main() -{ - int x = 'a'; - char y = x; - - char *a = "hello"; - - printf("%s\n", a); - - int c; - c = *a; - - char *b; - for (b = a; *b != 0; b++) - printf("%c: %d\n", *b, *b); - - char destarray[10]; - char *dest = &destarray[0]; - char *src = a; - - while (*src != 0) - *dest++ = *src++; - - *dest = 0; - - printf("copied string is %s\n", destarray); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/21_char_array.expect b/tests2/21_char_array.expect deleted file mode 100644 index dbc6068..0000000 --- a/tests2/21_char_array.expect +++ /dev/null @@ -1,7 +0,0 @@ -hello -h: 104 -e: 101 -l: 108 -l: 108 -o: 111 -copied string is hello diff --git a/tests2/22_floating_point.c b/tests2/22_floating_point.c deleted file mode 100644 index e3491f5..0000000 --- a/tests2/22_floating_point.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include - -int main() -{ - // variables - float a = 12.34 + 56.78; - printf("%f\n", a); - - // infix operators - printf("%f\n", 12.34 + 56.78); - printf("%f\n", 12.34 - 56.78); - printf("%f\n", 12.34 * 56.78); - printf("%f\n", 12.34 / 56.78); - - // comparison operators - printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78); - printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34); - printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34); - - // assignment operators - a = 12.34; - a += 56.78; - printf("%f\n", a); - - a = 12.34; - a -= 56.78; - printf("%f\n", a); - - a = 12.34; - a *= 56.78; - printf("%f\n", a); - - a = 12.34; - a /= 56.78; - printf("%f\n", a); - - // prefix operators - printf("%f\n", +12.34); - printf("%f\n", -12.34); - - // type coercion - a = 2; - printf("%f\n", a); - printf("%f\n", sin(2)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/22_floating_point.expect b/tests2/22_floating_point.expect deleted file mode 100644 index 75ea3a7..0000000 --- a/tests2/22_floating_point.expect +++ /dev/null @@ -1,16 +0,0 @@ -69.120003 -69.120000 --44.440000 -700.665200 -0.217330 -1 1 0 0 0 1 -0 1 1 1 0 0 -0 0 0 1 1 1 -69.120003 --44.439999 -700.665222 -0.217330 -12.340000 --12.340000 -2.000000 -0.909297 diff --git a/tests2/23_type_coercion.c b/tests2/23_type_coercion.c deleted file mode 100644 index 1fcc335..0000000 --- a/tests2/23_type_coercion.c +++ /dev/null @@ -1,54 +0,0 @@ -#include - -void charfunc(char a) -{ - printf("char: %c\n", a); -} - -void intfunc(int a) -{ - printf("int: %d\n", a); -} - -void floatfunc(float a) -{ - printf("float: %f\n", a); -} - -int main() -{ - charfunc('a'); - charfunc(98); - charfunc(99.0); - - intfunc('a'); - intfunc(98); - intfunc(99.0); - - floatfunc('a'); - floatfunc(98); - floatfunc(99.0); - - /* printf("%c %d %f\n", 'a', 'b', 'c'); */ - /* printf("%c %d %f\n", 97, 98, 99); */ - /* printf("%c %d %f\n", 97.0, 98.0, 99.0); */ - - char b = 97; - char c = 97.0; - - printf("%d %d\n", b, c); - - int d = 'a'; - int e = 97.0; - - printf("%d %d\n", d, e); - - float f = 'a'; - float g = 97; - - printf("%f %f\n", f, g); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/23_type_coercion.expect b/tests2/23_type_coercion.expect deleted file mode 100644 index d9076f0..0000000 --- a/tests2/23_type_coercion.expect +++ /dev/null @@ -1,12 +0,0 @@ -char: a -char: b -char: c -int: 97 -int: 98 -int: 99 -float: 97.000000 -float: 98.000000 -float: 99.000000 -97 97 -97 97 -97.000000 97.000000 diff --git a/tests2/24_math_library.c b/tests2/24_math_library.c deleted file mode 100644 index 4cc3d9e..0000000 --- a/tests2/24_math_library.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -int main() -{ - printf("%f\n", sin(0.12)); - printf("%f\n", cos(0.12)); - printf("%f\n", tan(0.12)); - printf("%f\n", asin(0.12)); - printf("%f\n", acos(0.12)); - printf("%f\n", atan(0.12)); - printf("%f\n", sinh(0.12)); - printf("%f\n", cosh(0.12)); - printf("%f\n", tanh(0.12)); - printf("%f\n", exp(0.12)); - printf("%f\n", fabs(-0.12)); - printf("%f\n", log(0.12)); - printf("%f\n", log10(0.12)); - printf("%f\n", pow(0.12, 0.12)); - printf("%f\n", sqrt(0.12)); - printf("%f\n", round(12.34)); - printf("%f\n", ceil(12.34)); - printf("%f\n", floor(12.34)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/24_math_library.expect b/tests2/24_math_library.expect deleted file mode 100644 index 99f7299..0000000 --- a/tests2/24_math_library.expect +++ /dev/null @@ -1,18 +0,0 @@ -0.119712 -0.992809 -0.120579 -0.120290 -1.450506 -0.119429 -0.120288 -1.007209 -0.119427 -1.127497 -0.120000 --2.120264 --0.920819 -0.775357 -0.346410 -12.000000 -13.000000 -12.000000 diff --git a/tests2/25_quicksort.c b/tests2/25_quicksort.c deleted file mode 100644 index 5cc08bd..0000000 --- a/tests2/25_quicksort.c +++ /dev/null @@ -1,83 +0,0 @@ -#include - -int array[16]; - -//Swap integer values by array indexes -void swap(int a, int b) -{ - int tmp = array[a]; - array[a] = array[b]; - array[b] = tmp; -} - -//Partition the array into two halves and return the -//index about which the array is partitioned -int partition(int left, int right) -{ - int pivotIndex = left; - int pivotValue = array[pivotIndex]; - int index = left; - int i; - - swap(pivotIndex, right); - for(i = left; i < right; i++) - { - if(array[i] < pivotValue) - { - swap(i, index); - index += 1; - } - } - swap(right, index); - - return index; -} - -//Quicksort the array -void quicksort(int left, int right) -{ - if(left >= right) - return; - - int index = partition(left, right); - quicksort(left, index - 1); - quicksort(index + 1, right); -} - -int main() -{ - int i; - - array[0] = 62; - array[1] = 83; - array[2] = 4; - array[3] = 89; - array[4] = 36; - array[5] = 21; - array[6] = 74; - array[7] = 37; - array[8] = 65; - array[9] = 33; - array[10] = 96; - array[11] = 38; - array[12] = 53; - array[13] = 16; - array[14] = 74; - array[15] = 55; - - for (i = 0; i < 16; i++) - printf("%d ", array[i]); - - printf("\n"); - - quicksort(0, 15); - - for (i = 0; i < 16; i++) - printf("%d ", array[i]); - - printf("\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/25_quicksort.expect b/tests2/25_quicksort.expect deleted file mode 100644 index 2d39cd3..0000000 --- a/tests2/25_quicksort.expect +++ /dev/null @@ -1,2 +0,0 @@ -62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55 -4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96 diff --git a/tests2/26_character_constants.c b/tests2/26_character_constants.c deleted file mode 100644 index 95c4423..0000000 --- a/tests2/26_character_constants.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() -{ - printf("%d\n", '\1'); - printf("%d\n", '\10'); - printf("%d\n", '\100'); - printf("%d\n", '\x01'); - printf("%d\n", '\x0e'); - printf("%d\n", '\x10'); - printf("%d\n", '\x40'); - printf("test \x40\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/26_character_constants.expect b/tests2/26_character_constants.expect deleted file mode 100644 index 8f8bfa4..0000000 --- a/tests2/26_character_constants.expect +++ /dev/null @@ -1,8 +0,0 @@ -1 -8 -64 -1 -14 -16 -64 -test @ diff --git a/tests2/27_sizeof.c b/tests2/27_sizeof.c deleted file mode 100644 index d1694b6..0000000 --- a/tests2/27_sizeof.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int main() -{ - char a; - int b; - double c; - - printf("%d\n", sizeof(a)); - printf("%d\n", sizeof(b)); - printf("%d\n", sizeof(c)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/27_sizeof.expect b/tests2/27_sizeof.expect deleted file mode 100644 index 7329e00..0000000 --- a/tests2/27_sizeof.expect +++ /dev/null @@ -1,3 +0,0 @@ -1 -4 -8 diff --git a/tests2/28_strings.c b/tests2/28_strings.c deleted file mode 100644 index 115fe09..0000000 --- a/tests2/28_strings.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include - -int main() -{ - char a[10]; - - strcpy(a, "hello"); - printf("%s\n", a); - - strncpy(a, "gosh", 2); - printf("%s\n", a); - - printf("%d\n", strcmp(a, "apple") > 0); - printf("%d\n", strcmp(a, "goere") > 0); - printf("%d\n", strcmp(a, "zebra") < 0); - - printf("%d\n", strlen(a)); - - strcat(a, "!"); - printf("%s\n", a); - - printf("%d\n", strncmp(a, "apple", 2) > 0); - printf("%d\n", strncmp(a, "goere", 2) == 0); - printf("%d\n", strncmp(a, "goerg", 2) == 0); - printf("%d\n", strncmp(a, "zebra", 2) < 0); - - printf("%s\n", index(a, 'o')); - printf("%s\n", rindex(a, 'l')); - printf("%d\n", rindex(a, 'x') == NULL); - - memset(&a[1], 'r', 4); - printf("%s\n", a); - - memcpy(&a[2], a, 2); - printf("%s\n", a); - - printf("%d\n", memcmp(a, "apple", 4) > 0); - printf("%d\n", memcmp(a, "grgr", 4) == 0); - printf("%d\n", memcmp(a, "zebra", 4) < 0); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/28_strings.expect b/tests2/28_strings.expect deleted file mode 100644 index fd9217a..0000000 --- a/tests2/28_strings.expect +++ /dev/null @@ -1,19 +0,0 @@ -hello -gollo -1 -1 -1 -5 -gollo! -1 -1 -1 -1 -ollo! -lo! -1 -grrrr! -grgrr! -1 -1 -1 diff --git a/tests2/29_array_address.c b/tests2/29_array_address.c deleted file mode 100644 index bda5ddd..0000000 --- a/tests2/29_array_address.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -int main() -{ - char a[10]; - strcpy(a, "abcdef"); - printf("%s\n", &a[1]); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/29_array_address.expect b/tests2/29_array_address.expect deleted file mode 100644 index 9bc8683..0000000 --- a/tests2/29_array_address.expect +++ /dev/null @@ -1 +0,0 @@ -bcdef diff --git a/tests2/30_hanoi.c b/tests2/30_hanoi.c deleted file mode 100644 index b1a1181..0000000 --- a/tests2/30_hanoi.c +++ /dev/null @@ -1,122 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/hanoi.c */ - -/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */ -/* By Terry R. McConnell (12/2/97) */ -/* Compile: cc -o hanoi hanoi.c */ - -/* This program does no error checking. But then, if it's right, - it's right ... right ? */ - - -/* The original towers of hanoi problem seems to have been originally posed - by one M. Claus in 1883. There is a popular legend that goes along with - it that has been often repeated and paraphrased. It goes something like this: - In the great temple at Benares there are 3 golden spikes. On one of them, - God placed 64 disks increasing in size from bottom to top, at the beginning - of time. Since then, and to this day, the priest on duty constantly transfers - disks, one at a time, in such a way that no larger disk is ever put on top - of a smaller one. When the disks have been transferred entirely to another - spike the Universe will come to an end in a large thunderclap. - - This paraphrases the original legend due to DeParville, La Nature, Paris 1884, - Part I, 285-286. For this and further information see: Mathematical - Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967, - 303-305. - * - * - */ - -#include -#include - -#define TRUE 1 -#define FALSE 0 - -/* This is the number of "disks" on tower A initially. Taken to be 64 in the - * legend. The number of moves required, in general, is 2^N - 1. For N = 64, - * this is 18,446,744,073,709,551,615 */ -#define N 4 - -/* These are the three towers. For example if the state of A is 0,1,3,4, that - * means that there are three discs on A of sizes 1, 3, and 4. (Think of right - * as being the "down" direction.) */ -int A[N], B[N], C[N]; - -void Hanoi(int,int*,int*,int*); - -/* Print the current configuration of A, B, and C to the screen */ -void PrintAll() -{ - int i; - - printf("A: "); - for(i=0;i - -int main(int argc, char **argv) -{ - int Count; - - printf("hello world %d\n", argc); - for (Count = 0; Count < argc; Count++) - printf("arg %d: %s\n", Count, argv[Count]); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/31_args.expect b/tests2/31_args.expect deleted file mode 100644 index c392b67..0000000 --- a/tests2/31_args.expect +++ /dev/null @@ -1,7 +0,0 @@ -hello world 6 -arg 0: 31_args.c -arg 1: - -arg 2: arg1 -arg 3: arg2 -arg 4: arg3 -arg 5: arg4 diff --git a/tests2/32_led.c b/tests2/32_led.c deleted file mode 100644 index 5596cbf..0000000 --- a/tests2/32_led.c +++ /dev/null @@ -1,266 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/led.c */ - -/* led.c: print out number as if on 7 line led display. I.e., write integer - given on command line like this: - _ _ _ - | _| _| |_| |_ - | |_ _| | _| etc. - - We assume the terminal behaves like a classical teletype. So the top - lines of all digits have to be printed first, then the middle lines of - all digits, etc. - - By Terry R. McConnell - -compile: cc -o led led.c - -If you just want to link in the subroutine print_led that does all the -work, compile with -DNO_MAIN, and declare the following in any source file -that uses the call: - -extern void print_led(unsigned long x, char *buf); - -Bug: you cannot call repeatedly to print more than one number to a line. -That would require curses or some other terminal API that allows moving the -cursor to a previous line. - -*/ - - - -#include -#include - -#define MAX_DIGITS 32 -#define NO_MAIN - - -/* Print the top line of the digit d into buffer. - Does not null terminate buffer. */ - -void topline(int d, char *p){ - - *p++ = ' '; - switch(d){ - - /* all these have _ on top line */ - - case 0: - case 2: - case 3: - case 5: - case 7: - case 8: - case 9: - *p++ = '_'; - break; - default: - *p++=' '; - - } - *p++=' '; -} - -/* Print the middle line of the digit d into the buffer. - Does not null terminate. */ - -void midline(int d, char *p){ - - switch(d){ - - /* those that have leading | on middle line */ - - case 0: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on middle line */ - - case 2: - case 3: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on middle line */ - - case 0: - case 1: - case 2: - case 3: - case 4: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Print the bottom line of the digit d. Does not null terminate. */ - -void botline(int d, char *p){ - - - switch(d){ - - /* those that have leading | on bottom line */ - - case 0: - case 2: - case 6: - case 8: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on bottom line */ - - case 0: - case 2: - case 3: - case 5: - case 6: - case 8: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on bottom line */ - - case 0: - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Write the led representation of integer to string buffer. */ - -void print_led(unsigned long x, char *buf) -{ - - int i=0,n; - static int d[MAX_DIGITS]; - - - /* extract digits from x */ - - n = ( x == 0L ? 1 : 0 ); /* 0 is a digit, hence a special case */ - - while(x){ - d[n++] = (int)(x%10L); - if(n >= MAX_DIGITS)break; - x = x/10L; - } - - /* print top lines of all digits */ - - for(i=n-1;i>=0;i--){ - topline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; /* move teletype to next line */ - - /* print middle lines of all digits */ - - for(i=n-1;i>=0;i--){ - midline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - - /* print bottom lines of all digits */ - - for(i=n-1;i>=0;i--){ - botline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - *buf='\0'; -} - -int main() -{ - char buf[5*MAX_DIGITS]; - print_led(1234567, buf); - printf("%s\n",buf); - - return 0; -} - -#ifndef NO_MAIN -int main(int argc, char **argv) -{ - - int i=0,n; - long x; - static int d[MAX_DIGITS]; - char buf[5*MAX_DIGITS]; - - if(argc != 2){ - fprintf(stderr,"led: usage: led integer\n"); - return 1; - } - - /* fetch argument from command line */ - - x = atol(argv[1]); - - /* sanity check */ - - if(x<0){ - fprintf(stderr,"led: %d must be non-negative\n",x); - return 1; - } - - print_led(x,buf); - printf("%s\n",buf); - - return 0; - -} -#endif - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/32_led.expect b/tests2/32_led.expect deleted file mode 100644 index c53b58a..0000000 --- a/tests2/32_led.expect +++ /dev/null @@ -1,4 +0,0 @@ - _ _ _ _ - | _| _| |_| |_ |_ | - | |_ _| | _| |_| | - diff --git a/tests2/33_ternary_op.c b/tests2/33_ternary_op.c deleted file mode 100644 index 8579b50..0000000 --- a/tests2/33_ternary_op.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int main() -{ - int Count; - - for (Count = 0; Count < 10; Count++) - { - printf("%d\n", (Count < 5) ? (Count*Count) : (Count * 3)); - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/33_ternary_op.expect b/tests2/33_ternary_op.expect deleted file mode 100644 index 45ea507..0000000 --- a/tests2/33_ternary_op.expect +++ /dev/null @@ -1,10 +0,0 @@ -0 -1 -4 -9 -16 -15 -18 -21 -24 -27 diff --git a/tests2/34_array_assignment.c b/tests2/34_array_assignment.c deleted file mode 100644 index 5885c97..0000000 --- a/tests2/34_array_assignment.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -int main() -{ - int a[4]; - - a[0] = 12; - a[1] = 23; - a[2] = 34; - a[3] = 45; - - printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]); - - int b[4]; - - b = a; - - printf("%d %d %d %d\n", b[0], b[1], b[2], b[3]); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/34_array_assignment.expect b/tests2/34_array_assignment.expect deleted file mode 100644 index 9736bf5..0000000 --- a/tests2/34_array_assignment.expect +++ /dev/null @@ -1,2 +0,0 @@ -12 23 34 45 -12 23 34 45 diff --git a/tests2/35_sizeof.c b/tests2/35_sizeof.c deleted file mode 100644 index 672e87e..0000000 --- a/tests2/35_sizeof.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int main() -{ - char a; - short b; - - printf("%d %d\n", sizeof(char), sizeof(a)); - printf("%d %d\n", sizeof(short), sizeof(b)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/35_sizeof.expect b/tests2/35_sizeof.expect deleted file mode 100644 index 534fb83..0000000 --- a/tests2/35_sizeof.expect +++ /dev/null @@ -1,2 +0,0 @@ -1 1 -2 2 diff --git a/tests2/36_array_initialisers.c b/tests2/36_array_initialisers.c deleted file mode 100644 index 1bc8ee0..0000000 --- a/tests2/36_array_initialisers.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int main() -{ - int Count; - - int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 }; - - for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array[Count]); - - int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, }; - - for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array2[Count]); - - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/36_array_initialisers.expect b/tests2/36_array_initialisers.expect deleted file mode 100644 index 3ac6c77..0000000 --- a/tests2/36_array_initialisers.expect +++ /dev/null @@ -1,20 +0,0 @@ -0: 12 -1: 34 -2: 56 -3: 78 -4: 90 -5: 123 -6: 456 -7: 789 -8: 8642 -9: 9753 -0: 12 -1: 34 -2: 56 -3: 78 -4: 90 -5: 123 -6: 456 -7: 789 -8: 8642 -9: 9753 diff --git a/tests2/37_sprintf.c b/tests2/37_sprintf.c deleted file mode 100644 index 1dd1dce..0000000 --- a/tests2/37_sprintf.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() -{ - char Buf[100]; - int Count; - - for (Count = 1; Count <= 20; Count++) - { - sprintf(Buf, "->%02d<-\n", Count); - printf("%s", Buf); - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/37_sprintf.expect b/tests2/37_sprintf.expect deleted file mode 100644 index a643da8..0000000 --- a/tests2/37_sprintf.expect +++ /dev/null @@ -1,20 +0,0 @@ -->01<- -->02<- -->03<- -->04<- -->05<- -->06<- -->07<- -->08<- -->09<- -->10<- -->11<- -->12<- -->13<- -->14<- -->15<- -->16<- -->17<- -->18<- -->19<- -->20<- diff --git a/tests2/38_multiple_array_index.c b/tests2/38_multiple_array_index.c deleted file mode 100644 index 4e1868e..0000000 --- a/tests2/38_multiple_array_index.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -int main() -{ - int a[4][4]; - int b = 0; - int x; - int y; - - for (x = 0; x < 4; x++) - { - for (y = 0; y < 4; y++) - { - b++; - a[x][y] = b; - } - } - - for (x = 0; x < 4; x++) - { - printf("x=%d: ", x); - for (y = 0; y < 4; y++) - { - printf("%d ", a[x][y]); - } - printf("\n"); - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/38_multiple_array_index.expect b/tests2/38_multiple_array_index.expect deleted file mode 100644 index 747ad75..0000000 --- a/tests2/38_multiple_array_index.expect +++ /dev/null @@ -1,4 +0,0 @@ -x=0: 1 2 3 4 -x=1: 5 6 7 8 -x=2: 9 10 11 12 -x=3: 13 14 15 16 diff --git a/tests2/39_typedef.c b/tests2/39_typedef.c deleted file mode 100644 index 79ab58b..0000000 --- a/tests2/39_typedef.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -typedef int MyInt; - -struct FunStruct -{ - int i; - int j; -}; - -typedef struct FunStruct MyFunStruct; - -typedef MyFunStruct *MoreFunThanEver; - -int main() -{ - MyInt a = 1; - printf("%d\n", a); - - MyFunStruct b; - b.i = 12; - b.j = 34; - printf("%d,%d\n", b.i, b.j); - - MoreFunThanEver c = &b; - printf("%d,%d\n", c->i, c->j); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/39_typedef.expect b/tests2/39_typedef.expect deleted file mode 100644 index b9050a9..0000000 --- a/tests2/39_typedef.expect +++ /dev/null @@ -1,3 +0,0 @@ -1 -12,34 -12,34 diff --git a/tests2/40_stdio.c b/tests2/40_stdio.c deleted file mode 100644 index b986093..0000000 --- a/tests2/40_stdio.c +++ /dev/null @@ -1,52 +0,0 @@ -#include - -int main() -{ - FILE *f = fopen("fred.txt", "w"); - fwrite("hello\nhello\n", 1, 12, f); - fclose(f); - - char freddy[7]; - f = fopen("fred.txt", "r"); - if (fread(freddy, 1, 6, f) != 6) - printf("couldn't read fred.txt\n"); - - freddy[6] = '\0'; - fclose(f); - - printf("%s", freddy); - - int InChar; - char ShowChar; - f = fopen("fred.txt", "r"); - while ( (InChar = fgetc(f)) != EOF) - { - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); - } - fclose(f); - - f = fopen("fred.txt", "r"); - while ( (InChar = getc(f)) != EOF) - { - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); - } - fclose(f); - - f = fopen("fred.txt", "r"); - while (fgets(freddy, sizeof(freddy), f) != NULL) - printf("x: %s", freddy); - - fclose(f); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/40_stdio.expect b/tests2/40_stdio.expect deleted file mode 100644 index e08167a..0000000 --- a/tests2/40_stdio.expect +++ /dev/null @@ -1,27 +0,0 @@ -hello -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -x: hello -x: hello diff --git a/tests2/41_hashif.c b/tests2/41_hashif.c deleted file mode 100644 index cb37b9e..0000000 --- a/tests2/41_hashif.c +++ /dev/null @@ -1,85 +0,0 @@ -#include - -int main() -{ - printf("#include test\n"); - -#if 1 -#if 0 - printf("a\n"); -#else - printf("b\n"); -#endif -#else -#if 0 - printf("c\n"); -#else - printf("d\n"); -#endif -#endif - -#if 0 -#if 1 - printf("e\n"); -#else - printf("f\n"); -#endif -#else -#if 1 - printf("g\n"); -#else - printf("h\n"); -#endif -#endif - -#define DEF - -#ifdef DEF -#ifdef DEF - printf("i\n"); -#else - printf("j\n"); -#endif -#else -#ifdef DEF - printf("k\n"); -#else - printf("l\n"); -#endif -#endif - -#ifndef DEF -#ifndef DEF - printf("m\n"); -#else - printf("n\n"); -#endif -#else -#ifndef DEF - printf("o\n"); -#else - printf("p\n"); -#endif -#endif - -#define ONE 1 -#define ZERO 0 - -#if ONE -#if ZERO - printf("q\n"); -#else - printf("r\n"); -#endif -#else -#if ZERO - printf("s\n"); -#else - printf("t\n"); -#endif -#endif - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/41_hashif.expect b/tests2/41_hashif.expect deleted file mode 100644 index 5fd414b..0000000 --- a/tests2/41_hashif.expect +++ /dev/null @@ -1,6 +0,0 @@ -#include test -b -g -i -p -r diff --git a/tests2/42_function_pointer.c b/tests2/42_function_pointer.c deleted file mode 100644 index 49c331b..0000000 --- a/tests2/42_function_pointer.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int fred(int p) -{ - printf("yo %d\n", p); - return 42; -} - -int (*f)(int) = &fred; - -int main() -{ - printf("%d\n", (*f)(24)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/42_function_pointer.expect b/tests2/42_function_pointer.expect deleted file mode 100644 index 6c8b6ce..0000000 --- a/tests2/42_function_pointer.expect +++ /dev/null @@ -1,2 +0,0 @@ -yo 24 -42 diff --git a/tests2/43_void_param.c b/tests2/43_void_param.c deleted file mode 100644 index de17098..0000000 --- a/tests2/43_void_param.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -void fred(void) -{ - printf("yo\n"); -} - -int main() -{ - fred(); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/43_void_param.expect b/tests2/43_void_param.expect deleted file mode 100644 index 092bfb9..0000000 --- a/tests2/43_void_param.expect +++ /dev/null @@ -1 +0,0 @@ -yo diff --git a/tests2/44_scoped_declarations.c b/tests2/44_scoped_declarations.c deleted file mode 100644 index 2febf98..0000000 --- a/tests2/44_scoped_declarations.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() -{ - int a; - - for (a = 0; a < 2; a++) - { - int b = a; - } - - printf("it's all good\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/44_scoped_declarations.expect b/tests2/44_scoped_declarations.expect deleted file mode 100644 index 231ccc0..0000000 --- a/tests2/44_scoped_declarations.expect +++ /dev/null @@ -1 +0,0 @@ -it's all good diff --git a/tests2/45_empty_for.c b/tests2/45_empty_for.c deleted file mode 100644 index b14e9d4..0000000 --- a/tests2/45_empty_for.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int main() -{ - int Count = 0; - - for (;;) - { - Count++; - printf("%d\n", Count); - if (Count >= 10) - break; - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/45_empty_for.expect b/tests2/45_empty_for.expect deleted file mode 100644 index f00c965..0000000 --- a/tests2/45_empty_for.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/tests2/46_grep.c b/tests2/46_grep.c deleted file mode 100644 index 5f52220..0000000 --- a/tests2/46_grep.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * The information in this document is subject to change - * without notice and should not be construed as a commitment - * by Digital Equipment Corporation or by DECUS. - * - * Neither Digital Equipment Corporation, DECUS, nor the authors - * assume any responsibility for the use or reliability of this - * document or the described software. - * - * Copyright (C) 1980, DECUS - * - * General permission to copy or modify, but not for profit, is - * hereby granted, provided that the above copyright notice is - * included and reference made to the fact that reproduction - * privileges were granted by DECUS. - */ -#include - -/* - * grep - * - * Runs on the Decus compiler or on vms, On vms, define as: - * grep :== "$disk:[account]grep" (native) - * grep :== "$disk:[account]grep grep" (Decus) - * See below for more information. - */ - -#if 0 -char *documentation[] = { - "grep searches a file for a given pattern. Execute by", - " grep [flags] regular_expression file_list\n", - "Flags are single characters preceeded by '-':", - " -c Only a count of matching lines is printed", - " -f Print file name for matching lines switch, see below", - " -n Each line is preceeded by its line number", - " -v Only print non-matching lines\n", - "The file_list is a list of files (wildcards are acceptable on RSX modes).", - "\nThe file name is normally printed if there is a file given.", - "The -f flag reverses this action (print name no file, not if more).\n", - 0 }; - -char *patdoc[] = { - "The regular_expression defines the pattern to search for. Upper- and", - "lower-case are always ignored. Blank lines never match. The expression", - "should be quoted to prevent file-name translation.", - "x An ordinary character (not mentioned below) matches that character.", - "'\\' The backslash quotes any character. \"\\$\" matches a dollar-sign.", - "'^' A circumflex at the beginning of an expression matches the", - " beginning of a line.", - "'$' A dollar-sign at the end of an expression matches the end of a line.", - "'.' A period matches any character except \"new-line\".", - "':a' A colon matches a class of characters described by the following", - "':d' character. \":a\" matches any alphabetic, \":d\" matches digits,", - "':n' \":n\" matches alphanumerics, \": \" matches spaces, tabs, and", - "': ' other control characters, such as new-line.", - "'*' An expression followed by an asterisk matches zero or more", - " occurrances of that expression: \"fo*\" matches \"f\", \"fo\"", - " \"foo\", etc.", - "'+' An expression followed by a plus sign matches one or more", - " occurrances of that expression: \"fo+\" matches \"fo\", etc.", - "'-' An expression followed by a minus sign optionally matches", - " the expression.", - "'[]' A string enclosed in square brackets matches any character in", - " that string, but no others. If the first character in the", - " string is a circumflex, the expression matches any character", - " except \"new-line\" and the characters in the string. For", - " example, \"[xyz]\" matches \"xx\" and \"zyx\", while \"[^xyz]\"", - " matches \"abc\" but not \"axb\". A range of characters may be", - " specified by two characters separated by \"-\". Note that,", - " [a-z] matches alphabetics, while [z-a] never matches.", - "The concatenation of regular expressions is a regular expression.", - 0}; -#endif - -#define LMAX 512 -#define PMAX 256 - -#define CHAR 1 -#define BOL 2 -#define EOL 3 -#define ANY 4 -#define CLASS 5 -#define NCLASS 6 -#define STAR 7 -#define PLUS 8 -#define MINUS 9 -#define ALPHA 10 -#define DIGIT 11 -#define NALPHA 12 -#define PUNCT 13 -#define RANGE 14 -#define ENDPAT 15 - -int cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0; - -char *pp, lbuf[LMAX], pbuf[PMAX]; - -char *cclass(); -char *pmatch(); - - -/*** Display a file name *******************************/ -void file(char *s) -{ - printf("File %s:\n", s); -} - -/*** Report unopenable file ****************************/ -void cant(char *s) -{ - fprintf(stderr, "%s: cannot open\n", s); -} - -/*** Give good help ************************************/ -void help(char **hp) -{ - char **dp; - - for (dp = hp; *dp; ++dp) - printf("%s\n", *dp); -} - -/*** Display usage summary *****************************/ -void usage(char *s) -{ - fprintf(stderr, "?GREP-E-%s\n", s); - fprintf(stderr, - "Usage: grep [-cfnv] pattern [file ...]. grep ? for help\n"); - exit(1); -} - -/*** Compile the pattern into global pbuf[] ************/ -void compile(char *source) -{ - char *s; /* Source string pointer */ - char *lp; /* Last pattern pointer */ - int c; /* Current character */ - int o; /* Temp */ - char *spp; /* Save beginning of pattern */ - - s = source; - if (debug) - printf("Pattern = \"%s\"\n", s); - pp = pbuf; - while (c = *s++) { - /* - * STAR, PLUS and MINUS are special. - */ - if (c == '*' || c == '+' || c == '-') { - if (pp == pbuf || - (o=pp[-1]) == BOL || - o == EOL || - o == STAR || - o == PLUS || - o == MINUS) - badpat("Illegal occurrance op.", source, s); - store(ENDPAT); - store(ENDPAT); - spp = pp; /* Save pattern end */ - while (--pp > lp) /* Move pattern down */ - *pp = pp[-1]; /* one byte */ - *pp = (c == '*') ? STAR : - (c == '-') ? MINUS : PLUS; - pp = spp; /* Restore pattern end */ - continue; - } - /* - * All the rest. - */ - lp = pp; /* Remember start */ - switch(c) { - - case '^': - store(BOL); - break; - - case '$': - store(EOL); - break; - - case '.': - store(ANY); - break; - - case '[': - s = cclass(source, s); - break; - - case ':': - if (*s) { - switch(tolower(c = *s++)) { - - case 'a': - case 'A': - store(ALPHA); - break; - - case 'd': - case 'D': - store(DIGIT); - break; - - case 'n': - case 'N': - store(NALPHA); - break; - - case ' ': - store(PUNCT); - break; - - default: - badpat("Unknown : type", source, s); - - } - break; - } - else badpat("No : type", source, s); - - case '\\': - if (*s) - c = *s++; - - default: - store(CHAR); - store(tolower(c)); - } - } - store(ENDPAT); - store(0); /* Terminate string */ - if (debug) { - for (lp = pbuf; lp < pp;) { - if ((c = (*lp++ & 0377)) < ' ') - printf("\\%o ", c); - else printf("%c ", c); - } - printf("\n"); - } -} - -/*** Compile a class (within []) ***********************/ -char *cclass(char *source, char *src) - /* char *source; // Pattern start -- for error msg. */ - /* char *src; // Class start */ -{ - char *s; /* Source pointer */ - char *cp; /* Pattern start */ - int c; /* Current character */ - int o; /* Temp */ - - s = src; - o = CLASS; - if (*s == '^') { - ++s; - o = NCLASS; - } - store(o); - cp = pp; - store(0); /* Byte count */ - while ((c = *s++) && c!=']') { - if (c == '\\') { /* Store quoted char */ - if ((c = *s++) == '\0') /* Gotta get something */ - badpat("Class terminates badly", source, s); - else store(tolower(c)); - } - else if (c == '-' && - (pp - cp) > 1 && *s != ']' && *s != '\0') { - c = pp[-1]; /* Range start */ - pp[-1] = RANGE; /* Range signal */ - store(c); /* Re-store start */ - c = *s++; /* Get end char and*/ - store(tolower(c)); /* Store it */ - } - else { - store(tolower(c)); /* Store normal char */ - } - } - if (c != ']') - badpat("Unterminated class", source, s); - if ((c = (pp - cp)) >= 256) - badpat("Class too large", source, s); - if (c == 0) - badpat("Empty class", source, s); - *cp = c; - return(s); -} - -/*** Store an entry in the pattern buffer **************/ -void store(int op) -{ - if (pp >= &pbuf[PMAX]) - error("Pattern too complex\n"); - *pp++ = op; -} - -/*** Report a bad pattern specification ****************/ -void badpat(char *message, char *source, char *stop) - /* char *message; // Error message */ - /* char *source; // Pattern start */ - /* char *stop; // Pattern end */ -{ - fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); - fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", - stop-source, stop[-1]); - error("?GREP-E-Bad pattern\n"); -} - -/*** Scan the file for the pattern in pbuf[] ***********/ -void grep(FILE *fp, char *fn) - /* FILE *fp; // File to process */ - /* char *fn; // File name (for -f option) */ -{ - int lno, count, m; - - lno = 0; - count = 0; - while (fgets(lbuf, LMAX, fp)) { - ++lno; - m = match(); - if ((m && !vflag) || (!m && vflag)) { - ++count; - if (!cflag) { - if (fflag && fn) { - file(fn); - fn = 0; - } - if (nflag) - printf("%d\t", lno); - printf("%s\n", lbuf); - } - } - } - if (cflag) { - if (fflag && fn) - file(fn); - printf("%d\n", count); - } -} - -/*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ -void match() -{ - char *l; /* Line pointer */ - - for (l = lbuf; *l; ++l) { - if (pmatch(l, pbuf)) - return(1); - } - return(0); -} - -/*** Match partial line with pattern *******************/ -char *pmatch(char *line, char *pattern) - /* char *line; // (partial) line to match */ - /* char *pattern; // (partial) pattern to match */ -{ - char *l; /* Current line pointer */ - char *p; /* Current pattern pointer */ - char c; /* Current character */ - char *e; /* End for STAR and PLUS match */ - int op; /* Pattern operation */ - int n; /* Class counter */ - char *are; /* Start of STAR match */ - - l = line; - if (debug > 1) - printf("pmatch(\"%s\")\n", line); - p = pattern; - while ((op = *p++) != ENDPAT) { - if (debug > 1) - printf("byte[%d] = 0%o, '%c', op = 0%o\n", - l-line, *l, *l, op); - switch(op) { - - case CHAR: - if (tolower(*l++) != *p++) - return(0); - break; - - case BOL: - if (l != lbuf) - return(0); - break; - - case EOL: - if (*l != '\0') - return(0); - break; - - case ANY: - if (*l++ == '\0') - return(0); - break; - - case DIGIT: - if ((c = *l++) < '0' || (c > '9')) - return(0); - break; - - case ALPHA: - c = tolower(*l++); - if (c < 'a' || c > 'z') - return(0); - break; - - case NALPHA: - c = tolower(*l++); - if (c >= 'a' && c <= 'z') - break; - else if (c < '0' || c > '9') - return(0); - break; - - case PUNCT: - c = *l++; - if (c == 0 || c > ' ') - return(0); - break; - - case CLASS: - case NCLASS: - c = tolower(*l++); - n = *p++ & 0377; - do { - if (*p == RANGE) { - p += 3; - n -= 2; - if (c >= p[-2] && c <= p[-1]) - break; - } - else if (c == *p++) - break; - } while (--n > 1); - if ((op == CLASS) == (n <= 1)) - return(0); - if (op == CLASS) - p += n - 2; - break; - - case MINUS: - e = pmatch(l, p); /* Look for a match */ - while (*p++ != ENDPAT); /* Skip over pattern */ - if (e) /* Got a match? */ - l = e; /* Yes, update string */ - break; /* Always succeeds */ - - case PLUS: /* One or more ... */ - if ((l = pmatch(l, p)) == 0) - return(0); /* Gotta have a match */ - case STAR: /* Zero or more ... */ - are = l; /* Remember line start */ - while (*l && (e = pmatch(l, p))) - l = e; /* Get longest match */ - while (*p++ != ENDPAT); /* Skip over pattern */ - while (l >= are) { /* Try to match rest */ - if (e = pmatch(l, p)) - return(e); - --l; /* Nope, try earlier */ - } - return(0); /* Nothing else worked */ - - default: - printf("Bad op code %d\n", op); - error("Cannot happen -- match\n"); - } - } - return(l); -} - -/*** Report an error ***********************************/ -void error(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -/*** Main program - parse arguments & grep *************/ -int main(int argc, char **argv) -{ - char *p; - int c, i; - int gotpattern; - - FILE *f; - - if (argc <= 1) - usage("No arguments"); - if (argc == 2 && argv[1][0] == '?' && argv[1][1] == 0) { - help(documentation); - help(patdoc); - return 0; - } - nfile = argc-1; - gotpattern = 0; - for (i=1; i < argc; ++i) { - p = argv[i]; - if (*p == '-') { - ++p; - while (c = *p++) { - switch(tolower(c)) { - - case '?': - help(documentation); - break; - - case 'C': - case 'c': - ++cflag; - break; - - case 'D': - case 'd': - ++debug; - break; - - case 'F': - case 'f': - ++fflag; - break; - - case 'n': - case 'N': - ++nflag; - break; - - case 'v': - case 'V': - ++vflag; - break; - - default: - usage("Unknown flag"); - } - } - argv[i] = 0; - --nfile; - } else if (!gotpattern) { - compile(p); - argv[i] = 0; - ++gotpattern; - --nfile; - } - } - if (!gotpattern) - usage("No pattern"); - if (nfile == 0) - grep(stdin, 0); - else { - fflag = fflag ^ (nfile > 0); - for (i=1; i < argc; ++i) { - if (p = argv[i]) { - if ((f=fopen(p, "r")) == NULL) - cant(p); - else { - grep(f, p); - fclose(f); - } - } - } - } - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/47_switch_return.c b/tests2/47_switch_return.c deleted file mode 100644 index 1ec7924..0000000 --- a/tests2/47_switch_return.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -void fred(int x) -{ - switch (x) - { - case 1: printf("1\n"); return; - case 2: printf("2\n"); break; - case 3: printf("3\n"); return; - } - - printf("out\n"); -} - -int main() -{ - fred(1); - fred(2); - fred(3); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/47_switch_return.expect b/tests2/47_switch_return.expect deleted file mode 100644 index b6deb7e..0000000 --- a/tests2/47_switch_return.expect +++ /dev/null @@ -1,4 +0,0 @@ -1 -2 -out -3 diff --git a/tests2/48_nested_break.c b/tests2/48_nested_break.c deleted file mode 100644 index 5bc5ba4..0000000 --- a/tests2/48_nested_break.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -int main() -{ - int a; - char b; - - a = 0; - while (a < 2) - { - printf("%d", a++); - break; - - b = 'A'; - while (b < 'C') - { - printf("%c", b++); - } - printf("e"); - } - printf("\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/48_nested_break.expect b/tests2/48_nested_break.expect deleted file mode 100644 index 573541a..0000000 --- a/tests2/48_nested_break.expect +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests2/49_bracket_evaluation.c b/tests2/49_bracket_evaluation.c deleted file mode 100644 index 0cbe57d..0000000 --- a/tests2/49_bracket_evaluation.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -struct point -{ - double x; - double y; -}; - -struct point point_array[100]; - -int main() -{ - int my_point = 10; - - point_array[my_point].x = 12.34; - point_array[my_point].y = 56.78; - - printf("%f, %f\n", point_array[my_point].x, point_array[my_point].y); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/49_bracket_evaluation.expect b/tests2/49_bracket_evaluation.expect deleted file mode 100644 index 1da66db..0000000 --- a/tests2/49_bracket_evaluation.expect +++ /dev/null @@ -1 +0,0 @@ -12.340000, 56.780000 diff --git a/tests2/50_logical_second_arg.c b/tests2/50_logical_second_arg.c deleted file mode 100644 index 5fa0bb9..0000000 --- a/tests2/50_logical_second_arg.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -int fred() -{ - printf("fred\n"); - return 0; -} - -int joe() -{ - printf("joe\n"); - return 1; -} - -int main() -{ - printf("%d\n", fred() && joe()); - printf("%d\n", fred() || joe()); - printf("%d\n", joe() && fred()); - printf("%d\n", joe() || fred()); - printf("%d\n", fred() && (1 + joe())); - printf("%d\n", fred() || (0 + joe())); - printf("%d\n", joe() && (0 + fred())); - printf("%d\n", joe() || (1 + fred())); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/50_logical_second_arg.expect b/tests2/50_logical_second_arg.expect deleted file mode 100644 index d6174ae..0000000 --- a/tests2/50_logical_second_arg.expect +++ /dev/null @@ -1,20 +0,0 @@ -fred -0 -fred -joe -1 -joe -fred -0 -joe -1 -fred -0 -fred -joe -1 -joe -fred -0 -joe -1 diff --git a/tests2/51_static.c b/tests2/51_static.c deleted file mode 100644 index d6c0917..0000000 --- a/tests2/51_static.c +++ /dev/null @@ -1,30 +0,0 @@ -#include - -static int fred = 1234; -static int joe; - -void henry() -{ - static int fred = 4567; - - printf("%d\n", fred); - fred++; -} - -int main() -{ - printf("%d\n", fred); - henry(); - henry(); - henry(); - henry(); - printf("%d\n", fred); - fred = 8901; - joe = 2345; - printf("%d\n", fred); - printf("%d\n", joe); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/51_static.expect b/tests2/51_static.expect deleted file mode 100644 index 18224fa..0000000 --- a/tests2/51_static.expect +++ /dev/null @@ -1,8 +0,0 @@ -1234 -4567 -4568 -4569 -4570 -1234 -8901 -2345 diff --git a/tests2/52_unnamed_enum.c b/tests2/52_unnamed_enum.c deleted file mode 100644 index d0395b2..0000000 --- a/tests2/52_unnamed_enum.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -enum fred { a, b, c }; - -int main() -{ - printf("a=%d\n", a); - printf("b=%d\n", b); - printf("c=%d\n", c); - - enum fred d; - - typedef enum { e, f, g } h; - typedef enum { i, j, k } m; - - printf("e=%d\n", e); - printf("f=%d\n", f); - printf("g=%d\n", g); - - printf("i=%d\n", i); - printf("j=%d\n", j); - printf("k=%d\n", k); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/52_unnamed_enum.expect b/tests2/52_unnamed_enum.expect deleted file mode 100644 index 84f2ac8..0000000 --- a/tests2/52_unnamed_enum.expect +++ /dev/null @@ -1,9 +0,0 @@ -a=0 -b=1 -c=2 -e=0 -f=1 -g=2 -i=0 -j=1 -k=2 diff --git a/tests2/54_goto.c b/tests2/54_goto.c deleted file mode 100644 index 9509e83..0000000 --- a/tests2/54_goto.c +++ /dev/null @@ -1,56 +0,0 @@ -#include - -void fred() -{ - printf("In fred()\n"); - goto done; - printf("In middle\n"); -done: - printf("At end\n"); -} - -void joe() -{ - int b = 5678; - - printf("In joe()\n"); - - { - int c = 1234; - printf("c = %d\n", c); - goto outer; - printf("uh-oh\n"); - } - -outer: - - printf("done\n"); -} - -void henry() -{ - int a; - - printf("In henry()\n"); - goto inner; - - { - int b; -inner: - b = 1234; - printf("b = %d\n", b); - } - - printf("done\n"); -} - -int main() -{ - fred(); - joe(); - henry(); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests2/54_goto.expect b/tests2/54_goto.expect deleted file mode 100644 index 8e553fa..0000000 --- a/tests2/54_goto.expect +++ /dev/null @@ -1,8 +0,0 @@ -In fred() -At end -In joe() -c = 1234 -done -In henry() -b = 1234 -done diff --git a/tests2/55_lshift_type.c b/tests2/55_lshift_type.c deleted file mode 100644 index aa3e51a..0000000 --- a/tests2/55_lshift_type.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $ - -Tests on left-shift type, written by Vincent Lefevre . - -ISO C99 TC3 says: [6.5.7#3] "The integer promotions are performed on -each of the operands. The type of the result is that of the promoted -left operand." -*/ - -#include - -#define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0) -#define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1)) -#define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0) -#define TEST2(X) \ - do \ - { \ - TEST1((X),short); \ - TEST1((X),int); \ - TEST1((X),long); \ - TEST1((X),long long); \ - } \ - while (0) -#define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0) -#define TEST4(X) \ - do \ - { \ - TEST3((X),short); \ - TEST3((X),int); \ - TEST3((X),long); \ - TEST3((X),long long); \ - } \ - while (0) - -static int debug, nfailed = 0; - -static void check (const char *s, int arg1, int shift) -{ - int failed = arg1 != shift; - if (debug || failed) - printf ("%s %d %d\n", s, arg1, shift); - nfailed += failed; -} - -int main (int argc, char **argv) -{ - debug = argc > 1; - TEST4(1); - TEST4(-1); - printf ("%d test(s) failed\n", nfailed); - return nfailed != 0; -} diff --git a/tests2/55_lshift_type.expect b/tests2/55_lshift_type.expect deleted file mode 100644 index 8523767..0000000 --- a/tests2/55_lshift_type.expect +++ /dev/null @@ -1 +0,0 @@ -0 test(s) failed diff --git a/tests2/LICENSE b/tests2/LICENSE deleted file mode 100644 index b08a652..0000000 --- a/tests2/LICENSE +++ /dev/null @@ -1,37 +0,0 @@ -The tests in this directory are either directly copied from the picoc project or -are subsequently modified and added to for the purpose of TinyCC project. All -these modifications are licensed under the same terms as TinyCC as specified in -the file COPYING. - -=== picoc license === - -Copyright (c) 2009-2011, Zik Saleeba -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the name of the Zik Saleeba nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests2/Makefile b/tests2/Makefile deleted file mode 100644 index d328ce7..0000000 --- a/tests2/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -TOP = .. -include $(TOP)/Makefile -VPATH = $(top_srcdir)/tests2 - -ifeq ($(TARGETOS),Darwin) - CFLAGS+=-Wl,-flat_namespace,-undefined,warning - TCCFLAGS=-D_ANSI_SOURCE - export MACOSX_DEPLOYMENT_TARGET:=10.2 -endif - -ifdef CONFIG_WIN32 - TCCFLAGS=-I $(TOP)/win32/include -L$(TOP) -endif - -TESTS= 00_assignment.test \ - 01_comment.test \ - 02_printf.test \ - 03_struct.test \ - 04_for.test \ - 05_array.test \ - 06_case.test \ - 07_function.test \ - 08_while.test \ - 09_do_while.test \ - 10_pointer.test \ - 11_precedence.test \ - 12_hashdefine.test \ - 13_integer_literals.test \ - 14_if.test \ - 15_recursion.test \ - 16_nesting.test \ - 17_enum.test \ - 18_include.test \ - 19_pointer_arithmetic.test \ - 20_pointer_comparison.test \ - 21_char_array.test \ - 22_floating_point.test \ - 23_type_coercion.test \ - 24_math_library.test \ - 25_quicksort.test \ - 26_character_constants.test \ - 27_sizeof.test \ - 28_strings.test \ - 29_array_address.test \ - 31_args.test \ - 32_led.test \ - 33_ternary_op.test \ - 35_sizeof.test \ - 36_array_initialisers.test \ - 37_sprintf.test \ - 38_multiple_array_index.test \ - 39_typedef.test \ - 40_stdio.test \ - 41_hashif.test \ - 42_function_pointer.test \ - 43_void_param.test \ - 44_scoped_declarations.test \ - 45_empty_for.test \ - 47_switch_return.test \ - 48_nested_break.test \ - 49_bracket_evaluation.test \ - 50_logical_second_arg.test \ - 51_static.test \ - 52_unnamed_enum.test \ - 54_goto.test \ - 55_lshift_type.test - - # 30_hanoi.test \ # seg fault in the code, gcc as well - # 34_array_assignment.test \ # array assignment is not in C standard - # 46_grep.test \ # does not compile even with gcc - -# some tests do not pass on all platforms, remove them for now -ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out 40_stdio.test,$(TESTS)) -endif -ifdef CONFIG_WIN32 - TESTS := $(filter-out 24_math_library.test,$(TESTS)) - TESTS := $(filter-out 28_strings.test,$(TESTS)) -endif - -%.test: %.c %.expect - @echo Test: $*... - @if [ "x`echo $* | grep args`" != "x" ]; \ - then \ - ../tcc -B.. $(TCCFLAGS) -run $< - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ - else \ - ../tcc -B.. $(TCCFLAGS) -run $< 2>&1 >$*.output; \ - fi - @if diff -bu $(<:.c=.expect) $*.output ; \ - then \ - rm -f $*.output \ - else \ - echo "ERROR: test $*"; \ - fi - -all: test - -test: $(TESTS) - -# vim: set expandtab ts=4 sw=4 sts=4 tw=80 : - -clean: - rm -vf fred.txt -- cgit v1.3.1