Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package tree for openSUSE:Factory checked in 
at 2023-06-19 22:50:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/tree (Old)
 and      /work/SRC/openSUSE:Factory/.tree.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "tree"

Mon Jun 19 22:50:32 2023 rev:29 rq:1093682 version:2.1.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/tree/tree.changes        2023-02-19 
18:19:07.529543376 +0100
+++ /work/SRC/openSUSE:Factory/.tree.new.15902/tree.changes     2023-06-19 
22:50:39.205594137 +0200
@@ -1,0 +2,24 @@
+Fri Jun 16 09:27:20 UTC 2023 - Jan Baier <[email protected]>
+
+- tree 2.1.1:
+  * Various spelling corrections.
+  * Fix issue where following links while doing JSON output would lead to
+    incorrect JSON output. (simonpmind)
+  * Fix issue where .info patterns relative to the .info file that did not use
+    a wildcard for matching the prefix were not matching files properly.
+    (German Lashevich)
+  * Added support for making trees from tab indented files (--fromtabfile)
+    (gitlab @AvidSeeker), also cleaned up some other issues in the fromfile
+    code.
+  * Fix buffer overflow in listdir() when file names are allowed to be longer
+    than 256 characters (like when using fromfile.) (Javier Jaramago 
Fernández)
+  * If when attempting to open a .gitignore or .info file from a top level
+    directory and failing, recursively check the parents for such a file.  This
+    stops when successful at opening such a file. This behavior might in the
+    future be modified to open all such files in all parents to until root is
+    reached. (Damien Bezborodov) Note that this requires the use of realpath()
+    which I think may be an issue for some OSes.
+  * Fix issue where tree would never descend (-l) a symbolic link when a full
+    tree is gathered (--du/matchdirs/prune) (gitlab @6ramr)
+
+-------------------------------------------------------------------

Old:
----
  tree-2.1.0.tgz

New:
----
  tree-2.1.1.tgz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ tree.spec ++++++
--- /var/tmp/diff_new_pack.X7wQr0/_old  2023-06-19 22:50:39.949598494 +0200
+++ /var/tmp/diff_new_pack.X7wQr0/_new  2023-06-19 22:50:39.953598518 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           tree
-Version:        2.1.0
+Version:        2.1.1
 Release:        0
 Summary:        File listing as a tree
 License:        GPL-2.0-or-later

++++++ tree-2.1.0.tgz -> tree-2.1.1.tgz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/CHANGES new/tree-2.1.1/CHANGES
--- old/tree-2.1.0/CHANGES      2022-12-26 17:11:30.000000000 +0100
+++ new/tree-2.1.1/CHANGES      2023-05-31 04:39:35.000000000 +0200
@@ -1,3 +1,24 @@
+Version 2.1.1 (05/31/2023)
+  - Various spelling corrections.
+  - Fix issue where following links while doing JSON output would lead to
+    incorrect JSON output. (simonpmind)
+  - Fix issue where .info patterns relative to the .info file that did not use
+    a wildcard for matching the prefix were not matching files properly.
+    (German Lashevich)
+  - Added support for making trees from tab indented files (--fromtabfile)
+    (gitlab @AvidSeeker), also cleaned up some other issues in the fromfile
+    code.
+  - Fix buffer overflow in listdir() when file names are allowed to be longer
+    than 256 characters (like when using fromfile.) (Javier Jaramago 
Fernández)
+  - If when attempting to open a .gitignore or .info file from a top level
+    directory and failing, recursively check the parents for such a file.  This
+    stops when successful at opening such a file. This behavior might in the
+    future be modified to open all such files in all parents to until root is
+    reached. (Damien Bezborodov) Note that this requires the use of realpath()
+    which I think may be an issue for some OSes.
+  - Fix issue where tree would never descend (-l) a symbolic link when a full
+    tree is gathered (--du/matchdirs/prune) (gitlab @6ramr)
+
 Version 2.1.0 (12/26/2022)
   This is a bit bigger release, due to not realizing that gitlab/github was
   not sending me email and [email protected] was broken.  This has
