Chapter 7 in the TOS textbook went over fixing bugs and then creating patches from those bugs. There were three exercises that the book walked through with patches and I will go through my responses to each exercise individually.
7.2.2
Section 7.2 of the TOS book dealt with explaining what a patch is, how to create one with out subversion and how to compare the change between an original file and a new file. In exercise 7.2.1 it walked through creating a patch for a Hello, World program written in c. It was pretty simple with the change from "Hello, World." to "Hello, World!". Once the change took place, it walked through the "diff" command with the -u flag in order to see the differences between the original hello world program and the patched one. Exercise 7.2.2 asked to use the diff command with out the -u flag to see the difference from the "diff -u" command. The differences that I found were that "diff -u" gave more information than just "diff", and it was easier to understand "diff -u". "diff -u" told me which file contained the old line using "---" and which file contained the new line using "+++". It also denotes what was changed inside the file by displaying the old line in the original code with a "-" and the new line with a "+". The "diff" command with out the -u flag did not give as much information. It gave the line number that was changed and it told the original line denoted with a "<" and the new line denoted with ">", but it does not tell you which file the lines are from so it can make it a bit confusing. I mean, for this example it is probably okay because it is just one line but for multiple changes it can probably get a little tough to read.
7.8
I'm guessing I did this one right. It asked to create a patch file that represented a new file with "foo" being the name of the patch file and the contents being "bar". So I created the patch file and put "bar" as the contents and then diffed the /dev/null file with the foo.patch file. My results were that foo.patch had the new line with "bar" and that /dev/null was empty. Again I'm not sure if I did this one right or not. The wording was a bit weird to me.
7.9
In this exercise, it walked through creating a patch for the "echo" command from the "coreutils" project. They walked through how to change the code in order to make the "echo" command print sentences out in reverse and then output the "diff -u" of the old echo and the new echo into a patch file. Once I carried out all the necessary steps, I found that the code change they provided, did not reverse the sentence with the new "echo" command. Instead that command just repeats the first word in the sentence for each word in the original sentence. So for example:
original: is this reversed
echo command output: is is is
What I found, is that I did make an error in changing the code. for the line that says "fputs(argv[0], stdout);" I was supposed to replace argv[0] with argv[argc]. That would explain why the first word in my sentences would repeat. Once I made the correct change, the "echo" command reversed the sentence.
No comments:
Post a Comment