diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2018-02-28 17:56:13 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2018-02-28 17:56:13 +0100 | 
| commit | e6a535093596d3732628b8114386eb9b72929a02 (patch) | |
| tree | 09279aaf64051767df0880faaaf22636856770eb | |
| parent | 8eaa39234a54fcdd3c9050a01790b152598af80d (diff) | |
| parent | 5a2db8f2ffc4371d2e88a65567d85663e6d16b36 (diff) | |
Merge branch 'ulteq-natural-sort'
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | config.mk | 10 | ||||
| -rw-r--r-- | man/Makefile | 1 | ||||
| -rw-r--r-- | man/feh.pre | 33 | ||||
| -rw-r--r-- | src/feh.h | 8 | ||||
| -rw-r--r-- | src/filelist.c | 18 | ||||
| -rw-r--r-- | src/help.raw | 1 | ||||
| -rw-r--r-- | src/options.c | 4 | ||||
| -rw-r--r-- | src/options.h | 1 | 
9 files changed, 64 insertions, 13 deletions
| @@ -83,6 +83,7 @@ Available flags are:  | exif | 0 | Builtin EXIF tag display support |  | help | 0 | include help text (refers to the manpage otherwise) |  | stat64 | 0 | Support CIFS shares from 64bit hosts on 32bit machines | +| verscmp | 1 | Support naturing sorting (`--version-sort`). Requires a GNU-compatible libc exposing `strverscmp` |  | xinerama | 1 | Support Xinerama/XRandR multiscreen setups |  So, by default **libcurl** and **Xinerama** are enabled, the rest is disabled. @@ -5,9 +5,10 @@ app ?= 0  cam ?= 0  curl ?= 1  debug ?= 0 +exif ?= 0  help ?= 0 +verscmp ?= 1  xinerama ?= 1 -exif ?= 0  # Prefix for all installed files  PREFIX ?= /usr/local @@ -63,6 +64,13 @@ ifeq (${stat64},1)  	CFLAGS += -D_FILE_OFFSET_BITS=64  endif +ifeq (${verscmp},1) +	CFLAGS += -DHAVE_VERSCMP +	MAN_VERSCMP = enabled +else +	MAN_VERSCMP = disabled +endif +  ifeq (${xinerama},1)  	CFLAGS += -DHAVE_LIBXINERAMA  	LDLIBS += -lXinerama diff --git a/man/Makefile b/man/Makefile index 65f2bc2..9209de1 100644 --- a/man/Makefile +++ b/man/Makefile @@ -12,6 +12,7 @@ all: ${TARGETS}  	-e 's/\$$MAN_CURL\$$/${MAN_CURL}/' \  	-e 's/\$$MAN_DEBUG\$$/${MAN_DEBUG}/' \  	-e 's/\$$MAN_EXIF\$$/${MAN_EXIF}/' \ +	-e 's/\$$MAN_VERSCMP\$$/${MAN_VERSCMP}/' \  	-e 's/\$$MAN_XINERAMA\$$/${MAN_XINERAMA}/' \  	< ${@:.1=.pre} > $@ diff --git a/man/feh.pre b/man/feh.pre index ab3f8d6..5290f79 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -24,7 +24,8 @@ $VERSION$  .  .Pp  . -Compile-time switches: libcurl support $MAN_CURL$, Xinerama support +Compile-time switches: libcurl support $MAN_CURL$, natural sorting support +$MAN_VERSCMP$, Xinerama support  $MAN_XINERAMA$, builtin EXIF support $MAN_EXIF$$MAN_DEBUG$  .  . @@ -194,7 +195,7 @@ Extra actions which can be set and triggered using the appropriate number key.  .  .It Cm --auto-rotate  . -.Pq only if compiled with exif=1 +.Pq optional feature, $MAN_EXIF$ in this build  Automatically rotate images based on EXIF data. Does not alter the image files.  .  .It Cm -Z , --auto-zoom @@ -253,7 +254,7 @@ Draw the defined actions and what they do at the top-left of the image.  .  .It Cm --draw-exif  . -.Pq only if compiled with exif=1 +.Pq optional feature, $MAN_EXIF$ in this build  display some EXIF information in the bottom left corner, similar to using  .Cm --info  with exiv2 / exifgrep . @@ -514,8 +515,8 @@ managers.  .  .It Cm --no-xinerama  . -Disable Xinerama support.  Only makes sense when you have Xinerama support -compiled in. +.Pq optional feature, $MAN_XINERAMA$ in this build +Disable Xinerama support.  .  .It Cm -j , --output-dir Ar directory  . @@ -696,8 +697,18 @@ output useful information, progress bars, etc.  .  output version information and exit.  . +.It Cm --version-sort +. +.Pq optional feature, $MAN_VERSCMP$ in this build +Use natural sorting for file and directory names. In this mode, filenames are +sorted as an ordinary human would expect, e.g. +.Qq 2.jpg +comes before +.Qq 10.jpg . +.  .It Cm --xinerama-index Ar screen  . +.Pq optional feature, $MAN_XINERAMA$ in this build  Override  .Nm Ns No 's  idea of the active Xinerama screen. May be useful in certain circumstances @@ -1282,7 +1293,7 @@ Toggle filename display  .  .It e Bq toggle_exif  . -.Pq only if compiled with exif=1 +.Pq optional feature, $MAN_EXIF$ in this build  Toggle EXIF tag display  .  .It f Bq save_filelist @@ -1695,10 +1706,14 @@ Show all images in ~/Pictures  .  Recursively show all images found in ~/Pictures and subdirectories  . -.It feh -rSfilename ~/Pictures +.It feh -rSfilename --version-sort ~/Pictures  . -Same as above, but sort by filename. By default, feh will show files in the -order it finds them on the hard disk, which is usually somewhat random. +Same as above, but sort naturally. By default, feh will show files in the +string order of their names, meaning e.g. +.Qq foo 10.jpg +will come before +.Qq foo 2.jpg . +In this case, they are instead ordered as a human would expect.  .  .It feh -t -Sfilename -E 128 -y 128 -W 1024 ~/Pictures  . @@ -27,6 +27,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  #ifndef FEH_H  #define FEH_H +/* + * strverscmp(3) is a GNU extension. In most supporting C libraries it + * requires _GNU_SOURCE to be defined. + */ +#ifdef HAVE_VERSCMP +#define _GNU_SOURCE +#endif +  #include <X11/Xlib.h>  #include <X11/Xutil.h>  #include <X11/Xatom.h> diff --git a/src/filelist.c b/src/filelist.c index 9a4af27..453f795 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -397,14 +397,26 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen)  	dst[n] = '\0';  } +#ifdef HAVE_VERSCMP +inline int strcmp_or_strverscmp(const char *s1, const char *s2) +{ +	if (!opt.version_sort) +		return(strcmp(s1, s2)); +	else +		return(strverscmp(s1, s2)); +} +#else +#define strcmp_or_strverscmp strcmp +#endif +  int feh_cmp_filename(void *file1, void *file2)  { -	return(strcmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename)); +	return(strcmp_or_strverscmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));  }  int feh_cmp_name(void *file1, void *file2)  { -	return(strcmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name)); +	return(strcmp_or_strverscmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));  }  int feh_cmp_dirname(void *file1, void *file2) @@ -413,7 +425,7 @@ int feh_cmp_dirname(void *file1, void *file2)  	int cmp;  	feh_file_dirname(dir1, FEH_FILE(file1), PATH_MAX);  	feh_file_dirname(dir2, FEH_FILE(file2), PATH_MAX); -	if ((cmp = strcmp(dir1, dir2)) != 0) +	if ((cmp = strcmp_or_strverscmp(dir1, dir2)) != 0)  		return(cmp);  	return(feh_cmp_name(file1, file2));  } diff --git a/src/help.raw b/src/help.raw index 8b244c1..86bb617 100644 --- a/src/help.raw +++ b/src/help.raw @@ -52,6 +52,7 @@ OPTIONS                             name, filename, mtime, width, height, pixels, size,                             or format   -n, --reverse             Reverse sort order +     --version-sort        Natural sort of (version) numbers within text   -A, --action [;]ACTION    Specify action to perform when pressing <return>.                             Executed by /bin/sh, may contain FORMAT SPECIFIERS                             reloads image with \";\", switches to next otherwise diff --git a/src/options.c b/src/options.c index 0ad7c74..3d11482 100644 --- a/src/options.c +++ b/src/options.c @@ -415,6 +415,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)  		{"insecure"      , 0, 0, 240},  		{"no-recursive"  , 0, 0, 241},  		{"cache-size"    , 1, 0, 243}, +		{"version-sort"  , 0, 0, 246},  		{0, 0, 0, 0}  	};  	int optch = 0, cmdx = 0; @@ -780,6 +781,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)  			if (opt.cache_size > 2048)  				opt.cache_size = 2048;  			break; +		case 246: +			opt.version_sort = 1; +			break;  		default:  			break;  		} diff --git a/src/options.h b/src/options.h index 33b2bd3..c6b4e0e 100644 --- a/src/options.h +++ b/src/options.h @@ -104,6 +104,7 @@ struct __fehoptions {  	unsigned int thumb_redraw;  	double reload;  	int sort; +	int version_sort;  	int debug;  	int geom_flags;  	int geom_x; | 
