Peculiar behavior of Sed

What is Sed?

Sed is the ultimate stream editor. If that sounds strange, picture a stream flowing through a pipe. Okay, you can’t see a stream if it’s inside a pipe. That’s what I get for attempting a flowing analogy. You want literature, read James Joyce.

Anyhow, sed is a marvelous utility. Unfortunately, most people never learn its real power. The language is very simple, but the documentation is terrible. The Solaris on-line manual pages for sed are five pages long, and two of those pages describe the 34 different errors you can get. A program that spends as much space documenting the errors than it does documenting the language has a serious learning curve.

You can read more about Sed here.

My project uses a thick binding of PostgreSQL/MySQL called APQ. APQ is a project by Warren and I helped to host it at my server. See my post here. The configure and make process are not really stable which I think is due to various version of MySQL and the Linux tools such as sed.

To build APQ, first, two MySQL include files, errmsg.h and mysqld_error.h need to be parsed. These files contain MySQL error codes and they need to be parsed and translated into Ada syntax. This translated Ada code will be inserted into apq_mysql.ads.

However, this parsing and translation process are not working correctly as they supposed to be. When I look into this problem, I found a peculiar abnormality. The parser uses sed. When I built APQ on Mac OS X, FC5 and Solaris (Intel), the result in apq_mysql.ads is not consistent on these different OS.

After I upgraded to Mac OS X 10.4.9, the parser refused to work with some error messages which I think caused by sed. I was mingling with the configure script until this hour. Suddenly, something struck my mind. Why do I need to mingle with configure? The problem is the parsing and it deserves the highest priority. The build configuration does not perform a thorough check of the environment but it still works fine at this point. So, I moved my priority to write a parser in Ada to solve the parsing problem. This light shed on me at this whee hour in the morning and I was really too tire to continue working on the parser.

Comments

Leave a Reply