diff options
Diffstat (limited to 'patches')
-rwxr-xr-x | patches/eowyn.sh | 27 | ||||
-rwxr-xr-x | patches/gollum.sh | 23 | ||||
-rw-r--r-- | patches/patches/001_hello.patch (renamed from patches/patches/01_hello.patch) | 0 | ||||
-rw-r--r-- | patches/patches/002_std.patch (renamed from patches/patches/02_std.patch) | 0 | ||||
-rw-r--r-- | patches/patches/003_assignment.patch (renamed from patches/patches/03_assignment.patch) | 0 | ||||
-rw-r--r-- | patches/patches/004_arrays.patch (renamed from patches/patches/04_arrays.patch) | 0 | ||||
-rw-r--r-- | patches/patches/005_arrays2.patch (renamed from patches/patches/05_arrays2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/006_strings.patch (renamed from patches/patches/06_strings.patch) | 0 | ||||
-rw-r--r-- | patches/patches/007_strings2.patch (renamed from patches/patches/07_strings2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/008_quiz.patch (renamed from patches/patches/08_quiz.patch) | 0 | ||||
-rw-r--r-- | patches/patches/009_if.patch (renamed from patches/patches/09_if.patch) | 0 | ||||
-rw-r--r-- | patches/patches/010_if2.patch (renamed from patches/patches/10_if2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/011_while.patch (renamed from patches/patches/11_while.patch) | 0 | ||||
-rw-r--r-- | patches/patches/012_while2.patch (renamed from patches/patches/12_while2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/013_while3.patch (renamed from patches/patches/13_while3.patch) | 0 | ||||
-rw-r--r-- | patches/patches/014_while4.patch (renamed from patches/patches/14_while4.patch) | 0 | ||||
-rw-r--r-- | patches/patches/015_for.patch (renamed from patches/patches/15_for.patch) | 0 | ||||
-rw-r--r-- | patches/patches/016_for2.patch (renamed from patches/patches/16_for2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/017_quiz2.patch (renamed from patches/patches/17_quiz2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/018_functions.patch (renamed from patches/patches/18_functions.patch) | 0 | ||||
-rw-r--r-- | patches/patches/019_functions2.patch (renamed from patches/patches/19_functions2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/020_quiz3.patch (renamed from patches/patches/20_quiz3.patch) | 0 | ||||
-rw-r--r-- | patches/patches/021_errors.patch (renamed from patches/patches/21_errors.patch) | 0 | ||||
-rw-r--r-- | patches/patches/022_errors2.patch (renamed from patches/patches/22_errors2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/023_errors3.patch (renamed from patches/patches/23_errors3.patch) | 0 | ||||
-rw-r--r-- | patches/patches/024_errors4.patch (renamed from patches/patches/24_errors4.patch) | 0 | ||||
-rw-r--r-- | patches/patches/025_errors5.patch (renamed from patches/patches/25_errors5.patch) | 0 | ||||
-rw-r--r-- | patches/patches/026_hello2.patch (renamed from patches/patches/26_hello2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/027_defer.patch (renamed from patches/patches/27_defer.patch) | 0 | ||||
-rw-r--r-- | patches/patches/028_defer2.patch (renamed from patches/patches/28_defer2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/029_errdefer.patch (renamed from patches/patches/29_errdefer.patch) | 0 | ||||
-rw-r--r-- | patches/patches/030_switch.patch (renamed from patches/patches/30_switch.patch) | 0 | ||||
-rw-r--r-- | patches/patches/031_switch2.patch (renamed from patches/patches/31_switch2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/032_unreachable.patch (renamed from patches/patches/32_unreachable.patch) | 0 | ||||
-rw-r--r-- | patches/patches/033_iferror.patch (renamed from patches/patches/33_iferror.patch) | 0 | ||||
-rw-r--r-- | patches/patches/034_quiz4.patch (renamed from patches/patches/34_quiz4.patch) | 0 | ||||
-rw-r--r-- | patches/patches/035_enums.patch (renamed from patches/patches/35_enums.patch) | 0 | ||||
-rw-r--r-- | patches/patches/036_enums2.patch (renamed from patches/patches/36_enums2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/037_structs.patch (renamed from patches/patches/37_structs.patch) | 0 | ||||
-rw-r--r-- | patches/patches/038_structs2.patch (renamed from patches/patches/38_structs2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/039_pointers.patch (renamed from patches/patches/39_pointers.patch) | 0 | ||||
-rw-r--r-- | patches/patches/040_pointers2.patch (renamed from patches/patches/40_pointers2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/041_pointers3.patch (renamed from patches/patches/41_pointers3.patch) | 0 | ||||
-rw-r--r-- | patches/patches/042_pointers4.patch (renamed from patches/patches/42_pointers4.patch) | 0 | ||||
-rw-r--r-- | patches/patches/043_pointers5.patch (renamed from patches/patches/43_pointers5.patch) | 0 | ||||
-rw-r--r-- | patches/patches/044_quiz5.patch (renamed from patches/patches/44_quiz5.patch) | 0 | ||||
-rw-r--r-- | patches/patches/045_optionals.patch (renamed from patches/patches/45_optionals.patch) | 0 | ||||
-rw-r--r-- | patches/patches/046_optionals2.patch (renamed from patches/patches/46_optionals2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/047_methods.patch (renamed from patches/patches/47_methods.patch) | 0 | ||||
-rw-r--r-- | patches/patches/048_methods2.patch (renamed from patches/patches/48_methods2.patch) | 0 | ||||
-rw-r--r-- | patches/patches/049_quiz6.patch (renamed from patches/patches/49_quiz6.patch) | 0 | ||||
-rw-r--r-- | patches/patches/050_no_value.patch (renamed from patches/patches/50_no_value.patch) | 0 | ||||
-rw-r--r-- | patches/patches/051_values.patch (renamed from patches/patches/51_values.patch) | 0 | ||||
-rw-r--r-- | patches/patches/052_slices.patch | 10 | ||||
-rw-r--r-- | patches/patches/053_slices2.patch | 20 | ||||
-rw-r--r-- | patches/patches/054_manypointers.patch | 4 | ||||
-rw-r--r-- | patches/patches/055_unions.patch | 6 | ||||
-rw-r--r-- | patches/patches/056_unions2.patch | 10 | ||||
-rw-r--r-- | patches/patches/057_unions3.patch | 4 |
59 files changed, 81 insertions, 23 deletions
diff --git a/patches/eowyn.sh b/patches/eowyn.sh index 1bb8385..a30a67a 100755 --- a/patches/eowyn.sh +++ b/patches/eowyn.sh @@ -13,35 +13,34 @@ # to convalesce in the healed directory. # -# We run from the patches dir. Go there now if not already. -cd $(dirname $0) -pwd # Show it upon the screen so all shall be made apparent. +# We check ourselves before we wreck ourselves. +if [ ! -f 'patches/eowyn.sh' ] +then + echo "But I must be run from the project root directory." + exit 1 +fi -# Create healed/ directory here if it doesn't already exist. -mkdir -p healed +# Create directory of healing if it doesn't already exist. +mkdir -p patches/healed # Cycle through all the little broken Zig applications. -for broken in ../exercises/*.zig +for broken in exercises/*.zig do # Remove the dir and extension, rendering the True Name. true_name=$(basename $broken .zig) - patch_name="patches/$true_name.patch" + patch_name="patches/patches/$true_name.patch" - if [[ -f $patch_name ]] + if [ -f $patch_name ] then # Apply the bandages to the wounds, grow new limbs, let # new life spring into the broken bodies of the fallen. echo Healing $true_name... - patch --output=healed/$true_name.zig $broken $patch_name + patch --output=patches/healed/$true_name.zig $broken $patch_name else - echo Cannot heal $true_name. Making empty patch. - echo > $patch_name + echo Cannot heal $true_name. No patch found. fi done -# Return to the home of our ancestors. -cd .. - # Test the healed exercises. May the compiler have mercy upon us. zig build -Dhealed diff --git a/patches/gollum.sh b/patches/gollum.sh index 6531044..495aa44 100755 --- a/patches/gollum.sh +++ b/patches/gollum.sh @@ -6,18 +6,23 @@ # Gollum, The Hobbit, or There and Back Again # -cd $(dirname $(realpath $0)) -f=$(basename ../exercises/$1*.zig .zig 2> /dev/null) -b=../exercises/$f.zig -a=../answers/$f.zig -p=patches/$f.patch +if [ ! -f 'patches/gollum.sh' ] +then + echo "We must be run from the project root dir, precious!"; exit 1 +fi -printf "\tf: '$f'\n\tb: '$b'\n\ta: '$a'\n" +ex=$(printf "%03d" $1) +echo "Nassssty exercise $ex..." -if [[ ! -f $b ]]; then echo "We hates it!"; exit 1; fi -if [[ ! -a $a ]]; then echo "Where is it? Where is the answer, precious?"; exit; fi +f=$(basename exercises/${ex}_*.zig .zig 2> /dev/null) +b=exercises/$f.zig +a=answers/$f.zig +p=patches/patches/$f.patch -echo Hisssss! +if [ ! -f $b ]; then echo "No $f! We hates it!"; exit 1; fi +if [ ! -f $a ]; then echo "No $a! Where is it? Where is the answer, precious?"; exit; fi + +echo "Hissss!\tbefore: '$b'\n\t after: '$a'\n\t patch: '$p'\n" diff $b $a > $p diff --git a/patches/patches/01_hello.patch b/patches/patches/001_hello.patch index fb360a7..fb360a7 100644 --- a/patches/patches/01_hello.patch +++ b/patches/patches/001_hello.patch diff --git a/patches/patches/02_std.patch b/patches/patches/002_std.patch index 6c97adb..6c97adb 100644 --- a/patches/patches/02_std.patch +++ b/patches/patches/002_std.patch diff --git a/patches/patches/03_assignment.patch b/patches/patches/003_assignment.patch index bef4b24..bef4b24 100644 --- a/patches/patches/03_assignment.patch +++ b/patches/patches/003_assignment.patch diff --git a/patches/patches/04_arrays.patch b/patches/patches/004_arrays.patch index c6f9de3..c6f9de3 100644 --- a/patches/patches/04_arrays.patch +++ b/patches/patches/004_arrays.patch diff --git a/patches/patches/05_arrays2.patch b/patches/patches/005_arrays2.patch index 1e7b6b1..1e7b6b1 100644 --- a/patches/patches/05_arrays2.patch +++ b/patches/patches/005_arrays2.patch diff --git a/patches/patches/06_strings.patch b/patches/patches/006_strings.patch index 040a73c..040a73c 100644 --- a/patches/patches/06_strings.patch +++ b/patches/patches/006_strings.patch diff --git a/patches/patches/07_strings2.patch b/patches/patches/007_strings2.patch index 34cd053..34cd053 100644 --- a/patches/patches/07_strings2.patch +++ b/patches/patches/007_strings2.patch diff --git a/patches/patches/08_quiz.patch b/patches/patches/008_quiz.patch index 3d35a5a..3d35a5a 100644 --- a/patches/patches/08_quiz.patch +++ b/patches/patches/008_quiz.patch diff --git a/patches/patches/09_if.patch b/patches/patches/009_if.patch index 46579ad..46579ad 100644 --- a/patches/patches/09_if.patch +++ b/patches/patches/009_if.patch diff --git a/patches/patches/10_if2.patch b/patches/patches/010_if2.patch index e78f644..e78f644 100644 --- a/patches/patches/10_if2.patch +++ b/patches/patches/010_if2.patch diff --git a/patches/patches/11_while.patch b/patches/patches/011_while.patch index a892191..a892191 100644 --- a/patches/patches/11_while.patch +++ b/patches/patches/011_while.patch diff --git a/patches/patches/12_while2.patch b/patches/patches/012_while2.patch index 29ae763..29ae763 100644 --- a/patches/patches/12_while2.patch +++ b/patches/patches/012_while2.patch diff --git a/patches/patches/13_while3.patch b/patches/patches/013_while3.patch index b0172da..b0172da 100644 --- a/patches/patches/13_while3.patch +++ b/patches/patches/013_while3.patch diff --git a/patches/patches/14_while4.patch b/patches/patches/014_while4.patch index fb67587..fb67587 100644 --- a/patches/patches/14_while4.patch +++ b/patches/patches/014_while4.patch diff --git a/patches/patches/15_for.patch b/patches/patches/015_for.patch index e937221..e937221 100644 --- a/patches/patches/15_for.patch +++ b/patches/patches/015_for.patch diff --git a/patches/patches/16_for2.patch b/patches/patches/016_for2.patch index 5aba37f..5aba37f 100644 --- a/patches/patches/16_for2.patch +++ b/patches/patches/016_for2.patch diff --git a/patches/patches/17_quiz2.patch b/patches/patches/017_quiz2.patch index b46dab6..b46dab6 100644 --- a/patches/patches/17_quiz2.patch +++ b/patches/patches/017_quiz2.patch diff --git a/patches/patches/18_functions.patch b/patches/patches/018_functions.patch index dd3f2f6..dd3f2f6 100644 --- a/patches/patches/18_functions.patch +++ b/patches/patches/018_functions.patch diff --git a/patches/patches/19_functions2.patch b/patches/patches/019_functions2.patch index 254889a..254889a 100644 --- a/patches/patches/19_functions2.patch +++ b/patches/patches/019_functions2.patch diff --git a/patches/patches/20_quiz3.patch b/patches/patches/020_quiz3.patch index 6a00d31..6a00d31 100644 --- a/patches/patches/20_quiz3.patch +++ b/patches/patches/020_quiz3.patch diff --git a/patches/patches/21_errors.patch b/patches/patches/021_errors.patch index b37b3c8..b37b3c8 100644 --- a/patches/patches/21_errors.patch +++ b/patches/patches/021_errors.patch diff --git a/patches/patches/22_errors2.patch b/patches/patches/022_errors2.patch index 0501159..0501159 100644 --- a/patches/patches/22_errors2.patch +++ b/patches/patches/022_errors2.patch diff --git a/patches/patches/23_errors3.patch b/patches/patches/023_errors3.patch index a850116..a850116 100644 --- a/patches/patches/23_errors3.patch +++ b/patches/patches/023_errors3.patch diff --git a/patches/patches/24_errors4.patch b/patches/patches/024_errors4.patch index bb3fc8f..bb3fc8f 100644 --- a/patches/patches/24_errors4.patch +++ b/patches/patches/024_errors4.patch diff --git a/patches/patches/25_errors5.patch b/patches/patches/025_errors5.patch index 8aa59d4..8aa59d4 100644 --- a/patches/patches/25_errors5.patch +++ b/patches/patches/025_errors5.patch diff --git a/patches/patches/26_hello2.patch b/patches/patches/026_hello2.patch index 0065da5..0065da5 100644 --- a/patches/patches/26_hello2.patch +++ b/patches/patches/026_hello2.patch diff --git a/patches/patches/27_defer.patch b/patches/patches/027_defer.patch index 6ff7f98..6ff7f98 100644 --- a/patches/patches/27_defer.patch +++ b/patches/patches/027_defer.patch diff --git a/patches/patches/28_defer2.patch b/patches/patches/028_defer2.patch index c042c45..c042c45 100644 --- a/patches/patches/28_defer2.patch +++ b/patches/patches/028_defer2.patch diff --git a/patches/patches/29_errdefer.patch b/patches/patches/029_errdefer.patch index f93c56f..f93c56f 100644 --- a/patches/patches/29_errdefer.patch +++ b/patches/patches/029_errdefer.patch diff --git a/patches/patches/30_switch.patch b/patches/patches/030_switch.patch index 05cbe1a..05cbe1a 100644 --- a/patches/patches/30_switch.patch +++ b/patches/patches/030_switch.patch diff --git a/patches/patches/31_switch2.patch b/patches/patches/031_switch2.patch index f786762..f786762 100644 --- a/patches/patches/31_switch2.patch +++ b/patches/patches/031_switch2.patch diff --git a/patches/patches/32_unreachable.patch b/patches/patches/032_unreachable.patch index 0883932..0883932 100644 --- a/patches/patches/32_unreachable.patch +++ b/patches/patches/032_unreachable.patch diff --git a/patches/patches/33_iferror.patch b/patches/patches/033_iferror.patch index 62904db..62904db 100644 --- a/patches/patches/33_iferror.patch +++ b/patches/patches/033_iferror.patch diff --git a/patches/patches/34_quiz4.patch b/patches/patches/034_quiz4.patch index b259352..b259352 100644 --- a/patches/patches/34_quiz4.patch +++ b/patches/patches/034_quiz4.patch diff --git a/patches/patches/35_enums.patch b/patches/patches/035_enums.patch index ed2344b..ed2344b 100644 --- a/patches/patches/35_enums.patch +++ b/patches/patches/035_enums.patch diff --git a/patches/patches/36_enums2.patch b/patches/patches/036_enums2.patch index 54a7094..54a7094 100644 --- a/patches/patches/36_enums2.patch +++ b/patches/patches/036_enums2.patch diff --git a/patches/patches/37_structs.patch b/patches/patches/037_structs.patch index c26510d..c26510d 100644 --- a/patches/patches/37_structs.patch +++ b/patches/patches/037_structs.patch diff --git a/patches/patches/38_structs2.patch b/patches/patches/038_structs2.patch index 5d0d188..5d0d188 100644 --- a/patches/patches/38_structs2.patch +++ b/patches/patches/038_structs2.patch diff --git a/patches/patches/39_pointers.patch b/patches/patches/039_pointers.patch index 57d67e5..57d67e5 100644 --- a/patches/patches/39_pointers.patch +++ b/patches/patches/039_pointers.patch diff --git a/patches/patches/40_pointers2.patch b/patches/patches/040_pointers2.patch index a69cb20..a69cb20 100644 --- a/patches/patches/40_pointers2.patch +++ b/patches/patches/040_pointers2.patch diff --git a/patches/patches/41_pointers3.patch b/patches/patches/041_pointers3.patch index 02f7744..02f7744 100644 --- a/patches/patches/41_pointers3.patch +++ b/patches/patches/041_pointers3.patch diff --git a/patches/patches/42_pointers4.patch b/patches/patches/042_pointers4.patch index 29ca2d0..29ca2d0 100644 --- a/patches/patches/42_pointers4.patch +++ b/patches/patches/042_pointers4.patch diff --git a/patches/patches/43_pointers5.patch b/patches/patches/043_pointers5.patch index 8a73551..8a73551 100644 --- a/patches/patches/43_pointers5.patch +++ b/patches/patches/043_pointers5.patch diff --git a/patches/patches/44_quiz5.patch b/patches/patches/044_quiz5.patch index 44d4451..44d4451 100644 --- a/patches/patches/44_quiz5.patch +++ b/patches/patches/044_quiz5.patch diff --git a/patches/patches/45_optionals.patch b/patches/patches/045_optionals.patch index c945b5a..c945b5a 100644 --- a/patches/patches/45_optionals.patch +++ b/patches/patches/045_optionals.patch diff --git a/patches/patches/46_optionals2.patch b/patches/patches/046_optionals2.patch index 10705d9..10705d9 100644 --- a/patches/patches/46_optionals2.patch +++ b/patches/patches/046_optionals2.patch diff --git a/patches/patches/47_methods.patch b/patches/patches/047_methods.patch index cde93af..cde93af 100644 --- a/patches/patches/47_methods.patch +++ b/patches/patches/047_methods.patch diff --git a/patches/patches/48_methods2.patch b/patches/patches/048_methods2.patch index 781a99e..781a99e 100644 --- a/patches/patches/48_methods2.patch +++ b/patches/patches/048_methods2.patch diff --git a/patches/patches/49_quiz6.patch b/patches/patches/049_quiz6.patch index 83f9faf..83f9faf 100644 --- a/patches/patches/49_quiz6.patch +++ b/patches/patches/049_quiz6.patch diff --git a/patches/patches/50_no_value.patch b/patches/patches/050_no_value.patch index 79db0a3..79db0a3 100644 --- a/patches/patches/50_no_value.patch +++ b/patches/patches/050_no_value.patch diff --git a/patches/patches/51_values.patch b/patches/patches/051_values.patch index 43d1f65..43d1f65 100644 --- a/patches/patches/51_values.patch +++ b/patches/patches/051_values.patch diff --git a/patches/patches/052_slices.patch b/patches/patches/052_slices.patch new file mode 100644 index 0000000..80f8d72 --- /dev/null +++ b/patches/patches/052_slices.patch @@ -0,0 +1,10 @@ +34,35c34,35 +< const hand1: []u8 = cards[???]; +< const hand2: []u8 = cards[???]; +--- +> const hand1: []u8 = cards[0..4]; +> const hand2: []u8 = cards[4..]; +45c45 +< fn printHand(hand: ???) void { +--- +> fn printHand(hand: []u8) void { diff --git a/patches/patches/053_slices2.patch b/patches/patches/053_slices2.patch new file mode 100644 index 0000000..f5403a2 --- /dev/null +++ b/patches/patches/053_slices2.patch @@ -0,0 +1,20 @@ +20,22c20,22 +< const base1: []u8 = scrambled[15..23]; +< const base2: []u8 = scrambled[6..10]; +< const base3: []u8 = scrambled[32..]; +--- +> const base1: []const u8 = scrambled[15..23]; +> const base2: []const u8 = scrambled[6..10]; +> const base3: []const u8 = scrambled[32..]; +25,27c25,27 +< const justice1: []u8 = scrambled[11..14]; +< const justice2: []u8 = scrambled[0..5]; +< const justice3: []u8 = scrambled[24..31]; +--- +> const justice1: []const u8 = scrambled[11..14]; +> const justice2: []const u8 = scrambled[0..5]; +> const justice3: []const u8 = scrambled[24..31]; +33c33 +< fn printPhrase(part1: []u8, part2: []u8, part3: []u8) void { +--- +> fn printPhrase(part1: []const u8, part2: []const u8, part3: []const u8) void { diff --git a/patches/patches/054_manypointers.patch b/patches/patches/054_manypointers.patch new file mode 100644 index 0000000..82824e8 --- /dev/null +++ b/patches/patches/054_manypointers.patch @@ -0,0 +1,4 @@ +33c33 +< const zen12_string: []const u8 = zen_manyptr; +--- +> const zen12_string: []const u8 = zen_manyptr[0..21]; diff --git a/patches/patches/055_unions.patch b/patches/patches/055_unions.patch new file mode 100644 index 0000000..c362f20 --- /dev/null +++ b/patches/patches/055_unions.patch @@ -0,0 +1,6 @@ +62,63c62,63 +< printInsect(ant, AntOrBee.c); +< printInsect(bee, AntOrBee.c); +--- +> printInsect(ant, AntOrBee.a); +> printInsect(bee, AntOrBee.b); diff --git a/patches/patches/056_unions2.patch b/patches/patches/056_unions2.patch new file mode 100644 index 0000000..7341f7a --- /dev/null +++ b/patches/patches/056_unions2.patch @@ -0,0 +1,10 @@ +47,48c47,48 +< printInsect(???); +< printInsect(???); +--- +> printInsect(ant); +> printInsect(bee); +54c54 +< switch (???) { +--- +> switch (insect) { diff --git a/patches/patches/057_unions3.patch b/patches/patches/057_unions3.patch new file mode 100644 index 0000000..17e27a2 --- /dev/null +++ b/patches/patches/057_unions3.patch @@ -0,0 +1,4 @@ +18c18 +< const Insect = union(InsectStat) { +--- +> const Insect = union(enum) { |