Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!seismo!mcvax!unido!tub!csch From: csch@tub.UUCP Newsgroups: comp.sys.atari.st Subject: getenv() with MWC & BDT - (nf) Message-ID: <49500014@tub.UUCP> Date: Fri, 3-Apr-87 07:38:00 EST Article-I.D.: tub.49500014 Posted: Fri Apr 3 07:38:00 1987 Date-Received: Wed, 15-Apr-87 00:43:55 EST Lines: 83 Nf-ID: #N:tub:49500014:000:1764 Nf-From: tub!csch Apr 3 13:38:00 1987 > Mark Williams C has a *working* getenv(). I assume you have sources to ME. > Just add a call to getenv("LIBDIR") to your ME and look in the directory > given to you by the call for your emacsrc file. Of course you have to define > 'setenv LIBDIR=c:\usr\lib' (or wherever your libraries are) to the profile > for msh.prg. > Michael Doerr Right! BUT: The MWC getenv() does NOT work together with Beckemeyer's C Shell! (He announced his new version 2.7, which I ordered, but not yet received - which should be compatible with the MWC package) The problem is: BDT puts a \0 behind the '=', as does MWC NOT ! So: Take this short routine, I wrote for uEmacs38b, which handles BOTH! Have fun, Clemens ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Contact via: csch@tub.uucp from the US: ...!pyramid!tub!csch from Europe: ...!unido!tub!csch Bitnet: csch@db0tui6 = tub.bitnet tel.: +49-30-393-3574 +49-30-332-4015 tlx.: (west-germany) + 186672 rdt d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------- cut here ------------------------------ /* for use with MWC --- csch@tub.uucp */ #include #define TRUE 1 #define FALSE 0 #define NULL (char *) (0) /* locate variable name in environment string */ static char *findenv(s) char *s; { static char name[32]; char *p; if (! s) return(NULL); strcpy(name, s); strcat(name, "="); for (p = (char *) (BP->p_env); *p; p++) { if (strncmp(p, name, strlen(name)) == 0) break; while (*p) p++; if (! *(p+1)) return(NULL); } return(p); } char *getenv(name) char *name; { char *p; p = findenv(name); if (p == NULL) return(NULL); while (*p && *p != '=') p++; return(*++p ? p : p+1); }