Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package cbonsai for openSUSE:Factory checked 
in at 2025-07-09 17:26:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cbonsai (Old)
 and      /work/SRC/openSUSE:Factory/.cbonsai.new.7373 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cbonsai"

Wed Jul  9 17:26:58 2025 rev:5 rq:1291215 version:1.4.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/cbonsai/cbonsai.changes  2021-08-23 
10:09:17.512167892 +0200
+++ /work/SRC/openSUSE:Factory/.cbonsai.new.7373/cbonsai.changes        
2025-07-09 17:27:32.553386264 +0200
@@ -1,0 +2,10 @@
+Fri Jun 20 19:32:57 UTC 2025 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 1.4.2
+  * Fix some bugs.
+- Update to version 1.4.1
+  * Fix documentation.
+- Update to version 1.4.0
+  * Add color customization feature.
+
+-------------------------------------------------------------------

Old:
----
  cbonsai-v1.3.1.tar.bz2

New:
----
  cbonsai-v1.4.2.tar.bz2

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

Other differences:
------------------
++++++ cbonsai.spec ++++++
--- /var/tmp/diff_new_pack.Ba5zCT/_old  2025-07-09 17:27:33.101409067 +0200
+++ /var/tmp/diff_new_pack.Ba5zCT/_new  2025-07-09 17:27:33.101409067 +0200
@@ -1,8 +1,8 @@
 #
 # spec file for package cbonsai
 #
-# Copyright (c) 2021 SUSE LLC
-# Copyright (c) 2021, Martin Hauke <mar...@gmx.de>
+# Copyright (c) 2025 SUSE LLC
+# Copyright (c) 2021-2025, Martin Hauke <mar...@gmx.de>
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 
 Name:           cbonsai
-Version:        1.3.1
+Version:        1.4.2
 Release:        0
 Summary:        A bonsai tree generator for your terminal
 License:        GPL-3.0-or-later
@@ -33,8 +33,18 @@
 creates, colors, and positions a bonsai tree, and is entirely
 configurable via CLI options.
 
+%package bash-completion
+Summary:        Bash Completion for %{name}
+Requires:       %{name} = %{version}
+Requires:       bash-completion
+Supplements:    (%{name} and bash-completion)
+BuildArch:      noarch
+
+%description bash-completion
+Bash completion script for %{name}.
+
 %prep
-%setup -q -n %{name}-v%{version}
+%autosetup -n %{name}-v%{version}
 
 %build
 %make_build
@@ -46,5 +56,8 @@
 %license LICENSE
 %doc README.md
 %{_bindir}/cbonsai
-%{_mandir}/man1/cbonsai.1%{?ext_man}
+%{_mandir}/man6/cbonsai.6%{?ext_man}
+
+%files bash-completion
+%{_datadir}/bash-completion/completions/cbonsai
 