@@ -8,7 +29,6 @@
   will not likely ever directly accept any merge requests. I will still use the
   patch information from them for inclusion into the code, so you are more than
   welcome to still submit such merges.
-
   - Add support for --info and --gitignore for the --fromfile option.
     (Suggested by Piotr Andruszkow)
   - Add options --infofile and --gitfile to load .info and .gitignore files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/Makefile new/tree-2.1.1/Makefile
--- old/tree-2.1.0/Makefile     2022-12-26 20:15:45.000000000 +0100
+++ new/tree-2.1.1/Makefile     2023-05-31 22:06:18.000000000 +0200
@@ -1,5 +1,5 @@
 # $Copyright: $
-# Copyright (c) 1996 - 2022 by Steve Baker
+# Copyright (c) 1996 - 2023 by Steve Baker
 # All Rights reserved
 #
 # This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
 CC=gcc
 INSTALL=install
 
-VERSION=2.1.0
+VERSION=2.1.1
 TREE_DEST=tree
 DESTDIR=${PREFIX}/bin
 MAN=tree.1
@@ -32,8 +32,8 @@
 # Uncomment options below for your particular OS:
 
 # Linux defaults:
-#CFLAGS+=-ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64
-CFLAGS+=-O3 -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64
+CFLAGS+=-ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64
+#CFLAGS+=-O3 -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64
 #LDFLAGS+=-s
 
 # Uncomment for FreeBSD:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/README new/tree-2.1.1/README
--- old/tree-2.1.0/README       2022-12-26 20:29:26.000000000 +0100
+++ new/tree-2.1.1/README       2023-05-31 22:05:24.000000000 +0200
@@ -9,7 +9,7 @@
 hide something from you.
 
   The main distribution site for tree is here:
-  http://oldmanprogrammer.net/code.php?src=tree
+  http://oldmanprogrammer.net/source.php?dir=projects/tree
 
   Backup GIT sites are:
   https://gitlab.com/OldManProgrammer/unix-tree
@@ -303,6 +303,20 @@
 Sith Wijesinghe and Matthew Sessions
  - Remove many C90 isms to make compiling with C90 compilers easier.
 
+simonpmind (gitlab)
+ - Reported issue where following links while doing JSON output would lead to
+   incorrect JSON output.
+
+German Lashevich
+ - Reported an issue where .info patterns relative to the .info file that did
+   not use a wildcard for matching the prefix were not matching files properly.
+
+Javier Jaramago Fernández
+ - Reported a buffer overflow in listdir() when file names are allowed to be
+   longer than 256 characters (like when using fromfile.)
+
+6ramr (gitlab)
+ - Reported issue with following symbolic links when a full tree was gathered.
 
 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.1.0/color.c new/tree-2.1.1/color.c
--- old/tree-2.1.0/color.c      2022-12-26 20:13:45.000000000 +0100
+++ new/tree-2.1.1/color.c      2023-04-08 01:53:54.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/doc/tree.1 new/tree-2.1.1/doc/tree.1
--- old/tree-2.1.0/doc/tree.1   2022-12-25 01:57:33.000000000 +0100
+++ new/tree-2.1.1/doc/tree.1   2023-04-08 01:52:31.000000000 +0200
@@ -17,7 +17,7 @@
 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 .\"
 ...
-.TH TREE 1 "" "Tree 2.1.0"
+.TH TREE 1 "" "Tree 2.1.1"
 .SH NAME
 tree \- list contents of directories in a tree-like format.
 .SH SYNOPSIS
@@ -49,6 +49,7 @@
 [\fB--charset[\fB=\fP]X\fP]
 [\fB--timefmt\fP[\fB=\fP]\fIformat\fP]
 [\fB--fromfile\fP]
