1 /*******************************************************************************
3 * motif.c: Determine stability of Motif *
5 * Copyright (C) 2003 Nathaniel Gray *
7 * This is free software; you can redistribute it and/or modify it under the *
8 * terms of the GNU General Public License as published by the Free Software *
9 * Foundation; either version 2 of the License, or (at your option) any later *
10 * version. In addition, you may distribute versions of this program linked to *
11 * Motif or Open Motif. See README for details. *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
20 * Place, Suite 330, Boston, MA 02111-1307 USA *
22 * Nirvana Text Editor *
25 * Written by Nathaniel Gray *
30 *******************************************************************************/
33 * About the different #defines that Motif gives us:
34 * All Motifs #define several values. These are the values in
35 * Open Motif 2.1.30, for example:
37 * #define XmREVISION 1
38 * #define XmUPDATE_LEVEL 30
39 * #define XmVersion (XmVERSION * 1000 + XmREVISION)
40 * #define XmVERSION_STRING "@(#)Motif Version 2.1.30"
42 * In addition, LessTif #defines several values as shown here for
44 * #define LESSTIF_VERSION 0
45 * #define LESSTIF_REVISION 93
46 * #define LesstifVersion (LESSTIF_VERSION * 1000 + LESSTIF_REVISION)
47 * #define LesstifVERSION_STRING \
48 * "@(#)GNU/LessTif Version 2.1 Release 0.93.0"
50 * Also, in LessTif the XmVERSION_STRING is identical to the
51 * LesstifVERSION_STRING. Unfortunately, the only way to find out the
52 * "update level" of a LessTif release is to parse the LesstifVERSION_STRING.
59 #ifdef LESSTIF_VERSION
60 static enum MotifStability
GetLessTifStability(void);
62 static enum MotifStability
GetOpenMotifStability(void);
66 * These are versions of LessTif that are known to be stable with NEdit in
69 static const char *const knownGoodLesstif
[] = {
79 * These are versions of LessTif that are known NOT to be stable with NEdit in
82 const char *const knownBadLessTif
[] = {
91 "0.93.95b", /* SF bug 1087192 */
92 "0.94.4", /* Alt-H, ESC => crash */
97 #ifdef LESSTIF_VERSION
99 static enum MotifStability
GetLessTifStability(void)
102 const char *rev
= NULL
;
104 /* We assume that the lesstif version is the string after the last
107 rev
= strrchr(LesstifVERSION_STRING
, ' ');
114 /* Check for known good LessTif versions */
115 for (i
= 0; knownGoodLesstif
[i
]; i
++)
116 if (!strcmp(rev
, knownGoodLesstif
[i
]))
117 return MotifKnownGood
;
119 /* Check for known bad LessTif versions */
120 for (i
= 0; knownBadLessTif
[i
]; i
++)
121 if (!strcmp(rev
, knownBadLessTif
[i
]))
122 return MotifKnownBad
;
129 /* The stability depends on the patch level, so fold it into the
130 usual XmVersion for easy comparison. */
131 static const int XmFullVersion
= (XmVersion
* 100 + XmUPDATE_LEVEL
);
133 static enum MotifStability
GetOpenMotifStability(void)
135 enum MotifStability result
= MotifUnknown
;
137 const Boolean really222
=
138 (strcmp("@(#)Motif Version 2.2.2", XmVERSION_STRING
) == 0);
140 if (XmFullVersion
<= 200200) /* 1.0 - 2.1 are fine */
142 result
= MotifKnownGood
;
144 else if ((XmFullVersion
< 200202) || really222
) /* 2.2.0 - 2.2.2 are bad */
146 result
= MotifKnownBad
;
148 else if (XmFullVersion
== 200203) /* 2.2.3 is good */
150 result
= MotifKnownGood
;
152 else /* Anything else unknown */
154 result
= MotifUnknown
;
163 enum MotifStability
GetMotifStability(void)
165 #ifdef LESSTIF_VERSION
166 return GetLessTifStability();
168 return GetOpenMotifStability();
173 const char *GetMotifStableVersions(void)
176 static char msg
[sizeof knownGoodLesstif
* 80];
178 for (i
= 0; knownGoodLesstif
[i
] != NULL
; i
++)
180 strcat(msg
, knownGoodLesstif
[i
]);
184 strcat(msg
, "OpenMotif 2.1.30\n");
185 strcat(msg
, "OpenMotif 2.2.3\n");