[Python-Dev] ANSIfication.

Thomas Wouters thomas@xs4all.net
Sun, 23 Jul 2000 02:24:53 +0200

I'm done checking in the ansification patches. It doesn't fix everything,
for a couple of reasons:

- Some function-declarations and function-pointers store functions I don't
have access to, like the 'sv' and 'gl' modules, and the 'gl' module seems
half auto-generated.

- the 'dl' module does some nasty things which I don't feel deserve a
prototype. (loading a function using dl_sym, and calling it with 10
char* arguments.)

- Some prototypes aren't standardized. This is only really a problem with
getopt(), called from Modules/main.c. On some systems, it's 'char **', on
some it's 'const char **', and those two pointers are not compatible. (Or
did they fix that in C9X ? Somehow I doubt it.)

- Readline is a mess. I can start adding prototypes, but the standard
readline include files don't do that either, and I'm not terribly sure on
some of the prototypes, having never worked with readline myself. The
infopages try to be as vague as possible on what kind of function the second
argument to 'rl_bind' is, for instance ;)

I've fixed the passing of 'PyErr_CheckSignals(void)' to Py_AddPendingCall
(which wants a function that takes a void* argument instead) by passing a
static wrapper function instead, in both instances (Modules/signalmodule.c
and Parser/intrcheck.c.)

I'm also tempted to suggest to remove most of the 'extern's, and possibly
add them to pyport.h if they are still an issue. Most of the current externs
for library functions seem to me like old cruft, though I have no way of
telling how old they are. The getopt() prototype would be solved that way,
in any case, by removing it and relying on the appropriate include file
defining it.

Here's an example of what I think is old cruft:
/* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */
extern int rename(const char *, const char *);
extern int pclose(FILE *);
extern int lstat(const char *, struct stat *);
extern int symlink(const char *, const char *);
extern int fsync(int fd);

There are a couple of more things that might be candidate for cleanup or
removal now, by the way. The 'ANY' #define in Include/mymalloc.h, and the
type(s) derived from it, for instance. I'm not sure how 'standard' the void*
type is, but I thought it was ANSI mandated ?

If anyone wants to look at one or more of the above problems, here's how you
can find them:

find . -name '*.[ch]' | xargs fgrep extern | fgrep '()'
find . -name '*.[ch]' | xargs fgrep ')()'

Night-night-ly y'rs,
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!