+[\fB--fromtabfile\fP]
 [\fB--fflinks\fP]
 [\fB--info\fP]
 [\fB--infofile\fP[\fB=\fP]\fIfile\fP]
@@ -325,7 +326,7 @@
 .TP
 .B -S
 Turn on CP437 line graphics (useful when using Linux console mode fonts). This
-option is now equivalent to `--charset=IBM437' and may eventually be 
depreciated.
+option is now equivalent to `\fB--charset=IBM437\fP' and may eventually be 
depreciated.
 .PP
 .TP
 .B -n
@@ -392,6 +393,12 @@
 is used.
 .PP
 .TP
+.B --fromtabfile
+Like \fB--fromfile\fP, tree reads a directory tree from a text file where the
+files are tab indented in a tree like format to indicate the directory nesting
+level.
+.PP
+.TP
 .B --fflinks
 Processes symbolic link information found in a file, as from the output of
 \fB'tree -fi --noreport'\fP.  Only the first occurrence of the string \fB' -> 
'\fP
@@ -415,7 +422,7 @@
 
 .SH .INFO FILES
 
-\fB.info\fP files are similiar to \.gitignore files, if a .info file is found
+\fB.info\fP files are similar to \.gitignore files, if a .info file is found
 while scanning a directory it is read and added to a stack of .info
 information. Each file is composed of comments (lines starting with hash marks
 (#),) or wild-card patterns which may match a file relative to the directory
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/file.c new/tree-2.1.1/file.c
--- old/tree-2.1.0/file.c       2022-12-24 18:15:56.000000000 +0100
+++ new/tree-2.1.1/file.c       2023-05-30 20:59:40.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -123,7 +123,7 @@
   cur = fpath + strlen(fpath);
   *(cur++) = '/';
 
-  push_files(path, &ig, &inf);
+  push_files(path, &ig, &inf, root);
 
   for(ent = head; ent != NULL;) {
     strcpy(cur, ent->name);
@@ -184,19 +184,18 @@
 {
   FILE *fp = (strcmp(d,".")? fopen(d,"r") : stdin);
   char *path, *spath, *s, *link;
-  long pathsize;
   struct _info *root = NULL, **cwd, *ent;
   int l, tok;
 
-  size = 0;
+  *size = 0;
   if (fp == NULL) {
-    fprintf(stderr,"Error opening %s for reading.\n", d);
+    fprintf(stderr,"tree: Error opening %s for reading.\n", d);
     return NULL;
   }
-  path = xmalloc(sizeof(char *) * (pathsize = MAXPATH));
+  path = xmalloc(sizeof(char) * MAXPATH);
 
-  while(fgets(path, pathsize, fp) != NULL) {
-    if (file_comment != NULL && strcmp(path,file_comment) == 0) continue;
+  while(fgets(path, MAXPATH, fp) != NULL) {
+    if (file_comment != NULL && 
strncmp(path,file_comment,strlen(file_comment)) == 0) continue;
     l = strlen(path);
     while(l && (path[l-1] == '\n' || path[l-1] == '\r')) path[--l] = '\0';
     if (l == 0) continue;
@@ -235,7 +234,7 @@
     if (link) {
       ent->isdir = 0;
       ent->mode = S_IFLNK;
-      ent->lnk = strdup(link);
+      ent->lnk = scopy(link);
     }
   }
   if (fp != stdin) fclose(fp);
@@ -244,4 +243,66 @@
 
   /* Prune accumulated directory tree: */
   return fprune(root, "", FALSE, TRUE);
+}
+
+struct _info **tabedfile_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, *link;
+  struct _info *root = NULL, **istack, *ent;
+  int line = 0, tabs, maxstack = 2048, top = 0, l;
+
+  *size = 0;
+  if (fp == NULL) {
+    fprintf(stderr,"tree: Error opening %s for reading.\n", d);
+    return NULL;
+  }
+  path = xmalloc(sizeof(char) * MAXPATH);
+  istack = xmalloc(sizeof(struct _info *) * maxstack);
+  memset(istack, 0, sizeof(struct _info *) * maxstack);
+
+  while(fgets(path, MAXPATH, fp) != NULL) {
+    line++;
+    if (file_comment != NULL && 
strncmp(path,file_comment,strlen(file_comment)) == 0) continue;
+    l = strlen(path);
+    while(l && (path[l-1] == '\n' || path[l-1] == '\r')) path[--l] = '\0';
+    if (l == 0) continue;
+
+    for(tabs=0; path[tabs] == '\t'; tabs++);
+    if (tabs >= maxstack) {
+      fprintf(stderr, "tree: Tab depth exceeds maximum path depth (%d >= %d) 
on line %d\n", tabs, maxstack, line);
+      continue;
+    }
+
+    spath = path+tabs;
+
+    link = fflinks? strstr(spath, " -> ") : NULL;
+    if (link) {
+      *link = '\0';
+      link += 4;
+    }
+    if (tabs-1 > top) {
+       fprintf(stderr, "tree: Orphaned file [%s] on line %d, check tab depth 
in file.\n", spath, line);
+       continue;
+    }
+    ent = istack[tabs] = search(tabs? &(istack[tabs-1]->tchild) : &root, 
spath);
+    ent->mode = S_IFREG;
+    if (tabs) {
+      istack[tabs-1]->isdir = 1;
+      istack[tabs-1]->mode = S_IFDIR;
+    }
+    if (link) {
+      ent->isdir = 0;
+      ent->mode = S_IFLNK;
+      ent->lnk = scopy(link);
+    }
+    top = tabs;
+  }
+  if (fp != stdin) fclose(fp);
+
+  free(path);
+  free(istack);
+
+  /* Prune accumulated directory tree: */
+  return fprune(root, "", FALSE, TRUE);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/filter.c new/tree-2.1.1/filter.c
--- old/tree-2.1.0/filter.c     2022-12-11 17:04:38.000000000 +0100
+++ new/tree-2.1.1/filter.c     2023-05-30 22:19:58.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -17,9 +17,9 @@
  */
 #include "tree.h"
 
-struct ignorefile *filterstack = NULL;
+extern char xpattern[PATH_MAX];
 
-static char fpattern[PATH_MAX];
+struct ignorefile *filterstack = NULL;
 
 void gittrim(char *s)
 {
@@ -48,10 +48,10 @@
   return p;
 }
 
-struct ignorefile *new_ignorefile(char *path)
+struct ignorefile *new_ignorefile(char *path, bool checkparents)
 {
   struct stat st;
-  char buf[PATH_MAX];
+  char buf[PATH_MAX], rpath[PATH_MAX];
   struct ignorefile *ig;
   struct pattern *remove = NULL, *remend, *p;
   struct pattern *reverse = NULL, *revend;
@@ -62,6 +62,16 @@
   if (rev < 0 || !S_ISREG(st.st_mode)) {
     snprintf(buf, PATH_MAX, "%s/.gitignore", path);
     fp = fopen(buf, "r");
+
+    if (fp == NULL && checkparents) {
+      strcpy(rpath, path);
+      while ((fp == NULL) && (strcmp(rpath, "/") != 0)) {
+       snprintf(buf, PATH_MAX, "%.*s/..", PATH_MAX-4, rpath);
+       if (realpath(buf, rpath) == NULL) break;
+       snprintf(buf, PATH_MAX, "%.*s/.gitignore", PATH_MAX-12, rpath);
+       fp = fopen(buf, "r");
+      }
+    }
   } else fp = fopen(path, "r");
   if (fp == NULL) return NULL;
 
@@ -137,7 +147,7 @@
   struct pattern *p;
 
   for(ig = filterstack; !filter && ig; ig = ig->next) {
-    int fpos = sprintf(fpattern, "%s/", ig->path);
+    int fpos = sprintf(xpattern, "%s/", ig->path);
 
     for(p = ig->remove; p != NULL; p = p->next) {
       if (p->relative) {
@@ -146,8 +156,8 @@
          break;
        }
       } else {
-       sprintf(fpattern + fpos, "%s", p->pattern);
-       if (patmatch(path, fpattern, isdir) == 1) {
+       sprintf(xpattern + fpos, "%s", p->pattern);
+       if (patmatch(path, xpattern, isdir) == 1) {
          filter = 1;
          break;
        }
@@ -157,14 +167,14 @@
   if (!filter) return 0;
 
   for(ig = filterstack; ig; ig = ig->next) {
-    int fpos = sprintf(fpattern, "%s/", ig->path);
+    int fpos = sprintf(xpattern, "%s/", ig->path);
 
     for(p = ig->reverse; p != NULL; p = p->next) {
       if (p->relative) {
        if (patmatch(name, p->pattern, isdir) == 1) return 0;
       } else {
-       sprintf(fpattern + fpos, "%s", p->pattern);
-       if (patmatch(path, fpattern, isdir) == 1) return 0;
+       sprintf(xpattern + fpos, "%s", p->pattern);
+       if (patmatch(path, xpattern, isdir) == 1) return 0;
       }
     }
   }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/hash.c new/tree-2.1.1/hash.c
--- old/tree-2.1.0/hash.c       2022-06-16 15:38:14.000000000 +0200
+++ new/tree-2.1.1/hash.c       2023-05-30 23:51:55.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/html.c new/tree-2.1.1/html.c
--- old/tree-2.1.0/html.c       2022-12-11 18:13:18.000000000 +0100
+++ new/tree-2.1.1/html.c       2023-04-08 01:54:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/info.c new/tree-2.1.1/info.c
--- old/tree-2.1.0/info.c       2022-12-11 17:02:16.000000000 +0100
+++ new/tree-2.1.1/info.c       2023-05-30 23:20:15.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -28,6 +28,7 @@
  */
 extern FILE *outfile;
 extern const struct linedraw *linedraw;
+extern char xpattern[PATH_MAX];
 
 struct infofile *infostack = NULL;
 
@@ -44,10 +45,10 @@
   return com;
 }
 
-struct infofile *new_infofile(char *path)
+struct infofile *new_infofile(char *path, bool checkparents)
 {
   struct stat st;
-  char buf[PATH_MAX];
+  char buf[PATH_MAX], rpath[PATH_MAX];
   struct infofile *inf;
   struct comment *chead = NULL, *cend = NULL, *com;
   struct pattern *phead = NULL, *pend = NULL, *p;
@@ -59,6 +60,16 @@
   if (i < 0 || !S_ISREG(st.st_mode)) {
     snprintf(buf, PATH_MAX, "%s/.info", path);
     fp = fopen(buf, "r");
+
+    if (fp == NULL && checkparents) {
+      strcpy(rpath, path);
+      while ((fp == NULL) && (strcmp(rpath, "/") != 0)) {
+       snprintf(buf, PATH_MAX, "%.*s/..", PATH_MAX-4, rpath);
+       if (realpath(buf, rpath) == NULL) break;
+       snprintf(buf, PATH_MAX, "%.*s/.info", PATH_MAX-7, rpath);
+       fp = fopen(buf, "r");
+      }
+    }
   } else fp = fopen(path, "r");
   if (fp == NULL) return NULL;
 
@@ -154,10 +165,15 @@
   if (inf == NULL) return NULL;
 
   for(inf = infostack; inf != NULL; inf = inf->next) {
+    int fpos = sprintf(xpattern, "%s/", inf->path);
+
     for(com = inf->comments; com != NULL; com = com->next) {
       for(p = com->pattern; p != NULL; p = p->next) {
        if (patmatch(path, p->pattern, isdir) == 1) return com;
        if (top && patmatch(name, p->pattern, isdir) == 1) return com;
+
+       sprintf(xpattern + fpos, "%s", p->pattern);
+       if (patmatch(path, xpattern, isdir) == 1) return com;
       }
     }
     top = 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/json.c new/tree-2.1.1/json.c
--- old/tree-2.1.0/json.c       2022-12-04 23:30:08.000000000 +0100
+++ new/tree-2.1.1/json.c       2023-04-08 01:54:32.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/list.c new/tree-2.1.1/list.c
--- old/tree-2.1.0/list.c       2022-12-24 19:06:56.000000000 +0100
+++ new/tree-2.1.1/list.c       2023-05-31 00:02:43.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -85,7 +85,7 @@
        dir = getfulltree(dirname[i], 0, st.st_dev, &(info->size), &err);
        n = err? -1 : 0;
       } else {
-       push_files(dirname[i], &ig, &inf);
+       push_files(dirname[i], &ig, &inf, TRUE);
        dir = read_dir(dirname[i], &n, inf != NULL);
       }
 
@@ -140,12 +140,16 @@
   struct ignorefile *ig = NULL;
   struct infofile *inf = NULL;
   struct _info **subdir = NULL;
+  int namemax = 257, namelen;
   int descend, htmldescend = 0, found, n, dirlen = strlen(dirname), pathlen = 
dirlen + 257;
   int needsclosed;
   char *path, *newpath, *filename, *err = NULL;
 
   int es = (dirname[strlen(dirname) - 1] == '/');
 
+  // Sanity check on dir, may or may not be necessary when using --fromfile:
+  if (dir == NULL || *dir == NULL) return tot;
+
   for(n=0; dir[n]; n++);
   if (topsort) qsort(dir, n, sizeof(struct _info *), topsort);
 
@@ -156,6 +160,9 @@
   for (;*dir != NULL; dir++) {
     lc.printinfo(dirname, *dir, lev);
 
+    namelen = strlen((*dir)->name) + 1;
+    if (namemax < namelen)
+      path = xrealloc(path, dirlen + (namemax = namelen));
     if (es) sprintf(path,"%s%s",dirname,(*dir)->name);
     else sprintf(path,"%s/%s",dirname,(*dir)->name);
     if (fflag) filename = path;
@@ -167,8 +174,12 @@
     if ((*dir)->isdir) {
       tot.dirs++;
 
-      found = findino((*dir)->inode,(*dir)->dev);
-      if (!found) saveino((*dir)->inode, (*dir)->dev);
+      if (!hasfulltree) {
+       found = findino((*dir)->inode,(*dir)->dev);
+       if (!found) {
+         saveino((*dir)->inode, (*dir)->dev);
+       }
+      } else found = FALSE;
 
       if (!(xdev && dev != (*dir)->dev) && (!(*dir)->lnk || ((*dir)->lnk && 
lflag))) {
        descend = 1;
@@ -182,7 +193,7 @@
          }
          if (found) {
            err = "recursive, not followed";
-           descend = 0;
+           descend = -1;
          }
        }
 
@@ -208,12 +219,12 @@
          descend = 0;
        }
 
-       if (descend) {
+       if (descend > 0) {
          if (hasfulltree) {
            subdir = (*dir)->child;
            err = (*dir)->err;
          } else {
-           push_files(newpath, &ig, &inf);
+           push_files(newpath, &ig, &inf, FALSE);
            subdir = read_dir(newpath, &n, inf != NULL);
            if (!subdir && n) {
              err = "error opening dir";
@@ -233,7 +244,7 @@
     needsclosed = lc.printfile(dirname, filename, *dir, descend + htmldescend 
+ (Jflag && errors));
     if (err) lc.error(err);
 
-    if (descend) {
+    if (descend > 0) {
       lc.newline(*dir, lev, 0, 0);
 
       subtotal = listdir(newpath, subdir, lev+1, dev, hasfulltree);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/tree.c new/tree-2.1.1/tree.c
--- old/tree-2.1.0/tree.c       2022-12-25 02:01:54.000000000 +0100
+++ new/tree-2.1.1/tree.c       2023-05-30 23:19:55.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -18,8 +18,8 @@
 
 #include "tree.h"
 
-char *version = "$Version: $ tree v2.1.0 %s 1996 - 2022 by Steve Baker, Thomas 
Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $";
-char *hversion= "\t\t tree v2.1.0 %s 1996 - 2022 by Steve Baker and Thomas 
Moore <br>\n"
+char *version = "$Version: $ tree v2.1.1 %s 1996 - 2023 by Steve Baker, Thomas 
Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $";
+char *hversion= "\t\t tree v2.1.1 %s 1996 - 2023 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";
@@ -54,6 +54,8 @@
 int Level, *dirs, maxdirs;
 int errors;
 
+char xpattern[PATH_MAX];
+
 int mb_cur_max;
 
 #ifdef __EMX__
@@ -451,6 +453,12 @@
              }
              break;
            }
+           if (!strcmp("--fromtabfile", argv[i])) {
+             j = strlen(argv[i])-1;
+             fromfile=TRUE;
+             getfulltree = tabedfile_getfulltree;
+             break;
+           }
            if (!strcmp("--fromfile",argv[i])) {
              j = strlen(argv[i])-1;
              fromfile=TRUE;
@@ -464,7 +472,7 @@
            }
            if ((arg = long_arg(argv, i, &j, &n, "--gitfile")) != NULL) {
              gitignore=TRUE;
-             ig = new_ignorefile(arg);
+             ig = new_ignorefile(arg, FALSE);
              if (ig != NULL) push_filterstack(ig);
              else {
                fprintf(stderr,"tree: Could not load gitignore file\n");
@@ -484,7 +492,7 @@
            }
            if ((arg = long_arg(argv, i, &j, &n, "--infofile")) != NULL) {
              showinfo = TRUE;
-             inf = new_infofile(arg);
+             inf = new_infofile(arg, FALSE);
              if (inf != NULL) push_infostack(inf);
              else {
                fprintf(stderr,"tree: Could not load infofile\n");
@@ -551,11 +559,11 @@
   if (gitignore && (stmp = getenv("GIT_DIR"))) {
     char *path = xmalloc(PATH_MAX);
     snprintf(path, PATH_MAX, "%s/info/exclude", stmp);
-    push_filterstack(new_ignorefile(path));
+    push_filterstack(new_ignorefile(path, FALSE));
     free(path);
   }
   if (showinfo) {
-    push_infostack(new_infofile(INFO_PATH));
+    push_infostack(new_infofile(INFO_PATH, FALSE));
   }
 
   needfulltree = duflag || pruneflag || matchdirs || fromfile;
@@ -607,8 +615,8 @@
        "\t[--nolinks] [--hintro[=]file] [--houtro[=]file] [--inodes] 
[--device]\n"
        "\t[--sort[=]<name>] [--dirsfirst] [--filesfirst] [--filelimit #] 
[--si]\n"
        "\t[--du] [--prune] [--charset[=]X] [--timefmt[=]format] [--fromfile]\n"
-       "\t[--fflinks] [--info] [--infofile[=]file] [--noreport] [--version]\n"
-       "\t[--help] [--] [directory ...]\n");
+       "\t[--fromtabfile] [--fflinks] [--info] [--infofile[=]file] 
[--noreport]\n"
+       "\t[--version] [--help] [--] [directory ...]\n");
 
   if (n < 2) return;
   fprintf(stdout,
@@ -675,7 +683,8 @@
        "  --houtro X    Use file X as the HTML outro.\n"
        "  ------- Input options -------\n"
        "  --fromfile    Reads paths from files (.=stdin)\n"
-       "  --fflinks     Process link informtion when using --fromfile.\n"
+       "  --fromtabfile Reads trees from tab indented files (.=stdin)\n"
+       "  --fflinks     Process link information when using --fromfile.\n"
        "  ------- Miscellaneous options -------\n"
        "  --version     Print version and exit.\n"
        "  --help        Print usage and this help message and exit.\n"
@@ -855,14 +864,14 @@
   return dl;
 }
 
-void push_files(char *dir, struct ignorefile **ig, struct infofile **inf)
+void push_files(char *dir, struct ignorefile **ig, struct infofile **inf, bool 
top)
 {
   if (gitignore) {
-    *ig = new_ignorefile(dir);
+    *ig = new_ignorefile(dir, top);
     if (*ig != NULL) push_filterstack(*ig);
   }
   if (showinfo) {
-    *inf = new_infofile(dir);
+    *inf = new_infofile(dir, top);
     if (*inf != NULL) push_infostack(*inf);
   }
 }
@@ -909,7 +918,7 @@
     }
   }
 
-  push_files(d, &ig, &inf);
+  push_files(d, &ig, &inf, lev==0);
 
   sav = dir = read_dir(d, &n, inf != NULL);
   if (tmp_pattern) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/tree.h new/tree-2.1.1/tree.h
--- old/tree-2.1.0/tree.h       2022-12-11 18:12:33.000000000 +0100
+++ new/tree-2.1.1/tree.h       2023-05-30 23:16:15.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
@@ -38,7 +38,7 @@
 #  include <os2.h>
 #  include <sys/nls.h>
 #  include <io.h>
-  /* On many systems stat() function is idential to lstat() function.
+  /* On many systems stat() function is identical to lstat() function.
    * But the OS/2 does not support symbolic links and doesn't have lstat() 
function.
    */
 #  define         lstat          stat
@@ -191,7 +191,7 @@
 void setoutput(char *filename);
 void print_version(int nl);
 void usage(int);
-void push_files(char *dir, struct ignorefile **ig, struct infofile **inf);
+void push_files(char *dir, struct ignorefile **ig, struct infofile **inf, bool 
top);
 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);
@@ -286,17 +286,18 @@
 
 /* file.c */
 struct _info **file_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, 
char **err);
+struct _info **tabedfile_getfulltree(char *d, u_long lev, dev_t dev, off_t 
*size, char **err);
 
 /* filter.c */
 void gittrim(char *s);
 struct pattern *new_pattern(char *pattern);
 int filtercheck(char *path, char *name, int isdir);
-struct ignorefile *new_ignorefile(char *path);
+struct ignorefile *new_ignorefile(char *path, bool checkparents);
 void push_filterstack(struct ignorefile *ig);
 struct ignorefile *pop_filterstack(void);
 
 /* info.c */
-struct infofile *new_infofile(char *path);
+struct infofile *new_infofile(char *path, bool checkparents);
 void push_infostack(struct infofile *inf);
 struct infofile *pop_infostack(void);
 struct comment *infocheck(char *path, char *name, int top, int isdir);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/unix.c new/tree-2.1.1/unix.c
--- old/tree-2.1.0/unix.c       2022-06-16 15:38:39.000000000 +0200
+++ new/tree-2.1.1/unix.c       2023-04-08 01:55:02.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tree-2.1.0/xml.c new/tree-2.1.1/xml.c
--- old/tree-2.1.0/xml.c        2022-12-04 23:36:52.000000000 +0100
+++ new/tree-2.1.1/xml.c        2023-04-08 01:55:07.000000000 +0200
@@ -1,5 +1,5 @@
 /* $Copyright: $
- * Copyright (c) 1996 - 2022 by Steve Baker ([email protected])
+ * Copyright (c) 1996 - 2023 by Steve Baker ([email protected])
  *
  * 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

Reply via email to