Mercurial > octave
annotate liboctave/util/oct-glob.cc @ 22402:4caa7b28d183
maint: Style check C++ code in liboctave/
* Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc, CColVector.h,
CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h,
CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc,
DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc,
MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse-C.cc,
MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h, MatrixType.cc, MatrixType.h,
PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-C.cc, Sparse-b.cc,
Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc,
boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.cc, chMatrix.h,
chNDArray.cc, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc,
dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc,
dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h,
fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc,
fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h,
fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc,
fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc,
idx-vector.h, int16NDArray.cc, int16NDArray.h, int32NDArray.cc, int32NDArray.h,
int64NDArray.cc, int64NDArray.h, int8NDArray.cc, int8NDArray.h, intNDArray.cc,
intNDArray.h, uint16NDArray.cc, uint16NDArray.h, uint32NDArray.cc,
uint32NDArray.h, uint64NDArray.h, uint8NDArray.h, blaswrap.c, cquit.c,
f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, lo-error.h, quit.cc, quit.h,
liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h,
DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.cc, DASPK.h, DASRT.cc, DASRT.h,
DASSL.cc, DASSL.h, DET.h, EIG.cc, EIG.h, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h,
ODES.cc, ODES.h, ODESFunc.h, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h,
base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h,
chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc,
gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h,
lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h,
lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h,
lo-slatec-proto.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc,
oct-fftw.cc, oct-fftw.h, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc,
oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h,
randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h,
sparse-chol.cc, sparse-chol.h, sparse-dmsolve.cc, sparse-dmsolve.h,
sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h,
Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h,
Sparse-perm-op-defs.h, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc,
mx-op-decl.h, mx-op-defs.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h,
file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-passwd.cc, oct-passwd.h, oct-syscalls.cc, oct-time.cc, oct-time.h,
oct-uname.cc, oct-uname.h, action-container.h, base-list.h, byte-swap.h,
caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, data-conv.cc,
data-conv.h, f2c-main.c, functor.h, glob-match.cc, glob-match.h, kpse.cc,
kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc,
lo-array-gripes.h, lo-cutils.c, lo-cutils.h, lo-hash.cc, lo-hash.h, lo-ieee.cc,
lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.cc, lo-regexp.h, lo-traits.h,
lo-utils.cc, lo-utils.h, oct-alloc.h, oct-base64.cc, oct-binmap.h, oct-cmplx.h,
oct-glob.cc, oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h,
oct-locbuf.cc, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c,
oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h,
oct-sort.cc, oct-sort.h, oct-sparse.h, oct-string.cc, oct-string.h,
pathsearch.cc, pathsearch.h, singleton-cleanup.cc, singleton-cleanup.h,
sparse-sort.cc, sparse-sort.h, sparse-util.cc, sparse-util.h, str-vec.cc,
str-vec.h, sun-utils.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc,
url-transfer.h, areadlink-wrapper.c, areadlink-wrapper.h,
async-system-wrapper.c, async-system-wrapper.h, base64-wrappers.c,
base64-wrappers.h, canonicalize-file-name-wrapper.c,
canonicalize-file-name-wrapper.h, dirent-wrappers.c, dirent-wrappers.h,
fcntl-wrappers.c, fcntl-wrappers.h, filepos-wrappers.c, filepos-wrappers.h,
fpucw-wrappers.c, fpucw-wrappers.h, gen-tempname-wrapper.c,
gen-tempname-wrapper.h, getopt-wrapper.c, glob-wrappers.c, hash-wrappers.c,
hash-wrappers.h, math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c,
mkostemp-wrapper.h, nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c,
nproc-wrapper.h, octave-popen2.c, octave-popen2.h, putenv-wrapper.c,
putenv-wrapper.h, set-program-name-wrapper.c, set-program-name-wrapper.h,
signal-wrappers.c, signal-wrappers.h, stat-wrappers.c, stat-wrappers.h,
strdup-wrapper.c, strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h,
strmode-wrapper.c, strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h,
time-wrappers.c, time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h,
uname-wrapper.c, uname-wrapper.h, unistd-wrappers.c, unistd-wrappers.h,
unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c,
vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c,
wait-wrappers.h:
Wrap long lines < 80 characters. Update incorrect indentation.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 29 Aug 2016 11:09:25 -0700 |
parents | bac0d6f07a3e |
children | 3a2b891d0b33 e9a0469dedd9 |
rev | line source |
---|---|
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
3 Copyright (C) 2010-2016 John W. Eaton |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 option) any later version. |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 for more details. |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
24 # include "config.h" |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
10345
33b012d39dce
Convert between back and forward slashes before and after calling glob.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10314
diff
changeset
|
27 #include <algorithm> |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include <string> |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
30 #include "glob-wrappers.h" |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include "oct-glob.h" |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "file-stat.h" |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
34 #include "unwind-prot.h" |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 // These functions are defined here and not in glob_match.cc so that we |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 // can include the glob.h file from gnulib, which defines glob to |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 // be rpl_glob. If we include glob.h in glob_match.cc, then it |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 // transforms the glob_match::glob function to be glob_match::rpl_glob, |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 // which is not what we want... |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 static bool |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 single_match_exists (const std::string& file) |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21734
diff
changeset
|
45 octave::sys::file_stat s (file); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 return s.exists (); |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 } |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21726
diff
changeset
|
50 namespace octave |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21726
diff
changeset
|
52 namespace sys |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 { |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
54 bool |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 fnmatch (const string_vector& pat, const std::string& str, int fnm_flags) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 { |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 int npat = pat.numel (); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 const char *cstr = str.c_str (); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 for (int i = 0; i < npat; i++) |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
62 if (octave_fnmatch_wrapper (pat(i).c_str (), cstr, fnm_flags) |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
63 != octave_fnm_nomatch_wrapper ()) |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 return true; |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 return false; |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 } |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 string_vector |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 glob (const string_vector& pat) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 { |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 string_vector retval; |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 int npat = pat.numel (); |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
76 int k = 0; |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
78 octave::unwind_protect frame; |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
79 |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
80 void *glob_info = octave_create_glob_info_struct (); |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
81 |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
82 frame.add_fcn (octave_destroy_glob_info_struct, glob_info); |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
83 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 for (int i = 0; i < npat; i++) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
85 { |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
86 std::string xpat = pat(i); |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
88 if (! xpat.empty ()) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
89 { |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22155
diff
changeset
|
90 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
91 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 std::replace_if (xpat.begin (), xpat.end (), |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 std::bind2nd (std::equal_to<char> (), '\\'), |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
94 '/'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
95 #endif |
10345
33b012d39dce
Convert between back and forward slashes before and after calling glob.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10314
diff
changeset
|
96 |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
97 int err = octave_glob_wrapper (xpat.c_str (), |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
98 octave_glob_nosort_wrapper (), |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
99 glob_info); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 if (! err) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
102 { |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
103 int n = octave_glob_num_matches (glob_info); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
105 const char * const *matches |
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
106 = octave_glob_match_list (glob_info); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
108 // FIXME: we shouldn't have to check to see if |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
109 // a single match exists, but it seems that glob() won't |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 // check for us unless the pattern contains globbing |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 // characters. Hmm. |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 if (n > 1 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
114 || (n == 1 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
115 && single_match_exists (std::string (matches[0])))) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
116 { |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 retval.resize (k+n); |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
118 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
119 for (int j = 0; j < n; j++) |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 { |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
121 std::string tmp = matches[j]; |
10345
33b012d39dce
Convert between back and forward slashes before and after calling glob.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10314
diff
changeset
|
122 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
123 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
124 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) |
21761 | 125 std::replace_if (tmp.begin (), tmp.end (), |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
126 std::bind2nd (std::equal_to<char> (), |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
127 '/'), |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
128 '\\'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
129 #endif |
10345
33b012d39dce
Convert between back and forward slashes before and after calling glob.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10314
diff
changeset
|
130 |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
131 retval[k++] = tmp; |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
133 } |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
134 |
21929
7ab7cd327257
hide fnmatch.h and glob.h headers
John W. Eaton <jwe@octave.org>
parents:
21761
diff
changeset
|
135 octave_globfree_wrapper (glob_info); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10138
diff
changeset
|
136 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10138
diff
changeset
|
137 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10138
diff
changeset
|
138 } |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
139 |
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
140 return retval.sort (); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 } |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
142 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
143 // Glob like Windows "dir". Treat only * and ? as wildcards, |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
144 // and "*.*" matches filenames even if they do not contain ".". |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
145 string_vector |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
146 windows_glob (const string_vector& pat) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
147 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
148 string_vector retval; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
149 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
150 int npat = pat.numel (); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
151 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
152 int k = 0; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
153 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
154 octave::unwind_protect frame; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
155 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
156 void *glob_info = octave_create_glob_info_struct (); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
157 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
158 frame.add_fcn (octave_destroy_glob_info_struct, glob_info); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
159 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
160 for (int i = 0; i < npat; i++) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
161 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
162 std::string xpat = pat(i); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
163 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
164 if (! xpat.empty ()) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
165 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
166 std::string escaped; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
167 escaped.reserve (xpat.length ()); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
168 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
169 for (size_t j = 0; j < xpat.length (); j++) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
170 { |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22155
diff
changeset
|
171 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
172 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
173 if (xpat[j] == '\\') |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22155
diff
changeset
|
174 escaped += '/'; |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
175 else |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
176 #endif |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
177 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 if (xpat[j] == ']' || xpat[j] == '[') |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
179 escaped += '\\'; |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
180 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
181 escaped += xpat[j]; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
182 } |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
183 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
184 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
185 // Replace trailing "*.*" by "*". |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
186 int len = escaped.length (); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
187 if (len >= 3 && escaped.substr (len - 3) == "*.*") |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
188 escaped = escaped.substr (0, len - 2); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
189 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
190 int err = octave_glob_wrapper (escaped.c_str (), |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
191 octave_glob_nosort_wrapper (), |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
192 glob_info); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
193 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
194 if (! err) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
195 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
196 int n = octave_glob_num_matches (glob_info); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
197 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
198 const char * const *matches |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
199 = octave_glob_match_list (glob_info); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
200 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
201 // FIXME: we shouldn't have to check to see if |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
202 // a single match exists, but it seems that glob() won't |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
203 // check for us unless the pattern contains globbing |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
204 // characters. Hmm. |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
205 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
206 if (n > 1 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
207 || (n == 1 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
208 && single_match_exists (std::string (matches[0])))) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
209 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
210 retval.resize (k + n); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
211 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
212 for (int j = 0; j < n; j++) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
213 { |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
214 std::string tmp = matches[j]; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
215 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
216 std::string unescaped; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
217 unescaped.reserve (tmp.length ()); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
218 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
219 for (size_t m = 0; m < tmp.length (); m++) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
220 { |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22155
diff
changeset
|
221 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
222 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
223 if (tmp[m] == '/') |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22155
diff
changeset
|
224 unescaped += '\\'; |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
225 else |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
226 #endif |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
227 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
228 if (tmp[m] == '\\' |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
229 && ++m == tmp.length ()) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
230 break; |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
231 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
232 unescaped += tmp[m]; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
233 } |
22155
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
234 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
235 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
236 retval[k++] = unescaped; |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
237 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
238 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
239 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
240 octave_globfree_wrapper (glob_info); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
241 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
242 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
243 } |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
244 |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
245 return retval.sort (); |
289409b2992d
Allow dir to accept [ and ] in arguments. (bug #47950)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21929
diff
changeset
|
246 } |
21726
f05a00e611ff
use namespace for glob and fnmatch wrapper functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
247 } |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 } |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
249 |