|
root / base / tree
tree Plain Text 122 lines 3.6 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Build script for tree
# Directory listing utility - no external dependencies

set -e

cd "$SRCDIR"

# illumos fix: rename 'struct comment' to avoid conflict with /usr/include/pwd.h
# which also defines struct comment
for f in *.h *.c; do
    sed -i 's/struct comment/struct tree_comment/g' "$f"
done

# tree uses a simple Makefile, needs some adjustments for illumos
# Override Linux-specific flags

gmake -j${JOBS:-1} \
    CC=gcc \
    CFLAGS="-O2 -Wall -fomit-frame-pointer -DSOLARIS" \
    LDFLAGS="" \
    prefix=$PREFIX \
    MANDIR=$PREFIX/share/man

# Manual install since Makefile doesn't properly support DESTDIR
mkdir -p "$PKGDIR$PREFIX/bin"
mkdir -p "$PKGDIR$PREFIX/share/man/man1"
install -m 755 tree "$PKGDIR$PREFIX/bin/tree"
install -m 644 doc/tree.1 "$PKGDIR$PREFIX/share/man/man1/tree.1"
# tree - List directory contents in a tree-like format
# https://oldmanprogrammer.net/source.php?dir=projects/tree

[package]
name = "tree"
version = "2.1.1"
release = 1
description = "List directory contents in a tree-like format"
url = "https://oldmanprogrammer.net/source.php?dir=projects/tree"
license = "GPL-2.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "2.1.1.tar.gz"
urls = ["https://github.com/Old-Man-Programmer/tree/archive/refs/tags/2.1.1.tar.gz"]
checksum = "1b70253994dca48a59d6ed99390132f4d55c486bf0658468f8520e7e63666a06"


[build]
parallel = true
jobs = 0
--- a/tree.h	2023-11-12 00:00:00.000000000 +0000
+++ b/tree.h	2024-01-24 00:00:00.000000000 +0000
@@ -173,12 +173,12 @@
 #define SORT_SIZE	8192

 /* Comment file parsing (via .info files) */
-struct comment {
+struct tree_comment {
   char *filename;
   int isdir;
-  struct comment *next;
+  struct tree_comment *next;
 };
 struct _info {
-  struct comment *comments;
+  struct tree_comment *comments;
 };

 /* For ANSI terminals */
@@ -300,7 +300,7 @@
 void htmldir(char *dirname, int level, char *newdir);
 void html_encode(FILE *fd, char *s);

-struct comment *infocheck(char *path, char *name, int top, int isdir);
+struct tree_comment *infocheck(char *path, char *name, int top, int isdir);
 struct _info *getinfo(char *name, struct _info *dir);
 void switch_on(char *opt);
 void switch_off(char *opt);
--- a/info.c	2023-11-12 00:00:00.000000000 +0000
+++ b/info.c	2024-01-24 00:00:00.000000000 +0000
@@ -31,7 +31,7 @@
  * Returns NULL if path/name is not found in the .info file.
  * The returned comment structure is in the given cwd _info structure.
  */
-struct comment *infocheck(char *path, char *name, int top, int isdir)
+struct tree_comment *infocheck(char *path, char *name, int top, int isdir)
 {
   static struct _info cwd = {NULL};
   static char *cpath = NULL;
@@ -39,7 +39,7 @@
   char *file, *ptr, *ent;
   FILE *fp;
   size_t flen = 0;
-  struct comment *com, *cp, *cpprev = NULL;
+  struct tree_comment *com, *cp, *cpprev = NULL;
   bool iscomment = false;

   if (cwd.comments != NULL && cpath != NULL && strcmp(path, cpath) == 0) {
@@ -68,7 +68,7 @@
   while (getdelim(&file, &flen, '\n', fp) > 0) {
     ptr = trim(file);
     if (!ptr[0]) continue;
-    if (ptr[0] == '#') { if (com) com = (struct comment *)1; continue; }
+    if (ptr[0] == '#') { if (com) com = (struct tree_comment *)1; continue; }
     if (ptr[0] == '[') {
       char *q = strchr(ptr,']');
       if (q) {
@@ -85,7 +85,7 @@
 	}
 	com = NULL;
       }
-    } else if (com == (struct comment *)1) {
+    } else if (com == (struct tree_comment *)1) {
       com = xmalloc(sizeof(*com));
       com->filename = scopy(ent);
       com->isdir = (*ent && ent[strlen(ent)-1] == '/');