It is time for a gripe.
Libc contains a lot of quite APIs. You probably know about the
gets dissaster, but there is a whole lot more.
- String-to-value conversions. Here is how you
convert from a string
s containing a decimal integer
into an int
errno = 0;
l = strtol (s, &end, 10);
if (s != end && *end == 0 &&
errno != ERANGE &&
l >= INT_MIN && l
And that is before considering locales (which typically do not
affect integers, mind you).
- Time zones. The
is great, but having $TZ as as implicit and not explicit argument
makes it really, really hard to use for anything but the default
- ctype functions. At least two things are wrong:
(1) the encoding used is an implicit argument; and (2) they are defined obscurely such that
char c = 'a'; isdigit(c) may or may not
be valid, depending on the platform. Most commonly it is not valid,
i.e., it may core dump. The right way to do that is,
isdigit((unsigned char)c) which is enough to make a sane man crazy. (Alternatively one
unsigned char but in
more practical code the type is often constrained by a parameter type.)
I have the feeling I might return to this subject later.
In the grand tradition of nntp-over-rss, let me kick in a word or two
about file choosers. Start by reading what Federico — wrote on the topic.
Regarding Emacs, Federico missed a few important things. (Any description of Emacs that is smaller than the tar ball is incomplete, naturally.)
- Case: Completion in Emacs is (optionally, this being Emacs) case insensitive. This is very useful if you are lazy
with the shift key or just happens to get a lot of filenames via a
- The Tab key will, after completions have been listed, scroll the completion window when you press it again. (I actually wrote that a decade or so ago.) This makes it possible to
navigate large directories fairly easily. A drop-down like the one
the GTK+ file chooser provides is not useful for this. Note, btw.,
that this feature also makes completion useful in keyboard-only mode.
- A completing Tab that ends up with multiple choices left does not also list the choices
for two reasons: (a) it is slow on a 9600 baud terminal and (b) if you are just using the Tab key to speed up entry you generally do not
want the list of possible matches until you are not making progress. The latter is still valid and
prevents the UI from getting in your way. The FileChooser’s
completion is very much getting in the way: it steals focus and
obscures parts of the dialog you want to see.
In my experience this means that the Emacs completion is useful while
the FileChooser’s is not. That is especially true in directories with hundreds of files. (And that is before we discuss bugs that cause people to overwrite files they did not intend. The current state of save-as is somewhere between “barely usable” and “dangerous to your files”.)
On opening files: suppose I want to add a “gtk-button-images = 0” setting in ~/.gtkrc-2.0. Why do I have to use two different UIs depending on whether that file already exists? The logical extension of that would be to have two entirely
different UIs for save-to-new-file and overwrite-existing-file; we
are lucky no-one in Redmond thought of that, I guess, 🙂
This should not be too hard to fix — I will have a go at it in a
On screen real estate: The GTK+ file chooser gives
me a vew of 7-8 files (typically directories, actually) when it comes
up. To locate a file I have got to scroll which is a bit hard with
such a small viewport. Emacs, on the other hand lists files in
batches of 36 files. Guess which one I find more useful. (This
is actually for a large part a treeview issue.)
All the above comes through a little more negative than I really
wanted it to. I do appreciate all the work that Federico has put
into the FileChooser. My goal is not to assign blame for where we
are — that would be pointless or worse — but to get us to a better state.