<feed xmlns='http://www.w3.org/2005/Atom'>
<title>knr/ch5, branch master</title>
<subtitle>Category-0 solutions to The C Programming Language, 2nd Edition</subtitle>
<id>https://git.zlg.space/knr/atom/ch5?h=master</id>
<link rel='self' href='https://git.zlg.space/knr/atom/ch5?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/'/>
<updated>2016-06-16T17:15:33Z</updated>
<entry>
<title>The massive astyle sweep!</title>
<updated>2016-06-16T17:15:33Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-06-16T17:15:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7'/>
<id>urn:sha1:f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7</id>
<content type='text'>
Code style should be consistent now. All future commits will be run through
astyle or they will be amended.
</content>
</entry>
<entry>
<title>1-16 solution code and comment style cleanup</title>
<updated>2015-12-20T02:40:02Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-12-20T02:40:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=0c7a59180de778a4e9019176a65eb02b5493b6f7'/>
<id>urn:sha1:0c7a59180de778a4e9019176a65eb02b5493b6f7</id>
<content type='text'>
Also of note is the length that the program reports includes the newline
character at the end. This has been clarified in a comment. The exercise
text does not specify whether to include newlines as part of the length,
so it was left alone.

Removed the contributor notice, since contributor acknowledgements are
centralized.
</content>
</entry>
<entry>
<title>Solve Exercise 5-20: Expanded `dcl`</title>
<updated>2015-02-21T06:35:43Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-02-21T06:35:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=e859c083a97edf6be14b17c652835f1e27b75210'/>
<id>urn:sha1:e859c083a97edf6be14b17c652835f1e27b75210</id>
<content type='text'>
This marks the end of chapter 5. Admittedly, the solution for 5-20 is
terrible, but it does what it's supposed to do. I'm just excited to move
onto chapter 6 and start learning structures!
</content>
</entry>
<entry>
<title>Solve Exercise 5-19: Omit extra parens in `undcl`</title>
<updated>2015-02-21T05:35:39Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-02-21T05:35:39Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=af502c08e870ea3374d9c3d20d0e195aa3658f22'/>
<id>urn:sha1:af502c08e870ea3374d9c3d20d0e195aa3658f22</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-18: error-recovering `dcl`</title>
<updated>2015-01-30T08:55:59Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-01-30T08:55:59Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=1f92ea2a90d98ef150a8546cf5695a73ba68312d'/>
<id>urn:sha1:1f92ea2a90d98ef150a8546cf5695a73ba68312d</id>
<content type='text'>
This exercise was a real pain in the ass. The original use of
getch() and ungetch() was inferior to a line-based approach. It
really doesn't seem like the way a parser should be built, but
it taught me a little about the order of recursion. I'm convinced
that a debugger is necessary if you want to build a good parser.

This implementation doesn't recurse in a natural way, or even
enough to stack data type prefixes. Hopefully by the time I get to
5-20 I'll have enough ideas to implement something that *does*
recurse well.
</content>
</entry>
<entry>
<title>Solve Exercise 5-17: field sorting</title>
<updated>2014-06-15T05:24:38Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-06-15T05:24:38Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=893e4a375873f4b98d8691ffafbba8a2ccb1b55d'/>
<id>urn:sha1:893e4a375873f4b98d8691ffafbba8a2ccb1b55d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Refactor flag handling</title>
<updated>2014-05-21T10:54:51Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-05-21T10:54:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=cb197e459c381591f9cb0a92a0cbd720bdbda5a7'/>
<id>urn:sha1:cb197e459c381591f9cb0a92a0cbd720bdbda5a7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-16: directory-ordered `tail`</title>
<updated>2014-05-20T11:36:21Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-05-20T11:36:21Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=209fffb91f965f4fa20ad2986218fd8557e01391'/>
<id>urn:sha1:209fffb91f965f4fa20ad2986218fd8557e01391</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove line_tolower()</title>
<updated>2014-04-08T10:08:32Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-04-08T10:08:32Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=81f406956731e70f190e79ec85cfc38f504240ea'/>
<id>urn:sha1:81f406956731e70f190e79ec85cfc38f504240ea</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-15: Case-insensitive sort</title>
<updated>2014-04-08T09:51:09Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-04-08T09:51:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=76f1afed408bb0dc25f95f5979b731ee236e18cf'/>
<id>urn:sha1:76f1afed408bb0dc25f95f5979b731ee236e18cf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-14: reverse sort</title>
<updated>2014-03-20T19:57:51Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2014-03-20T19:57:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=2d67fcd7aefe4e78716003e9dfd8220103a5b132'/>
<id>urn:sha1:2d67fcd7aefe4e78716003e9dfd8220103a5b132</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-13: tail</title>
<updated>2013-10-18T07:14:57Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-10-18T07:14:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=eb44b112e7ac2ffbd7d48d47f26c5e210fed677c'/>
<id>urn:sha1:eb44b112e7ac2ffbd7d48d47f26c5e210fed677c</id>
<content type='text'>
This exercise was somewhat irritating until I caved and used the code in
section 5.6 like the exercise suggested. The solution is not what I
think is clean, but given that [mc]*alloc haven't been covered yet, it's
probably the best one can muster.

