1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
/*******************************************************************************
* *
* motif.c: Determine stability of Motif *
* *
* Copyright (C) 2003 Nathaniel Gray *
* *
* This is free software; you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. In addition, you may distribute versions of this program linked to *
* Motif or Open Motif. See README for details. *
* *
* This software is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* software; if not, write to the Free Software Foundation, Inc., 59 Temple *
* Place, Suite 330, Boston, MA 02111-1307 USA *
* *
* Nirvana Text Editor *
* July 28, 1992 *
* *
* Written by Nathaniel Gray *
* *
* Modifications by: *
* Scott Tringali *
* *
*******************************************************************************/
/*
* About the different #defines that Motif gives us:
* All Motifs #define several values. These are the values in
* Open Motif 2.1.30, for example:
* #define XmVERSION 2
* #define XmREVISION 1
* #define XmUPDATE_LEVEL 30
* #define XmVersion (XmVERSION * 1000 + XmREVISION)
* #define XmVERSION_STRING "@(#)Motif Version 2.1.30"
*
* In addition, LessTif #defines several values as shown here for
* version 0.93.0:
* #define LESSTIF_VERSION 0
* #define LESSTIF_REVISION 93
* #define LesstifVersion (LESSTIF_VERSION * 1000 + LESSTIF_REVISION)
* #define LesstifVERSION_STRING \
* "@(#)GNU/LessTif Version 2.1 Release 0.93.0"
*
* Also, in LessTif the XmVERSION_STRING is identical to the
* LesstifVERSION_STRING. Unfortunately, the only way to find out the
* "update level" of a LessTif release is to parse the LesstifVERSION_STRING.
*/
#include "motif.h"
#include <Xm/Xm.h>
#include <string.h>
#ifdef LESSTIF_VERSION
static enum MotifStability GetLessTifStability(void);
#else
static enum MotifStability GetOpenMotifStability(void);
#endif
/*
* These are versions of LessTif that are known to be stable with NEdit in
* Motif 2.1 mode.
*/
static const char *const knownGoodLesstif[] = {
"0.92.32",
"0.93.0",
"0.93.12",
"0.93.18",
#ifndef __x86_64
"0.93.94", /* 64-bit build .93.94 is broken */
#endif
NULL
};
/*
* These are versions of LessTif that are known NOT to be stable with NEdit in
* Motif 2.1 mode.
*/
const char *const knownBadLessTif[] = {
"0.93.25",
"0.93.29",
"0.93.34"
"0.93.36",
"0.93.39",
"0.93.40",
"0.93.41",
"0.93.44",
#ifdef __x86_64
"0.93.94", /* 64-bit build .93.94 is broken */
#endif
"0.93.95b", /* SF bug 1087192 */
"0.94.4", /* Alt-H, ESC => crash */
"0.95.0", /* same as above */
NULL
};
#ifdef LESSTIF_VERSION
static enum MotifStability GetLessTifStability(void)
{
int i;
const char *rev = NULL;
/* We assume that the lesstif version is the string after the last
space. */
rev = strrchr(LesstifVERSION_STRING, ' ');
if (rev == NULL)
return MotifUnknown;
rev += 1;
/* Check for known good LessTif versions */
for (i = 0; knownGoodLesstif[i]; i++)
if (!strcmp(rev, knownGoodLesstif[i]))
return MotifKnownGood;
/* Check for known bad LessTif versions */
for (i = 0; knownBadLessTif[i]; i++)
if (!strcmp(rev, knownBadLessTif[i]))
return MotifKnownBad;
return MotifUnknown;
}
#else
/* The stability depends on the patch level, so fold it into the
usual XmVersion for easy comparison. */
static const int XmFullVersion = (XmVersion * 100 + XmUPDATE_LEVEL);
static enum MotifStability GetOpenMotifStability(void)
{
enum MotifStability result = MotifUnknown;
const Boolean really222 =
(strcmp("@(#)Motif Version 2.2.2", XmVERSION_STRING) == 0);
if (XmFullVersion <= 200200) /* 1.0 - 2.1 are fine */
{
result = MotifKnownGood;
}
else if ((XmFullVersion < 200202) || really222) /* 2.2.0 - 2.2.2 are bad */
{
result = MotifKnownBad;
}
else if (XmFullVersion >= 200203 && XmFullVersion <= 200304) /* 2.2.3 - 2.3 is good */
{
result = MotifKnownGood;
}
else /* Anything else unknown */
{
result = MotifUnknown;
}
return result;
}
#endif
enum MotifStability GetMotifStability(void)
{
#ifdef LESSTIF_VERSION
return GetLessTifStability();
#else
return GetOpenMotifStability();
#endif
}
const char *GetMotifStableVersions(void)
{
int i;
static char msg[sizeof knownGoodLesstif * 80];
for (i = 0; knownGoodLesstif[i] != NULL; i++)
{
strcat(msg, knownGoodLesstif[i]);
strcat(msg, "\n");
}
strcat(msg, "OpenMotif 2.1.30\n");
strcat(msg, "OpenMotif 2.2.3\n");
strcat(msg, "OpenMotif 2.3\n");
strcat(msg, "OpenMotif 2.3.4\n");
return msg;
}
|