Mercurial > hg > octave-avbm
comparison src/dirfns.cc @ 2496:9823f8bfd1a5
[project @ 1996-11-11 03:17:10 by jwe]
author | jwe |
---|---|
date | Mon, 11 Nov 1996 03:17:12 +0000 |
parents | 29cd3862a9dc |
children | fda09c1e787e |
comparison
equal
deleted
inserted
replaced
2495:29cd3862a9dc | 2496:9823f8bfd1a5 |
---|---|
586 } | 586 } |
587 | 587 |
588 DEFUN (glob, args, , | 588 DEFUN (glob, args, , |
589 "glob (PATTERN)\n\ | 589 "glob (PATTERN)\n\ |
590 \n\ | 590 \n\ |
591 Given an array of strings in PATTERN, return the list of file names | 591 Given an array of strings in PATTERN, return the list of file names\n\ |
592 that any of them, or an empty string if no patterns match. Tilde | 592 that any of them, or an empty string if no patterns match. Tilde\n\ |
593 expansion is performed on each of the patterns before looking for | 593 expansion is performed on each of the patterns before looking for\n\ |
594 matching file names.") | 594 matching file names.") |
595 { | 595 { |
596 octave_value retval; | 596 octave_value retval; |
597 | 597 |
598 if (args.length () == 1) | 598 if (args.length () == 1) |
613 retval = list; | 613 retval = list; |
614 } | 614 } |
615 } | 615 } |
616 else | 616 else |
617 print_usage ("glob"); | 617 print_usage ("glob"); |
618 | |
619 return retval; | |
620 } | |
621 | |
622 DEFUN (fnmatch, args, , | |
623 "fnmatch (PATTERN, STRING)\n\ | |
624 \n\ | |
625 Return 1 or zero for each element of STRING that matches any of the\n\ | |
626 elements of the string array PATTERN, using the rules of filename\n\ | |
627 pattern matching.") | |
628 { | |
629 octave_value retval; | |
630 | |
631 if (args.length () == 2) | |
632 { | |
633 string_vector pat = args(0).all_strings (); | |
634 string_vector str = args(1).all_strings (); | |
635 | |
636 if (error_state) | |
637 gripe_wrong_type_arg ("fnmatch", args(0)); | |
638 else | |
639 { | |
640 glob_match pattern (oct_tilde_expand (pat)); | |
641 | |
642 Array<bool> tmp = pattern.match (str); | |
643 | |
644 int n = tmp.length (); | |
645 | |
646 ColumnVector result (n); | |
647 | |
648 for (int i = 0; i < n; i++) | |
649 result(i) = tmp(i); | |
650 | |
651 retval = octave_value (result, true); | |
652 } | |
653 } | |
654 else | |
655 print_usage ("fnmatch"); | |
618 | 656 |
619 return retval; | 657 return retval; |
620 } | 658 } |
621 | 659 |
622 static int | 660 static int |