<feed xmlns='http://www.w3.org/2005/Atom'>
<title>knr, branch master</title>
<subtitle>Category-0 solutions to The C Programming Language, 2nd Edition</subtitle>
<id>https://git.zlg.space/knr/atom/?h=master</id>
<link rel='self' href='https://git.zlg.space/knr/atom/?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/'/>
<updated>2022-01-24T20:57:59Z</updated>
<entry>
<title>README.mdown: Add Roadmap section</title>
<updated>2022-01-24T20:57:59Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-24T20:57:59Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=d7aade6d78b8b307861875b9319a69bae1460fd6'/>
<id>urn:sha1:d7aade6d78b8b307861875b9319a69bae1460fd6</id>
<content type='text'>
The exercises may be completed, but that doesn't mean the work is over!
I'll need to verify the correctness of the later exercises, and will
someday comb over the messier solutions that I'm less satisfied with.

I'd like to put together a modern set of solutions, too, to illustrate
how C has improved over the years. Outside interest will determine
whether this is pursued.
</content>
</entry>
<entry>
<title>README.mdown: Add some extra bits about the project</title>
<updated>2022-01-24T07:26:33Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-24T07:26:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=13a2623393c3223ff32abc9e7d5979daf7391301'/>
<id>urn:sha1:13a2623393c3223ff32abc9e7d5979daf7391301</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 8-8: bfree()</title>
<updated>2022-01-24T07:19:22Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-24T07:19:22Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=45f0db25dac2d5e69a71bd402039a698549abfdb'/>
<id>urn:sha1:45f0db25dac2d5e69a71bd402039a698549abfdb</id>
<content type='text'>
Well, here it is. The final solution to the final exercise! These last
few exercise solutions are not ideal by any measure of coding
excellence, but they function.

I plan to come back to this some day, with better debugging knowledge.
Then I can correct any issues.
</content>
</entry>
<entry>
<title>Solve Exercise 8-7: malloc &amp; free, improved</title>
<updated>2022-01-24T05:20:25Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-24T05:20:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=06988a01833c5f669f83b16b35f0b3f70c36f807'/>
<id>urn:sha1:06988a01833c5f669f83b16b35f0b3f70c36f807</id>
<content type='text'>
There wasn't much to check for, but I checked for what I could think of.
</content>
</entry>
<entry>
<title>Solve Exercise 8-6: calloc()</title>
<updated>2022-01-24T01:59:56Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-24T01:59:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=2bbb384783f667226e117e62992779498bc7e5b8'/>
<id>urn:sha1:2bbb384783f667226e117e62992779498bc7e5b8</id>
<content type='text'>
I chose to implement calloc() by calling malloc.

