mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] implement glibc's glob_pattern_p
@ 2014-07-17  9:12 Glauber Costa
  2014-07-19 20:11 ` Rich Felker
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Glauber Costa @ 2014-07-17  9:12 UTC (permalink / raw)
  To: musl; +Cc: Glauber Costa

Currently, glob is implemented but glob_pattern_p is not. This function
can trivially be implemented with existing glob machinery, since all it
does is to tell whether or not the string contains special symbols. This
is basically the same logic as is_literal, but with inverted return value.

The value of the "quote" parameter should also be inverted, since the man
page states that when the quote parameter is *non*-zero, then backslashes
are ignored. is_literal ignores them when useesc is *zero*.
---
 src/regex/glob.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/regex/glob.c b/src/regex/glob.c
index 6affee0..cc488b0 100644
--- a/src/regex/glob.c
+++ b/src/regex/glob.c
@@ -234,5 +234,11 @@ void globfree(glob_t *g)
 	g->gl_pathv = NULL;
 }
 
+int __glob_pattern_p(const char *pattern, int quote)
+{
+    return !is_literal(pattern, !quote);
+}
+
 LFS64(glob);
 LFS64(globfree);
+weak_alias(__glob_pattern_p, glob_pattern_p);
-- 
1.9.3



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-07-21 23:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17  9:12 [PATCH] implement glibc's glob_pattern_p Glauber Costa
2014-07-19 20:11 ` Rich Felker
2014-07-19 23:17   ` Glauber Costa
2014-07-19 23:45     ` Rich Felker
2014-07-20 20:01       ` Thomas Petazzoni
2014-07-21 10:19         ` Glauber Costa
2014-07-20 20:36 ` Szabolcs Nagy
2014-07-21 10:29   ` Glauber Costa
2014-07-21 14:11     ` Rich Felker
2014-07-21 23:45       ` John Spencer
2014-07-21 14:33 ` Rich Felker
2014-07-21 22:44   ` Glauber Costa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).