1. file.e, dir() function and glob

Spawned from bug report
(http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782)

I did some research and as already known, dir("*.abc") is not cross-platform. It
only works in some cases on DOS and Windows. *.abc will return (using OpenWatcom
only, as the test compiler) *.abc and *.abcd, *.abce, or whatever happens to
follow *.abc.

In the bug report I suggested using dir() in the POSIX manner it was intended,
i.e. no wildcards... dir("."), dir(".."), dir ("\\EUPHORIA"),
dir("/opt/euphoria") for example and then introduce a new function in file.e
named glob, http://en.wikipedia.org/wiki/Glob_%28programming%29 ...

I've created the glob function and tested it on Windows and Linux and it works
just as expected.

glob("*.abc") returns anything .abc, not everything .abc and .abcd. But the real
benefit is it works on Windows, Linux and presumably FreeBSD.

I would like to commit the glob function to SVN and recommend it for a
cross-platform, working solution to the dir("*.abc") problem. Does anyone have
objections?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » topic index » view message » categorize

2. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> Spawned from bug report (<a
> href="http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782">http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782</a>)
> 
> 
> I did some research and as already known, dir("*.abc") is not cross-platform.
> It only works in some cases on DOS and Windows. *.abc will return (using
> OpenWatcom
> only, as the test compiler) *.abc and *.abcd, *.abce, or whatever happens to
> follow *.abc. 
> 
> In the bug report I suggested using dir() in the POSIX manner it was intended,
> i.e. no wildcards...
> dir("."), dir(".."), dir ("\\EUPHORIA"), dir("/opt/euphoria") for example and
> then introduce
> a new function in file.e named glob, <a
> href="http://en.wikipedia.org/wiki/Glob_%28programming%29">http://en.wikipedia.org/wiki/Glob_%28programming%29</a>
> ...
> 
> I've created the glob function and tested it on Windows and Linux and it works
> just as expected.
> 
> glob("*.abc") returns anything .abc, not everything .abc and .abcd. But the
> real benefit is it works on Windows, Linux and presumably FreeBSD.
> 
> I would like to commit the glob function to SVN and recommend it for a
> cross-platform,
> working solution to the dir("*.abc") problem. Does anyone have objections?
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

I object.  By changing the existing functionality of dir, any program that
depends on it using wildcards (I have several dozen) will break.  I recommend
that the glob function be named glob_dir to allow for future introduction of
glob(sequence pattern, sequence strings).  I also recommend that glob_dir be
introduced immediately, but that existing dir functionality not be changed
until version 3.3.  Documentation for dir in version 3.1.x and 3.2 should 
clearly state that the behavior of the statement will be changing.  This 
should give programmers time to adjust their code without having to scramble.
Thank you, Jeremy, for taking the time to address this issue.  BTW, what
are you doing differently to prevent DOS and Windows from returning
*.abc* when only *.abc was requested?

Michael J. Sabal

new topic     » goto parent     » topic index » view message » categorize

3. Re: file.e, dir() function and glob

To me, it is better to leave a design that could have been better in
place than to change it after being in use for years and years by 
other people.

The documentation tells of what dir() should do for the Rapid Development
version
of EUPHORIA.  If building on different compilers produces different results
use conditional compiling to make adjustments where need be to match the
production
version.

Shawn Pringle

new topic     » goto parent     » topic index » view message » categorize

4. Re: file.e, dir() function and glob

Michael J. Sabal wrote:
> 
> I object.  By changing the existing functionality of dir, any program that
> depends on it using wildcards (I have several dozen) will break.  I recommend
> that the glob function be named glob_dir to allow for future introduction of
> glob(sequence pattern, sequence strings).  I also recommend that glob_dir be
> introduced immediately, but that existing dir functionality not be changed
> until version 3.3.  Documentation for dir in version 3.1.x and 3.2 should 
> clearly state that the behavior of the statement will be changing.  This 
> should give programmers time to adjust their code without having to scramble.
> Thank you, Jeremy, for taking the time to address this issue.  BTW, what
> are you doing differently to prevent DOS and Windows from returning
> *.abc* when only *.abc was requested?
> 

Michael,

