Changes

Jump to: navigation, search

User:Lkates

1,429 bytes added, 17:31, 18 January 2007
Code Reading Exercise: - Saving again so the computer doesn't crash
==Code Reading Exercise==
 
Looking at MAKE and ???
#Which file(s) did you have to examine?
'''make'''
First I looked at loadargc, since argc reminds me of the C/C++ standard command line variables that you use in main. However, that turned out to be a load balancing program. Next I looked at Main.h, since main seems like a good start, and headers tend to define stuff. But there wasn’t anything useful there. So I opened Main.c, and voila! Code that has to do with command line switches.
#What are your first reactions to these files when you examine them?
'''make'''
I don’t think I can put them down, in accordance to Seneca’s Acceptable Use Policy. But the sheer amount of code and underscores and structs were a bit overwhelming.
#How is the code for working with command-line switches organized at the method, class and project levels? (e.g. is is all in one class? broken across multiple classes? spread across many methods? etc)
'''make'''
There are a couple methods defined right near the beginning:
fatal (NILF, _("empty string invalid as file name"));
</code>
 
Shortly after, main goes into its main() function. It starts to do a bunch of crazy stuff with backslash conversion and allocating temp space for variables and stuff. After its done that, it goes ahead and re-interprets the command line switches, in case Make itself has added any:
 
<code>
/* Decode switches again, in case the variables were set by the makefile. */
decode_env_switches ("MAKEFLAGS", 9);
#if 0
decode_env_switches ("MFLAGS", 6);
#endif
</code>
 
 
It then goes into a bunch of "goal files", which are, as far as I can tell, files that have to be made. If none are specified, but are expected, it dies:
 
<code>
if (!goals)
{
if (read_makefiles == 0)
fatal (NILF, _("No targets specified and no makefile found"));
 
fatal (NILF, _("No targets"));
}
</code>
 
#How are invalid or non-existent Filenames dealt with?
 
In general, a fatal flag is put up, and the program dies. This seems to be mostly done when the command line switches are processed. If a file was expected (ie: a Make file, or a file specified after a switch argument), then the errors are found when the switch is processed, or the file is looked at. This is different from what I was expecting. I was expecting it to do mandatory file checking right off the bat (start of main function, perhaps), and dying before it did any other work.
=Other Wiki Courses=
[[lkates:dps909]]
1
edit

Navigation menu