Re: patches to make it compile with very old compilers
"J. R. Mauro" <[email protected]>
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <[email protected]> |
On Jul 17, 2009, at 11:39, "Bernhard R. Link" <[email protected]> wrote: > Here are two patches to make ratpoison compile with older > compilers. > > The first one fixes an actual bug in putting libraries in library > flags instead of libraries: > > Subject: [PATCH] move libraries from LDFLAGS to LDADD to avoid > problems in argument order > > diff --git a/src/Makefile.am b/src/Makefile.am > index 715c47b..b4ce142 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -22,7 +22,8 @@ > bin_PROGRAMS = ratpoison > MAINTAINERCLEANFILES = Makefile.in config.h.in > > -AM_LDFLAGS=${X_LDFLAGS} ${X_LIBS} ${X_EXTRA_LIBS} ${XFT_LIBS} $ > {HISTORY_LIBS} > +AM_LDFLAGS=${X_LDFLAGS} > +ratpoison_LDADD=${XFT_LIBS} ${X_LIBS} ${X_EXTRA_LIBS} ${HISTORY_LIBS} > AM_CPPFLAGS=${X_CFLAGS} ${XFT_CFLAGS} > > ratpoison_SOURCES = actions.c \ > > I've applied this as "obvious trivial bugfix". > > The second patch[1] stops using some c99 features to make it compile > with > gcc version 2, which I am very unsure about: > > --- a/src/history.c > +++ b/src/history.c > @@ -65,7 +65,7 @@ extract_shell_part (const char *p) > > struct history_item { > struct list_head node; > - char line[]; > + char line[1]; > }; > > static struct history { > @@ -155,7 +155,7 @@ history_add_upto (int history_id, const char > *item, size_t max) > return; > > item_len = strlen(item); > - i = xmalloc (sizeof(struct history_item) + item_len + 1); > + i = xmalloc (sizeof(struct history_item) + item_len); > > memcpy (i->line, item, item_len + 1); > list_add_tail (&i->node, &h->head); > > Pros: > - makes it work with some gcc 2.9x compilers. > (I do not know how many, as linkedlist.h also uses enhancements, > so that even with this it is not c89 compatible but at most some > older variants of gnu89). IIRC the Linux linkedlist includes more portable non-gcc-specific idioms in case of an old GCC. You might try bringing those into the RP linked list. > > Cons: > - we are 10 years after c99 > - might confuse any array length checkers (though they might have > an exception for [1], as that does not make much sense otherwise). > > What do you think? > > Hochachtungsvoll, > Bernhard R. Link > > [1] written and tested by Ineiev <[email protected]> > > > _______________________________________________ > Ratpoison-devel mailing list > [email protected] > http://lists.nongnu.org/mailman/listinfo/ratpoison-devel