1. getenv
- Posted by George Walters <gwalters at ?c.?r.com> May 29, 2008
- 753 views
- Last edited May 30, 2008
I have set an environmental variable in XP to null. It exists but is empty. getenv returns a -1 which I would think should be {}. An empty sequence, however the function returns -1 which the doc says is undefined. It is not undefined but is a null sequence as I have set it up. Is this correct? I'm using EU 2.4 but I suspect it has not change in the current version. Syntax: x = getenv(s) Description: Return the value of an environment variable. If the variable is undefined, return -1. Comments: Because either a sequence or an atom (-1) might be returned, you should probably assign the result to a variable declared as object.
2. Re: getenv
- Posted by Jeremy Cowgar <jeremy at cowgar.c?m> May 29, 2008
- 683 views
- Last edited May 30, 2008
George Walters wrote: > > I have set an environmental variable in XP to null. It exists but is empty. > getenv returns a -1 which I would think should be {}. An empty sequence, > however the function returns -1 which the doc says is undefined. It is not > undefined but is a null sequence as I have set it up. Is this correct? I'm > using EU 2.4 but I suspect it has not change in the current version. > I tried this on Linux: [jeremy at jdesk ~]$ exu test.e -1 [jeremy@jdesk ~]$ export HELLO=A [jeremy at jdesk ~]$ exu test.e {65} [jeremy@jdesk ~]$ export HELLO= [jeremy at jdesk ~]$ exu test.e {} I then tried on Windows Vista: C:\EUPHORIA> exwc test.e -1 C:\EUPHORIA> SET HELLO=A C:\EUPHORIA> exwc test.e {65} C:\EUPHORIA> SET HELLO= C:\EUPHORIA> exwc test.e -1 So, the problem is in 4.0 as well. I then went and made a C app: void main(void) { printf("%s\n", getenv("HELLO")); } And here is where the problem is: C:\EUPHORIA> .\test.exe NULL C:\EUPHORIA> SET HELLO=A C:\EUPHORIA> exwc test.e A C:\EUPHORIA> SET HELLO= C:\EUPHORIA> exwc test.e NULL So, the underlying C function call getenv() doesn't know. So, I am unsure of how Euphoria is going to be able to know. Anyone with thoughts? -- Jeremy Cowgar http://jeremy.cowgar.com
3. Re: getenv
- Posted by Matt Lewis <matthewwalkerlewis at g?a?l.com> May 29, 2008
- 689 views
- Last edited May 30, 2008
Jeremy Cowgar wrote: > > George Walters wrote: > > > > I have set an environmental variable in XP to null. It exists but is empty. > > getenv returns a -1 which I would think should be {}. An empty sequence, > > however the function returns -1 which the doc says is undefined. It is not > > undefined but is a null sequence as I have set it up. Is this correct? I'm > > using EU 2.4 but I suspect it has not change in the current version. > So, the underlying C function call getenv() doesn't know. So, I am unsure of > how Euphoria is going to be able to know. > > Anyone with thoughts? This is how I would expect it to work. I also tried this in cmd.exe: >SET FOO=BAR >SET FOO FOO=BAR >SET FOO= >SET FOO Environment variable FOO not defined George, I don't think you can really set something to be null, and expect to get an answer back. Matt
4. Re: getenv
- Posted by ChrisBurch2 <crylex at freeuk.co.??> May 29, 2008
- 685 views
- Last edited May 30, 2008
George Walters wrote: > > > I have set an environmental variable in XP to null. It exists but is empty. > getenv returns a -1 which I would think should be {}. An empty sequence, > however the function returns -1 which the doc says is undefined. It is not > undefined but is a null sequence as I have set it up. Is this correct? I'm > using EU 2.4 but I suspect it has not change in the current version. > > Syntax: x = getenv(s) > > Description: Return the value of an environment variable. If the variable is > undefined, return -1. > > Comments: Because either a sequence or an atom (-1) might be returned, you > should probably assign the result to a variable declared as > object. Hi That is correct. If you set the variable to '' or ' ', then -1 is still returned as practically speaking trailing spaces are removed. Its easy to work around object x x = getenv("ENIRONMENT_VAR"IABLE") if x = -1 then x = {} end if Chris
5. Re: getenv
- Posted by Derek Parnell <ddparnell at b??pond.com> May 29, 2008
- 702 views
- Last edited May 30, 2008
George Walters wrote: > I have set an environmental variable in XP to null. It exists but is empty. How did you do that? I can't work out a way to set a ENVSYM to null in Windows. SET FOO= in Windows/DOS is the syntax to remove the symbol. It doesn't set it to null. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
6. Re: getenv
- Posted by George Walters <gwalters at sc?rr.?om> May 30, 2008
- 705 views
This is not an important issue for me. I just stumbled upon it and was curious. Derek I set the var to null using windows XP programs. start>settings > control panel > systems > advanced > environmental variables Windows allows you to have a name and an empty value for it which I wanted to use at the moment.
7. Re: getenv
- Posted by Jeremy Cowgar <jeremy at c?wgar.co?> May 30, 2008
- 680 views
ChrisBurch2 wrote: > > That is correct. If you set the variable to '' or ' ', then -1 is still > returned > as practically speaking trailing spaces are removed. > > Its easy to work around > That's not true on Linux. Behavior is different. unset VARNAME -1 export VARNAME=A {A} export VARNAME= {} -- Jeremy Cowgar http://jeremy.cowgar.com
8. Re: getenv
- Posted by Jeremy Cowgar <jeremy at cowgar?c?m> May 30, 2008
- 669 views
George Walters wrote: > > This is not an important issue for me. I just stumbled upon it and was > curious. > Derek I set the var to null using windows XP programs. > > start>settings > control panel > systems > advanced > environmental variables > > Windows allows you to have a name and an empty value for it which I wanted to > use at the moment. Fact is in Linux getenv() returns {} when an empty value is set as the Linux version of getenv() returns "" on an empty value. However, getenv() returns -1 in Windows on an empty value because the Windows version of getenv() returns NULL on an empty value. Therefore, I think we need to change the way getenv() in Euphoria works to be consistent. I think the Linux version should return -1 as well, thus, a cross-platform application will work in either environment, but will this break existing code? -- Jeremy Cowgar http://jeremy.cowgar.com
9. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at yahoo.co?> May 30, 2008
- 676 views
Jeremy Cowgar wrote: > > George Walters wrote: > > > > This is not an important issue for me. I just stumbled upon it and was > > curious. > > Derek I set the var to null using windows XP programs. > > > > start>settings > control panel > systems > advanced > environmental > > variables > > > > Windows allows you to have a name and an empty value for it which I wanted > > to > > use at the moment. > > Fact is in Linux getenv() returns {} when an empty value is set as the Linux > version of getenv() returns "" on an empty value. However, getenv() returns > -1 in Windows on an empty value because the Windows version of getenv() > returns > NULL on an empty value. > > Therefore, I think we need to change the way getenv() in Euphoria works to be > consistent. I think the Linux version should return -1 as well, thus, a > cross-platform > application will work in either environment, but will this break existing > code? > > -- > Jeremy Cowgar Your kidding, right? {} and " " are empty values. Muck arround with Windows to your hearts content, thats what its there for. Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
10. Re: getenv
- Posted by Derek Parnell <ddparnell at bigpo?d.com> May 30, 2008
- 665 views
Jeremy Cowgar wrote: > > George Walters wrote: > > > > This is not an important issue for me. I just stumbled upon it and was > > curious. > > Derek I set the var to null using windows XP programs. > > > > start>settings > control panel > systems > advanced > environmental > > variables > > > > Windows allows you to have a name and an empty value for it which I wanted > > to > > use at the moment. Actually it doesn't appear to be that simple. When using the method above to set a null symbol, what happens is that Windows stores the list of symbols and values you want to have, and when it creates a process it copies all of those EXCEPT any 'empty' symbols to the new process. In short, Windows does not support the concept of symbol having a NULL value. And so the getenv() is correctly returning the fact that the symbol does not exist for your process. > Fact is in Linux getenv() returns {} when an empty value is set as the Linux > version of getenv() returns "" on an empty value. However, getenv() returns > -1 in Windows on an empty value because the Windows version of getenv() > returns > NULL on an empty value. Yes, unix supports a NULL valued symbol, but Windows doesn't. > Therefore, I think we need to change the way getenv() in Euphoria works to be > consistent. I think the Linux version should return -1 as well, thus, a > cross-platform > application will work in either environment, but will this break existing > code? So is there any unix code that just tests for the existence of a symbol regardless of its value? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
11. Re: getenv
- Posted by Jeremy Cowgar <jeremy at c??gar.com> May 30, 2008
- 692 views
Kenneth Rhodes wrote: > > > Your kidding, right? {} and " " are empty values. Muck arround with Windows > to your hearts content, thats what its there for. > Hm, I do not follow. {} is empty, " " is a space, it's not empty. Fact is that this C program: void main() { printf("...%s...\n", getenv("HELLO")); } acts differently on Windows and Linux. That's the root cause that makes Euphoria act differently also. C:\> c_test.exe ...NULL... C:\> SET HELLO=A C:\> c_test.exe ...A... C:\> SET HELLO= C:\> c_test.exe ...NULL... $ c_test ...NULL... $ export HELLO=A $ c_test ...A... $ export HELLO= $ c_test ...... Notice the last.... It does not return null, it returns "", an empty value. In windows it will return NULL, therefore, in Windows you have no idea if a env var is actually empty or non-existent. -- Jeremy Cowgar http://jeremy.cowgar.com
12. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at yahoo.?o?> May 30, 2008
- 706 views
Jeremy Cowgar wrote: . > ... therefore, in Windows you have no idea if a > env var is actually empty or non-existent. > If the problem is under Windows, shouldn't that be where the fix is applied? I admit that I am hampered by my lack of programming expertise. Your patience is appreciated. Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
13. Re: getenv
- Posted by Jeremy Cowgar <jeremy at cowgar.c?m> May 30, 2008
- 701 views
Kenneth Rhodes wrote: > > If the problem is under Windows, shouldn't that > be where the fix is applied? > Yes, that would be ideal, but I do think that is possible. Windows does not provide the means (that I can find) to tell if an environment variable is set with an empty value or unset. For both of those cases, it returns the same value. So, we have two options. #1 dumb down the Linux version so that Euphoria is consistent or document that getenv() works differently on Windows and Linux (which is not my favorite option). Maybe someone else knows a function call we can make in the win/dos api? -- Jeremy Cowgar http://jeremy.cowgar.com
14. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at ya??o.com> May 30, 2008
- 679 views
Jeremy Cowgar wrote: > > Kenneth Rhodes wrote: > > > > If the problem is under Windows, shouldn't that > > be where the fix is applied? > > > > Yes, that would be ideal, but I do think that is possible. Windows does not > provide the means (that I can find) to tell if an environment variable is set > with an empty value or unset. For both of those cases, it returns the same > value. > > So, we have two options. #1 dumb down the Linux version so that Euphoria is > consistent or document that getenv() works differently on Windows and Linux > (which is not my favorite option). > > Maybe someone else knows a function call we can make in the win/dos api? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> Once again, I'm probably talking over my head here... I do understand the simplicity of "dumbing down" the Linux version of Euphoria, its the easiest way out-- at least as far as cross-platform consistency. However, it strikes me as fundamentally wrong to throw away, ignore, or mis-report information which might be useful. So is it really that difficult to document the deficient functioning of Windows? Can cross-platform consistency be achieved by a platform contingent routine? Or did we drop platform()? Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
15. Re: getenv
- Posted by CChris <christian.cuvier at agricultur?.?ouv.fr> May 30, 2008
- 680 views
Jeremy Cowgar wrote: > > Kenneth Rhodes wrote: > > > > If the problem is under Windows, shouldn't that > > be where the fix is applied? > > > > Yes, that would be ideal, but I do think that is possible. Windows does not > provide the means (that I can find) to tell if an environment variable is set > with an empty value or unset. For both of those cases, it returns the same > value. > > So, we have two options. #1 dumb down the Linux version so that Euphoria is > consistent or document that getenv() works differently on Windows and Linux > (which is not my favorite option). > > Maybe someone else knows a function call we can make in the win/dos api? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> It will never work under DOS: in the environment segment, an env var is coded as follows: <var-name>=<value>0 The 0 is the separator between two variable descriptions. From this, it would follow that an empty string would be coded as <var-name>=00 But 00 marks the end of the environment table. And, since I strongly suspect M$ uses the same representation of an env block under DOS and Windows, there is nothing as an env string with a null value under Windows. So how did George get one? Simply because he entered it. For any operation on environment, 0 is treated as a variable separator, not as a terminating \0. So there is no inconsistency nor miracle. He didn't get it for long I bet. CChris
16. Re: getenv
- Posted by Bernie Ryan <xotron at bluefrog.c??> May 30, 2008
- 695 views
CChris wrote: > > Jeremy Cowgar wrote: > > > > Kenneth Rhodes wrote: > > > > > > If the problem is under Windows, shouldn't that > > > be where the fix is applied? > > > > > > > Yes, that would be ideal, but I do think that is possible. Windows does not > > provide the means (that I can find) to tell if an environment variable is > > set > > with an empty value or unset. For both of those cases, it returns the same > > value. > > > > So, we have two options. #1 dumb down the Linux version so that Euphoria is > > consistent or document that getenv() works differently on Windows and Linux > > (which is not my favorite option). > > > > Maybe someone else knows a function call we can make in the win/dos api? > > > > -- > > Jeremy Cowgar > > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> > > It will never work under DOS: > in the environment segment, an env var is coded as follows: > > <var-name>=<value>0 > > The 0 is the separator between two variable descriptions. From this, it would > follow that an empty string would be coded as > > <var-name>=00 > > But 00 marks the end of the environment table. > > And, since I strongly suspect M$ uses the same representation of an env block > under DOS and Windows, there is nothing as an env string with a null value > under > Windows. > > So how did George get one? Simply because he entered it. For any operation > on environment, 0 is treated as a variable separator, not as a terminating \0. > So there is no inconsistency nor miracle. He didn't get it for long I bet. > > CChris DWORD GetEnvironmentVariable( LPCTSTR lpName, // address of environment variable name LPTSTR lpBuffer, // address of buffer for variable value DWORD nSize // size of buffer, in characters ); Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
17. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?o?gar.com> May 30, 2008
- 682 views
Kenneth Rhodes wrote: > > > Once again, I'm probably talking over my head here... > > I do understand the simplicity of "dumbing down" the Linux version > of Euphoria, its the easiest way out-- at least as far as cross-platform > consistency. However, it strikes me as fundamentally wrong to throw away, > ignore, or mis-report information which might be useful. > Yes, I agree. > So is it really that difficult to document the deficient functioning > of Windows? > I think this is worse then dumbing down the Linux version. If the language is cross-platform then it should do it's best to be truly cross-platform. As a developer, I want to know that it runs on Windows therefore it will work on Linux. I do not want to have to code all sorts of ifdef's or if platform() checks all over. > Can cross-platform consistency be achieved by a platform contingent > routine? Or did we drop platform()? platform() was never dropped. I posted a message with a misleading subject that made some people think that (I was not thinking). However, there is a much better way of doing platform checks now that will probably lead to platform() becoming a function that no one uses. instead of if platform() = WIN32 then ... you can do ifdef WIN32 then ... The later decision is made at parse time only once in your applications life. The platform() check is done as many times as you call it. -- Jeremy Cowgar http://jeremy.cowgar.com
18. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?owgar.?om> May 30, 2008
- 707 views
Bernie Ryan wrote: > > > DWORD GetEnvironmentVariable( > LPCTSTR lpName, // address of environment variable name > LPTSTR lpBuffer, // address of buffer for variable value > DWORD nSize // size of buffer, in characters > ); > Thank you, however, we still have a problem with DOS. Now, how to solve that one... otherwise, we will have Win32 and Linux that work alike, but now your app will have problems in DOS -- Jeremy Cowgar http://jeremy.cowgar.com
19. Re: getenv
- Posted by Jason Gade <jaygade at ?ahoo.co?> May 30, 2008
- 677 views
Jeremy Cowgar wrote: > > Bernie Ryan wrote: > > > > > DWORD GetEnvironmentVariable( > > LPCTSTR lpName, // address of environment variable name > > LPTSTR lpBuffer, // address of buffer for variable value > > DWORD nSize // size of buffer, in characters > > ); > > > > Thank you, however, we still have a problem with DOS. Now, how to solve that > one... otherwise, we will have Win32 and Linux that work alike, but now your > app will have problems in DOS > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> I don't think that differences in the operating system internals is the responsibility of the interpreter. If the two OSes operate differently for this edge case, so be it, document it and move on. I mean, after a point, being cross-platform is a best-effort proposition. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
20. Re: getenv
- Posted by Jeremy Cowgar <jeremy at c??gar.com> May 30, 2008
- 661 views
Jason Gade wrote: > > If the two OSes operate differently for this edge case, so be it, document it > and move on. > > I mean, after a point, being cross-platform is a best-effort proposition. > Yes, but we should at least try to solve any problems we can. As a developer, I don't want to have to worry about platform A or platform B or some new platform that 4.1, 4.2, 5.0 makes available that I do not even have access to. If at all possible, I would like my Euphoria app to run across the board as expected. Given, that I am using Euphoria routines. Obviously this is not the desired case if I start linking into OS dependent libraries. -- Jeremy Cowgar http://jeremy.cowgar.com
21. Re: getenv
- Posted by Matt Lewis <matthewwalkerlewis at gmail?c?m> May 30, 2008
- 671 views
Jeremy Cowgar wrote: > > > So is it really that difficult to document the deficient functioning > > of Windows? > > > > I think this is worse then dumbing down the Linux version. If the language is > cross-platform then it should do it's best to be truly cross-platform. As a > developer, I want to know that it runs on Windows therefore it will work on > Linux. I do not want to have to code all sorts of ifdef's or if platform() > checks > all over. It's true that you want to smooth out a lot of the differences, but at some point you have to recognize that they're different operating systems, and that there are probably valid reasons for letting that come through to the coder. I'm not sure if this is one of those cases, but it's certainly a candidate in my book. Matt
22. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?o?gar.com> May 30, 2008
- 676 views
Matt Lewis wrote: > > It's true that you want to smooth out a lot of the differences, but at some > point you have to recognize that they're different operating systems, and > that there are probably valid reasons for letting that come through to > the coder. I'm not sure if this is one of those cases, but it's certainly > a candidate in my book. > In all my Linux experience I've never seen anything depend on an empty env var. For instance: export ABC that just doesn't happen. export ABC=1 or export ABC=YES happens, which is fine. My suggestion would be to forget about trying to make Windows and DOS work just as Linux, but make Linux act like Windows. That's easy and it's practical. Due to how getenv() works in linux, your checks would have to be: var = genenv("ABC") if atom(var) or length(var) = 0 then ... end if and that's what most people will have to do. Again, while my knowledge is not infinite on Linux I do have a great deal of experience, I have never seen simply the ABC var being in existence triggering something. It's ABC=1, ABC=YES, etc... -- Jeremy Cowgar http://jeremy.cowgar.com
23. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at ya?o?.com> May 30, 2008
- 683 views
Jeremy Cowgar wrote: > > Kenneth Rhodes wrote: > > > > > > Once again, I'm probably talking over my head here... > > > > I do understand the simplicity of "dumbing down" the Linux version > > of Euphoria, its the easiest way out-- at least as far as cross-platform > > consistency. However, it strikes me as fundamentally wrong to throw away, > > ignore, or mis-report information which might be useful. > > > > Yes, I agree. > > > So is it really that difficult to document the deficient functioning > > of Windows? > > > > I think this is worse then dumbing down the Linux version. If the language is > cross-platform then it should do it's best to be truly cross-platform. As a > developer, I want to know that it runs on Windows therefore it will work on > Linux. I do not want to have to code ALL SORTS of IFDEF'S... checks > ALL OVER. > ... > instead of if platform() = WIN32 then ... you can do IFDEF WIN32 then ... The later decision is made at parse time ONLY ONCE in your applications life... > > Jeremy Cowgar So which is it? ALL SORTS / ALL OVER or ONLY ONCE? It sounds as though your new ifdef code might simply the cross-platform problem with getenv() without having to dumb down Linux. Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
24. Re: getenv
- Posted by Jeremy Cowgar <jeremy at c?wgar.com> May 30, 2008
- 678 views
Kenneth Rhodes wrote: > > So which is it? ALL SORTS / ALL OVER or ONLY ONCE? It sounds as > though your new ifdef code might simply the cross-platform problem > with getenv() without having to dumb down Linux. > It makes it possible but it does not simplify anything. It just places the burden on the programmer. The programmer must know there is a difference, then he/she must account for that difference in their program. And the real issue to me is that the getenv() returning "" in Linux has no practical benefit. -- Jeremy Cowgar http://jeremy.cowgar.com
25. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at ?aho?.com> May 30, 2008
- 679 views
Jeremy Cowgar wrote: > > Bernie Ryan wrote: > > > > > DWORD GetEnvironmentVariable( > > LPCTSTR lpName, // address of environment variable name > > LPTSTR lpBuffer, // address of buffer for variable value > > DWORD nSize // size of buffer, in characters > > ); > > > > Thank you, however, we still have a problem with DOS. Now, how to solve that > one... otherwise, we will have Win32 and Linux that work alike, but now your > app will have problems in DOS > > -- > Jeremy Cowgar I haven't a clue as to what Bernie's code actually does. However, if it "smarten's" up Euphoria/Win32 code up to the point where it is compatible with Linux, then I'm all for it. DOS<-->Linux developers will have to bear the burden of any onerous cross-platform code - as they always have, right? Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
26. Re: getenv
- Posted by Bernie Ryan <xotron at blu?f?og.com> May 30, 2008
- 673 views
Jeremy Cowgar wrote: > And the real issue to me is that the getenv() returning "" in Linux has no > > practical benefit. I think it is because on Linux getenv() is used in script files that are looking to see that nothing is in a variable. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
27. Re: getenv
- Posted by Jason Gade <jaygade at yaho??com> May 30, 2008
- 670 views
Jeremy Cowgar wrote: > > Kenneth Rhodes wrote: > > > > So which is it? ALL SORTS / ALL OVER or ONLY ONCE? It sounds as > > though your new ifdef code might simply the cross-platform problem > > with getenv() without having to dumb down Linux. > > > > It makes it possible but it does not simplify anything. It just places the > burden > on the programmer. The programmer must know there is a difference, then he/she > must account for that difference in their program. > > And the real issue to me is that the getenv() returning "" in Linux has no > practical > benefit. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> Right, but that's a "feature" of Linux and not a "bug" in Windows. If the OS returns an empty string then so should Euphoria. If the OS returns "does not exist" then so should Euphoria. en = getenv("FOO") if atom(en) or length(en) = 0 then -- empty end if -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
28. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?owgar.?om> May 30, 2008
- 681 views
Jason Gade wrote: > > > Right, but that's a "feature" of Linux and not a "bug" in Windows. If the OS > returns an empty string then so should Euphoria. If the OS returns "does not > exist" then so should Euphoria. > Hm, then Euphoria does not aim to be a cross-platform language. It's simply a language that will run on multiple platforms. The difference is a cross-platform language handles cross-platform issues for the user. A language that runs on multiple platforms simply does that, it leaves all the cross-platform nuances up to the programmer to know, understand and deal with in code. -- Jeremy Cowgar http://jeremy.cowgar.com
29. Re: getenv
- Posted by Bernie Ryan <xotron at blue??og.com> May 30, 2008
- 661 views
Jeremy Cowgar wrote: > > Jason Gade wrote: > > > > > > Right, but that's a "feature" of Linux and not a "bug" in Windows. If the OS > > returns an empty string then so should Euphoria. If the OS returns "does not > > exist" then so should Euphoria. > > > > Hm, then Euphoria does not aim to be a cross-platform language. It's simply > a language that will run on multiple platforms. The difference is a > cross-platform > language handles cross-platform issues for the user. A language that runs on > multiple platforms simply does that, it leaves all the cross-platform nuances > up to the programmer to know, understand and deal with in code. > > -- Jeremy: THE MOUSE DON'T WORK ON ALL PLATFORMS Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
30. Re: getenv
- Posted by Jason Gade <jaygade at yaho?.co?> May 30, 2008
- 667 views
Jeremy Cowgar wrote: > > Jason Gade wrote: > > > > > > Right, but that's a "feature" of Linux and not a "bug" in Windows. If the OS > > returns an empty string then so should Euphoria. If the OS returns "does not > > exist" then so should Euphoria. > > > > Hm, then Euphoria does not aim to be a cross-platform language. It's simply > a language that will run on multiple platforms. The difference is a > cross-platform > language handles cross-platform issues for the user. A language that runs on > multiple platforms simply does that, it leaves all the cross-platform nuances > up to the programmer to know, understand and deal with in code. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> How does Java deal with this situation? C#/Mono? Kinda like path separation and whether drives are assigned letters or not. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
31. Re: getenv
- Posted by Jeremy Cowgar <jeremy at c?wgar?com> May 30, 2008
- 651 views
Bernie Ryan wrote: > > > > > Hm, then Euphoria does not aim to be a cross-platform language. It's simply > > a language that will run on multiple platforms. The difference is a > > cross-platform > > language handles cross-platform issues for the user. A language that runs on > > multiple platforms simply does that, it leaves all the cross-platform > > nuances > > up to the programmer to know, understand and deal with in code. > > > > -- > > > THE MOUSE DON'T WORK ON ALL PLATFORMS > I'm sorry to laugh at your problems right now, but that's pretty funny, but this does bring up a good point. At one time it did and it did so the exact same way it did in DOS and Windows. Hence, Euphoria's original goal at being a cross-platform language. -- Jeremy Cowgar http://jeremy.cowgar.com
32. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> May 30, 2008
- 683 views
Jason Gade wrote: > > How does Java deal with this situation? C#/Mono? > > Kinda like path separation and whether drives are assigned letters or not. > Hm, I am not sure about getenv, I'll look. About path seperations, they provide functions like we do now in the standard library with filename, fileext, pathinfo, join_path. -- Jeremy Cowgar http://jeremy.cowgar.com
33. Re: getenv
- Posted by Derek Parnell <ddparnell at bigpo?d.c?m> May 30, 2008
- 716 views
Bernie Ryan wrote: > DWORD GetEnvironmentVariable( > LPCTSTR lpName, // address of environment variable name > LPTSTR lpBuffer, // address of buffer for variable value > DWORD nSize // size of buffer, in characters > ); Please note that this Windows API function does NOT find environment symbols that have no value because such symbols will not exist. In such case the return value is zero. The corresponding function ... BOOL WINAPI SetEnvironmentVariable( LPCTSTR lpName, LPCTSTR lpValue ); does not set/create the symbol if lName is NULL, or points to a null, or points to a string that contains an '=' character. Also, if lpValue is NULL or points to a null, it deletes the symbol if it existed. The symbols are stored in RAM using the format ... Var1=Value1\0 Var2=Value2\0 Var3=Value3\0 ... VarN=ValueN\0\0 But Windows and DOS never has an entry in the form ... VarX=\0 So, I'm inclined to let the current functionality of getvar() remain unchanged. If someone is actually relying on testing for the existance of a symbol regardless of its value then either that code needs to be wrapped in an 'ifdef' block or only run on *nix platforms. However, I suspect that this will be a very rare requirement so I think the risk is acceptable. There is no need to homogenize the function. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
34. Re: getenv
- Posted by Kenneth Rhodes <ken_rhodes30436 at y?hoo?com> May 30, 2008
- 689 views
Jeremy Cowgar wrote: > > Kenneth Rhodes wrote: > > > > So which is it? ALL SORTS / ALL OVER or ONLY ONCE? It sounds as > > though your new ifdef code might simply the cross-platform problem > > with getenv() without having to dumb down Linux. > > > > It makes it possible but it does not simplify anything. It just places the > burden > on the programmer. The programmer must know there is a difference, then he/she > must account for that difference in their program. > I would say that if the ifdef code only has to be used once, then it is a vast simplification. I understand that the programmer must know the difference, but that knowledge can be easily provided in the language documentation. > And the real issue to me is that the getenv() returning "" in Linux has > no practical benefit. > From Bernie's recent post: >I think it is because on Linux getenv() is used in script files that >are looking to see that nothing is in a variable. From Jason's recent post: >Right, but that's a "feature" of Linux and not a "bug" in Windows. If >the OS returns an empty string then so should Euphoria. If the OS >returns "does not exist" then so should Euphoria. > en = getenv("FOO") > if atom(en) or length(en) = 0 then > -- empty > end if From your (Jeremy Cowgar) recent post: > Hm, then Euphoria does not aim to be a cross-platform language. It's > simply a language that will run on multiple platforms. The difference > is a cross-platform language handles cross-platform issues for the user. > A language that runs on multiple platforms simply does that, it leaves > all the cross-platform nuances up to the programmer to know, understand > and deal with in code. Your solution is not to "handle" a cross-platform issue, but to make a false report about it. Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.3 No AdWare, SpyWare, or Viruses! Life is Good,
35. Re: getenv
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> May 30, 2008
- 672 views
Kenneth Rhodes wrote: > > Your solution is not to "handle" a cross-platform issue, but to > make a false report about it. > Wow. A false report? My attempt at a solution was to simply harmonize platforms which takes place all the time in *any* cross-platform libraries. That's the whole reason for such libraries and languages. Most programmers would not even know what the C api does or returns, they only know the language docs that says "getenv returns the value or -1 on non-existent or empty value." If people want it left alone, that's fine, but I guess this is where I will be glad over being able to override internal functions:
override function getenv(sequence name) object v v = getenv(name) if atom(v) or length(v) = 0 then return -1 end if return v end function
So that at least I will not have to deal with senseless checks added for absolutely no value in my code. -- Jeremy Cowgar http://jeremy.cowgar.com
36. Re: getenv
- Posted by Derek Parnell <ddparnell at bigpon?.?om> May 30, 2008
- 695 views
Jeremy Cowgar really meant to write:
override function getenv(sequence name) object v v = eu:getenv(name) ifdef LINUX then if atom(v) or length(v) = 0 then v = -1 end if end ifdef return v end function
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
37. Re: getenv
- Posted by Bernie Ryan <xotron at ?luefrog.co?> May 30, 2008
- 684 views
Derek Parnell wrote: > > Jeremy Cowgar really meant to write: > > > }}} <eucode> > override function getenv(sequence name) > object v > v = eu:getenv(name) > ifdef LINUX then > if atom(v) or length(v) = 0 then > v = -1 > end if > end ifdef > return v > end function > </eucode> {{{ > > > > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell if not getenv(name) and platform() = 3 then return -1 else return getenv(name) ) Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
38. Re: getenv
- Posted by Jim Brown <jbrown105 at linuxbu?dhist?net> May 30, 2008
- 703 views
Ok, I'll give you this. I just tried exu 2.3 (old version, back when the binary still linked to and used ncurses and gpm) and it segfaults when I call get_mouse(). In fact mev (gpm's included test utlitiy to prove that GPM works) doesn't work either. I can't get gpm working period. Maybe somebody should fix gpm first, before we talk about integrating it back into Euphoria. Bernie Ryan wrote: > > Jeremy Cowgar wrote: > > > > Jason Gade wrote: > > > > > > > > > Right, but that's a "feature" of Linux and not a "bug" in Windows. If the > > > OS > > > returns an empty string then so should Euphoria. If the OS returns "does > > > not > > > exist" then so should Euphoria. > > > > > > > Hm, then Euphoria does not aim to be a cross-platform language. It's simply > > a language that will run on multiple platforms. The difference is a > > cross-platform > > language handles cross-platform issues for the user. A language that runs on > > multiple platforms simply does that, it leaves all the cross-platform > > nuances > > up to the programmer to know, understand and deal with in code. > > > > -- > > Jeremy: > > > THE MOUSE DON'T WORK ON ALL PLATFORMS > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > <a > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>
39. Re: getenv
- Posted by CChris <christian.cuvier at ag?iculture.gou?.fr> May 31, 2008
- 689 views
Jason Gade wrote: > > Jeremy Cowgar wrote: > > > > Kenneth Rhodes wrote: > > > > > > So which is it? ALL SORTS / ALL OVER or ONLY ONCE? It sounds as > > > though your new ifdef code might simply the cross-platform problem > > > with getenv() without having to dumb down Linux. > > > > > > > It makes it possible but it does not simplify anything. It just places the > > burden > > on the programmer. The programmer must know there is a difference, then > > he/she > > must account for that difference in their program. > > > > And the real issue to me is that the getenv() returning "" in Linux has no > > practical > > benefit. > > > > -- > > Jeremy Cowgar > > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> > > Right, but that's a "feature" of Linux and not a "bug" in Windows. If the OS > returns an empty string then so should Euphoria. If the OS returns "does not > exist" then so should Euphoria. > > en = getenv("FOO") > if atom(en) or length(en) = 0 then > -- empty > end if > Or, faster:
en = getenv("FOO") if compare(en,"")=1 then -- empty end if
CChris > -- > A complex system that works is invariably found to have evolved from a simple > system that works. > --John Gall's 15th law of Systemantics. > > "Premature optimization is the root of all evil in programming." > --C.A.R. Hoare > > j.
40. Re: getenv
- Posted by Jim Brown <jbrown105 at li?ux?uddhist.net> May 31, 2008
- 714 views
CChris wrote: > > Or, faster: > }}} <eucode> > en = getenv("FOO") > if compare(en,"")=1 then > -- empty > end if > </eucode> {{{ > > CChris > Also wrong. It fails to catch the (more portable) getenv() = -1 case. You want (compare(en,"") or compare(en,-1)), or possibly find(en, {"",-1}) (I'm not sure which would be faster.) Unless you meant this: > en = getenv("FOO") > if compare(en,"")=1 then > en = -1 > end if