++++++ cbonsai-v1.3.1.tar.bz2 -> cbonsai-v1.4.2.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbonsai-v1.3.1/Makefile new/cbonsai-v1.4.2/Makefile
--- old/cbonsai-v1.3.1/Makefile 2021-08-14 23:04:52.000000000 +0200
+++ new/cbonsai-v1.4.2/Makefile 2025-06-20 04:28:16.000000000 +0200
@@ -4,25 +4,36 @@
 CFLAGS += -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -pedantic $(shell 
$(PKG_CONFIG) --cflags ncursesw panelw)
 LDLIBS = $(shell $(PKG_CONFIG) --libs ncursesw panelw || echo "-lncursesw 
-ltinfo -lpanelw")
 PREFIX = /usr/local
-MANDIR = $(PREFIX)/share/man
+DATADIR        = $(PREFIX)/share
+MANDIR = $(DATADIR)/man
+WITH_BASH      = 1
 
 cbonsai: cbonsai.c
 
-cbonsai.1: cbonsai.scd
+cbonsai.6: cbonsai.scd
+ifeq ($(shell command -v scdoc 2>/dev/null),)
+       $(warning Missing dependency: scdoc. The man page will not be 
generated.)
+else
        scdoc <$< >$@
+endif
 
-install: cbonsai cbonsai.1
+install: cbonsai cbonsai.6
        mkdir -p $(DESTDIR)$(PREFIX)/bin
-       mkdir -p $(DESTDIR)$(MANDIR)/man1
+       mkdir -p $(DESTDIR)$(MANDIR)/man6
        install -m 0755 cbonsai $(DESTDIR)$(PREFIX)/bin/cbonsai
-       install -m 0644 cbonsai.1 $(DESTDIR)$(MANDIR)/man1/cbonsai.1
+       [ ! -f cbonsai.6 ] || install -m 0644 cbonsai.6 
$(DESTDIR)$(MANDIR)/man6/cbonsai.6
+ifeq ($(WITH_BASH),1)
+       mkdir -p $(DESTDIR)$(DATADIR)/bash-completion/completions
+       install -m 0644 completions/bash/cbonsai.bash 
$(DESTDIR)$(DATADIR)/bash-completion/completions/cbonsai
+endif
 
 uninstall:
        rm -f $(DESTDIR)$(PREFIX)/bin/cbonsai
-       rm -f $(DESTDIR)$(MANDIR)/man1/cbonsai.1
+       rm -f $(DESTDIR)$(MANDIR)/man6/cbonsai.6
+       rm -f $(DESTDIR)$(DATADIR)/bash-completion/completions/cbonsai
 
 clean:
        rm -f cbonsai
-       rm -f cbonsai.1
+       rm -f cbonsai.6
 
 .PHONY: install uninstall clean
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbonsai-v1.3.1/README.md new/cbonsai-v1.4.2/README.md
--- old/cbonsai-v1.3.1/README.md        2021-08-14 23:04:52.000000000 +0200
+++ new/cbonsai-v1.4.2/README.md        2025-06-20 04:28:16.000000000 +0200
@@ -25,7 +25,7 @@
 
 ### Debian-based
 
-`cbonsai` is only available in the Debian Unstable repository. However, if 
you're not on unstable, Robin Gustafsson has kindly packaged `cbonsai` as a 
`.deb` file over in [this 
repository](https://gitlab.com/rgson/debian_cbonsai/-/packages).
+`cbonsai` is available in Debian Testing and Unstable via `apt`. Robin 
Gustafsson has also kindly packaged `cbonsai` as a `.deb` file over in [this 
repository](https://gitlab.com/rgson/debian_cbonsai/-/packages).
 
 ### Fedora
 
@@ -38,20 +38,13 @@
 
 ### MacOS
 
-Follow the [Manual](#manual) installation, but if you install `ncurses` via 
homebrew, you may see this:
+You may install `cbonsai` using [Homebrew](https://brew.sh):
 
+```bash
+brew install cbonsai
 ```
-For pkg-config to find ncurses you may need to set:
-  set -gx PKG_CONFIG_PATH "/usr/local/opt/ncurses/lib/pkgconfig"
-```
-
-You may need to follow these instructions before running `make install`.
-
-If you are having trouble installing on MacOS, try reading [this 
issue](https://gitlab.com/jallbrit/cbonsai/-/issues/10).
 
-#### MacPorts
-
-On macOS, you may also install `cbonsai` using 
[MacPorts](https://www.macports.org). Simply install MacPorts, then issue the 
following commands:
+You may also install `cbonsai` using [MacPorts](https://www.macports.org). 
Simply install MacPorts, then issue the following commands:
 
 ```bash
 sudo port selfupdate
@@ -60,18 +53,33 @@
 
 ### Manual
 
-You'll need to have a working `ncursesw` library. If you're on a 
`Debian`-based system, you can install `ncursesw` like so:
+You'll need to have a working `ncursesw`/`ncurses` library.
+
+#### Debian-based
 
 ```bash
 sudo apt install libncursesw5-dev
 ```
 
-Or on Fedora:
+#### Fedora
 
 ```bash
 sudo dnf install ncursesw5-devel
 ```
 
+#### macOS
+
+Follow the [Manual](#manual) installation, but if you install `ncurses` via 
homebrew, you may see this:
+
+```
+For pkg-config to find ncurses you may need to set:
+  set -gx PKG_CONFIG_PATH "/usr/local/opt/ncurses/lib/pkgconfig"
+```
+
+You may need to follow these instructions before running `make install`.
+
+If you are having trouble installing on MacOS, try reading [this 
issue](https://gitlab.com/jallbrit/cbonsai/-/issues/10).
+
 Once dependencies are met, then install:
 
 ```bash
@@ -105,6 +113,9 @@
   -b, --base=INT         ascii-art plant base to use, 0 is none
   -c, --leaf=LIST        list of comma-delimited strings randomly chosen
                            for leaves
+  -k, --color=LIST       list of 4 comma-delimited color indices (0-255) for
+                           each of dark leaves, dark wood, light leaves, and
+                           light wood, in that order [default: 2,3,10,11]
   -M, --multiplier=INT   branch multiplier; higher -> more
                            branching (0-20) [default: 5]
   -L, --life=INT         life; higher -> more growth (0-200) [default: 32]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbonsai-v1.3.1/cbonsai.c new/cbonsai-v1.4.2/cbonsai.c
--- old/cbonsai-v1.3.1/cbonsai.c        2021-08-14 23:04:52.000000000 +0200
+++ new/cbonsai-v1.4.2/cbonsai.c        2025-06-20 04:28:16.000000000 +0200
@@ -12,6 +12,13 @@
 #include <wchar.h>
 #include <ctype.h>
 #include <unistd.h>
+#include <errno.h>
+
+#define COLOR_WOOD_BRIGHT COLOR_PAIR(4)
+#define COLOR_WOOD_DARK COLOR_PAIR(2)
+#define COLOR_LEAF_BRIGHT COLOR_PAIR(3)
+#define COLOR_LEAF_DARK COLOR_PAIR(1)
+#define COLOR_TEXT COLOR_PAIR(5)
 
 enum branchType {trunk, shootLeft, shootRight, dying, dead};
 
@@ -31,10 +38,11 @@
        int targetBranchCount;
 
        double timeWait;
-       double timeStep;
+       float timeStep;
 
        char* message;
        char* leaves[64];
+       int colors[4];
        char* saveFile;
        char* loadFile;
 };
@@ -57,7 +65,7 @@
        int shootCounter;
 };
 
-void quit(struct config *conf, struct ncursesObjects *objects, int returnCode) 
{
+void delObjects(struct ncursesObjects *objects) {
        // delete panels
        del_panel(objects->basePanel);
        del_panel(objects->treePanel);
@@ -69,7 +77,10 @@
        delwin(objects->treeWin);
        delwin(objects->messageBorderWin);
        delwin(objects->messageWin);
+}
 
+void quit(struct config *conf, struct ncursesObjects *objects, int returnCode) 
{
+       delObjects(objects);
        free(conf->saveFile);
        free(conf->loadFile);
        exit(returnCode);
@@ -121,47 +132,52 @@
 }
 
 void printHelp(void) {
-       printf("Usage: cbonsai [OPTION]...\n");
-       printf("\n");
-       printf("cbonsai is a beautifully random bonsai tree generator.\n");
-       printf("\n");
-       printf("Options:\n");
-       printf("  -l, --live             live mode: show each step of 
growth\n");
-       printf("  -t, --time=TIME        in live mode, wait TIME secs 
between\n");
-       printf("                           steps of growth (must be larger than 
0) [default: 0.03]\n");
-       printf("  -i, --infinite         infinite mode: keep growing trees\n");
-       printf("  -w, --wait=TIME        in infinite mode, wait TIME between 
each tree\n");
-       printf("                           generation [default: 4.00]\n");
-       printf("  -S, --screensaver      screensaver mode; equivalent to -li 
and\n");
-       printf("                           quit on any keypress\n");
-       printf("  -m, --message=STR      attach message next to the tree\n");
-       printf("  -b, --base=INT         ascii-art plant base to use, 0 is 
none\n");
-       printf("  -c, --leaf=LIST        list of comma-delimited strings 
randomly chosen\n");
-       printf("                           for leaves\n");
-       printf("  -M, --multiplier=INT   branch multiplier; higher -> more\n");
-       printf("                           branching (0-20) [default: 5]\n");
-       printf("  -L, --life=INT         life; higher -> more growth (0-200) 
[default: 32]\n");
-       printf("  -p, --print            print tree to terminal when 
finished\n");
-       printf("  -s, --seed=INT         seed random number generator\n");
-       printf("  -W, --save=FILE        save progress to file [default: 
$XDG_CACHE_HOME/cbonsai or $HOME/.cache/cbonsai]\n");
-       printf("  -C, --load=FILE        load progress from file [default: 
$XDG_CACHE_HOME/cbonsai]\n");
-       printf("  -v, --verbose          increase output verbosity\n");
-       printf("  -h, --help             show help      \n");
+       printf("%s",
+               "Usage: cbonsai [OPTION]...\n"
+               "\n"
+               "cbonsai is a beautifully random bonsai tree generator.\n"
+               "\n"
+               "Options:\n"
+               "  -l, --live             live mode: show each step of growth\n"
+               "  -t, --time=TIME        in live mode, wait TIME secs 
between\n"
+               "                           steps of growth (must be larger 
than 0) [default: 0.03]\n"
+               "  -i, --infinite         infinite mode: keep growing trees\n"
+               "  -w, --wait=TIME        in infinite mode, wait TIME between 
each tree\n"
+               "                           generation [default: 4.00]\n"
+               "  -S, --screensaver      screensaver mode; equivalent to -li 
and\n"
+               "                           quit on any keypress\n"
+               "  -m, --message=STR      attach message next to the tree\n"
+               "  -b, --base=INT         ascii-art plant base to use, 0 is 
none\n"
+               "  -c, --leaf=LIST        list of comma-delimited strings 
randomly chosen\n"
+               "                           for leaves [default: &]\n"
+               "  -k, --color=LIST       list of 4 comma-delimited color 
indices (0-255) for\n"
+               "                           each of dark leaves, dark wood, 
light leaves, and\n"
+               "                           light wood, in that order [default: 
2,3,10,11]\n"
+               "  -M, --multiplier=INT   branch multiplier; higher -> more\n"
+               "                           branching (0-20) [default: 5]\n"
+               "  -L, --life=INT         life; higher -> more growth (0-200) 
[default: 32]\n"
+               "  -p, --print            print tree to terminal when 
finished\n"
+               "  -s, --seed=INT         seed random number generator\n"
+               "  -W, --save=FILE        save progress to file [default: 
$XDG_CACHE_HOME/cbonsai or $HOME/.cache/cbonsai]\n"
+               "  -C, --load=FILE        load progress from file [default: 
$XDG_CACHE_HOME/cbonsai]\n"
+               "  -v, --verbose          increase output verbosity\n"
+               "  -h, --help             show help\n"
+    );
 }
 
 void drawBase(WINDOW* baseWin, int baseType) {
        // draw base art
        switch(baseType) {
        case 1:
-               wattron(baseWin, A_BOLD | COLOR_PAIR(8));
+               wattron(baseWin, A_BOLD | COLOR_TEXT);
                wprintw(baseWin, "%s", ":");
-               wattron(baseWin, COLOR_PAIR(2));
+               wattron(baseWin, COLOR_LEAF_BRIGHT);
                wprintw(baseWin, "%s", "___________");
-               wattron(baseWin, COLOR_PAIR(11));
+               wattron(baseWin, COLOR_WOOD_BRIGHT);
                wprintw(baseWin, "%s", "./~~~\\.");
-               wattron(baseWin, COLOR_PAIR(2));
+               wattron(baseWin, COLOR_LEAF_BRIGHT);
                wprintw(baseWin, "%s", "___________");
-               wattron(baseWin, COLOR_PAIR(8));
+               wattron(baseWin, COLOR_TEXT);
                wprintw(baseWin, "%s", ":");
 
                mvwprintw(baseWin, 1, 0, "%s", " \\                           / 
");
@@ -171,15 +187,15 @@
                wattroff(baseWin, A_BOLD);
                break;
        case 2:
-               wattron(baseWin, COLOR_PAIR(8));
+               wattron(baseWin, COLOR_TEXT);
                wprintw(baseWin, "%s", "(");
-               wattron(baseWin, COLOR_PAIR(2));
+               wattron(baseWin, COLOR_LEAF_BRIGHT);
                wprintw(baseWin, "%s", "---");
-               wattron(baseWin, COLOR_PAIR(11));
+               wattron(baseWin, COLOR_WOOD_BRIGHT);
                wprintw(baseWin, "%s", "./~~~\\.");
-               wattron(baseWin, COLOR_PAIR(2));
+               wattron(baseWin, COLOR_LEAF_BRIGHT);
                wprintw(baseWin, "%s", "---");
-               wattron(baseWin, COLOR_PAIR(8));
+               wattron(baseWin, COLOR_TEXT);
                wprintw(baseWin, "%s", ")");
 
                mvwprintw(baseWin, 1, 0, "%s", " (           ) ");
@@ -209,20 +225,16 @@
        int baseOriginY = (rows - baseHeight);
        int baseOriginX = (cols / 2) - (baseWidth / 2);
 
+       // clean up old objects
+       delObjects(objects);
+
        // create windows
        objects->baseWin = newwin(baseHeight, baseWidth, baseOriginY, 
baseOriginX);
        objects->treeWin = newwin(rows - baseHeight, cols, 0, 0);
 
-       // create/replace tree and base panels
-       if (objects->basePanel)
-               replace_panel(objects->basePanel, objects->baseWin);
-       else
-               objects->basePanel = new_panel(objects->baseWin);
-
-       if (objects->treePanel)
-               replace_panel(objects->treePanel, objects->treeWin);
-       else
-               objects->treePanel = new_panel(objects->treeWin);
+       // create tree and base panels
+       objects->basePanel = new_panel(objects->baseWin);
+       objects->treePanel = new_panel(objects->treeWin);
 
        drawBase(objects->baseWin, baseType);
 }
@@ -257,18 +269,18 @@
        case trunk:
        case shootLeft:
        case shootRight:
-               if (rand() % 2 == 0) wattron(treeWin, A_BOLD | COLOR_PAIR(11));
-               else wattron(treeWin, COLOR_PAIR(3));
+               if (rand() % 2 == 0) wattron(treeWin, A_BOLD | 
COLOR_WOOD_BRIGHT);
+               else wattron(treeWin, COLOR_WOOD_DARK);
                break;
 
        case dying:
-               if (rand() % 10 == 0) wattron(treeWin, A_BOLD | COLOR_PAIR(2));
-               else wattron(treeWin, COLOR_PAIR(2));
+               if (rand() % 10 == 0) wattron(treeWin, A_BOLD | 
COLOR_LEAF_BRIGHT);
+               else wattron(treeWin, COLOR_LEAF_BRIGHT);
                break;
 
        case dead:
-               if (rand() % 3 == 0) wattron(treeWin, A_BOLD | COLOR_PAIR(10));
-               else wattron(treeWin, COLOR_PAIR(10));
+               if (rand() % 3 == 0) wattron(treeWin, A_BOLD | COLOR_LEAF_DARK);
+               else wattron(treeWin, COLOR_LEAF_DARK);
                break;
        }
 }
@@ -534,19 +546,12 @@
        objects->messageWin = newwin(boxHeight, boxWidth + 1, maxY * 0.7, maxX 
* 0.7);
 
        // draw box
-       wattron(objects->messageBorderWin, COLOR_PAIR(8) | A_BOLD);
+       wattron(objects->messageBorderWin, COLOR_TEXT | A_BOLD);
        wborder(objects->messageBorderWin, '|', '|', '-', '-', '+', '+', '+', 
'+');
 
-       // create/replace message panels
-       if (objects->messageBorderPanel)
-               replace_panel(objects->messageBorderPanel, 
objects->messageBorderWin);
-       else
-               objects->messageBorderPanel = 
new_panel(objects->messageBorderWin);
-
-       if (objects->messagePanel)
-               replace_panel(objects->messagePanel, objects->messageWin);
-       else
-               objects->messagePanel = new_panel(objects->messageWin);
+       // create message panels
+       objects->messageBorderPanel = new_panel(objects->messageBorderWin);
+       objects->messagePanel = new_panel(objects->messageWin);
 }
 
 int drawMessage(const struct config *conf, struct ncursesObjects *objects, 
char* message) {
@@ -629,7 +634,7 @@
 
                if (conf->verbosity >= 2) {
                        updateScreen(1);
-                       mvwprintw(objects->treeWin, 11, 5, "word buffer: |% 
15s|", wordBuffer);
+                       mvwprintw(objects->treeWin, 11, 5, "word buffer: 
|%-15s|", wordBuffer);
                }
                if (thisChar == '\0') break;    // quit when we reach the end 
of the message
                i++;
@@ -653,21 +658,32 @@
                int bg = COLOR_BLACK;
                if (use_default_colors() != ERR) bg = -1;
 
-               // define color pairs
-               for(int i=0; i<16; i++){
-                       init_pair(i, i, bg);
+               // initialize color pairs
+               int warnedAlready = 0;
+               for(int id = 1; id <= 4; id++) {
+                       int color_id = conf->colors[id-1];
+
+                       // restrict color pallete in non-256color terminals
+                       if (COLORS < 256) {
+                               init_pair(id, color_id % 8, bg);
+                       } else {
+                               init_pair(id, color_id, bg);
+                       }
+
+                       if (!warnedAlready && COLORS < 256 && color_id >= 8) {
+                               endwin();
+                               printf("Warning: defaulting to 8-color 
support.\n");
+                               warnedAlready = 1;
+                               doupdate();
+                       }
                }
 
-               // restrict color pallete in non-256color terminals (e.g. 
screen or linux)
+               // initialize COLOR_TEXT pair
                if (COLORS < 256) {
-                       init_pair(8, 7, bg);    // gray will look white
-                       init_pair(9, 1, bg);
-                       init_pair(10, 2, bg);
-                       init_pair(11, 3, bg);
-                       init_pair(12, 4, bg);
-                       init_pair(13, 5, bg);
-                       init_pair(14, 6, bg);
-                       init_pair(15, 7, bg);
+                       init_pair(5, 7, bg);
+               }
+               else {
+                       init_pair(5, 8, bg);
                }
        } else {
                printf("%s", "Warning: terminal does not have color 
support.\n");
@@ -727,11 +743,17 @@
 
                        // enable correct color
                        if (fg == 0) printf("\033[0m");
+                       else if (fg >= 16) printf("\033[38;5;%him", fg);
                        else if (fg <= 7) printf("\033[3%him", fg);
                        else if (fg >= 8) printf("\033[9%him", fg - 8);
 
+                       // print wchar
                        printf("%ls", wch);
 
+                       // if we're on the last char in the row, print a newline
+                       if (x == maxX - 1)
+                               printf("\n");
+
                        short clen = wcslen(wch);
                        short cwidth = 0;
                        for (int i = 0; i < clen; ++i)
@@ -804,6 +826,7 @@
 
                .message = NULL,
                .leaves = {0},
+               .colors = {0, 0, 0, 0},
                .saveFile = createDefaultCachePath(),
                .loadFile = createDefaultCachePath(),
        };
@@ -817,6 +840,7 @@
                {"message", required_argument, NULL, 'm'},
                {"base", required_argument, NULL, 'b'},
                {"leaf", required_argument, NULL, 'c'},
+               {"colors", required_argument, NULL, 'k'},
                {"multiplier", required_argument, NULL, 'M'},
                {"life", required_argument, NULL, 'L'},
                {"print", required_argument, NULL, 'p'},
@@ -831,17 +855,18 @@
        struct ncursesObjects objects = { NULL, NULL, NULL, NULL, NULL, NULL, 
NULL, NULL };
 
        char leavesInput[128] = "&";
+       char colorsInput[128] = "2,3,10,11";
 
        // parse arguments
        int option_index = 0;
        int c;
-       while ((c = getopt_long(argc, argv, ":lt:iw:Sm:b:c:M:L:ps:C:W:vh", 
long_options, &option_index)) != -1) {
+       while ((c = getopt_long(argc, argv, ":lt:iw:Sm:b:c:k:M:L:ps:C:W:vh", 
long_options, &option_index)) != -1) {
                switch (c) {
                case 'l':
                        conf.live = 1;
                        break;
                case 't':
-                       if (strtold(optarg, NULL) != 0) conf.timeStep = 
strtod(optarg, NULL);
+                       if (strtof(optarg, NULL) != 0) conf.timeStep = 
strtof(optarg, NULL);
                        else {
                                printf("error: invalid step time: '%s'\n", 
optarg);
                                quit(&conf, &objects, 1);
@@ -878,7 +903,13 @@
                        conf.message = optarg;
                        break;
                case 'b':
-                       if (strtold(optarg, NULL) != 0) conf.baseType = 
strtod(optarg, NULL);
+                        /* 0 can legitimately be returned, so we cannot check 
wether
+                           strtold(optarg, NULL) != 0.  We need to set errno 
to zero
+                           before the conversion attempt, and check it it 
changed
+                           afterwards. */
+                        errno = 0;
+                        strtold(optarg, NULL);
+                        if (!errno) conf.baseType = strtod(optarg, NULL);
                        else {
                                printf("error: invalid base index: '%s'\n", 
optarg);
                                quit(&conf, &objects, 1);
@@ -888,6 +919,10 @@
                        strncpy(leavesInput, optarg, sizeof(leavesInput) - 1);
                        leavesInput[sizeof(leavesInput) - 1] = '\0';
                        break;
+               case 'k':
+                       strncpy(colorsInput, optarg, sizeof(colorsInput) - 1);
+                       colorsInput[sizeof(colorsInput) - 1] = '\0';
+                       break;
                case 'M':
                        if (strtold(optarg, NULL) != 0) conf.multiplier = 
strtod(optarg, NULL);
                        else {
@@ -993,6 +1028,32 @@
                conf.leavesSize++;
        }
 
+       // delimit colors on "," and add each color to the colors[] list
+       token = strtok(colorsInput, ",");
+       for(int i = 0; i<4; i++) {
+               if (token == NULL) {
+                       printf("error: too few color indices provided\n");
+                       quit(&conf, &objects, 1);
+               }
+               char* temp;
+               errno = 0;
+
+               // parse each number
+               long parsed = strtol(token, &temp, 0);
+               if (temp == token || *temp != '\0' || errno == ERANGE || parsed 
< 0 || parsed >= 256) {
+                       printf("error: invalid color index: '%s'\n", token);
+                       quit(&conf, &objects, 1);
+               } else {
+                       // add to list and continue
+                       conf.colors[i] = parsed;
+                       token = strtok(NULL, ",");
+               }
+       }
+       if (token != NULL) {
+               printf("error: too many color indices provided\n");
+               quit(&conf, &objects, 1);
+       }
+
        if (conf.load)
                loadFromFile(&conf);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbonsai-v1.3.1/cbonsai.scd 
new/cbonsai-v1.4.2/cbonsai.scd
--- old/cbonsai-v1.3.1/cbonsai.scd      2021-08-14 23:04:52.000000000 +0200
+++ new/cbonsai-v1.4.2/cbonsai.scd      2025-06-20 04:28:16.000000000 +0200
@@ -1,4 +1,4 @@
-cbonsai(1)
+cbonsai(6)
 
 # NAME
 
@@ -36,7 +36,11 @@
        ascii-art plant base to use, 0 is none
 
 *-c*, *--leaf*=_LIST_
-       list of comma-delimited strings randomly chosen for leaves
+       list of comma-delimited strings randomly chosen for leaves [default: &]
+
+*-k*, *--color*=_LIST_
+       list of 4 comma-delimited color indices (0-255) for each of dark 
leaves, dark wood,
+       light leaves, and light wood, in that order [default: 2,3,10,11]
 
 *-M*, *--multiplier*=_INT_
        branch multiplier; higher -> more branching (0-20) [default: 5]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbonsai-v1.3.1/completions/bash/cbonsai.bash 
new/cbonsai-v1.4.2/completions/bash/cbonsai.bash
--- old/cbonsai-v1.3.1/completions/bash/cbonsai.bash    1970-01-01 
01:00:00.000000000 +0100
+++ new/cbonsai-v1.4.2/completions/bash/cbonsai.bash    2025-06-20 
04:28:16.000000000 +0200
@@ -0,0 +1,58 @@
+# cbonsai(1) completion
+
+_cbonsai()
+{
+  local cur prev opts
+  _get_comp_words_by_ref cur prev
+
+  opts=(
+    '-l'
+    '--live'
+    '-t'
+    '--time'
+    '-i'
+    '--infinite'
+    '-w'
+    '--wait'
+    '-S'
+    '--screensaver'
+    '-m'
+    '--message'
+    '-b'
+    '--base'
+    '-c'
+    '--leaf'
+    '-k'
+    '--colors'
+    '-M'
+    '--multiplier'
+    '-L'
+    '--life'
+    '-p'
+    '--print'
+    '-s'
+    '--seed'
+    '-W'
+    '--save'
+    '-C'
+    '--load'
+    '-v'
+    '--verbose'
+    '-h'
+    '--help'
+  )
+
+  case "$prev" in
+    -[WC]|--save|--load)
+      COMPREPLY=($(compgen -f -- "$cur"))
+      return
+      ;;
+    
-[twmbckMLs]|--time|--wait|--message|--base|--leaf|--colors|--multiplier|--life|--seed)
+      return
+      ;;
+  esac
+
+  COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
+
+} &&
+complete -F _cbonsai cbonsai

Reply via email to