1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
$NetBSD: patch-dj,v 1.4 2009/12/10 20:35:58 abs Exp $
--- lib/libxview/file_chooser/file_list.c.orig 1993-06-29 05:17:56.000000000 +0000
+++ lib/libxview/file_chooser/file_list.c
@@ -23,6 +23,9 @@ static char sccsid[] = "@(#)file_lis
#include <xview_private/flist_impl.h>
#include <xview_private/portable.h>
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+#include <regex.h>
+#endif
/* X bitmaps for default glyphs */
@@ -41,6 +44,7 @@ static int go_down_one_directory();
static int flist_list_notify();
static int validate_new_directory();
static void flist_new_dir();
+static int flist_match_regex();
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
static void flist_error(File_list_private *private, char *format, ...);
@@ -521,7 +525,11 @@ file_list_destroy ( public, status )
if (status == DESTROY_CLEANUP) {
xv_free_ref( private->directory );
xv_free_ref( private->regex_pattern );
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
xv_free_ref( private->regex_compile );
+#else
+ xv_free_regex_t( private->regex_compile );
+#endif
xv_free_ref( private->dotdot_string );
if ( private->dir_ptr )
(void) closedir( private->dir_ptr );
@@ -1174,14 +1182,16 @@ static char *compile();
static int step();
#endif /* SVR4 */
-
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
#include <regexp.h>
+#endif
static void
flist_compile_regex( private )
File_list_private *private;
{
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
char compile_buf[MAXPATHLEN+1];
char *end_ptr;
size_t num_bytes;
@@ -1197,6 +1207,17 @@ flist_compile_regex( private )
xv_free_ref( private->regex_compile );
private->regex_compile = xv_alloc_n(char, num_bytes);
(void) XV_BCOPY(compile_buf, private->regex_compile, num_bytes);
+#else
+ regex_t *compile_buf = malloc(sizeof(regex_t));
+ if (compile_buf == NULL){
+ fprintf(stderr, "Couldn't allocate compile buffer\n");
+ exit(-1);
+ }
+ regcomp(compile_buf, private->regex_pattern, 0);
+ xv_free_regex_t(private->regex_compile);
+ private->regex_compile = (char *)compile_buf;
+#endif
+
}
@@ -1205,7 +1226,11 @@ flist_match_regex( s, private )
char *s;
File_list_private *private;
{
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
return step(s, private->regex_compile);
+#else
+ return !regexec((regex_t *)private->regex_compile, s, 0, NULL, 0);
+#endif
}
/****************************************************************************/
|