ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] patches to make it compile with very old compilers


From: Bernhard R. Link
Subject: [RP] patches to make it compile with very old compilers
Date: Fri, 17 Jul 2009 17:39:50 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

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).

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 <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]