This exercise went well, but I found it difficult to verify the contents
of the headers and buffers within memory. Valgrind showed the correct
number of bytes allocated, and a memory dump pointed to a good
result, but research was not conclusive.
</content>
</entry>
<entry>
<title>Solve Exercise 8-05: fsize extended</title>
<updated>2022-01-19T05:58:37Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-19T05:58:37Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=b1805ae57e314be9d56c099a282206053043fa4b'/>
<id>urn:sha1:b1805ae57e314be9d56c099a282206053043fa4b</id>
<content type='text'>
This exercise uses the standard library instead of the homegrown
dirent.h outlined in the book. This is due to misbehavior in outputting
the file or directory names. This pointed to a data mismatch between the
data model supplied by the book and the data model actually used by my
operating system (GNU/Linux).
</content>
</entry>
<entry>
<title>Solve Exercise 8-4: fseek() implementation</title>
<updated>2022-01-10T04:18:52Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-10T04:18:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=bfd18a52e1baa4da7040b8df04a3f29e83b0d6b6'/>
<id>urn:sha1:bfd18a52e1baa4da7040b8df04a3f29e83b0d6b6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve exercise 8-3: fflush and fclose</title>
<updated>2022-01-10T00:46:25Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-10T00:46:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=41d86a29051af9e3b5fe7e37bd4c0c0a18993767'/>
<id>urn:sha1:41d86a29051af9e3b5fe7e37bd4c0c0a18993767</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Refactor syscalls.h for ch8 exercises</title>
<updated>2022-01-10T00:41:26Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2022-01-10T00:41:26Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=2b68c3d06fb2961ae3797d1ef461cff655f328b2'/>
<id>urn:sha1:2b68c3d06fb2961ae3797d1ef461cff655f328b2</id>
<content type='text'>
The refactor includes implementations for fflush and fclose as well,
needed in 8-03.
</content>
</entry>
<entry>
<title>Solve Exercise 8-2: fopen and fillbuf</title>
<updated>2018-12-22T09:23:35Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2018-12-22T09:23:35Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=4ad4e6c7f6d2fb414d22dd3e55801c85b02c1af7'/>
<id>urn:sha1:4ad4e6c7f6d2fb414d22dd3e55801c85b02c1af7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>AUTHORS: update contact info</title>
<updated>2018-08-23T03:07:12Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2018-08-23T03:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=963091b93c3330bd562df204fdd1a063efebc7c6'/>
<id>urn:sha1:963091b93c3330bd562df204fdd1a063efebc7c6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>perfeeerrrrrm</title>
<updated>2017-05-21T05:48:50Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2017-05-21T05:48:50Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=f3e194ceb2405d2063501bd46b270d988931d36b'/>
<id>urn:sha1:f3e194ceb2405d2063501bd46b270d988931d36b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>8-1: Correct superfluous increment, comment</title>
<updated>2017-05-20T08:21:01Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2017-05-20T08:21:01Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=3a80ead1cbe94d23205a490c8bf469feb5960f95'/>
<id>urn:sha1:3a80ead1cbe94d23205a490c8bf469feb5960f95</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 8-1: `cat` remastered</title>
<updated>2017-05-20T08:13:28Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2017-05-20T08:13:28Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=443c8b479d7ca0bf45f691ab2da6fb8d35045d1f'/>
<id>urn:sha1:443c8b479d7ca0bf45f691ab2da6fb8d35045d1f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 7-9: isupper, time, and space</title>
<updated>2017-02-27T09:20:38Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2017-02-27T09:20:38Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=fcfb2db63b01f209fb2c8fdc500023241435377f'/>
<id>urn:sha1:fcfb2db63b01f209fb2c8fdc500023241435377f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 7-8: Paged file print-outs</title>
<updated>2017-02-20T11:21:59Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2017-02-20T11:21:59Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=729b54b9f6921ca9a4ee91ddb743a6fb7203658c'/>
<id>urn:sha1:729b54b9f6921ca9a4ee91ddb743a6fb7203658c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 7-7: Match pattern in files</title>
<updated>2016-11-21T08:07:37Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-11-21T08:07:37Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=0947afc6a1338a0408c8d6fe12cda08f87cca2bb'/>
<id>urn:sha1:0947afc6a1338a0408c8d6fe12cda08f87cca2bb</id>
<content type='text'>
This one was tricky, but the solution was rather simple.
</content>
</entry>
<entry>
<title>Remove unneeded function declaration in 7-06</title>
<updated>2016-11-21T08:04:34Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-11-21T08:04:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=55e5e56ff1eae9b6234ec885b4fc6fee907d1e75'/>
<id>urn:sha1:55e5e56ff1eae9b6234ec885b4fc6fee907d1e75</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 7-6: simple `diff` utility</title>
<updated>2016-11-17T15:34:18Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-11-17T15:34:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=54b3475b3041bf35c25bfad2f521d5751e6eadbf'/>
<id>urn:sha1:54b3475b3041bf35c25bfad2f521d5751e6eadbf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Actually run astyle on the file...</title>
<updated>2016-10-12T13:54:44Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-10-12T13:54:44Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=ce7f0379df5dbfca9b86492ea5d2993196a1cc52'/>
<id>urn:sha1:ce7f0379df5dbfca9b86492ea5d2993196a1cc52</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Solve Exercise 7-5: RPN calculator with scanf()</title>
<updated>2016-10-12T13:49:26Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-10-12T13:49:26Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=edf72affee48c3e6530d6f60142d834eecae8aa3'/>
<id>urn:sha1:edf72affee48c3e6530d6f60142d834eecae8aa3</id>
<content type='text'>
This exercise was deceptively simple, and ended up simpler than the
original! The *scanf series of functions is very useful, but you also
have to be careful or you'll run into segfaults.
</content>
</entry>
<entry>
<title>Solve Exercise 7-4: minscanf()</title>
<updated>2016-06-30T10:56:52Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-06-30T10:56:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=3aa9b1189dc7ee6660a2b7123ee9a00df0f9ca09'/>
<id>urn:sha1:3aa9b1189dc7ee6660a2b7123ee9a00df0f9ca09</id>
<content type='text'>
This one wasn't too bad, either! There's a minor bug in the code, but
I'm not sure how to fix it. It *technically* meets muster, though. :P
</content>
</entry>
<entry>
<title>Solve Exercise 7-3: minprintf()</title>
<updated>2016-06-26T09:57:18Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-06-26T09:57:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=a8db504e7d098123075bd00d2a998488a97af81d'/>
<id>urn:sha1:a8db504e7d098123075bd00d2a998488a97af81d</id>
<content type='text'>
</content>
</entry>
<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>Solve Exercise 7-2: Format arbitrary input</title>
<updated>2016-06-16T16:51:16Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2016-06-16T16:51:16Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=82656bf5aa4edd668e1adc3faa8148251509b912'/>
<id>urn:sha1:82656bf5aa4edd668e1adc3faa8148251509b912</id>
<content type='text'>
The solution is technically not 100% correct, but good luck figuring out
a robust solution inside Category-0 restrictions. Unicode characters
like ¬ or ♥ show up as 64-bit hex codes and I couldn't find a way to
shorten them. Then again, UTF-8 supports characters up to 8 bytes long.
Use it with plain ASCII and it looks only minorly off.
</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>Change license to GPLv3, add contributing guide</title>
<updated>2015-12-20T02:37:40Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-12-20T02:37:40Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=57df72caf8d749c7cd5f36117ff35e41975db3d3'/>
<id>urn:sha1:57df72caf8d749c7cd5f36117ff35e41975db3d3</id>
<content type='text'>
* Improve README tone
* Add `astylerc` for use with the astyle package
* Add AUTHORS file to acknowledge contributors
</content>
</entry>
<entry>
<title>Re-solve Exercise 1-16: arbitrarily long maxline</title>
<updated>2015-12-20T01:43:20Z</updated>
<author>
<name>Isa Hassen</name>
<email>hassen.isa@gmail.com</email>
</author>
<published>2015-12-19T00:40:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=032b64e37a23541e136dcf082a4564023579ed39'/>
<id>urn:sha1:032b64e37a23541e136dcf082a4564023579ed39</id>
<content type='text'>
A completely rewritten solution which follows the spec given in the book
exactly; make the program work for arbitrarily long input lines while
modifying `main()` only. I've only changed the name of the macro MAXLINE
to BUFFSIZE for clarity - otherwise the code is typed up exactly as
found in the book.

