Older blog entries for redi (starting at number 14)

I'm adding buffering to the PStreams stream buffer class (it's currently unbuffered, which isn't an oxymoron, honest) and have found some errors in Langer & Kreft's IOStream book so I went to find the errata, and found that my first printing has quite a few errors. This isn't the first time I've wished I could exchange a 1st printing for a discount on a corrected one, as these things ain't cheap. I'll have to be more patient and wait for a reprint of the next new book I want to buy. Unless I find way to patch hardcopy I'll have to take sharp pencil to the book tomorrow.

I've also started abstracting the creation and control of the child process to a separate class to separate the responsibilities of the streambuf. I keep being pleased with the results of applying received programming wisdom even on such a small set of classes as I'm writing. The code is so much simpler when the design is right.

14 Sep 2002 (updated 11 Oct 2002 at 14:33 UTC) »

Finally got djbdns running at home. For some reason it took me ages as I kept putting the wrong addresses in resolv.conf, or the dnscache environment, or something else over and over again. I think setting bind up would have taken me longer, and I wouldn't have been confident I'd done it securely. Learning a bit about DNS doesn't really make up for being ill and missing a band on a friday night, but my computer's a bit better now. bah. I think I quite like DJ Bernstein's svscan alternative to init.d for starting and stopping services.

bgeiger: to get Mozilla to do a tooltip style popup use the title attribute. The standard specifically says it can be rendered as a tooltip in visual browsers, it says no such thing for alt. title can also be applied to any element, not just <img>, try it with <span> around some text (in a good browser anyway). If you must use tooltips you can put the same text for alt and title to do a tooltip that works in Netscape4, Mozilla, Konqueror, Opera and IE. And that's why Mozilla won't change. A more accessible reference here
Update: oops, that "more accessible reference" was a local file on my hard drive! Fixed to point to the online version

11 Sep 2002 (updated 14 Sep 2002 at 15:22 UTC) »

A fair bit of work on PStreams over the weekend, not much sleep, but lots of big ideas for where to take it once the current work is done and it's feature complete. More on this soon, once I've thunked a bit more and need to make some notes for myself. I had to get out of bed the other night to scribble some ideas down that had come to me as I was drifting of to sleep. I would have been able to remember them fine in the morning, but they were burning a whole in my head and I had to write them down to so I could go to sleep. I've learnt a lot from doing this project (what's used in the code is only a fraction of it) and it's interesting to look at the progression of my ideas and how they and the classes coalesced into the current design. Interesting for me anyway. I don't expect anyone else is even reading this. Go read a good book instead if you are, you'll get a lot more out of it.

Reminder: track down SIGPIPEs on Solaris and see why they're raised there and not on other platforms. Hmm.

Reminder: check the latest code into CVS. It's functionally better than the previous version, has more features, and I'll not be able to implement my big ideas for the future until it's in. done

Some responses...
goingware: Happy birthday to your mother and aunt. I'm about to go see a friend who's birthday it is today as well. I don't think he's been looking forward to it much, with the other significance this date has now. He owns a pub though, so I imagine we'll all get into birthday mood eventually. You can't let every birthday be ruined because something tragic happened on that date. There's no logical reason why today should be any more upsetting than the 100 day anniversary, or 1000 days. But that's logic for you.
fxn: Glad to hear there'll be a filter on recentlog. I'm not sure I'd use it often (some unrated people have interesting things to say) but it could be useful sometimes. Will it only work on diary ratings? Or on cert level and/or username as well? The diary ratings include other people's ratings, which might someone who's scribblings you enjoy reading are filtered out because everyone else has rated them down. Ignore me for now, I'll have a look when you release it.
mtearle: I got someone to download OpenOffice to install at their workplace today. I'd mentioned it before, and he phoned me up to ask about it, as he didn't want the hassle of finding out whether they were licensed to install another copy of Office, and the hassle of using Office! I hope he's happy with it.

4 Sep 2002 (updated 4 Sep 2002 at 18:16 UTC) »
mathieu: I was only half paying attention. Yes, line 3 might not behave as expected. You probably know this already, but I'm explaining for my own benefit as much as anything! The array initialisation in line 2 creates an array on the stack, of size strlen("this is a string you can modify")+1, and copies the characters in the string literal into the array. Line 1 assigns the address of the string literal to p. a is therefore an array of non-const chars that can be modified and line 3 is fine. p points to the actual string literal, which is an array of non-modifiable chars and so line 4 invokes undefined behaviour (on my OS the literal is in the text section of the executable, which can't be modified, but that's an implementation detail).

I agree that the code shouldn't be valid; if string literals in C had type const char [] instead of being "non-modifiable char" [] the problem wouldn't exist. Bjarne Stroustrup's doing an interesting series of articles in the C/C++ Users Journal at the moment about C/C++ compatibility and why C++ retains this sort of gotcha from C, rather than fixing the mistake and abandoning compatibility.

bjf: Have you looked at WML?
3 Sep 2002 (updated 3 Sep 2002 at 10:35 UTC) »

Passed the technical test thing I took last week for a job, so I'm in for an interview. I'm quite surprised, as although the test was very easy, I spent too long on the C++ section crafting the perfect answers and stupidly ran out of time and didn't write anything for some other chunks of it (and wrote complete rubbish for the database bit as I rushed to scribble something down.) Nevermind, I'm the only person to get through to the interview. Which is nice.

