BRL-CAD source code currently has over 450 C header (include) files. Header files usually include a preprocessor block that ensures the header is only included once. It usually looks something like this:
#ifndef THIS_HEADER
#define THIS_HEADER
... file contents ...
#endif /* THIS_HEADER */
This tasks basically involves editing that THIS_HEADER string for 200+ src/conv subdirectory headers so that they're using a consistent header guard naming convention. Some of our files use a convention like __FILE_H__ while others use FILE_H or FILE_H__ or others still using some other convention.
Your job is to make them all the same, based on the file name, for some of our headers. Our convention should be {SUBPATH_}FILENAME_H where SUBPATH indicates the subdirectory where the header resides minus the first directory; and FILENAME_H is the name of the file with punctuation and spaces converted to underscores.
Some examples:
- include/bu.h becomes just BU_H
- src/libbu/anim.h becomes LIBBU_ANIM_H
- src/conv/iges/iges.h becomes CONV_IGES_IGES_H
Code:
- src/conv
- http://brlcad.org/wiki/Compiling
Suggest using the VM if you're not on Linux, but this command will locate all of the header files for you from the top of a source tree checkout:
find . \( -not -regex '.*src/other.*' -not -regex '.*svn.*' -not -regex '.*cmake.*' \) -name \*.h | grep 'conv/'
This is a lot of edits, but they are very simple edits. You don't even really need to understand C to do this task, but it might help you go a little faster. You're welcome to write a script or not.
You only need to be able to first compile BRL-CAD successfully so you can recompile during/after your edits and know whether you changed anything wrong.
Obtain our trunk sources from a Subversion checkout or VM from Sourceforge. Submit a patch file of all your changes: svn diff my_patch.diff
File name/URL | File size | Date submitted | |
---|---|---|---|
headers.patch | 140.8 KB | December 15 2013 22:50 UTC |
I would like to work on this task.
This task has been assigned to agkphysics. You have 72 hours to complete this task, good luck!
The work on this task is ready to be reviewed.
The changes build correctly on my system.
Upon quick inspection, this looks fantastic. Did you automate the edits or perform them manually? Also, how long did it take you (not including compile time)?
Very nicely accomplished, applied in r58935.
Congratulations, this task has been completed successfully.
I started doing the few odd ones by hand. But I wrote a little script which uses sed to change the three lines necessary, in all the 200 odd ones in that one directory.
All in all it probably took a few hours. I had to take a crash course in sed usage and shell scripting because had never really used them before.
Do you want me to supply the script?
Since the task is closed, how about just pasting the script here in a comment? Really glad to hear about the crash course exploration of a topic new to you! That's exactly what you should be doing. ;) That will make you a far better programmer than most in the long run. Keep it up.
#!/bin/sh
for file in $(ls *.h)
do
HEADER=$(echo $file | tr '[:lower:]' '[:upper:]' | sed -e 's/\./_/')
HEADER="CONV_STEP_STEP_G_${HEADER}"
sed -e "s/#ifndef [A-Z][A-Z_]*_H_/#ifndef $HEADER/" -e "s/#define [A-Z][A-Z_]*_H_/#define $HEADER/" -e "s/#endif \/\* .*/#endif \/\* $HEADER \*\//" $file ${file}.new
mv ${file}.new $file
done