Once I used the code in §5.6, the program fell into place. Still, it was
a neat exercise.
</content>
</entry>
<entry>
<title>Solve Exercise 5-12: flexible `detab` and `entab`</title>
<updated>2013-10-13T08:24:07Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-10-13T08:24:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=8d64674314e55a1c2fa044cf9552886a4e852ec9'/>
<id>urn:sha1:8d64674314e55a1c2fa044cf9552886a4e852ec9</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-11: `entab` and `detab` remixed!</title>
<updated>2013-09-26T12:17:51Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-26T12:17:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=22ddf92e89b19c30ff77b368cab60cc95315db35'/>
<id>urn:sha1:22ddf92e89b19c30ff77b368cab60cc95315db35</id>
<content type='text'>
This one was pretty rough. At first I wanted to include a bunch of
error-catching and "smart" stuff. When I took a second look at it and
realized `itoa` returns 0 on a string, things became a bit easier. I
may have been able to outsource a few things to a function or two, but
overall I think it worked out.
</content>
</entry>
<entry>
<title>Clean up 5-10's printf() calls</title>
<updated>2013-09-24T13:36:25Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-24T13:36:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=6acde01f13a875193c8a17f100683c7cf4f804a1'/>
<id>urn:sha1:6acde01f13a875193c8a17f100683c7cf4f804a1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-10: expr</title>
<updated>2013-09-24T13:33:37Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-24T13:33:37Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=b4d63aa4acb84c9bb71f6b4cd62de0560a0b3f84'/>
<id>urn:sha1:b4d63aa4acb84c9bb71f6b4cd62de0560a0b3f84</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-9: day of year functions with pointers</title>
<updated>2013-09-21T09:39:09Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-21T09:39:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=cbfac3701fa8b7a1e3233f9fa437d6e3347710c7'/>
<id>urn:sha1:cbfac3701fa8b7a1e3233f9fa437d6e3347710c7</id>
<content type='text'>
This exercise was fun and taught me a bit about initializing arrays and
working with pointers.
</content>
</entry>
<entry>
<title>Solve Exercise 5-8: Checking for errors</title>
<updated>2013-09-15T15:17:40Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-15T15:17:40Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=ce588670229cc68cebe4d93b19e9bc2c6f3c65cd'/>
<id>urn:sha1:ce588670229cc68cebe4d93b19e9bc2c6f3c65cd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-7: Improved readlines()</title>
<updated>2013-09-11T11:49:22Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-11T11:49:22Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=0c2e23ea497d5e83cd1b518cd597628ba35f46d8'/>
<id>urn:sha1:0c2e23ea497d5e83cd1b518cd597628ba35f46d8</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-6: pointer-based functions</title>
<updated>2013-09-08T08:07:54Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-08T08:07:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=5d5ee724cedf6124a84c0425be4f6bca0c082092'/>
<id>urn:sha1:5d5ee724cedf6124a84c0425be4f6bca0c082092</id>
<content type='text'>
This exercise was not very fun or interesting. While I somewhat enjoyed
learning to use pointers, this was a bunch of busywork. It felt like
homework, and that's terrible. It's the first exercise I've outright
disliked. If you're writing a programming book, *don't* make exercises
like this one!
</content>
</entry>
<entry>
<title>Solve Exercise 5-5: strn{cpy|cat|cmp}</title>
<updated>2013-09-03T09:33:09Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-03T09:33:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=ca6b2c0ef3d3245b528303ce8d871520acaf68eb'/>
<id>urn:sha1:ca6b2c0ef3d3245b528303ce8d871520acaf68eb</id>
<content type='text'>
This exercise seemed like it was designed to "pull it all together"
with things learned in the previous few pages. Not much new in terms
of techniques, but more a test to see how you could blend everything
together.
</content>
</entry>
<entry>
<title>Solve Exercise 5-4: strend()</title>
<updated>2013-09-02T12:11:07Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-09-02T12:11:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=5d4b543ae9fbdaf7b86cbbd2b652808ce282c91f'/>
<id>urn:sha1:5d4b543ae9fbdaf7b86cbbd2b652808ce282c91f</id>
<content type='text'>
Detailed answers below the question will only occur now if I cannot
explain myself well enough in code and nearby comments. I'm looking
to learn how to write better comments so there's less need for prose.
</content>
</entry>
<entry>
<title>Solve Exercise 5-3: pointer-powered strcat()</title>
<updated>2013-08-29T11:29:09Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-08-29T11:29:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=6484527cec80136b09288abb1583046f5b776411'/>
<id>urn:sha1:6484527cec80136b09288abb1583046f5b776411</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-2: getfloat()</title>
<updated>2013-08-19T07:35:49Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-08-19T07:35:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=8bb191cb2808968db87ce39d45f40c1996690553'/>
<id>urn:sha1:8bb191cb2808968db87ce39d45f40c1996690553</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 5-1: fixed getint()</title>
<updated>2013-08-13T09:37:02Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2013-08-13T09:37:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=fcbbe1a17fcb9fa129b737ddb8d72683ec9bfc3b'/>
<id>urn:sha1:fcbbe1a17fcb9fa129b737ddb8d72683ec9bfc3b</id>
<content type='text'>
</content>
</entry>
</feed>
