lkubuntu

A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

extract-xxx – An easy way of extracting XXX/FIXME’s

First: The “Why”. Well, it’s because when I write code, I usually don’t have the time (or the patience) to write everything perfectly, so I usually just write in a small XXX, TODO, or FIXME for later. The issue is, when I do want to fix them (e.g. in the final polishing stage of development), it’s hard to find them (especially if you have many source files, and it takes some time to open any of them). Also, it’s because I wanted to learn perl, and I wanted to take a small break from my other project (which is taking up most of my free time).

The repository is here: https://github.com/MiJyn/extract-xxx. Download it however you want, then run extract-xxx.pl.

What it basically does is that it searches through a file for the “comment types” (which is just a name I assigned for things like “XXX” or “TODO”, since I don’t know that they’re really called), and then prints them with (by default), 2 lines of context, both before and after. It’s kind of like grep, but it’s a bit more specialized towards this task (though you could theoretically do everything this does by fancy utilization of grep, find, and nl).

Example usage:

$ ./extract-xxx.pl -e 'cpp,h'
./src/engine/box.cpp

 51   |  */
 52   | bool Box::uncollide(Box* other, QVector3D old_pos) {
>53>>>|         // XXX: VAR_IS_UNUSED(old_pos)
 54   | 
 55   |         // Broadphase (?)
>56>>>|         // TODO: Check if this actually increases performance
 57   |         if (!this->collides(other)) {
 58   |                 return false;

 61   |                   ds = d + other->size;
 62   |         QVector3D overlap;
>63>>>|         // TODO: Decide the side from `old_pos`
 64   | #define syd_box_ov(x, X) {\
 65   |         qreal x##l_s = syd_max(0, d.x()),\

 79   |  */
 80   | bool Box::render() {
>81>>>|         // TODO: Use Vertex Array Object!
 82   |         qreal ex = size.x() / 2,
 83   |               ey = size.y() / 2,

./src/engine/image.cpp

 66   |         }
 67   |         this->image = image;
>68>>>|         // TODO: Maybe add support for graphics cards that support non-POT images?
 69   |         bool use_mipmaps = this->power_of_two();
 70   |         if (!this->id) {
 71   |                 glGenTextures(1, &this->id);
 72   |         }
>73>>>|         // TODO: Add support for GL_LUMINANCE and GL_LUMINANCE_ALPHA
 74   |         GLint format = this->image.hasAlphaChannel() ? GL_RGBA : GL_RGB;
 75   |         glBindTexture(GL_TEXTURE_2D, this->id);

 78   |                         /* This value must be 0, according to the OpenGL documentation... */ 0,
 79   |                         format, GL_UNSIGNED_BYTE, this->image.bits());
>80>>>|         // TODO: Add support for GL_LINEAR
 81   |         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 82   |         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (use_mipmaps) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);

./include/syd/math.h

 23  | }
 24  | 
>25>>| // TODO: Add/use those ultra-optimized-and-hacky functions
 26  | 
 27  | SYD_END_FILE

When run with no arguments, it will recursively go through the current directory (including sub-directories, and sub-sub-directories, etc…), and will then go through each file, as mentioned previously. As you can notice, many lines are highlighted (e.g. >53>>>), as they contain a “comment type” (in this case, either TODO or XXX), proceeded by a colon.

Instead of rewriting everything here, check out the repository, as the README explains pretty much everything you need to know about it.

Anyways, let me know what you think, any constructive criticism is appreciated :)

About these ads

One response to “extract-xxx – An easy way of extracting XXX/FIXME’s

  1. Robert Schroll April 27, 2013 at 2:10 pm

    FYI: grep -R -n -C2 -E “(TODO|XXX|FIXME):”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 166 other followers

%d bloggers like this: