jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 45461] New: GlobCompiler: * should not match the path separator '/'
Date Tue, 22 Jul 2008 17:50:32 GMT

           Summary: GlobCompiler: * should not match the path separator '/'
           Product: ORO
           Version: 2.0.8
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: oro-dev@jakarta.apache.org
        ReportedBy: eric.sirianni@gmail.com

import org.apache.oro.text.GlobCompiler;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Matcher;

public class Main {

    public static void main(String[] args) throws MalformedPatternException {
        GlobCompiler globCompiler = new GlobCompiler();
        Pattern pattern = globCompiler.compile("*.c");
        Perl5Matcher perl5Matcher = new Perl5Matcher();

        System.out.println(perl5Matcher.matches("foo.c", pattern));
        System.out.println(perl5Matcher.matches("subdir/bar.c", pattern));


$ java -cp ... Main

Expected behavior is:

The glob man page states:
Globbing is applied on each of the components of a pathname separately. A '/'
in a pathname cannot be matched by a '?' or '*' wildcard, or by a range like
'[.-0]'. A range cannot contain an explicit '/' character; this would lead to a
syntax error.

If a filename starts with a '.', this character must be matched explicitly.
(Thus, 'rm *' will not remove .profile, and 'tar c *' will not archive all your
files; 'tar c .' is better.) 

Writing a simple C program that uses glob confirms this:
$ cat testglob.c 
#include <glob.h>

main(int argc, char *argv[]) {

  glob_t globbuf;

  globbuf.gl_offs = 2;
  glob("*.c", GLOB_DOOFFS, 0, &globbuf);
  globbuf.gl_pathv[0] = "ls";
  globbuf.gl_pathv[1] = "-l";
  execvp("ls", &globbuf.gl_pathv[0]);


$ find

$ ./a.out 
-rw-rw-r--  1 sirianni engr 236 2008-07-22 13:36 testglob.c

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: oro-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-dev-help@jakarta.apache.org

View raw message