aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-01-23Solve Exercise 8-8: bfree()zlg1-0/+200
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.
2022-01-23Solve Exercise 8-7: malloc & free, improvedzlg1-0/+179
There wasn't much to check for, but I checked for what I could think of.
2022-01-23Solve Exercise 8-6: calloc()zlg1-0/+136
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.
2022-01-18Solve Exercise 8-05: fsize extendedzlg1-0/+77
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).
2022-01-09Solve Exercise 8-4: fseek() implementationzlg2-11/+68
2022-01-09Solve exercise 8-3: fflush and fclosezlg1-0/+40
2022-01-09Refactor syscalls.h for ch8 exerciseszlg3-117/+234
The refactor includes implementations for fflush and fclose as well, needed in 8-03.
2018-12-22Solve Exercise 8-2: fopen and fillbufzlg3-0/+181
2018-08-22AUTHORS: update contact infozlg1-1/+1
2017-05-20perfeeerrrrrmzlg1-1/+1
2017-05-208-1: Correct superfluous increment, commentzlg1-2/+1
2017-05-20Solve Exercise 8-1: `cat` remasteredzlg1-0/+115
2017-02-27Solve Exercise 7-9: isupper, time, and spacezlg1-0/+32
2017-02-20Solve Exercise 7-8: Paged file print-outszlg1-0/+91
2016-11-21Solve Exercise 7-7: Match pattern in fileszlg1-0/+128
This one was tricky, but the solution was rather simple.
2016-11-21Remove unneeded function declaration in 7-06zlg1-1/+0
2016-11-17Solve Exercise 7-6: simple `diff` utilityzlg1-0/+81
2016-10-12Actually run astyle on the file...zlg1-23/+23
2016-10-12Solve Exercise 7-5: RPN calculator with scanf()zlg1-0/+114
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.
2016-06-30Solve Exercise 7-4: minscanf()zlg1-0/+70
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
2016-06-26Solve Exercise 7-3: minprintf()zlg1-0/+75
2016-06-16The massive astyle sweep!zlg66-266/+72
Code style should be consistent now. All future commits will be run through astyle or they will be amended.
2016-06-16Solve Exercise 7-2: Format arbitrary inputzlg1-0/+101
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.
2015-12-191-16 solution code and comment style cleanupzlg2-48/+51
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.
2015-12-19Change license to GPLv3, add contributing guidezlg6-26/+834
* Improve README tone * Add `astylerc` for use with the astyle package * Add AUTHORS file to acknowledge contributors
2015-12-19Re-solve Exercise 1-16: arbitrarily long maxlineIsa Hassen1-44/+60
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.
2015-12-08Solve Exercise 7-1: `upper` and `lower`zlg1-0/+52
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...
2015-12-05Solve Exercise 6-6: A simple `#define` processorzlg2-2/+200
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.
2015-11-20Solve Exercise 6-5: undef()zlg1-0/+107
We're getting close to more useful data structures! Wee!
2015-11-07Solve Exercise 6-4: Highest Word Frequencyzlg1-0/+177
This exercise was good practice to get back into the mindset of programming. It's not a pretty solution, but it works. I may end up coming back to this solution, because I feel like I've missed something that would make this exercise simpler.
2015-08-04Solve Exercise 6-03: Word cross-referencingzlg1-0/+190
2015-03-08Solve Exercise 6-02: Common prefix printingzlg1-0/+239
2015-03-03Solve Exercise 6-01: Enhanced `getword`zlg1-0/+170
This exercise improved my understanding of identifying comments and quotes by focusing on edge cases.
2015-02-20Solve Exercise 5-20: Expanded `dcl`zlg1-0/+215
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!
2015-02-20Solve Exercise 5-19: Omit extra parens in `undcl`zlg1-0/+113
2015-01-30Solve Exercise 5-18: error-recovering `dcl`zlg1-0/+172
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.
2014-08-03Ensure 1-02's solution compileszlg1-1/+4
I'm preparing for build automation, so everything needs to build
2014-06-15Solve Exercise 5-17: field sortingzlg2-1/+268
2014-05-21Refactor flag handlingzlg3-24/+51
2014-05-20Solve Exercise 5-16: directory-ordered `tail`zlg1-0/+191
2014-04-08Remove line_tolower()zlg1-9/+0
2014-04-08Solve Exercise 5-15: Case-insensitive sortzlg2-1/+179
2014-03-20Solve Exercise 5-14: reverse sortzlg1-0/+152
2013-10-18Solve Exercise 5-13: tailzlg1-0/+106
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.
2013-10-13Solve Exercise 5-12: flexible `detab` and `entab`zlg2-0/+157
2013-09-26Solve Exercise 5-11: `entab` and `detab` remixed!zlg2-0/+137
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.
2013-09-24Clean up 5-10's printf() callszlg1-4/+0
2013-09-24Solve Exercise 5-10: exprzlg1-0/+107
2013-09-21Solve Exercise 5-9: day of year functions with pointerszlg1-0/+74
This exercise was fun and taught me a bit about initializing arrays and working with pointers.
2013-09-15Solve Exercise 5-8: Checking for errorszlg1-0/+83