Older blog entries for whatever (starting at number 2)

OK, so I lied. I'll write about code visualisation when I can be bothered. Besides, when I read my previous diary entry, I sounded like Steve Job's pet gerbil on speed. I'm writing code, not marketing!

Speaking of Apple... I've been looking at those liquid gel buttons for ages, admiring just how beautiful they are. I'd love to have that under Linux, perhaps with some modelling of ink-drops, so this delicious red mist can swirl around inside a transluent blue button. Moving a window could shake the buttons inside, changing the swirl patterns. I'd buy another CPU to handle that sort of user interface! :)

I've written most of the parser for csed/cgrep. The parser is able to comprehend and step through itself, extract comments, functions, strings and variables (basic types only). Next step is to add in structs and typedefs so the parser can understand more complicated variable declarations. I'll know I've done a good job here when it understands Gtk+ types.

However, I've run into the same old brick wall. I've written the parser two ways and I don't know which one to keep.

The first is to have a central routine which feeds data character by character into state machines. This has the advantage of allowing me to feed in data from anywhere, so it would be easy to hook an editor into it.

The second method allows the state machines to retrieve information themselves, using callbacks to inform the main routines of any changes. This has the advantage of being able to embed any kind of callback, not just state changes, but would require an editor to have knowledge of the parser.

I could just flip a coin and pick one at random, but it would be a lot of work to back out one method and insert the other method if I discover my chosen method won't expand far enough to be capable of doing what I want. The hard part is that I want this to be totally compatible with existing code and methods. Eg, this ain't gonna be another IDE, but it should be easy to integrate into existing environments.

I'm ignoring this problem for the time being and have started writing a multi-state pattern matcher for the variable namespaces. When that's mostly complete, I'll look into how the parser and namespace engines can best hook into each other. I'm not using lex/yacc or any external libraries at this point, just ANSI C, so I have more leeway in choosing how to fit things together.

On the bright side, it should be pretty easy to change things around once I have these things working, so maybe I shouldn't sweat so much.

A major design feature of the world's most advanced transportation system, the capacity of the engines on the Space Shuttle, is determined by the size of a horse's arse. In the same way, the world's most advanced computers are limited by the size of our naughty bits.

How are we supposed to be perfect when Nature only gave us 7 registers? By the time the initial solution is half coded, programmers usually wish they'd written the code another way.

The problem is that it's hard to go back and update existing code.

As a trivial example, if you want to rename a function, you have to change the name in the code, the header, and everywhere the function is called. So much time is wasted doing this, yet this is something the computer could be doing. It could nearly be done with a for "*.c *.h" loop and sed.

The problem is that sed doesn't understand C code. It wouldn't have a clue whether the "fred(" in its buffer is the start of a function declaration or a function call. So Step 1 is to write a sed that does understand C code. Tedious but not hard.

Now we can change function names with a "csed --funcname s/oldname/newname/". We can now also change global variable names without touching local variables with "csed --global s/oldname/newname". And update function parameters. And insert function calls in the right places. And delete function calls. Lots of things like that.

If you're modifying library code that other projects use, you can generate csed commands to go along with your updates. The development teams on the other projects can then run those csed commands on their own code (with the "--ask" option of course!) to do the finding, tagging and most of the conversion for the tweaks and updates to your new API.

Sure, it can't do everything automatically, but you can tag csed changes with explanations, possibly even with URLs to relevant documentation, which is inserted into code above the changed functions to indicate which parts need more attention to complete the conversion.

You can also use this same code to grep for what you want. Looking for a macro definition? Type "cgrep --macdef MACRONAME *.h". Want to know where a function is called? How does "cgrep --calls funcname *.c" look? Want to know how much code depends on a function when planning a change? Try "cgrep --calls --descend funcname *.c".

That's quite a lot of useful functionality for embedding a simple C parser into grep and sed. Also allows for a few useful extensions too.

I'm in the middle of coding this now. It's boring, but it's one of the tools I need for what I REALLY want to do. The visualisation part.

More on that topic next entry.

I've been around for a long time, since the earliest days of Linux. I started with 0.11a and enjoyed hacking the kernel to get it to do what I wanted. I was one of the first developers in the Debian project, but I got burned out by all the ego-wars and left.

10 years later, Gtk+ and Gnome have caught my attention and I'm in the process of learning how it's all put together. I'm interested in writing code visualisation and modification tools; eg, being able to automate things like moving the GtkObject code to Glib, rather than having to spend a lot of time doing this manually.

I'm a drivers and low level kind of programmer, so this is my first foray into the world of writing programs that actually interact with the user. The hardest part is coming to grips with OOPs and other stuff that I bypassed for all these years.

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!