Hello community, here is the log from the commit of package tree for openSUSE:Factory checked in at 2018-12-11 15:49:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/tree (Old) and /work/SRC/openSUSE:Factory/.tree.new.19453 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "tree" Tue Dec 11 15:49:26 2018 rev:22 rq:657085 version:1.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/tree/tree.changes 2014-07-21 22:35:10.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.tree.new.19453/tree.changes 2018-12-11 15:49:30.138095861 +0100 @@ -1,0 +2,27 @@ +Mon Dec 10 13:07:00 UTC 2018 - [email protected] + +Update to 1.8.0: + * Added an experimental --fromfile option (suggested by several people.) + This may eventually be replaced or supplimented by a --fromjson option. + * Added support for BSD's CLICOLOR and CLICOLOR_FORCE environment variables. + (Suggested by Alyssa Ross) + * Use strftime() exclusively when formatting date/time to respect locale. + * Some man page fixes and cleanups curtsey of Kirill Kolyshkin + * Update BINDIR in Makefile for MacOS X -- It is not allowed to install + programs to /usr/bin on MacOS X any longer due to System Integrity + Protection (SIP) (Shawn Mehan) + * Misc patches from Jacob Wahlgren: + - Improved command line switch error reporting. + - Symbolic links not displayed if a -P pattern is active + - Missing argument error reporting fixes on long format switches. + * Fixed JSON output hanging commas (John Lane, Tad, others) + * JSON size output ignored -h/--si flags (Wagner Camarao) + * Fixed issue with malformed multibyte string handling. (Mantas + Mikulėnas) + * Fixed issue where mbstowcs() fails to null terminate the string due to + improper UTF-8 encoding leading to garbage being printed. (Nick Craig-Wood) + * Found a bug where the wrong inode (and device) information would be printed + for symbolic links. (Stephan Gabert) + - adjust tree-makefile.patch + +------------------------------------------------------------------- Old: ---- tree-1.7.0.tgz New: ---- tree-1.8.0.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ tree.spec ++++++ --- /var/tmp/diff_new_pack.cVNZzr/_old 2018-12-11 15:49:30.590095362 +0100 +++ /var/tmp/diff_new_pack.cVNZzr/_new 2018-12-11 15:49:30.594095357 +0100 @@ -1,7 +1,7 @@ # # spec file for package tree # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,10 +17,10 @@ Name: tree -Version: 1.7.0 +Version: 1.8.0 Release: 0 Summary: File listing as a tree -License: GPL-2.0+ +License: GPL-2.0-or-later Group: Productivity/File utilities Url: http://mama.indstate.edu/users/ice/tree/ Source0: http://mama.indstate.edu/users/ice/tree/src/%{name}-%{version}.tgz ++++++ tree-1.7.0.tgz -> tree-1.8.0.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/CHANGES new/tree-1.8.0/CHANGES --- old/tree-1.7.0/CHANGES 2014-04-22 19:46:42.000000000 +0200 +++ new/tree-1.8.0/CHANGES 2018-11-16 16:12:18.000000000 +0100 @@ -1,4 +1,27 @@ -Version 1.7.0 +Version 1.8.0 (11/16/2018) + - Added an experimental --fromfile option (suggested by several people.) + This may eventually be replaced or supplimented by a --fromjson option. + - Added support for BSD's CLICOLOR and CLICOLOR_FORCE environment variables. + (Suggested by Alyssa Ross) + - Use strftime() exclusively when formatting date/time to respect locale. + - Some man page fixes and cleanups curtsey of Kirill Kolyshkin + - Update BINDIR in Makefile for MacOS X -- It is not allowed to install + programs to /usr/bin on MacOS X any longer due to System Integrity + Protection (SIP) (Shawn Mehan) + - Misc patches from Jacob Wahlgren: + - Improved command line switch error reporting. + - Symbolic links not displayed if a -P pattern is active + - Missing argument error reporting fixes on long format switches. + - Fixed JSON output hanging commas (John Lane, Tad, others) + - JSON size output ignored -h/--si flags (Wagner Camarao) + - Fixed issue with malformed multibyte string handling. (Mantas + Mikulėnas) + - Fixed issue where mbstowcs() fails to null terminate the string due to + improper UTF-8 encoding leading to garbage being printed. (Nick Craig-Wood) + - Found a bug where the wrong inode (and device) information would be printed + for symbolic links. (Stephan Gabert) + +Version 1.7.0 (04/23/2014) - Allow user/group names up to 32 characters before clipping. - Made -i compress XML and JSON output as much as possible by eliminating extraneous whitespace. @@ -25,7 +48,7 @@ to mean CP437 (console) output codes, not ASCII. (Ivan Shmakov <[email protected]>) -Version 1.6.0 +Version 1.6.0 (05/24/11) - Re-org of code into multiple files, split HTML and Unix listdir() into separate functions, various code cleanups and optimizations. - Fixed a memory leak in listdir() when memory was allocated early and not @@ -63,7 +86,7 @@ - Added --timefmt option to specify the format of time display (implies -D). Uses the strftime format. -Version 1.5.3 +Version 1.5.3 (11/24/09) - Properly quote directories for the system command when tree is relaunched using the -R option. - Fixed possible indentation problem if dirs[*] is not properly zeroed @@ -75,32 +98,32 @@ - Automatically select UTF-8 charset if TREE_CHARSET is not set, and the locale is set to *UTF-8 (overridden with --charset option.) -Version 1.5.2.2 +Version 1.5.2.2 (01/22/09) - Set locale before checking MB_CUR_MAX. - Added HP-NonStop platform support (Craig McDaniel <[email protected]>) - Fixed to support 32 bit UID/GIDs. - Added Solaris build options to Makefile (edit and uncomment to use). Provided by Wang Quanhong -Version 1.5.2.1 +Version 1.5.2.1 (08/29/08) - Added strverscmp.c file for os's without strverscmp. Source file is attributed to: Jean-Franois Bignolles <[email protected]> - Try different approach to MB_CUR_MAX problem. - Changed the argument to printit() to be signed char to avoid warnings. -Version 1.5.2 +Version 1.5.2 (06/06/08) - Added --filelimit X option to not descend directories that have more than X number of files in them. - Added -v option for version sorting (also called natural sorting) ala ls. -Version 1.5.1.2 +Version 1.5.1.2 (06/04/08) - Fixed compile issues related to MB_CUR_MAX on non-linux machines. - Removed unecessary features.h -Version 1.5.1.1 +Version 1.5.1.1 (06/11/07) - Regression in HTML output, fixed formatting issues. -Version 1.5.1 +Version 1.5.1 (?) - Remove extraneous / at end of user input directory names when using -f option (Zurd) - List available charsets if --charset option is missing charset argument. @@ -110,7 +133,7 @@ - Colorization bugfix for special files and directories (make tree behave as ls does) -Version 1.5.0 +Version 1.5.0 (08/15/04) - Added -T option to change title and H1 header in HTML output. - Added -r option to reverse alpha sort output, ala. 'ls -r'. - '|' wildcard support added by David MacMahon <[email protected]>. @@ -139,7 +162,7 @@ - Change version to standard major.minor.patch format. - Switch from artistic license to GPLv2. -Version 1.4 +Version 1.4 (02/21/02 (b1), 03/24/02 (b2), 02/06/03 (b3)) - Added large file support under Linux. - Fixed crashing on missing command line arguments. - Fixed several memory leaks @@ -160,7 +183,7 @@ - Added --inodes and --device options. - Added --noreport option. -Version 1.3 +Version 1.3 (02/15/99) - Fixed long pathname problem by dynamically allocating the path. - Added recursive symlink detection. - Added --help and --version options. @@ -176,7 +199,7 @@ - Added -R to recursively restart the search at the level given by `-L' option (adding as well `-o 00Tree.html'). -Version 1.2 +Version 1.2 (01/05/97) - Added -D to print the date of the last modification. - Added -t option to sort by last modification time (ala ls -t). - Added -I <pattern>, similar to the -P option except tree does not print @@ -192,7 +215,7 @@ name/gid. - Fully (pass the salt) implemented dircolors support. -Version 1.1 +Version 1.1 (07/09/96) - Made some changes to the Makefile to insure proper installation and for multi-architecture support and a bug-fix. - Made root directory colorized if dircolors is enabled. @@ -206,5 +229,5 @@ - Made uid 0 the same as anyone else (-a was default for uid 0) - Added -x directive to stay on one filesystem (ala find -xdev). -Version 1.0 +Version 1.0 (??/??/90?) - The original, a model of perfection... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/INSTALL new/tree-1.8.0/INSTALL --- old/tree-1.7.0/INSTALL 2011-06-24 16:34:17.000000000 +0200 +++ new/tree-1.8.0/INSTALL 2018-01-04 02:58:32.000000000 +0100 @@ -1,6 +1,6 @@ Installation instructions: -1. Edit the Makefile for your OS. Comment out the Linux options and uncomment +1. Edit the Makefile for your OS. Comment out the Linux options and un-comment the options for your OS. 2. Type: make 3. Type: make install diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/Makefile new/tree-1.8.0/Makefile --- old/tree-1.7.0/Makefile 2014-04-18 19:35:39.000000000 +0200 +++ new/tree-1.8.0/Makefile 2018-01-18 21:02:20.000000000 +0100 @@ -1,5 +1,5 @@ # $Copyright: $ -# Copyright (c) 1996 - 2014 by Steve Baker +# Copyright (c) 1996 - 2018 by Steve Baker # All Rights reserved # # This program is free software; you can redistribute it and/or modify @@ -20,17 +20,17 @@ CC=gcc -VERSION=1.7.0 +VERSION=1.8.0 TREE_DEST=tree BINDIR=${prefix}/bin MAN=tree.1 MANDIR=${prefix}/man/man1 -OBJS=tree.o unix.o html.o xml.o json.o hash.o color.o +OBJS=tree.o unix.o html.o xml.o json.o hash.o color.o file.o # Uncomment options below for your particular OS: # Linux defaults: -CFLAGS=-ggdb -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +CFLAGS=-ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 #CFLAGS=-O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 #LDFLAGS=-s @@ -39,6 +39,13 @@ #LDFLAGS=-s #OBJS+=strverscmp.o +# Uncomment for OpenBSD: +#TREE_DEST=colortree +#MAN=colortree.1 +#CFLAGS=-O2 -Wall -fomit-frame-pointer +#LDFLAGS=-s +#OBJS+=strverscmp.o + # Uncomment for Solaris: #CC=cc #CFLAGS=-xO0 -v @@ -53,6 +60,8 @@ #OBJS+=strverscmp.o # Uncomment for OS X: +# It is not allowed to install to /usr/bin on OS X any longer (SIP): +#prefix = /usr/local #CC=cc #CFLAGS=-O2 -Wall -fomit-frame-pointer -no-cpp-precomp #LDFLAGS= @@ -78,6 +87,11 @@ #LDFLAGS= #OBJS+=strverscmp.o +# AIX +#CC=cc_r -q64 +#LD=ld -d64 +#LDFLAGS=-lc +#OBJS+=strverscmp.o #------------------------------------------------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/README new/tree-1.8.0/README --- old/tree-1.7.0/README 2014-04-21 22:31:27.000000000 +0200 +++ new/tree-1.8.0/README 2015-06-22 22:17:21.000000000 +0200 @@ -177,6 +177,10 @@ - Added --caseinsentive, renamed --ignore-case option. - Bugged me a lot. +Stephan Gabert + - Found a bug where the wrong inode (and device) information would be printed + for symbolic links. + And many others whom I've failed to keep track of. I should have started this list years ago. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/TODO new/tree-1.8.0/TODO --- old/tree-1.7.0/TODO 2011-06-24 16:34:53.000000000 +0200 +++ new/tree-1.8.0/TODO 2015-02-11 21:57:02.000000000 +0100 @@ -1,4 +1,9 @@ Should do: +- Use stdint.h and inttypes.h to standardize the int sizes and format strings. + +- Add --DU option to fully report disk usage, taking into account files that + are not displayed in the output. + - Should be a better way code the various tree formats (XML/HTML/Unix) to share more code. Probably make a generic tree crawling routine that calls various function pointers to emit the file information based on the kind diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/color.c new/tree-1.8.0/color.c --- old/tree-1.7.0/color.c 2014-04-18 19:33:54.000000000 +0200 +++ new/tree-1.8.0/color.c 2018-11-16 15:29:35.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -74,7 +74,7 @@ void parse_dir_colors() { - char buf[1025], **arg, **c, *colors, *s; + char buf[1025], **arg, **c, *colors, *s, *cc; int i, n; struct extensions *e; @@ -87,8 +87,9 @@ s = getenv("TREE_COLORS"); if (s == NULL) s = getenv("LS_COLORS"); - if ((s == NULL || strlen(s) == 0) && force_color) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; - + cc = getenv("CLICOLOR"); + if (getenv("CLICOLOR_FORCE") != NULL) force_color=TRUE; + if ((s == NULL || strlen(s) == 0) && (force_color || cc != NULL)) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if (s == NULL || (!force_color && (nocolor || !isatty(1)))) { colorize = FALSE; @@ -233,10 +234,11 @@ }; int i; - for(i=0;cmds[i].cmdnum;i++) + if (s[0] == '*') return DOT_EXTENSION; + for(i=0;cmds[i].cmdnum;i++) { if (!strcmp(cmds[i].cmd,s)) return cmds[i].cmdnum; - if (s[0] == '*') return DOT_EXTENSION; - return ERROR; + } + return ERROR; } int color(u_short mode, char *name, bool orphan, bool islink) @@ -486,10 +488,12 @@ if (flag) { fprintf(stderr,"tree: missing argument to --charset, valid charsets include:\n"); - for(linedraw=cstable;linedraw->name;++linedraw) - for(s=linedraw->name;*s;++s) + for(linedraw=cstable;linedraw->name;++linedraw) { + for(s=linedraw->name;*s;++s) { fprintf(stderr," %s\n",*s); - return; + } + } + return; } if (charset) { for(linedraw=cstable;linedraw->name;++linedraw) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/doc/tree.1 new/tree-1.8.0/doc/tree.1 --- old/tree-1.7.0/doc/tree.1 2014-04-23 21:39:12.000000000 +0200 +++ new/tree-1.8.0/doc/tree.1 2018-11-16 15:56:21.000000000 +0100 @@ -1,5 +1,5 @@ .\" $Copyright: $ -.\" Copyright (c) 1996 - 2012 by Steve Baker +.\" Copyright (c) 1996 - 2018 by Steve Baker .\" All Rights reserved .\" .\" This program is free software; you can redistribute it and/or modify @@ -17,11 +17,11 @@ .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .\" ... -.TH TREE 1 "" "Tree 1.7.0" +.TH TREE 1 "" "Tree 1.8.0" .SH NAME tree \- list contents of directories in a tree-like format. .SH SYNOPSIS -\fBtree\fP [\fB-acdfghilnpqrstuvxACDFQNSUX\fP] [\fB-L\fP \fIlevel\fP [\fB-R\fP]] [\fB-H\fP \fIbaseHREF\fP] [\fB-T\fP \fItitle\fP] [\fB-o\fP \fIfilename\fP] [\fB--nolinks\fP] [\fB-P\fP \fIpattern\fP] [\fB-I\fP \fIpattern\fP] [\fB--inodes\fP] [\fB--device\fP] [\fB--noreport\fP] [\fB--dirsfirst\fP] [\fB--version\fP] [\fB--help\fP] [\fB--filelimit\fP \fI#\fP] [\fB--si\fP] [\fB--prune\fP] [\fB--du\fP] [\fB--timefmt\fP \fIformat\fP] [\fB--matchdirs\fP] [\fB--\fP] [\fIdirectory\fP ...] +\fBtree\fP [\fB-acdfghilnpqrstuvxACDFQNSUX\fP] [\fB-L\fP \fIlevel\fP [\fB-R\fP]] [\fB-H\fP \fIbaseHREF\fP] [\fB-T\fP \fItitle\fP] [\fB-o\fP \fIfilename\fP] [\fB--nolinks\fP] [\fB-P\fP \fIpattern\fP] [\fB-I\fP \fIpattern\fP] [\fB--inodes\fP] [\fB--device\fP] [\fB--noreport\fP] [\fB--dirsfirst\fP] [\fB--version\fP] [\fB--help\fP] [\fB--filelimit\fP \fI#\fP] [\fB--si\fP] [\fB--prune\fP] [\fB--du\fP] [\fB--timefmt\fP \fIformat\fP] [\fB--matchdirs\fP] [\fB--fromfile\fP] [\fB--\fP] [\fIdirectory\fP ...] .br .SH DESCRIPTION @@ -99,7 +99,7 @@ .B -I \fIpattern\fP Do not list those files that match the wild-card \fIpattern\fP. .PP - .TP +.TP .B --ignore-case If a match pattern is specified by the \fB-P\fP or \fB-I\fP option, this will cause the pattern to match without regards to the case of each letter. @@ -240,9 +240,11 @@ This option is disabled when \fB-U\fP is used. .PP .TP -.B --sort[=]<name> -Sort the output by name (as per ls): name (default), ctime (\fP-c\fP), mtime -(\fP-t\fB), size or version (\fP-v\fB). +.B --sort\fR[\fB=\fR]\fItype\fR +Sort the output by \fItype\fR instead of name. Possible values are: +\fBctime\fR (\fB-c\fP), +\fBmtime\fR (\fB-t\fB), \fBsize\fR, or \fBversion\fR (\fB-v\fB). + .SH GRAPHICS OPTIONS .TP @@ -266,8 +268,9 @@ .PP .TP .B -C -Turn colorization on always, using built-in color defaults if the LS_COLORS -environment variable is not set. Useful to colorize output to a pipe. +Turn colorization on always, using built-in color defaults if the LS_COLORS or +TREE_COLORS environment variables are not set. Useful to colorize output to a +pipe. .PP .SH XML/JSON/HTML OPTIONS @@ -288,7 +291,7 @@ `ftp://hostname.organization.domain/pub' (\fIbaseHREF\fP should be `ftp://hostname.organization.domain'). Hint: don't use ANSI lines with this option, and don't give more than one directory in the directory list. If you -wish to use colors via CCS style-sheet, use the -C option in addition to this +wish to use colors via CSS style-sheet, use the -C option in addition to this option to force color output. .PP .TP @@ -300,6 +303,14 @@ Turns off hyperlinks in HTML output. .PP +.SH INPUT OPTIONS + +.B --fromfile +Reads a directory listing from a file rather than the file-system. Paths +provided on the command line are files to read from rather than directories to +search. The dot (.) directory indicates that tree should read paths from +standard input. + .SH MISC OPTIONS .TP @@ -329,11 +340,15 @@ .br \fBTREE_CHARSET\fP Character set for tree to use in HTML mode. .br +\fBCLICOLOR\fP Enables colorization even if TREE_COLORS or LS_COLORS is not set. +.br +\fBCLICOLOR_FORCE\fP Always enables colorization (effectively -C) +.br \fBLC_CTYPE\fP Locale for filename output. .br \fBLC_TIME\fP Locale for timefmt output, see \fBstrftime\fP(3). .br -\fBTZ\fP Timezone for timefmt output, see \fBstrftime\fP(3). +\fBTZ\fP Timezone for timefmt output, see \fBstrftime\fP(3). .SH AUTHOR Steve Baker ([email protected]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/file.c new/tree-1.8.0/file.c --- old/tree-1.7.0/file.c 1970-01-01 01:00:00.000000000 +0100 +++ new/tree-1.8.0/file.c 2018-01-09 17:50:49.000000000 +0100 @@ -0,0 +1,284 @@ +/* $Copyright: $ + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) + * All Rights reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "tree.h" + +extern bool dflag, Fflag, aflag, fflag, pruneflag; +extern bool noindent, force_color, flimit, matchdirs; +extern bool reverse; +extern char *pattern, *ipattern; + +extern int (*cmpfunc)(); +extern FILE *outfile; +extern int Level, *dirs, maxdirs; + +extern bool colorize; +extern char *endcode; + +extern char *file_comment, *file_pathsep; + +enum ftok { T_PATHSEP, T_DIR, T_FILE, T_EOP }; + +char *nextpc(char **p, int *tok) +{ + static char prev = 0; + char *s = *p; + if (!**p) { + *tok = T_EOP; // Shouldn't happen. + return NULL; + } + if (prev) { + prev = 0; + *tok = T_PATHSEP; + return NULL; + } + if (strchr(file_pathsep, **p) != NULL) { + (*p)++; + *tok = T_PATHSEP; + return NULL; + } + while(**p && strchr(file_pathsep,**p) == NULL) (*p)++; + + if (**p) { + *tok = T_DIR; + prev = **p; + *(*p)++ = '\0'; + } else *tok = T_FILE; + return s; +} + +struct _info *newent(char *name) { + struct _info *n = xmalloc(sizeof(struct _info)); + memset(n,0,sizeof(struct _info)); + n->name = strdup(name); + n->child = NULL; + n->tchild = n->next = NULL; + return n; +} + +// Should replace this with a Red-Black tree implementation or the like +struct _info *search(struct _info **dir, char *name) +{ + struct _info *ptr, *prev, *n; + int cmp; + + if (*dir == NULL) return (*dir = newent(name)); + + for(prev = ptr = *dir; ptr != NULL; ptr=ptr->next) { + cmp = strcmp(ptr->name,name); + if (cmp == 0) return ptr; + if (cmp > 0) break; + prev = ptr; + } + n = newent(name); + n->next = ptr; + if (prev == ptr) *dir = n; + else prev->next = n; + return n; +} + +void freefiletree(struct _info *ent) +{ + struct _info *ptr = ent, *t; + + while (ptr != NULL) { + if (ptr->tchild) freefiletree(ptr->tchild); + t = ptr; + ptr = ptr->next; + free(t); + } +} + +/** + * Recursively prune (unset show flag) files/directories of matches/ignored + * patterns: + */ +struct _info **fprune(struct _info *head, bool matched, bool root) +{ + struct _info **dir, *new = NULL, *end = NULL, *ent, *t; + int show, count = 0; + + for(ent = head; ent != NULL;) { + if (ent->tchild) ent->isdir = 1; + + show = 1; + if (dflag && !ent->isdir) show = 0; + if (!aflag && !root && ent->name[0] == '.') show = 0; + if (show && !matched) { + if (!ent->isdir) { + if (pattern && patmatch(ent->name, pattern) == 0) show = 0; + if (ipattern && patmatch(ent->name, pattern) == 1) show = 0; + } + if (ent->isdir && show && matchdirs && pattern) { + if (patmatch(ent->name, pattern) == 1) matched = TRUE; + } + } + if (pruneflag && !matched && ent->isdir && ent->tchild == NULL) show = 0; + if (show && ent->tchild != NULL) ent->child = fprune(ent->tchild, matched, FALSE); + + t = ent; + ent = ent->next; + if (show) { + if (end) end = end->next = t; + else new = end = t; + count++; + } else { + t->next = NULL; + freefiletree(t); + } + } + if (end) end->next = NULL; + + dir = xmalloc(sizeof(struct _info *) * (count+1)); + for(count = 0, ent = new; ent != NULL; ent = ent->next, count++) { + dir[count] = ent; + } + dir[count] = NULL; + + return dir; +} + +struct _info **file_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err) +{ + FILE *fp = (strcmp(d,".")? fopen(d,"r") : stdin); + char *path, *spath, *s; + long pathsize; + struct _info *root = NULL, **cwd, *ent; + int l, tok; + + size = 0; + if (fp == NULL) { + fprintf(stderr,"Error opening %s for reading.\n", d); + return NULL; + } + // 64K paths maximum + path = xmalloc(sizeof(char *) * (pathsize = (64 * 1024))); + + while(fgets(path, pathsize, fp) != NULL) { + if (file_comment != NULL && strcmp(path,file_comment) == 0) continue; + l = strlen(path); + while(l && isspace(path[l-1])) path[--l] = '\0'; + if (l == 0) continue; + + spath = path; + cwd = &root; + do { + s = nextpc(&spath, &tok); + if (tok == T_PATHSEP) continue; + switch(tok) { + case T_PATHSEP: continue; + case T_FILE: + case T_DIR: + // Should probably handle '.' and '..' entries here + ent = search(cwd, s); + // Might be empty, but should definitely be considered a directory: + if (tok == T_DIR) { + ent->isdir = 1; + ent->mode = S_IFDIR; + } else { + ent->mode = S_IFREG; + } + cwd = &(ent->tchild); + break; + } + } while (tok != T_FILE && tok != T_EOP); + } + if (fp != stdin) fclose(fp); + + // Prune accumulated directory tree: + return fprune(root, FALSE, TRUE); +} + +// void f_listdir(struct _info *dir, char *d, int *dt, int *ft, u_long lev) +// { +// char *path; +// long pathsize = 0; +// bool nlf = FALSE, colored = FALSE; +// +// if (dir == NULL) return; +// +// dirs[lev] = (dir->next? 1 : 2); +// fprintf(outfile,"\n"); +// +// path = malloc(pathsize=4096); +// +// while(dir) { +// if (!noindent) indent(lev); +// +// if (colorize) { +// colored = color(dir->isdir? S_IFDIR : S_IFREG, dir->name, FALSE, FALSE); +// } +// +// if (fflag) { +// if (sizeof(char) * (strlen(d)+strlen(dir->name)+2) > pathsize) +// path=xrealloc(path,pathsize=(sizeof(char) * (strlen(d)+strlen(dir->name)+1024))); +// if (!strcmp(d,"/")) sprintf(path,"%s%s",d,dir->name); +// else sprintf(path,"%s/%s",d,dir->name); +// } else { +// if (sizeof(char) * (strlen(dir->name)+1) > pathsize) +// path=xrealloc(path,pathsize=(sizeof(char) * (strlen(dir->name)+1024))); +// sprintf(path,"%s",dir->name); +// } +// +// printit(path); +// +// if (colored) fprintf(outfile,"%s",endcode); +// if (Fflag && dir->isdir) fputc(Ftype(S_IFDIR), outfile); +// +// if (dir->child) { +// if (fflag) { +// if (strlen(d)+strlen(dir->name)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen(dir->name)+1024)); +// if (!strcmp(d,"/")) sprintf(path,"%s%s",d,dir->name); +// else sprintf(path,"%s/%s",d,dir->name); +// } +// f_listdir(dir->child, fflag? path : NULL, dt, ft, lev+1); +// nlf = TRUE; +// *dt += 1; +// } else { +// if (dir->isdir) *dt += 1; +// else *ft += 1; +// } +// +// if (dir->next && !dir->next->next) dirs[lev] = 2; +// if (nlf) nlf = FALSE; +// else fprintf(outfile,"\n"); +// dir=dir->next; +// } +// dirs[lev] = 0; +// free(path); +// } + +// void file_listdir(char *d, int *dt, int *ft, u_long lev) +// { +// FILE *fp = (d != NULL? fopen(d,"r") : stdin); +// struct _info *root; +// +// if (fp == NULL) { +// fprintf(stderr,"Error opening %s for reading.\n", d); +// return; +// } +// root = getfulltree(fp, lev); +// if (d != NULL) fclose(fp); +// +// memset(dirs, 0, sizeof(int) * maxdirs); +// +// f_listdir(root, "/", dt, ft, lev); +// +// freefiletree(root); +// return; +// } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/hash.c new/tree-1.8.0/hash.c --- old/tree-1.7.0/hash.c 2014-04-21 20:53:14.000000000 +0200 +++ new/tree-1.8.0/hash.c 2018-01-10 17:47:40.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/html.c new/tree-1.8.0/html.c --- old/tree-1.7.0/html.c 2014-04-21 22:31:19.000000000 +0200 +++ new/tree-1.8.0/html.c 2018-01-10 17:47:45.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -24,6 +24,7 @@ //extern char *title, extern char *host, *sp; +extern struct _info **(*getfulltree)(char *d, u_long lev, dev_t dev, off_t *size, char **err); extern void (*listdir)(char *, int *, int *, u_long, dev_t); extern int (*cmpfunc)(); extern FILE *outfile; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/json.c new/tree-1.8.0/json.c --- old/tree-1.7.0/json.c 2014-04-21 17:40:35.000000000 +0200 +++ new/tree-1.8.0/json.c 2018-01-10 17:47:51.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -19,12 +19,13 @@ #include "tree.h" extern bool dflag, lflag, pflag, sflag, Fflag, aflag, fflag, uflag, gflag; -extern bool Dflag, inodeflag, devflag, Rflag, cflag; +extern bool Dflag, inodeflag, devflag, Rflag, cflag, hflag, siflag; extern bool noindent, force_color, xdev, nolinks, flimit; extern const int ifmt[]; extern const char fmt[], *ftype[]; +extern struct _info **(*getfulltree)(char *d, u_long lev, dev_t dev, off_t *size, char **err); extern void (*listdir)(char *, int *, int *, u_long, dev_t); extern int (*cmpfunc)(); extern FILE *outfile; @@ -238,8 +239,10 @@ } json_fillinfo(*dir); - if (mt != S_IFDIR && mt != S_IFLNK && (*dir)->err == NULL) fprintf(outfile,"},"); - else fprintf(outfile, ",\"contents\":["); + if (mt != S_IFDIR && mt != S_IFLNK && (*dir)->err == NULL) { + fputc('}', outfile); + if (*(dir+1)) fputc(',',outfile); + } else fprintf(outfile, ",\"contents\":["); if ((*dir)->err) { fprintf(outfile,",\"error\":\"%s\"", (*dir)->err); @@ -265,10 +268,11 @@ nlf = FALSE; if (!noindent) json_indent(lev); } - if (mt == S_IFDIR || mt == S_IFLNK || (*dir)->err != NULL) fprintf(outfile,"]},%s",noindent?"":"\n"); - else { - if (!noindent) putc('\n',outfile); + if (mt == S_IFDIR || mt == S_IFLNK || (*dir)->err != NULL) { + fprintf(outfile,"]}"); + if (*(dir+1)) fputc(',',outfile); } + if (!noindent) putc('\n',outfile); dir++; } dirs[lev] = 0; @@ -300,6 +304,15 @@ #endif if (uflag) fprintf(outfile, ",\"user\":\"%s\"", uidtoname(ent->uid)); if (gflag) fprintf(outfile, ",\"group\":\"%s\"", gidtoname(ent->gid)); - if (sflag) fprintf(outfile, ",\"size\":%lld", (long long int)ent->size); + if (sflag) { + if (hflag || siflag) { + char nbuf[64]; + int i; + psize(nbuf,ent->size); + for(i=0; isspace(nbuf[i]); i++); // trim() hack + fprintf(outfile, ",\"size\":\"%s\"", nbuf+i); + } else + fprintf(outfile, ",\"size\":%lld", (long long int)ent->size); + } if (Dflag) fprintf(outfile, ",\"time\":\"%s\"", do_date(cflag? ent->ctime : ent->mtime)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/tree.c new/tree-1.8.0/tree.c --- old/tree-1.7.0/tree.c 2014-04-23 23:38:24.000000000 +0200 +++ new/tree-1.8.0/tree.c 2018-01-10 17:47:14.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -19,8 +19,8 @@ #include "tree.h" -static char *version ="$Version: $ tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $"; -static char *hversion="\t\t tree v1.7.0 %s 1996 - 2014 by Steve Baker and Thomas Moore <br>\n" +static char *version ="$Version: $ tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $"; +static char *hversion="\t\t tree v1.8.0 %s 1996 - 2018 by Steve Baker and Thomas Moore <br>\n" "\t\t HTML output hacked and copyleft %s 1998 by Francesc Rocher <br>\n" "\t\t JSON output hacked and copyleft %s 2014 by Florian Sesser <br>\n" "\t\t Charsets / OS/2 support %s 2001 by Kyosuke Tokoro\n"; @@ -30,12 +30,14 @@ bool qflag, Nflag, Qflag, Dflag, inodeflag, devflag, hflag, Rflag; bool Hflag, siflag, cflag, Xflag, Jflag, duflag, pruneflag; bool noindent, force_color, nocolor, xdev, noreport, nolinks, flimit, dirsfirst; -bool ignorecase, matchdirs; +bool ignorecase, matchdirs, fromfile; bool reverse; char *pattern = NULL, *ipattern = NULL, *host = NULL, *title = "Directory Tree", *sp = " ", *_nl = "\n"; +char *file_comment = "#", *file_pathsep = "/"; char *timefmt = NULL; const char *charset = NULL; +struct _info **(*getfulltree)(char *d, u_long lev, dev_t dev, off_t *size, char **err) = unix_getfulltree; off_t (*listdir)(char *, int *, int *, u_long, dev_t) = unix_listdir; int (*cmpfunc)() = alnumsort; @@ -312,6 +314,9 @@ flimit=atoi(argv[i]+12); j = strlen(argv[i])-1; break; + } else { + fprintf(stderr,"tree: missing argument to --filelimit=\n"); + exit(1); } } if (argv[n] != NULL) { @@ -329,6 +334,9 @@ if (*(charset = (argv[i]+10))) { j = strlen(argv[i])-1; break; + } else { + fprintf(stderr,"tree: missing argument to --charset=\n"); + exit(1); } } if (argv[n] != NULL) { @@ -365,6 +373,9 @@ timefmt=scopy(argv[i]+j); j = strlen(argv[i])-1; break; + }else { + fprintf(stderr,"tree: missing argument to --timefmt=\n"); + exit(1); } } else if (argv[n] != NULL) { timefmt = scopy(argv[n]); @@ -403,14 +414,14 @@ fprintf(stderr,"tree: missing argument to --sort\n"); exit(1); } - cmpfunc = (void *)1; + cmpfunc = NULL; for(k=0;sorts[k].name;k++) { if (strcasecmp(sorts[k].name,stmp) == 0) { cmpfunc = sorts[k].cmpfunc; break; } } - if (cmpfunc == (void *)1) { + if (cmpfunc == NULL) { fprintf(stderr,"tree: sort type '%s' not valid, should be one of: ", stmp); for(k=0; sorts[k].name; k++) printf("%s%c", sorts[k].name, sorts[k+1].name? ',': '\n'); @@ -418,6 +429,14 @@ } break; } + if (!strncmp("--fromfile",argv[i],10)) { + j = strlen(argv[i])-1; + fromfile=TRUE; + break; + } + fprintf(stderr,"tree: Invalid argument `%s'.\n",argv[i]); + usage(1); + exit(1); } default: fprintf(stderr,"tree: Invalid argument -`%c'.\n",argv[i][j]); @@ -452,10 +471,18 @@ } } + + if (timefmt) + setlocale(LC_TIME,""); + parse_dir_colors(); initlinedraw(0); - needfulltree = duflag || pruneflag || matchdirs; + needfulltree = duflag || pruneflag || matchdirs || fromfile; + + if (fromfile) { + getfulltree = file_getfulltree; + } /* Set our listdir function and sanity check options. */ if (Hflag) { @@ -474,7 +501,6 @@ } if (dflag) pruneflag = FALSE; /* You'll just get nothing otherwise. */ - if (Rflag && (Level == -1)) Rflag = FALSE; @@ -606,7 +632,8 @@ "\t[-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version]\n" "\t[--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst]\n" "\t[--charset charset] [--filelimit[=]#] [--si] [--timefmt[=]<f>]\n" - "\t[--sort[=]<name>] [--matchdirs] [--ignore-case] [--] [<directory list>]\n"); + "\t[--sort[=]<name>] [--matchdirs] [--ignore-case] [--fromfile] [--]\n" + "\t[<directory list>]\n"); if (n < 2) return; fprintf(stdout, " ------- Listing options -------\n" @@ -626,7 +653,7 @@ " --filelimit # Do not descend dirs with more than # files in them.\n" " --timefmt <f> Print and format time according to the format <f>.\n" " -o filename Output to file instead of stdout.\n" - " -------- File options ---------\n" + " ------- File options -------\n" " -q Print non-printable characters as '?'.\n" " -N Print non-printable characters as is.\n" " -Q Quote filenames with double quotes.\n" @@ -648,7 +675,7 @@ " -r Reverse the order of the sort.\n" " --dirsfirst List directories before files (-U disables).\n" " --sort X Select sort: name,version,size,mtime,ctime.\n" - " ------- Graphics options ------\n" + " ------- Graphics options -------\n" " -i Don't print indentation lines.\n" " -A Print ANSI lines graphic indentation lines.\n" " -S Print with CP437 (console) graphics indentation lines.\n" @@ -660,7 +687,9 @@ " -H baseHREF Prints out HTML format with baseHREF as top directory.\n" " -T string Replace the default HTML title and H1 header with string.\n" " --nolinks Turn off hyperlinks in HTML output.\n" - " ---- Miscellaneous options ----\n" + " ------- Input options -------\n" + " --fromfile Reads paths from files (.=stdin)\n" + " ------- Miscellaneous options -------\n" " --version Print version and exit.\n" " --help Print usage and this help message and exit.\n" " -- Options processing terminator.\n"); @@ -698,16 +727,16 @@ sprintf(path,"%s/%s",dir,ent->d_name); if (lstat(path,&lst) < 0) continue; if ((lst.st_mode & S_IFMT) == S_IFLNK) { - if ((rs = stat(path,&st)) < 0) st.st_mode = 0; + if ((rs = stat(path,&st)) < 0) memset(&st, 0, sizeof(st)); } else { rs = 0; st.st_mode = lst.st_mode; st.st_dev = lst.st_dev; st.st_ino = lst.st_ino; } - + #ifndef __EMX__ - if ((lst.st_mode & S_IFMT) != S_IFDIR && !(((lst.st_mode & S_IFMT) == S_IFLNK) && lflag)) { + if ((lst.st_mode & S_IFMT) != S_IFDIR && !(lflag && ((st.st_mode & S_IFMT) == S_IFDIR))) { if (pattern && patmatch(ent->d_name,pattern) != 1) continue; } if (ipattern && patmatch(ent->d_name,ipattern) == 1) continue; @@ -715,7 +744,7 @@ if (dflag && ((st.st_mode & S_IFMT) != S_IFDIR)) continue; #ifndef __EMX__ - if (pattern && ((lst.st_mode & S_IFMT) == S_IFLNK) && !lflag) continue; +// if (pattern && ((lst.st_mode & S_IFMT) == S_IFLNK) && !lflag) continue; #endif if (p == (ne-1)) dl = (struct _info **)xrealloc(dl,sizeof(struct _info *) * (ne += MINC)); @@ -731,6 +760,8 @@ dl[p]->size = lst.st_size; dl[p]->dev = st.st_dev; dl[p]->inode = st.st_ino; + dl[p]->ldev = lst.st_dev; + dl[p]->linode = lst.st_ino; dl[p]->lnk = NULL; dl[p]->orphan = FALSE; dl[p]->err = NULL; @@ -776,7 +807,7 @@ * This can and will use a large amount of memory for large directory trees * and also take some time. */ -struct _info **getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err) +struct _info **unix_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err) { char *path; long pathsize = 0; @@ -847,12 +878,12 @@ } else { saveino((*dir)->inode, (*dir)->dev); if (*(*dir)->lnk == '/') - (*dir)->child = getfulltree((*dir)->lnk,lev+1,dev,&((*dir)->size),&((*dir)->err)); + (*dir)->child = unix_getfulltree((*dir)->lnk,lev+1,dev,&((*dir)->size),&((*dir)->err)); else { if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024)); if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk); else sprintf(path,"%s/%s",d,(*dir)->lnk); - (*dir)->child = getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err)); + (*dir)->child = unix_getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err)); } } } @@ -861,7 +892,7 @@ if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->name); else sprintf(path,"%s/%s",d,(*dir)->name); saveino((*dir)->inode, (*dir)->dev); - (*dir)->child = getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err)); + (*dir)->child = unix_getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err)); } // prune empty folders, unless they match the requested pattern if (pruneflag && (*dir)->child == NULL && @@ -1094,7 +1125,7 @@ } -/* +/** * They cried out for ANSI-lines (not really), but here they are, as an option * for the xterm and console capable among you, as a run-time option. */ @@ -1104,7 +1135,7 @@ if (ansilines) { if (dirs[0]) fprintf(outfile,"\033(0"); - for(i=0; dirs[i] && i <= maxlevel; i++) { + for(i=0; (i <= maxlevel) && dirs[i]; i++) { if (dirs[i+1]) { if (dirs[i] == 1) fprintf(outfile,"\170 "); else printf(" "); @@ -1116,7 +1147,7 @@ if (dirs[0]) fprintf(outfile,"\033(B"); } else { if (Hflag) fprintf(outfile,"\t"); - for(i=0; dirs[i] && i <= maxlevel; i++) { + for(i=0; (i <= maxlevel) && dirs[i]; i++) { fprintf(outfile,"%s ", dirs[i+1] ? (dirs[i]==1 ? linedraw->vert : (Hflag? " " : " ") ) : (dirs[i]==1 ? linedraw->vert_left:linedraw->corner)); @@ -1146,7 +1177,10 @@ for(i=0;ifmt[i] && (m&S_IFMT) != ifmt[i];i++); buf[0] = fmt[i]; - /* Nice, but maybe not so portable, it is should be no less portable than the old code. */ + /** + * Nice, but maybe not so portable, it is should be no less portable than the + * old code. + */ for(b=S_IRUSR,i=0; i<9; b>>=1,i++) buf[i+1] = (m & (b)) ? perms[i] : '-'; if (m & S_ISUID) buf[3] = (buf[3]=='-')? 'S' : 's'; @@ -1158,15 +1192,11 @@ return buf; } -static char *month[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; - #define SIXMONTHS (6*31*24*60*60) char *do_date(time_t t) { - static char buf[256]; /* More than enough rope to hang em */ + static char buf[256]; struct tm *tm; tm = localtime(&t); @@ -1176,15 +1206,18 @@ buf[255] = 0; } else { time_t c = time(0); - if (t > c) return " The Future "; - sprintf(buf,"%s %2d",month[tm->tm_mon],tm->tm_mday); - if (t+SIXMONTHS < c) sprintf(buf+6," %4d",1900+tm->tm_year); - else sprintf(buf+6," %2d:%02d",tm->tm_hour,tm->tm_min); + /* Use strftime() so that locale is respected: */ + if (t > c || (t+SIXMONTHS) < c) + strftime(buf,255,"%b %e %Y",tm); + else + strftime(buf,255,"%b %e %R", tm); } return buf; } - +/** + * Must fix this someday + */ void printit(char *s) { int c; @@ -1197,9 +1230,9 @@ if (mb_cur_max > 1) { wchar_t *ws, *tp; ws = xmalloc(sizeof(wchar_t)* (c=(strlen(s)+1))); - if (mbstowcs(ws,s,c) > 0) { + if (mbstowcs(ws,s,c) != (size_t)-1) { if (Qflag) putc('"',outfile); - for(tp=ws;*tp;tp++) { + for(tp=ws;*tp && c > 1;tp++, c--) { if (iswprint(*tp)) fprintf(outfile,"%lc",(wint_t)*tp); else { if (qflag) putc('?',outfile); @@ -1247,7 +1280,7 @@ for (idx=size<usize?0:1; size >= (usize*usize); idx++,size/=usize); if (!idx) return sprintf(buf, " %4d", (int)size); else return sprintf(buf, ((size/usize) >= 10)? " %3.0f%c" : " %3.1f%c" , (float)size/(float)usize,unit[idx]); - } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", (long long int)size); + } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9lld", (long long int)size); } char Ftype(mode_t mode) @@ -1258,7 +1291,7 @@ else if (m == S_IFIFO) return '|'; else if (m == S_IFLNK) return '@'; /* Here, but never actually used though. */ #ifdef S_IFDOOR - else if (m == S_ISDOOR) return '>'; + else if (m == S_IFDOOR) return '>'; #endif else if ((m == S_IFREG) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return '*'; return 0; @@ -1269,11 +1302,11 @@ int n; buf[n=0] = 0; #ifdef __USE_FILE_OFFSET64 - if (inodeflag) n += sprintf(buf," %7lld",(long long)ent->inode); + if (inodeflag) n += sprintf(buf," %7lld",(long long)ent->linode); #else - if (inodeflag) n += sprintf(buf," %7ld",(long int)ent->inode); + if (inodeflag) n += sprintf(buf," %7ld",(long int)ent->linode); #endif - if (devflag) n += sprintf(buf+n, " %3d", (int)ent->dev); + if (devflag) n += sprintf(buf+n, " %3d", (int)ent->ldev); #ifdef __EMX__ if (pflag) n += sprintf(buf+n, " %s",prot(ent->attr)); #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/tree.h new/tree-1.8.0/tree.h --- old/tree-1.7.0/tree.h 2014-04-21 17:08:30.000000000 +0200 +++ new/tree-1.8.0/tree.h 2018-01-10 17:50:55.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -84,13 +84,13 @@ gid_t gid; off_t size; time_t atime, ctime, mtime; - dev_t dev; - ino_t inode; + dev_t dev, ldev; + ino_t inode, linode; #ifdef __EMX__ long attr; #endif char *err; - struct _info **child; + struct _info **child, *next, *tchild; }; /* hash.c */ struct xtable { @@ -120,7 +120,7 @@ /* Function prototypes: */ /* tree.c */ void usage(int); -struct _info **getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err); +struct _info **unix_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err); struct _info **read_dir(char *, int *); int alnumsort(struct _info **, struct _info **); @@ -185,6 +185,9 @@ int findino(ino_t, dev_t); void saveino(ino_t, dev_t); +/* file.c */ +struct _info **file_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err); + /* We use the strverscmp.c file if we're not linux */ #if ! defined (LINUX) int strverscmp (const char *s1, const char *s2); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/unix.c new/tree-1.8.0/unix.c --- old/tree-1.7.0/unix.c 2014-04-18 19:35:24.000000000 +0200 +++ new/tree-1.8.0/unix.c 2018-01-10 17:51:00.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,7 @@ extern bool Dflag, inodeflag, devflag, Rflag, duflag, pruneflag; extern bool noindent, force_color, xdev, nolinks, flimit; +extern struct _info **(*getfulltree)(char *d, u_long lev, dev_t dev, off_t *size, char **err); extern void (*listdir)(char *, int *, int *, u_long, dev_t); extern int (*cmpfunc)(); extern FILE *outfile; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-1.7.0/xml.c new/tree-1.8.0/xml.c --- old/tree-1.7.0/xml.c 2014-04-21 21:04:37.000000000 +0200 +++ new/tree-1.8.0/xml.c 2018-11-16 15:27:32.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2014 by Steve Baker ([email protected]) + * Copyright (c) 1996 - 2018 by Steve Baker ([email protected]) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,7 @@ extern bool Dflag, inodeflag, devflag, Rflag, cflag; extern bool noindent, force_color, xdev, nolinks, flimit; +extern struct _info **(*getfulltree)(char *d, u_long lev, dev_t dev, off_t *size, char **err); extern const int ifmt[]; extern const char fmt[], *ftype[]; ++++++ tree-makefile.patch ++++++ --- /var/tmp/diff_new_pack.cVNZzr/_old 2018-12-11 15:49:30.662095282 +0100 +++ /var/tmp/diff_new_pack.cVNZzr/_new 2018-12-11 15:49:30.666095278 +0100 @@ -4,7 +4,7 @@ # Uncomment options below for your particular OS: # Linux defaults: --CFLAGS=-ggdb -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +-CFLAGS=-ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -#CFLAGS=-O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -#LDFLAGS=-s +#CFLAGS=-ggdb -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
