$NetBSD: patch-dj,v 1.5 2013/05/20 11:35:22 jperkin 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 #include +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) +#include +#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 ); @@ -1166,7 +1174,7 @@ flist_update_list( private, rows, num_ro * ifdef'd for SVR4 because it causes the 4.x MIT build to fail, not just print * warnings. */ -#ifdef SVR4 +#ifdef notSVR4 static int sed, nbra, circf; static char *loc1, *loc2, *locs; static int advance(); @@ -1174,14 +1182,16 @@ static char *compile(); static int step(); #endif /* SVR4 */ - +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) #include +#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 } /****************************************************************************/