diff options
Diffstat (limited to 'patches')
48 files changed, 157 insertions, 0 deletions
diff --git a/patches/README.md b/patches/README.md new file mode 100644 index 0000000..b3249fa --- /dev/null +++ b/patches/README.md @@ -0,0 +1,35 @@ +# No Peeking! :-) + +Welcome to the ziglings/patches directory. This is how ziglings is tested. + +The patches fix the broken exercises so that they work again, which means the +answers are here, so no peeking! + +## Éowyn + +A Bash shell script named `eowyn.sh` dwells here. She heals the little broken +programs and places them in a `healed` directory, which is NOT committed to the +repo. + +```bash +$ ./eowyn.sh +``` + +(If you invoke her from elsewhere, she'll come here to ply her trade.) + +The `build.zig` build script at the heart of Ziglings has a top-secret option +which tells it to test from the `patches/healed/` dir rather than `exercises/`: + +```bash +$ zig build -Dhealed [step] +``` + +Éowyn tests all healed programs using this secret option. + + +## Gollum + +Another Bash shell script named `gollum.sh` may also be found. He snatches the +original answers and stows them in his secret answers stash. If you leave him +alone, he'll leave you alone. + diff --git a/patches/eowyn.sh b/patches/eowyn.sh new file mode 100755 index 0000000..5a802f6 --- /dev/null +++ b/patches/eowyn.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# "I will be a shieldmaiden no longer, +# nor vie with the great Riders, nor +# take joy only in the songs of slaying. +# I will be a healer, and love all things +# that grow and are not barren." +# Éowyn, The Return of the King +# +# +# This script shall heal the little broken programs +# using the patches in this directory and convey them +# to convalesce in the healed directory. +# + +# We run from the patches dir. Go there now if not already. +cd $(dirname $(which $0)) +pwd # Show it upon the screen so all shall be made apparent. + +# Create healed/ directory here if it doesn't already exist. +mkdir -p healed + +# Cycle through all the little broken Zig applications. +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" + + + 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 + else + echo Cannot heal $true_name. Making empty patch. + echo > $patch_name + 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 new file mode 100755 index 0000000..423d376 --- /dev/null +++ b/patches/gollum.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# "It isn't fair, my precious, is it, +# to ask us what it's got in it's +# nassty little pocketsess?" +# Gollum, The Hobbit, or There and Back Again +# + +cd $(dirname $(which $0)) +f=$(basename ../exercises/$1*.zig .zig 2> /dev/null) +b=../exercises/$f.zig +a=../answers/$f.zig +p=patches/$f.patch + +printf "\tf: '$f'\n\tb: '$b'\n\ta: '$a'\n" + +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 + +echo Hisssss! + +diff $b $a > $p + +cat $p diff --git a/patches/patches/01_hello.patch b/patches/patches/01_hello.patch new file mode 100644 index 0000000..fb360a7 --- /dev/null +++ b/patches/patches/01_hello.patch @@ -0,0 +1,4 @@ +19c19 +< fn main() void { +--- +> pub fn main() void { diff --git a/patches/patches/02_std.patch b/patches/patches/02_std.patch new file mode 100644 index 0000000..6c97adb --- /dev/null +++ b/patches/patches/02_std.patch @@ -0,0 +1,4 @@ +14c14 +< ??? = @import("std"); +--- +> const std = @import("std"); diff --git a/patches/patches/03_assignment.patch b/patches/patches/03_assignment.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/03_assignment.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/04_arrays.patch b/patches/patches/04_arrays.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/04_arrays.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/05_arrays2.patch b/patches/patches/05_arrays2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/05_arrays2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/06_strings.patch b/patches/patches/06_strings.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/06_strings.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/07_strings2.patch b/patches/patches/07_strings2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/07_strings2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/08_quiz.patch b/patches/patches/08_quiz.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/08_quiz.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/09_if.patch b/patches/patches/09_if.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/09_if.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/10_if2.patch b/patches/patches/10_if2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/10_if2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/11_while.patch b/patches/patches/11_while.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/11_while.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/12_while2.patch b/patches/patches/12_while2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/12_while2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/13_while3.patch b/patches/patches/13_while3.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/13_while3.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/14_while4.patch b/patches/patches/14_while4.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/14_while4.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/15_for.patch b/patches/patches/15_for.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/15_for.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/16_for2.patch b/patches/patches/16_for2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/16_for2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/17_quiz2.patch b/patches/patches/17_quiz2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/17_quiz2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/18_functions.patch b/patches/patches/18_functions.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/18_functions.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/19_functions2.patch b/patches/patches/19_functions2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/19_functions2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/20_quiz3.patch b/patches/patches/20_quiz3.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/20_quiz3.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/21_errors.patch b/patches/patches/21_errors.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/21_errors.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/22_errors2.patch b/patches/patches/22_errors2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/22_errors2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/23_errors3.patch b/patches/patches/23_errors3.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/23_errors3.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/24_errors4.patch b/patches/patches/24_errors4.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/24_errors4.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/25_errors5.patch b/patches/patches/25_errors5.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/25_errors5.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/26_hello2.patch b/patches/patches/26_hello2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/26_hello2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/27_defer.patch b/patches/patches/27_defer.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/27_defer.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/28_defer2.patch b/patches/patches/28_defer2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/28_defer2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/29_errdefer.patch b/patches/patches/29_errdefer.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/29_errdefer.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/30_switch.patch b/patches/patches/30_switch.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/30_switch.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/31_switch2.patch b/patches/patches/31_switch2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/31_switch2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/32_unreachable.patch b/patches/patches/32_unreachable.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/32_unreachable.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/33_iferror.patch b/patches/patches/33_iferror.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/33_iferror.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/34_quiz4.patch b/patches/patches/34_quiz4.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/34_quiz4.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/35_enums.patch b/patches/patches/35_enums.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/35_enums.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/36_enums2.patch b/patches/patches/36_enums2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/36_enums2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/37_structs.patch b/patches/patches/37_structs.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/37_structs.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/38_structs2.patch b/patches/patches/38_structs2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/38_structs2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/39_pointers.patch b/patches/patches/39_pointers.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/39_pointers.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/40_pointers2.patch b/patches/patches/40_pointers2.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/40_pointers2.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/41_pointers3.patch b/patches/patches/41_pointers3.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/41_pointers3.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/42_pointers4.patch b/patches/patches/42_pointers4.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/42_pointers4.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/43_pointers5.patch b/patches/patches/43_pointers5.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/43_pointers5.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/44_quiz5.patch b/patches/patches/44_quiz5.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/44_quiz5.patch @@ -0,0 +1 @@ + diff --git a/patches/patches/45_optionals.patch b/patches/patches/45_optionals.patch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/patches/patches/45_optionals.patch @@ -0,0 +1 @@ + |
