[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
glob() does not set GLOB_MAGCHAR properly when globbing subdirs
From: |
Mike Frysinger |
Subject: |
glob() does not set GLOB_MAGCHAR properly when globbing subdirs |
Date: |
Thu, 20 Dec 2012 23:44:26 -0500 |
User-agent: |
KMail/1.13.7 (Linux/3.7.1; KDE/4.6.5; x86_64; ; ) |
i've found (with a pointer from Michał Górny) that using glob("*/") does not
set GLOB_MAGCHAR in gl_flags. for example, this code:
#include <config.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <glob.h>
int main()
{
glob_t g;
int ret;
size_t i;
/* Create test tree */
system("rm -rf foo");
system("mkdir -p foo/{a,b,c,d}");
assert(chdir("foo") == 0);
ret = glob("*/", GLOB_NOMAGIC, 0, &g);
printf("glob() = %i\n", ret);
printf("gl_pathc = %zu\n", g.gl_pathc);
for (i = 0; i < g.gl_pathc; ++i)
printf("\t%zu: %s\n", i, g.gl_pathv[i]);
printf("gl_flags = %#x (GLOB_MAGCHAR = %#x)\n", g.gl_flags,
GLOB_MAGCHAR);
globfree(&g);
return 0;
}
will show (gl_flags should be 0x130, not 0x30):
glob() = 0
gl_pathc = 4
0: a/
1: b/
2: c/
3: d/
gl_flags = 0x30 (GLOB_MAGCHAR = 0x100)
tested using gnulib f022473fdaf724d84817c4003120b9a38fbf884b and doing:
./gnulib-tool --create-testdir --dir=$PWD/glob glob
cd glob
./configure && make
gcc test.c gllib/libgnu.a -Wall -I. -Igllib && ./a.out
-mike
signature.asc
Description: This is a digitally signed message part.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- glob() does not set GLOB_MAGCHAR properly when globbing subdirs,
Mike Frysinger <=