Add LessTif 0.94.4 to known-bad list
[nedit.git] / util / motif.c
blob8fc06bee170fa0b03950efe404b5240cd3b53e91
1 /*******************************************************************************
2 * *
3 * motif.c: Determine stability of Motif *
4 * *
5 * Copyright (C) 2003 Nathaniel Gray *
6 * *
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. *
12 * *
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 *
16 * for more details. *
17 * *
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 *
21 * *
22 * Nirvana Text Editor *
23 * July 28, 1992 *
24 * *
25 * Written by Nathaniel Gray *
26 * *
27 * Modifications by: *
28 * Scott Tringali *
29 * *
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:
36 * #define XmVERSION 2
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
43 * version 0.93.0:
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.
55 #include "motif.h"
56 #include <Xm/Xm.h>
57 #include <string.h>
59 #ifdef LESSTIF_VERSION
60 static enum MotifStability GetLessTifStability(void);
61 #else
62 static enum MotifStability GetOpenMotifStability(void);
63 #endif
65 /*
66 * These are versions of LessTif that are known to be stable with NEdit in
67 * Motif 2.1 mode.
69 static const char *const knownGoodLesstif[] = {
70 "0.92.32",
71 "0.93.0",
72 "0.93.12",
73 "0.93.18",
74 "0.93.94",
75 NULL
78 /*
79 * These are versions of LessTif that are known NOT to be stable with NEdit in
80 * Motif 2.1 mode.
82 const char *const knownBadLessTif[] = {
83 "0.93.25",
84 "0.93.29",
85 "0.93.34"
86 "0.93.36",
87 "0.93.39",
88 "0.93.40",
89 "0.93.41",
90 "0.93.44",
91 "0.93.95b", /* SF bug 1087192 */
92 "0.94.4", /* Alt-H, ESC => crash */
93 NULL
97 #ifdef LESSTIF_VERSION
99 static enum MotifStability GetLessTifStability(void)
101 int i;
102 const char *rev = NULL;
104 /* We assume that the lesstif version is the string after the last
105 space. */
107 rev = strrchr(LesstifVERSION_STRING, ' ');
109 if (rev == NULL)
110 return MotifUnknown;
112 rev += 1;
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;
124 return MotifUnknown;
127 #else
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;
157 return result;
160 #endif
163 enum MotifStability GetMotifStability(void)
165 #ifdef LESSTIF_VERSION
166 return GetLessTifStability();
167 #else
168 return GetOpenMotifStability();
169 #endif
173 const char *GetMotifStableVersions(void)
175 int i;
176 static char msg[sizeof knownGoodLesstif * 80];
178 for (i = 0; knownGoodLesstif[i] != NULL; i++)
180 strcat(msg, knownGoodLesstif[i]);
181 strcat(msg, "\n");
184 strcat(msg, "OpenMotif 2.1.30\n");
185 strcat(msg, "OpenMotif 2.2.3\n");
187 return msg;