|
26 | 26 |
|
27 | 27 | #ifndef DOS
|
28 | 28 | #include <pwd.h>
|
| 29 | +#include <sys/utsname.h> |
29 | 30 | #endif
|
30 | 31 |
|
31 | 32 | #include "lispemul.h"
|
@@ -212,47 +213,36 @@ LispPTR unix_username(LispPTR *args) {
|
212 | 213 | /* */
|
213 | 214 | /************************************************************************/
|
214 | 215 | /*
|
215 |
| - * The code for "MACH" and "ARCH" are really not correct and it's not |
216 |
| - * clear what use they are. RS/6000 systems use a PowerPC processor, |
217 |
| - * and so did PowerBook Macintosh systems. |
218 |
| - * "MACH" and "ARCH" both seem to be a mix of instruction set architecture and |
219 |
| - * system types (rs/6000 used PowerPC). |
220 |
| - * The only usage seems to be checking "ARCH" == "dos" and for the existance |
221 |
| - * of *any* result from the call, which indicates it's an emulated system. |
| 216 | + * The only usage for "ARCH" seems to be checking "ARCH" == "dos" |
| 217 | + * and for the existence of *any* result from the call, which |
| 218 | + * indicates it's an emulated system. |
222 | 219 | */
|
223 | 220 | char *getenv(const char *);
|
224 | 221 |
|
225 | 222 | LispPTR unix_getparm(LispPTR *args) {
|
226 | 223 | char envname[20], result[128], *envvalue;
|
| 224 | +#ifndef DOS |
| 225 | + struct utsname u; |
| 226 | +#endif |
| 227 | + |
227 | 228 | if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL;
|
228 | 229 |
|
| 230 | +#ifdef DOS |
229 | 231 | if (strcmp(envname, "MACH") == 0) {
|
230 |
| -#if defined(sparc) |
231 |
| - envvalue = "sparc"; |
232 |
| -#elif defined(I386) |
233 |
| - envvalue = "i386"; |
234 |
| -#elif defined(DOS) |
235 | 232 | envvalue = "386";
|
236 |
| -#elif defined(MACOSX) |
237 |
| - envvalue = "i386"; |
238 |
| -#else |
239 |
| - envvalue = "mc68020"; |
240 |
| -#endif |
241 |
| - |
242 | 233 | } else if (strcmp(envname, "ARCH") == 0) {
|
243 |
| -#if defined(sparc) |
244 |
| - envvalue = "sun4"; |
245 |
| -#elif defined(I386) |
246 |
| - envvalue = "sun386"; |
247 |
| -#elif defined(DOS) |
248 | 234 | envvalue = "dos";
|
249 |
| -#elif defined(MACOSX) |
250 |
| - envvalue = "i386"; |
| 235 | + } |
251 | 236 | #else
|
252 |
| - envvalue = "sun3"; |
253 |
| -#endif |
| 237 | + if (uname(&u) == -1) return NIL; |
254 | 238 |
|
255 |
| - } else if (strcmp(envname, "DISPLAY") == 0) { |
| 239 | + if (strcmp(envname, "MACH") == 0) { |
| 240 | + envvalue = u.machine; |
| 241 | + } else if (strcmp(envname, "ARCH") == 0) { |
| 242 | + envvalue = u.sysname; |
| 243 | + } |
| 244 | +#endif |
| 245 | + else if (strcmp(envname, "DISPLAY") == 0) { |
256 | 246 | #if defined(XWINDOW)
|
257 | 247 | envvalue = "X";
|
258 | 248 | #elif defined(DISPLAYBUFFER)
|
|
0 commit comments