I am not suggesting (or in fact can) change the way the current dir works. It's
a direct call to the C dir function, thus, I cannot change it. What I am
suggesting is that from here on out we do not rely on it to provide *.abc type
functionality, because in fact, it does not do it correctly and it's not
cross-platform. An application that runs on Windows and/or DOS will still work
exactly as it did. That, however could change as the Watcom compiler is aging and
no longer supported. The new OpenWatcom compiler does not work the same as the
old Watcom compiler works. So, a defunc dir command may come about whether we
like it or not, and not due to any Euphoria change.

What I am suggesting is that if you want *.abc functionality, you use a new
function that is created but yet to be added called glob. The glob function will
work regardless of compiler and/or platform.

Now, what I am doing differently is I call dir() to get the list. I then filter
the list in a for loop to remove unwanted files. I am not relying on dir to do it
for me.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

5. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> What I am suggesting is that if you want *.abc functionality, you use a new
> function that is created but yet to be added called glob. The glob function
> will work regardless of compiler and/or platform.

I say go for it.

new topic     » goto parent     » topic index » view message » categorize

6. Re: file.e, dir() function and glob

Hm,

I could modify the dir() function to check if a wildcard exists. If so, do the
wildcard in a cross-platform manner and thus, not even introduce a new function.

How does that sound? Thus, dir("*.abc") will always work regardless of
compiler/platform. That may be the best solution?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

7. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> Hm,
> 
> I could modify the dir() function to check if a wildcard exists. If so, do the
> wildcard in a cross-platform manner and thus, not even introduce a new
> function.
> 
> 
> How does that sound? Thus, dir("*.abc") will always work regardless of
> compiler/platform.
> That may be the best solution?
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

I think so.

JG

new topic     » goto parent     » topic index » view message » categorize

8. Re: file.e, dir() function and glob

The dir() command as of SVN revision 307 now works properly and is cross
platform. The idea of glob_dir has been scrapped and the original function fixed.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

9. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> Hm,
> 
> I could modify the dir() function to check if a wildcard exists. If so, do the
> wildcard in a cross-platform manner and thus, not even introduce a new
> function.

I changed strtok thusly:

** wildtok()**
wildtok(string,token,n,separator)
A more controlled matchtok(). Wildtok no longer matches abc if you ask for *a*,
like it did in strtok v1. Note the difference between *a and a* and *a* in the
examples.

I'd not introduce glob(), i'd fix dir().

Kat

new topic     » goto parent     » topic index » view message » categorize

10. Re: file.e, dir() function and glob

Kat wrote:
> 
> I'd not introduce glob(), i'd fix dir().
> 
> Kat

Kat,

Yes, I fixed dir and committed to SVN. It now works regardless of the compiler
or platform.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

11. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> Kat wrote:
> > 
> > I'd not introduce glob(), i'd fix dir().
> > 
> > Kat
> 
> Kat,
> 
> Yes, I fixed dir and committed to SVN. It now works regardless of the compiler
> or platform.

Kool, now fix goto ?

Kat

new topic     » goto parent     » topic index » view message » categorize

12. Re: file.e, dir() function and glob

Kat wrote:
> 
> Jeremy Cowgar wrote:

> > Kat,
> > 
> > Yes, I fixed dir and committed to SVN. It now works regardless of the
> > compiler
> > or platform.
> 
> Kool, now fix goto ?
> 

Kat, sorry, I don't follow. goto ?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

13. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> Kat wrote:
> > Jeremy Cowgar wrote:
> > > Kat,
> > > Yes, I fixed dir and committed to SVN. It now works regardless of the
> > > compiler
> > > or platform.
> > Kool, now fix goto ?
> Kat, sorry, I don't follow. goto ?

Just smile and nod, Jeremy.

:D

new topic     » goto parent     » topic index » view message » categorize

14. Re: file.e, dir() function and glob

Jeremy Cowgar wrote:
> 
> Kat wrote:
> > 
> > Jeremy Cowgar wrote:
> 
> > > Kat,
> > > 
> > > Yes, I fixed dir and committed to SVN. It now works regardless of the
> > > compiler
> > > or platform.
> > 
> > Kool, now fix goto ?
> > 
> 
> Kat, sorry, I don't follow. goto ?
> 
> --
> Jeremy Cowgar


Jeremy,

Kat has wanted a "goto" ADDED to Euphoria for a LONG time :)

Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu