Io: my errno adventure in C

This pastie holds my first C patch. It actually repaired a Readline problem that appeared on my Mac when I git pull‘d Io’s source today. See the Io issue at their bugtracker.

The pgsql heroes fixed the problem way before, so I could stand on the shoulders of smart giants.

I don’t know how to test C stuff, except for running the programs, and Jonas reminded to actually do that:

c-5b66e555:~ olle$ rm .io_history 
c-5b66e555:~ olle$ mkdir .io_history
c-5b66e555:~ olle$ io
Io 20080120

 Exception: while loading history file '/Users/olle/.io_history', reason: Is a directory
 ---------
 loadHistory                         Z_CLI.io 47
 ReadLine ?                           Z_CLI.io 47
 Call relayStopStatus                 A2_Object.io 295
 CLI loadHistory                      Z_CLI.io 94
 CLI interactiveMultiline             Z_CLI.io 82
 CLI run                              IoState_runCLI() 1

c-5b66e555:~ olle$ 

So, the complaining functionality is retained.

What’s it do?

For those who are beginners at C, like I am, this small digression might interest:

  • First we include the errno mechanism as an include: #include <errno.h>
  • in each function, initialize the value of the static global variable “errno” to 0
  • functions like read_history(filename), from the libedit library return an int, but…
  • We are not interested in the return value, so we cast the computation to be void, the errno mechanism will take care of remembering that int on its own
  • It seems to be culturally correct to check for success instead of failure.

All these factoids are guesstimates of what went on, and I’m interested in the real story someday. Please provide any insight as comments, dear reader.

PS: As you can tell, mucking about other people’s C code is not something I do every day. I felt good, but weird.

Web Hacking? Hackmeetup!

Our little Open Source Tuesday was yesterday night – we had a sit-down, took out our laptops, and continued our projects. All three of us.

I worked on understanding the PHP build system and workflow when creating C extensions. Got a bit further. I feel the need to write down the sequence of my failures, so that it can evolve into a guide. Here are the tips I got from ekneuss – First: compile your extension statically into a PHP5.3 source tree. Second: do not use make install.

Fredrik worked on exposing his C++ objects to Lua. A game, with spaceships, no less.

David was hacking Python on his cellphone. His invention: make the phone complain loudly every 5 minutes when there are still unread SMSes in its inbox.

Also new, another gathering: Our town’s Open Source environment is getting moving, more and more folks start gatherings, a really good thing. An open meetup on things Web 2.0 organized in Tomas’ home (!), as advertised on Facebook, and T’s blog “What’s Next”. (Via Guppy, of Polar Rose.)

Mercurial fanboy

I am impressed with the simplicity of Mercurial (the distributed version control system). It’s Python, and it’s got a built-in webserver, so it’s simple to show stuff to people:

hg serve [OPTION]...

export the repository via HTTP

    Start a local HTTP repository browser and pull server.

    By default, the server logs accesses to stdout and errors to
    stderr.  Use the "-A" and "-E" options to log to files.

options:

 -A --accesslog       name of access log file to write to
 -d --daemon          run server in background
    --daemon-pipefds  used internally by daemon mode
 -E --errorlog        name of error log file to write to
 -p --port            port to use (default: 8000)
 -a --address         address to use
 -n --name            name to show in web pages (default: working dir)
    --webdir-conf     name of the webdir config file (serve more than one repo)
    --pid-file        name of file to write process ID to
    --stdio           for remote clients
 -t --templates       web templates to use
    --style           template style to use
 -6 --ipv6            use IPv6 in addition to IPv4
    --certificate     SSL certificate file

This will put up a nice little website, with search box that looks in the commit messages to find revisions.

Neat! Use this with nginx‘s port-forwarding functionality, and you’re done.

Marketing that Open Source Tuesday




20

Originally uploaded by Br0m

Today I asked Henriette Weber where to post the concept of “hack meetups” in Malmö to get folks to know about it. She said she’d email the BarCamp Copenhagen mailing list. Excellent idea. Thanks.

Also, when making your mind up if you want to come, please tell me about it (also, if you cancel), that helps with any capacity planning.

Obama, Open Government: machine-readable govt documentation trails

By reading random($foo), which had a long list of Obama facts, I now understand why Mr. Barack Obama is a chance for USA to heal. I endorse that guy.

Read about machine-readable docs at the xkcd guy’s blog. Programming folks would be enabled and implicitly encouraged to create community tools that actually monitored the decisions of the elect. I’m moved.

Talk on software quality with phpUnderControl

Update: More details on the place, and THANKS to Peytz & co. for hosting.

The dog ate my fine blog post about the PHP Meetup this past Thursday. So I reconstruct this from memory.

The past Thursday, there was a PHP Meetup Copenhagen, and I talked about phpUnderControl, a continuous integration server for PHP. Basically, it’s an ambitious patch for CruiseControl, a big old Java project. The folks that hosted the thing were Peytz & Co, a web app company, who creates little services, like user surveys and such. Their facilities were awesome, and we got fine pizza and even a pilsner. Large, mess hall-like room with two huge tables. It was out in the sticks, though (Nordvest is far off for a Nørrebro guy; or is it, folks?), so I had to get on a bus to get there.

During the talk, I asked the attendees about their testing/coverage situation. Turns out we all have lots of room for improvement, so most of my talk was not about “how to install” phpUnderControl, nor any other tool (this info is readily available online), but on practical tips on getting coverage. How to start, when your legacy is huge. How to use the numbers and other metrics from PHPUnit. I showed Michael Feathersbook about testing & legacy code.

I met with David T, with whom I had only talked online before. He once sent me an email out of the blue: “I am moving to Copenhagen, I also hack the web, I’m also Swedish”, and we’ve kept track of each other since. But Thursday was the first time I met him.

Bonus detail, on blog only: Manuel, author of phpUnderControl, told me to also point to PHP_Depend, his new metrics tool that wants to visualize the dependencies among the packages involved in your application. Package? Yes, PHP has no package scope, nor anything near it, so PHP_Depend parses the @package marker in a documentation block.

I am working on making the slides into a useful online read, as a PDF you can spacebar through.

Mini-reminder: Mosig meetup at La Trattoria at 18:30 tonight

The amazing Malmö Open Source Interest Group (abbreviated Mosig) rolls on. “Odd Wednesday nights” is the meme that is our meetup schedule. The pizza place La Trattoria near Drottningtorget is the place to go.

Also in the news: February 8 is the opening day for the new library in Sofielund. It’s called “Garaget” (English: The Garage). Has some novel ideas already implemented. The municipality seems interested in FOSS (free and open source software, to you), and Mosig has done some demos of free software at the city library before.

I guess the reminder is more about that these meetups come back every other week. Not about the meetup that is in 2 hours.