mathieu:

You're modifying a string literal. String literals in C have type (non-const) char*, but are non-modifiable, doing so invokes the dreaded undefined behaviour, so a coredump isn't too bad, you should think yourself lucky you didn't rupture a hole in the fabric of the universe. In C++ string literals are const, but as Stroustrup The Wise explains:

The type of a string literal is "array of the appropriate number of const characters," so "Bohr" is of type const char[5].
A string literal can be assigned to a char*. This is allowed because in previous definitions of C and C++, the type of a string literal was char*. Allowing this assignment of a string literal to a char* ensures that millions of lines of C and C++ remain valid. It is, however, an error to try to modify a string literal through such a pointer:
void f()
{
    char* p = "Plato";
    p[4] = 'e';  // error: assigment to const; result is undefined
}
This kind of error cannot in general be caught until run-time, and implementations differ in their enforcement of this rule.
Stroustrup, C++PL3E, ยง5.2.2

amars:

"Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians."
Edsger Dijkstra
I'm not sure I agree, but who am I to argue with Dijkstra?
28 Aug 2002 (updated 12 Sep 2003 at 08:42 UTC) »
xach's Nigeria 419 Scam beats the hell out of the original. Cheers for a giggle, xach!
I guess it's the online equivalent of inviting Jehova's Witnesses in and preaching to them rather than the other way round, just to see if you can twist their melons. My brother and I tried this with a couple of Mormons who stopped us in the street on friday night (or all times!)
Them: "Have you heard of the Church of Jesus Christ and the Latter Day Saints?"
Me: "Yes, I have actually, but it's not my bag. Want a toke on this? No, I thought not."
Bro: "Are you familiar with Sufism? Read any Idris Shah? Oooh, let me enlighten you..."
I have nothing against people who've "Got Faith", but I resent their assumption that everyone else is spiritually ignorant and is just waiting to be shown the light.
Oops, back to software...

Found an ICE in mainline GCC, but probably didn't need to include preprocessed unistd.h file in the report since test case doesn't use anything from it (it used to, but I reduced it). Or maybe it doesn't ICE without unistd.h? Should have been paying more attention when I reported it - this diary entry is to remind me to check tonight!

Another reminder: fix JavaScript on my sidebars page: left "//" out of baseurl variable. Doh! Still works though. Mozilla won't let you add sidebars from local URLs, neither file://fnordikus nor http://localhost/ting is allowed to be used as a sidebar. I wonder why not. When I'm at home I want to have my sidebars loaded from the localhost, not across my dialup connection. Workaround: use external hostname instead of localhost.

(That's enough rambling nonsense - Ed.)

Update: The 3rd Annual Nigerian EMail Conference

What have I been up to recently...

Fixed some dumbass copy'n'paste errors in PStreams - I should make time to work on it, rather than trying to do it in 5 mins late at night

Started converting the libstdc++ web pages to XHTML. It's a fairly simple process using sed, sh, vim and some scissors and glue.

Got annoyed at the MySQL people, but resisted the urge to fire off an angry email. In version 3.23.48 (I think) they made the mysqldump utility generate output that causes an error when you try to import the dump into any earlier version. Not the sort of change I expect from a minor minor revision, especially as it wasn't mentioned in the ChangeLog. The change was in the meaning of the --opt option, which from 3.23.48 onwards has the additional meaning of "make the output incompatible with all previous versions". Nice. No need to document that, no no no. You'd spoil the fun of letting people find that out for themselves. The option's supposed to have some use for the development version, 4.0, but for the stable 3.23 series it's ignored, or for older versions it means "cause an error".

Video Editing
Hoorah! Finished struggling with flaky hardware/win2k and captured all the video we want. Now for the fun part - editing it.
I've just been having a brief look at some apps for video capture and editing on unix (although most of them appear to be linux only) and it looks as though there's a lot more choice than the last time I looked. Unsurprisingly, I haven't seen anything as good as Adobe Premiere yet, that can do everything from capturing over 1394 to multi-track editing, but I'll keep looking, there must be something out there...

I can't remember the last time I wrote any code outside of work. After a recent holiday I had managed to wean myself off the Playstation2 and was about to do some work on my little open-source project (including re-licensing to LGPL which I'd promised to do weeks ago) when someone lent me a great cricket game. Now I keep playing it until the sun comes up (which is when I notice the time and that I have to work in about 4 hours). I must get some more sleep, and then I'll find time to do fix the outstanding problems with PStreams. Yeah right.
async: i've found an alternative to overusing parentheses when writing (and thinking!) - which i do too - use hyphens - recently I find they map better to my train of thought - but that's probably just because it's about to be derailed by lack of sleep.
I would get an early night now, but have promised someone I'd help them with some DV editing. Why do people assume that because you're a programmer you'd love to install PCI cards for them and arse about with broken drivers and try to get Adobe Premiere working on a Celeron with only 64MB RAM that's already struggling to breaking point under Win2k? I might be able to write C++ in my sleep, but that doesn't mean I want to wrestle with bloody windoze instead of sleeping! :)

5 older entries...

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!