It demonstrates the use of a buffer without modifying any of the helper
functions.
</content>
</entry>
<entry>
<title>Solve Exercise 7-1: `upper` and `lower`</title>
<updated>2015-12-08T11:10:43Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-12-08T11:10:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=ea3c92d58cdf2d4030598d1052c2eb6cf2d8cc7e'/>
<id>urn:sha1:ea3c92d58cdf2d4030598d1052c2eb6cf2d8cc7e</id>
<content type='text'>
Two cases, one file. This exercise was a welcome departure from the
recent head-scratchers. It made me think about a solution for the
pathname issue I realized would crop up, too.

I'm roughly 75% done with the book! Maybe by the time I finish it, I'll
have a Makefile ready for the project...
</content>
</entry>
<entry>
<title>Solve Exercise 6-6: A simple `#define` processor</title>
<updated>2015-12-06T05:46:57Z</updated>
<author>
<name>zlg</name>
<email>zlg@zlg.space</email>
</author>
<published>2015-12-06T05:46:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zlg.space/knr/commit/?id=45b8159cc39792ddc4e989b11036f026d49f33e7'/>
<id>urn:sha1:45b8159cc39792ddc4e989b11036f026d49f33e7</id>
<content type='text'>
This exercise is probably the most challenging "function puzzle" thus
far. Modifying getword(), using various states, and the hashtable all
create an example of how small building blocks can work together to
make something.

The implementation is very simple and nowhere near completely supporting
'#define', but that's not the point. To properly support it, you'd need
to build an entire preprocessor/parser, and that's far beyond the scope
of both the exercise and book.
</content>
</entry>
</feed>
