Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package tree for openSUSE:Factory checked in at 2022-01-06 15:50:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/tree (Old) and /work/SRC/openSUSE:Factory/.tree.new.1896 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "tree" Thu Jan 6 15:50:56 2022 rev:24 rq:943932 version:2.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/tree/tree.changes 2022-01-04 19:37:39.761943648 +0100 +++ /work/SRC/openSUSE:Factory/.tree.new.1896/tree.changes 2022-01-06 15:51:04.240964251 +0100 @@ -1,0 +2,9 @@ +Tue Jan 4 19:05:56 UTC 2022 - Andreas Stieger <andreas.stie...@gmx.de> + +- tree 2.0.1: + * Make patterns ending in '/' match directories (but not files) + for -I / -P, should also fix issues with --gitignore as well + - Fix --gitignore not matching files relative to the path of the + .gitignore + +------------------------------------------------------------------- Old: ---- tree-2.0.0.tgz New: ---- tree-2.0.1.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ tree.spec ++++++ --- /var/tmp/diff_new_pack.o6dRJs/_old 2022-01-06 15:51:04.708964508 +0100 +++ /var/tmp/diff_new_pack.o6dRJs/_new 2022-01-06 15:51:04.712964511 +0100 @@ -17,7 +17,7 @@ Name: tree -Version: 2.0.0 +Version: 2.0.1 Release: 0 Summary: File listing as a tree License: GPL-2.0-or-later ++++++ tree-2.0.0.tgz -> tree-2.0.1.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/CHANGES new/tree-2.0.1/CHANGES --- old/tree-2.0.0/CHANGES 2021-12-21 20:38:25.000000000 +0100 +++ new/tree-2.0.1/CHANGES 2022-01-03 22:30:53.000000000 +0100 @@ -1,3 +1,14 @@ +Version 2.0.1 (01/03/2022) + - Simplify Makefile and the following changes: prefix -> PREFIX, + BINDIR -> DESTDIR, -O4 -> -O3, mode 644 for man page installation + (Michal Vasilek) + - Make patterns ending in '/' match directories (but not files) for -I / -P + (Michiel Beijen) should also fix issues with --gitignore as well + (Taylor Faubion) + - Fix --gitignore not matching files relative to the path of the .gitignore + (Taylor Faubion) I did say it was hacked together. + - Refactored color.c a bit to simplify the code as a prelude to meta coloring. + Version 2.0.0 (12/21/2021) - This started out as a 1.9.0 release but then I got fed up with the abundance of directory listers (8 in total, 2 each for each output mode). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/Makefile new/tree-2.0.1/Makefile --- old/tree-2.0.0/Makefile 2021-12-21 23:22:11.000000000 +0100 +++ new/tree-2.0.1/Makefile 2022-01-03 20:11:10.000000000 +0100 @@ -1,5 +1,5 @@ # $Copyright: $ -# Copyright (c) 1996 - 2021 by Steve Baker +# Copyright (c) 1996 - 2022 by Steve Baker # All Rights reserved # # This program is free software; you can redistribute it and/or modify @@ -16,24 +16,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -prefix=/usr/local +PREFIX=/usr/local CC=gcc INSTALL=install -VERSION=2.0.0 +VERSION=2.0.1 TREE_DEST=tree -BINDIR=${prefix}/bin +DESTDIR=${PREFIX}/bin MAN=tree.1 -MANDIR=${prefix}/man -#OBJS=tree.o unix.o html.o xml.o json.o hash.o color.o file.o filter.o info.o strverscmp.o +MANDIR=${PREFIX}/man OBJS=tree.o list.o hash.o color.o file.o filter.o info.o unix.o xml.o json.o html.o strverscmp.o # Uncomment options below for your particular OS: # Linux defaults: #CFLAGS=-ggdb -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -CFLAGS=-O4 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +CFLAGS=-O3 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 LDFLAGS=-s # Uncomment for FreeBSD: @@ -100,22 +99,16 @@ $(CC) $(CFLAGS) -c -o $@ $< clean: - if [ -x $(TREE_DEST) ]; then rm $(TREE_DEST); fi - if [ -f tree.o ]; then rm *.o; fi - rm -f *~ + rm -f $(TREE_DEST) *.o *~ install: tree - $(INSTALL) -d $(BINDIR) + $(INSTALL) -d $(DESTDIR) $(INSTALL) -d $(MANDIR)/man1 - if [ -e $(TREE_DEST) ]; then \ - $(INSTALL) $(TREE_DEST) $(BINDIR)/$(TREE_DEST); \ - fi - $(INSTALL) doc/$(MAN) $(MANDIR)/man1/$(MAN) + $(INSTALL) $(TREE_DEST) $(DESTDIR)/$(TREE_DEST); \ + $(INSTALL) -m 644 doc/$(MAN) $(MANDIR)/man1/$(MAN) distclean: - if [ -f tree.o ]; then rm *.o; fi - rm -f *~ - + rm -f *.o *~ dist: distclean tar zcf ../tree-$(VERSION).tgz -C .. `cat .tarball` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/README new/tree-2.0.1/README --- old/tree-2.0.0/README 2021-12-21 23:52:44.000000000 +0100 +++ new/tree-2.0.1/README 2022-01-03 22:27:14.000000000 +0100 @@ -247,7 +247,10 @@ Michiel Beijen (and others) - Suggest Support multiple -I and -P instances. + - Suggest that / match directories in patterns (also Taylor Faubion) +Michal Vasilek + - Various Makefile fixes 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-2.0.0/color.c new/tree-2.0.1/color.c --- old/tree-2.0.0/color.c 2021-12-21 19:46:52.000000000 +0100 +++ new/tree-2.0.1/color.c 2022-01-03 20:09:33.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -38,11 +38,13 @@ * something. */ enum { - CMD_COLOR, CMD_OPTIONS, CMD_TERM, CMD_EIGHTBIT, COL_RESET, COL_NORMAL, COL_FILE, - COL_DIR, COL_LINK, COL_FIFO, COL_DOOR, COL_BLK, COL_CHR, COL_ORPHAN, COL_SOCK, - COL_SETUID, COL_SETGID, COL_STICKY_OTHER_WRITABLE, COL_OTHER_WRITABLE, - COL_STICKY, COL_EXEC, COL_MISSING, COL_LEFTCODE, COL_RIGHTCODE, COL_ENDCODE, - DOT_EXTENSION, ERROR + ERROR = -1, CMD_COLOR = 0, CMD_OPTIONS, CMD_TERM, CMD_EIGHTBIT, COL_RESET, + COL_NORMAL, COL_FILE, COL_DIR, COL_LINK, COL_FIFO, COL_DOOR, COL_BLK, COL_CHR, + COL_ORPHAN, COL_SOCK, COL_SETUID, COL_SETGID, COL_STICKY_OTHER_WRITABLE, + COL_OTHER_WRITABLE, COL_STICKY, COL_EXEC, COL_MISSING, + COL_LEFTCODE, COL_RIGHTCODE, COL_ENDCODE, +// Keep this one last, sets the size of the color_code array: + DOT_EXTENSION }; enum { @@ -52,13 +54,8 @@ bool colorize = FALSE, ansilines = FALSE, linktargetcolor = FALSE; char *term, termmatch = FALSE, istty; -char *leftcode = NULL, *rightcode = NULL, *endcode = NULL; -char *reset_flgs = NULL, *norm_flgs = NULL, *file_flgs = NULL, *dir_flgs = NULL; -char *link_flgs = NULL, *fifo_flgs = NULL, *door_flgs = NULL, *block_flgs = NULL; -char *char_flgs = NULL, *orphan_flgs = NULL, *sock_flgs = NULL, *suid_flgs = NULL; -char *sgid_flgs = NULL, *stickyow_flgs = NULL, *otherwr_flgs = NULL; -char *sticky_flgs = NULL, *exec_flgs = NULL, *missing_flgs = NULL; +char *color_code[DOT_EXTENSION+1] = {NULL}; char *vgacolor[] = { "black", "red", "green", "yellow", "blue", "fuchsia", "aqua", "white", @@ -80,7 +77,7 @@ void parse_dir_colors() { char buf[1025], **arg, **c, *colors, *s, *cc; - int i, n; + int i, n, col; struct extensions *e; if (Hflag) return; @@ -89,96 +86,31 @@ colorize = FALSE; return; } - + s = getenv("TREE_COLORS"); if (s == NULL) s = getenv("LS_COLORS"); cc = getenv("CLICOLOR"); if (getenv("CLICOLOR_FORCE") != NULL && !nocolor) force_color=TRUE; if ((s == NULL || strlen(s) == 0) && (force_color || cc != NULL)) s = ":no=00:rs=0: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; return; - } else { - colorize = TRUE; - /* You can uncomment the below line and tree will always try to ANSI-fy the indentation lines */ - /* ansilines = TRUE; */ } - + + colorize = TRUE; + + for(int i=0; i < DOT_EXTENSION; i++) color_code[i] = NULL; + colors = scopy(s); arg = split(colors,":",&n); for(i=0;arg[i];i++) { c = split(arg[i],"=",&n); - switch(cmd(c[0])) { - case COL_RESET: - if (c[1]) reset_flgs = scopy(c[1]); - break; - case COL_NORMAL: - if (c[1]) norm_flgs = scopy(c[1]); - break; - case COL_FILE: - if (c[1]) file_flgs = scopy(c[1]); - break; - case COL_DIR: - if (c[1]) dir_flgs = scopy(c[1]); - break; - case COL_LINK: - if (c[1]) { - if (strcasecmp("target",c[1]) == 0) { - linktargetcolor = TRUE; - link_flgs = "01;36"; /* Should never actually be used */ - } else link_flgs = scopy(c[1]); - } - break; - case COL_FIFO: - if (c[1]) fifo_flgs = scopy(c[1]); - break; - case COL_DOOR: - if (c[1]) door_flgs = scopy(c[1]); - break; - case COL_BLK: - if (c[1]) block_flgs = scopy(c[1]); - break; - case COL_CHR: - if (c[1]) char_flgs = scopy(c[1]); - break; - case COL_ORPHAN: - if (c[1]) orphan_flgs = scopy(c[1]); - break; - case COL_SOCK: - if (c[1]) sock_flgs = scopy(c[1]); - break; - case COL_SETUID: - if (c[1]) suid_flgs = scopy(c[1]); - break; - case COL_SETGID: - if (c[1]) sgid_flgs = scopy(c[1]); - break; - case COL_STICKY_OTHER_WRITABLE: - if (c[1]) stickyow_flgs = scopy(c[1]); - break; - case COL_OTHER_WRITABLE: - if (c[1]) otherwr_flgs = scopy(c[1]); - break; - case COL_STICKY: - if (c[1]) sticky_flgs = scopy(c[1]); - break; - case COL_EXEC: - if (c[1]) exec_flgs = scopy(c[1]); - break; - case COL_MISSING: - if (c[1]) missing_flgs = scopy(c[1]); - break; - case COL_LEFTCODE: - if (c[1]) leftcode = scopy(c[1]); - break; - case COL_RIGHTCODE: - if (c[1]) rightcode = scopy(c[1]); - break; - case COL_ENDCODE: - if (c[1]) endcode = scopy(c[1]); + + switch(col = cmd(c[0])) { + case ERROR: break; case DOT_EXTENSION: if (c[1]) { @@ -188,24 +120,35 @@ e->nxt = ext; ext = e; } + break; + case COL_LINK: + if (c[1] && strcasecmp("target",c[1]) == 0) { + linktargetcolor = TRUE; + color_code[COL_LINK] = "01;36"; /* Should never actually be used */ + break; + } + default: + if (c[1]) color_code[col] = scopy(c[1]); + break; } + free(c); } free(arg); - /* make sure at least reset_flgs (not norm_flgs) is defined. We're going to assume ANSI/vt100 support */ - if (!leftcode) leftcode = scopy("\033["); - if (!rightcode) rightcode = scopy("m"); - if (!reset_flgs) reset_flgs = scopy("0"); - - if (!endcode) { - sprintf(buf,"%s%s%s",leftcode,reset_flgs,rightcode); - endcode = scopy(buf); + /** + * Make sure at least reset (not normal) is defined. We're going to assume + * ANSI/vt100 support: + */ + if (!color_code[COL_LEFTCODE]) color_code[COL_LEFTCODE] = scopy("\033["); + if (!color_code[COL_RIGHTCODE]) color_code[COL_RIGHTCODE] = scopy("m"); + if (!color_code[COL_RESET]) color_code[COL_RESET] = scopy("0"); + if (!color_code[COL_ENDCODE]) { + sprintf(buf,"%s%s%s",color_code[COL_LEFTCODE],color_code[COL_RESET],color_code[COL_RIGHTCODE]); + color_code[COL_ENDCODE] = scopy(buf); } free(colors); - - /* if (!termmatch) colorize = FALSE; */ } /* @@ -216,14 +159,14 @@ { int n = 128; char **w = xmalloc(sizeof(char *) * n); - + w[*nwrds = 0] = strtok(str,delim); - + while (w[*nwrds]) { if (*nwrds == (n-2)) w = xrealloc(w,sizeof(char *) * (n+=256)); w[++(*nwrds)] = strtok(NULL,delim); } - + w[*nwrds] = NULL; return w; } @@ -243,7 +186,7 @@ {"ec", COL_ENDCODE}, {NULL, 0} }; int i; - + if (s[0] == '*') return DOT_EXTENSION; for(i=0;cmds[i].cmdnum;i++) { if (!strcmp(cmds[i].cmd,s)) return cmds[i].cmdnum; @@ -251,6 +194,22 @@ return ERROR; } +int print_color(int color) +{ + if (!color_code[color]) return FALSE; + + fputs(color_code[COL_LEFTCODE],outfile); + fputs(color_code[color],outfile); + fputs(color_code[COL_RIGHTCODE],outfile); + return TRUE; +} + +void endcolor(void) +{ + if (color_code[COL_ENDCODE]) + fputs(color_code[COL_ENDCODE],outfile); +} + int color(u_short mode, char *name, bool orphan, bool islink) { struct extensions *e; @@ -258,93 +217,63 @@ if (orphan) { if (islink) { - if (missing_flgs) { - fprintf(outfile,"%s%s%s",leftcode,missing_flgs,rightcode); - return TRUE; - } + if (print_color(COL_MISSING)) return TRUE; } else { - if (orphan_flgs) { - fprintf(outfile,"%s%s%s",leftcode,orphan_flgs,rightcode); - return TRUE; - } + if (print_color(COL_ORPHAN)) return TRUE; } } + + // It's probably safe to assume short-circuit evaluation, but we'll do it this way: switch(mode & S_IFMT) { case S_IFIFO: - if (!fifo_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,fifo_flgs,rightcode); - return TRUE; + return print_color(COL_FIFO); case S_IFCHR: - if (!char_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,char_flgs,rightcode); - return TRUE; + return print_color(COL_CHR); case S_IFDIR: if (mode & S_ISVTX) { - if ((mode & S_IWOTH) && stickyow_flgs) { - fprintf(outfile, "%s%s%s",leftcode,stickyow_flgs,rightcode); - return TRUE; - } - if (!(mode & S_IWOTH) && sticky_flgs) { - fprintf(outfile, "%s%s%s",leftcode,sticky_flgs,rightcode); - return TRUE; - } + if ((mode & S_IWOTH)) + if (print_color(COL_STICKY_OTHER_WRITABLE)) return TRUE; + if (!(mode & S_IWOTH)) + if (print_color(COL_STICKY)) return TRUE; } - if ((mode & S_IWOTH) && otherwr_flgs) { - fprintf(outfile,"%s%s%s",leftcode,otherwr_flgs,rightcode); - return TRUE; - } - if (!dir_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,dir_flgs,rightcode); - return TRUE; + if ((mode & S_IWOTH)) + if (print_color(COL_OTHER_WRITABLE)) return TRUE; + return print_color(COL_DIR); #ifndef __EMX__ case S_IFBLK: - if (!block_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,block_flgs,rightcode); - return TRUE; + return print_color(COL_BLK); case S_IFLNK: - if (!link_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,link_flgs,rightcode); - return TRUE; + return print_color(COL_LINK); #ifdef S_IFDOOR case S_IFDOOR: - if (!door_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,door_flgs,rightcode); - return TRUE; + return print_color(COL_DOOR); #endif #endif case S_IFSOCK: - if (!sock_flgs) return FALSE; - fprintf(outfile,"%s%s%s",leftcode,sock_flgs,rightcode); - return TRUE; + return print_color(COL_SOCK); case S_IFREG: - if ((mode & S_ISUID) && suid_flgs) { - fprintf(outfile,"%s%s%s",leftcode,suid_flgs,rightcode); - return TRUE; - } - if ((mode & S_ISGID) && sgid_flgs) { - fprintf(outfile,"%s%s%s",leftcode,sgid_flgs,rightcode); - return TRUE; - } - if (!exec_flgs) return FALSE; - if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { - fprintf(outfile,"%s%s%s",leftcode,exec_flgs,rightcode); - return TRUE; - } + if ((mode & S_ISUID)) + if (print_color(COL_SETUID)) return TRUE; + if ((mode & S_ISGID)) + if (print_color(COL_SETGID)) return TRUE; + if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) + if (print_color(COL_EXEC)) return TRUE; + /* not a directory, link, special device, etc, so check for extension match */ l = strlen(name); for(e=ext;e;e=e->nxt) { xl = strlen(e->ext); if (!strcmp((l>xl)?name+(l-xl):name,e->ext)) { - fprintf(outfile,"%s%s%s",leftcode,e->term_flg,rightcode); + fputs(color_code[COL_LEFTCODE], outfile); + fputs(e->term_flg, outfile); + fputs(color_code[COL_RIGHTCODE], outfile); return TRUE; } } - if (!norm_flgs) return FALSE; /* colorize just normal files too */ - fprintf(outfile, "%s%s%s",leftcode,norm_flgs,rightcode); - return TRUE; + return print_color(COL_FILE); } - return FALSE; + return print_color(COL_NORMAL); } /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/doc/tree.1 new/tree-2.0.1/doc/tree.1 --- old/tree-2.0.0/doc/tree.1 2021-12-22 00:06:26.000000000 +0100 +++ new/tree-2.0.1/doc/tree.1 2022-01-03 22:29:45.000000000 +0100 @@ -122,7 +122,8 @@ well as null /'s, i.e. /**/ may match a single /), `?' (any single character), `[...]' (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and `[^...]' (any single character -not listed in brackets) and `|' separates alternate patterns. +not listed in brackets) and `|' separates alternate patterns. A '/' at the +end of the pattern matches directories, but not files. .PP .TP .B -I \fIpattern\fP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/file.c new/tree-2.0.1/file.c --- old/tree-2.0.0/file.c 2021-12-21 02:40:16.000000000 +0100 +++ new/tree-2.0.1/file.c 2022-01-03 20:15:09.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -121,11 +121,11 @@ if (!aflag && !root && ent->name[0] == '.') show = 0; if (show && !matched) { if (!ent->isdir) { - if (pattern && !patinclude(ent->name)) show = 0; - if (ipattern && patignore(ent->name)) show = 0; + if (pattern && !patinclude(ent->name, 0)) show = 0; + if (ipattern && patignore(ent->name, 0)) show = 0; } if (ent->isdir && show && matchdirs && pattern) { - if (patinclude(ent->name)) matched = TRUE; + if (patinclude(ent->name, 1)) matched = TRUE; } } if (pruneflag && !matched && ent->isdir && ent->tchild == NULL) show = 0; @@ -151,7 +151,7 @@ dir[count] = NULL; if (topsort) qsort(dir,count,sizeof(struct _info *),topsort); - + return dir; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/filter.c new/tree-2.0.1/filter.c --- old/tree-2.0.0/filter.c 2021-12-19 02:12:12.000000000 +0100 +++ new/tree-2.0.1/filter.c 2022-01-03 20:09:40.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -20,6 +20,8 @@ struct ignorefile *filterstack = NULL; +static char fpattern[PATH_MAX]; + void gittrim(char *s) { int i, e = strnlen(s,PATH_MAX)-1; @@ -63,6 +65,7 @@ if (buf[0] == '#') continue; rev = (buf[0] == '!'); gittrim(buf); + if (strlen(buf) == 0) continue; p = new_pattern(buf + (rev? 1 : 0)); if (rev) { if (reverse == NULL) reverse = revend = p; @@ -77,7 +80,6 @@ remend = p; } } - } fclose(fp); @@ -120,29 +122,41 @@ /** * true if remove filter matches and no reverse filter matches. */ -int filtercheck(char *path, char *name) +int filtercheck(char *path, char *name, int isdir) { int filter = 0; - struct ignorefile *ig = filterstack; + struct ignorefile *ig; struct pattern *p; - while (!filter && ig) { + for(ig = filterstack; !filter && ig; ig = ig->next) { + int fpos = sprintf(fpattern, "%s/", ig->path); + for(p = ig->remove; p != NULL; p = p->next) { - if (patmatch(path, p->pattern) == 1) { + if (patmatch(path, p->pattern, isdir) == 1) { + filter = 1; + break; + } + if (p->pattern[0] == '/') continue; + sprintf(fpattern + fpos, "%s", p->pattern); + if (patmatch(path, fpattern, isdir) == 1) { filter = 1; break; } } - ig = ig->next; } if (!filter) return 0; - ig = filterstack; - while (ig) { + for(ig = filterstack; ig; ig = ig->next) { + int fpos = sprintf(fpattern, "%s/", ig->path); + for(p = ig->reverse; p != NULL; p = p->next) { - if (patmatch(path, p->pattern) == 1) return 0; + if (patmatch(path, p->pattern, isdir) == 1) return 0; + + if (p->pattern[0] == '/') continue; + sprintf(fpattern + fpos, "%s", p->pattern); + + if (patmatch(path, fpattern, isdir) == 1) return 0; } - ig = ig->next; } return 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/hash.c new/tree-2.0.1/hash.c --- old/tree-2.0.0/hash.c 2021-06-26 02:28:54.000000000 +0200 +++ new/tree-2.0.1/hash.c 2022-01-03 20:14:47.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -84,15 +84,15 @@ { struct inotable *it, *ip, *pp; int hp = inohash(inode); - + for(pp = ip = itable[hp];ip;ip = ip->nxt) { if (ip->inode > inode) break; if (ip->inode == inode && ip->device >= device) break; pp = ip; } - + if (ip && ip->inode == inode && ip->device == device) return; - + it = xmalloc(sizeof(struct inotable)); it->inode = inode; it->device = device; @@ -104,12 +104,12 @@ int findino(ino_t inode, dev_t device) { struct inotable *it; - + for(it=itable[inohash(inode)]; it; it=it->nxt) { if (it->inode > inode) break; if (it->inode == inode && it->device >= device) break; } - + if (it && it->inode == inode && it->device == device) return TRUE; return FALSE; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/html.c new/tree-2.0.1/html.c --- old/tree-2.0.0/html.c 2021-12-14 02:33:10.000000000 +0100 +++ new/tree-2.0.1/html.c 2022-01-03 20:09:50.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * 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-2.0.0/info.c new/tree-2.0.1/info.c --- old/tree-2.0.0/info.c 2021-12-21 23:17:10.000000000 +0100 +++ new/tree-2.0.1/info.c 2022-01-03 20:09:54.000000000 +0100 @@ -1,3 +1,21 @@ +/* $Copyright: $ + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) + * 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" /** @@ -123,7 +141,7 @@ * Returns an info pointer if a path matches a pattern. * top == 1 if called in a directory with a .info file. */ -struct comment *infocheck(char *path, char *name, int top) +struct comment *infocheck(char *path, char *name, int top, int isdir) { struct infofile *inf = infostack; struct comment *com; @@ -134,8 +152,8 @@ for(inf = infostack; inf != NULL; inf = inf->next) { for(com = inf->comments; com != NULL; com = com->next) { for(p = com->pattern; p != NULL; p = p->next) { - if (patmatch(path, p->pattern) == 1) return com; - if (top && patmatch(name, p->pattern) == 1) return com; + if (patmatch(path, p->pattern, isdir) == 1) return com; + if (top && patmatch(name, p->pattern, isdir) == 1) return com; } } top = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/json.c new/tree-2.0.1/json.c --- old/tree-2.0.0/json.c 2021-12-19 02:28:14.000000000 +0100 +++ new/tree-2.0.1/json.c 2022-01-03 20:11:03.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * 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-2.0.0/list.c new/tree-2.0.1/list.c --- old/tree-2.0.0/list.c 2021-12-21 20:13:20.000000000 +0100 +++ new/tree-2.0.1/list.c 2022-01-03 20:13:51.000000000 +0100 @@ -1,3 +1,21 @@ +/* $Copyright: $ + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) + * 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, lflag, pflag, sflag, Fflag, aflag, fflag, uflag, gflag; @@ -18,7 +36,7 @@ /** * Maybe TODO: Refactor the listing calls / when they are called. A more thorough * analysis of the different outputs is required. This all is not as clean as I - * Had hoped it to be. + * had hoped it to be. */ extern struct listingcalls lc; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/tree.c new/tree-2.0.1/tree.c --- old/tree-2.0.0/tree.c 2021-12-21 20:29:58.000000000 +0100 +++ new/tree-2.0.1/tree.c 2022-01-03 20:12:51.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -19,8 +19,8 @@ #include "tree.h" -char *version ="$Version: $ tree v2.0.0 (c) 1996 - 2021 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $"; -char *hversion="\t\t tree v2.0.0 %s 1996 - 2021 by Steve Baker and Thomas Moore <br>\n" +char *version ="$Version: $ tree v2.0.1 (c) 1996 - 2022 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $"; +char *hversion="\t\t tree v2.0.1 %s 1996 - 2022 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"; @@ -658,20 +658,20 @@ /** * True if file matches an -I pattern */ -int patignore(char *name) +int patignore(char *name, int isdir) { for(int i=0; i < ipattern; i++) - if (patmatch(name, ipatterns[i])) return 1; + if (patmatch(name, ipatterns[i], isdir)) return 1; return 0; } /** * True if name matches a -P pattern */ -int patinclude(char *name) +int patinclude(char *name, int isdir) { for(int i=0; i < pattern; i++) - if (patmatch(name, patterns[i])) return 1; + if (patmatch(name, patterns[i], isdir)) return 1; return 0; } @@ -699,13 +699,15 @@ st.st_ino = lst.st_ino; } + int isdir = (st.st_mode & S_IFMT) == S_IFDIR; + #ifndef __EMX__ - if (gitignore && filtercheck(path, name)) return NULL; + if (gitignore && filtercheck(path, name, isdir)) return NULL; if ((lst.st_mode & S_IFMT) != S_IFDIR && !(lflag && ((st.st_mode & S_IFMT) == S_IFDIR))) { - if (pattern && !patinclude(name)) return NULL; + if (pattern && !patinclude(name, isdir)) return NULL; } - if (ipattern && patignore(name)) return NULL; + if (ipattern && patignore(name, isdir)) return NULL; #endif if (dflag && ((st.st_mode & S_IFMT) != S_IFDIR)) return NULL; @@ -743,7 +745,7 @@ #else /* These should be eliminated, as they're barely used: */ - ent->isdir = ((st.st_mode & S_IFMT) == S_IFDIR); + ent->isdir = isdir; ent->issok = ((st.st_mode & S_IFMT) == S_IFSOCK); ent->isfifo = ((st.st_mode & S_IFMT) == S_IFIFO); ent->isexe = (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) ? 1 : 0; @@ -799,7 +801,7 @@ info = getinfo(ent->d_name, path); if (info) { - if (showinfo && (com = infocheck(path, ent->d_name, infotop))) { + if (showinfo && (com = infocheck(path, ent->d_name, infotop, info->isdir))) { for(i = 0; com->desc[i] != NULL; i++); info->comment = xmalloc(sizeof(char *) * (i+1)); for(i = 0; com->desc[i] != NULL; i++) info->comment[i] = scopy(com->desc[i]); @@ -868,7 +870,7 @@ break; } } - if (*start_rel_path && patinclude(start_rel_path)) { + if (*start_rel_path && patinclude(start_rel_path, 1)) { tmp_pattern = pattern; pattern = 0; } @@ -903,7 +905,7 @@ if (lev >= maxdirs-1) { dirs = xrealloc(dirs,sizeof(int) * (maxdirs += 1024)); } - + while (*dir) { if ((*dir)->isdir && !(xdev && dev != (*dir)->dev)) { if ((*dir)->lnk) { @@ -931,7 +933,7 @@ } // prune empty folders, unless they match the requested pattern if (pruneflag && (*dir)->child == NULL && - !(matchdirs && pattern && patinclude((*dir)->name))) { + !(matchdirs && pattern && patinclude((*dir)->name, (*dir)->isdir))) { sp = *dir; for(p=dir;*p;p++) *p = *(p+1); n--; @@ -1062,7 +1064,7 @@ { int size = 100; char *buffer = (char *) xmalloc (size); - + while (1) { char *value = getcwd (buffer, size); if (value != 0) return buffer; @@ -1086,7 +1088,7 @@ * 0 on a mismatch * -1 on a syntax error in the pattern */ -int patmatch(char *buf, char *pat) +int patmatch(char *buf, char *pat, int isdir) { int match = 1,m,n; char *bar = strchr(pat, '|'); @@ -1101,9 +1103,9 @@ } /* Break pattern into two sub-patterns */ *bar = '\0'; - match = patmatch(buf, pat); + match = patmatch(buf, pat, isdir); if (!match) { - match = patmatch(buf,bar+1); + match = patmatch(buf, bar+1, isdir); } /* Join sub-patterns back into one pattern */ *bar = '|'; @@ -1146,20 +1148,25 @@ pat++; if(!*pat) return 1; - while(*buf && !(match = patmatch(buf, pat))) { + while(*buf && !(match = patmatch(buf, pat, isdir))) { // ../**/.. is allowed to match a null /: - if (pprev == '/' && *pat == '/' && *(pat+1) && (match = patmatch(buf, pat+1))) return match; + if (pprev == '/' && *pat == '/' && *(pat+1) && (match = patmatch(buf, pat+1, isdir))) return match; buf++; while(*buf && *buf != '/') buf++; } } else { - while(*buf && !(match = patmatch(buf++,pat))); + while(*buf && !(match = patmatch(buf++, pat, isdir))); + if (!*buf && !match) match = patmatch(buf, pat, isdir); } return match; case '?': if(!*buf) return 0; buf++; break; + case '/': + if (!*(pat+1) && !*buf) return isdir; + match = (*buf++ == *pat); + break; case '\\': if(*pat) pat++; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/tree.h new/tree-2.0.1/tree.h --- old/tree-2.0.0/tree.h 2021-12-21 02:39:06.000000000 +0100 +++ new/tree-2.0.1/tree.h 2022-01-03 20:11:27.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -190,8 +190,8 @@ void setoutput(char *filename); void usage(int); void push_files(char *dir, struct ignorefile **ig, struct infofile **inf); -int patignore(char *name); -int patinclude(char *name); +int patignore(char *name, int isdir); +int patinclude(char *name, int isdir); struct _info **unix_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, char **err); struct _info **read_dir(char *dir, int *n, int infotop); @@ -207,7 +207,7 @@ void *xmalloc(size_t), *xrealloc(void *, size_t); char *gnu_getcwd(); -int patmatch(char *, char *); +int patmatch(char *, char *, int); void indent(int maxlevel); void free_dir(struct _info **); #ifdef __EMX__ @@ -272,6 +272,7 @@ /* color.c */ void parse_dir_colors(); int color(u_short mode, char *name, bool orphan, bool islink); +void endcolor(void); const char *getcharset(void); void initlinedraw(int); @@ -287,7 +288,7 @@ /* filter.c */ void gittrim(char *s); struct pattern *new_pattern(char *pattern); -int filtercheck(char *path, char *name); +int filtercheck(char *path, char *name, int isdir); struct ignorefile *new_ignorefile(char *path); void push_filterstack(struct ignorefile *ig); struct ignorefile *pop_filterstack(void); @@ -296,7 +297,7 @@ struct infofile *new_infofile(char *path); void push_infostack(struct infofile *inf); struct infofile *pop_infostack(void); -struct comment *infocheck(char *path, char *name, int top); +struct comment *infocheck(char *path, char *name, int top, int isdir); void printcomment(int line, int lines, char *s); /* list.c */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/unix.c new/tree-2.0.1/unix.c --- old/tree-2.0.0/unix.c 2021-12-21 20:40:28.000000000 +0100 +++ new/tree-2.0.1/unix.c 2022-01-03 20:11:45.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,6 @@ extern FILE *outfile; extern bool dflag, Fflag, duflag, metafirst, hflag, siflag, noindent; extern bool colorize, linktargetcolor; -extern char *endcode; extern const struct linedraw *linedraw; extern int *dirs; @@ -48,10 +47,10 @@ if (file->lnk && linktargetcolor) colored = color(file->lnkmode,file->name,file->orphan,FALSE); else colored = color(file->mode,file->name,file->orphan,FALSE); } - + printit(filename); - if (colored) fprintf(outfile,"%s",endcode); + if (colored) endcolor(); if (file) { if (Fflag && !file->lnk) { @@ -62,7 +61,7 @@ fprintf(outfile," -> "); if (colorize) colored = color(file->lnkmode,file->lnk,file->orphan,TRUE); printit(file->lnk); - if (colored) fprintf(outfile,"%s",endcode); + if (colored) endcolor(); if (Fflag) { if ((c = Ftype(file->lnkmode))) fputc(c, outfile); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tree-2.0.0/xml.c new/tree-2.0.1/xml.c --- old/tree-2.0.0/xml.c 2021-12-14 02:30:38.000000000 +0100 +++ new/tree-2.0.1/xml.c 2022-01-03 20:11:33.000000000 +0100 @@ -1,5 +1,5 @@ /* $Copyright: $ - * Copyright (c) 1996 - 2021 by Steve Baker (i...@mama.indstate.edu) + * Copyright (c) 1996 - 2022 by Steve Baker (i...@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify