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
[] = {
75 "0.93.94", /* 64-bit build .93.94 is broken */
81 * These are versions of LessTif that are known NOT to be stable with NEdit in
84 const char *const knownBadLessTif
[] = {
94 "0.93.94", /* 64-bit build .93.94 is broken */
96 "0.93.95b", /* SF bug 1087192 */
97 "0.94.4", /* Alt-H, ESC => crash */
98 "0.95.0", /* same as above */
103 #ifdef LESSTIF_VERSION
105 static enum MotifStability
GetLessTifStability(void)
108 const char *rev
= NULL
;
110 /* We assume that the lesstif version is the string after the last
113 rev
= strrchr(LesstifVERSION_STRING
, ' ');
120 /* Check for known good LessTif versions */
121 for (i
= 0; knownGoodLesstif
[i
]; i
++)
122 if (!strcmp(rev
, knownGoodLesstif
[i
]))
123 return MotifKnownGood
;
125 /* Check for known bad LessTif versions */
126 for (i
= 0; knownBadLessTif
[i
]; i
++)
127 if (!strcmp(rev
, knownBadLessTif
[i
]))
128 return MotifKnownBad
;
135 /* The stability depends on the patch level, so fold it into the
136 usual XmVersion for easy comparison. */
137 static const int XmFullVersion
= (XmVersion
* 100 + XmUPDATE_LEVEL
);
139 static enum MotifStability
GetOpenMotifStability(void)
141 enum MotifStability result
= MotifUnknown
;
143 const Boolean really222
=
144 (strcmp("@(#)Motif Version 2.2.2", XmVERSION_STRING
) == 0);
146 if (XmFullVersion
<= 200200) /* 1.0 - 2.1 are fine */
148 result
= MotifKnownGood
;
150 else if ((XmFullVersion
< 200202) || really222
) /* 2.2.0 - 2.2.2 are bad */
152 result
= MotifKnownBad
;
154 else if (XmFullVersion
>= 200203 && XmFullVersion
<= 200300) /* 2.2.3 - 2.3 is good */
156 result
= MotifKnownGood
;
158 else /* Anything else unknown */
160 result
= MotifUnknown
;
169 enum MotifStability
GetMotifStability(void)
171 #ifdef LESSTIF_VERSION
172 return GetLessTifStability();
174 return GetOpenMotifStability();
179 const char *GetMotifStableVersions(void)
182 static char msg
[sizeof knownGoodLesstif
* 80];
184 for (i
= 0; knownGoodLesstif
[i
] != NULL
; i
++)
186 strcat(msg
, knownGoodLesstif
[i
]);
190 strcat(msg
, "OpenMotif 2.1.30\n");
191 strcat(msg
, "OpenMotif 2.2.3\n");
192 strcat(msg
, "OpenMotif 2.3\n");