URI: 
       tMake cropping rectangle specification more strict; add some todos - croptool - Image cropping tool
  HTML git clone git://lumidify.org/croptool.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/croptool.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 7b37880b62538c326cb4d73b218b0f3eca27d21c
   DIR parent 7d46e3125b1c4276ae020e6e0b59e21e08fc54f4
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Thu, 13 Jan 2022 12:56:08 +0100
       
       Make cropping rectangle specification more strict; add some todos
       
       Diffstat:
         M LICENSE                             |       2 +-
         M Makefile                            |       2 +-
         M TODO                                |       4 ++++
         M croptool.c                          |       5 +++--
         M croptool_crop.c                     |       8 ++++----
       
       5 files changed, 13 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/LICENSE b/LICENSE
       t@@ -1,4 +1,4 @@
       -Copyright (c) 2021 lumidify <nobody@lumidify.org>
       +Copyright (c) 2022 lumidify <nobody@lumidify.org>
        
        Permission to use, copy, modify, and/or distribute this software for any
        purpose with or without fee is hereby granted, provided that the above
   DIR diff --git a/Makefile b/Makefile
       t@@ -20,7 +20,7 @@ DB_LDFLAGS = `pkg-config --libs xext`
        #DB_CFLAGS = -DNODB
        #DB_LDFLAGS =
        
       -CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `imlib2-config --cflags`
       +CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -Wall -Wextra -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `imlib2-config --cflags`
        CROP_LDFLAGS = ${CFLAGS} ${DB_LDFLAGS} `pkg-config --libs x11` `imlib2-config --libs` -lm
        
        all: ${BIN}
   DIR diff --git a/TODO b/TODO
       t@@ -3,3 +3,7 @@
          expensive image resizing each time
        * Maybe add zooming support
        * Maybe optionally show rectangle coordinates on screen
       +* Allow to copy/paste selection
       +* Key for allowing/disallowing rectangle out of image bounds
       +* Read selections from file - to modify again later
       +* Better navigation - jump to beginning, etc.
   DIR diff --git a/croptool.c b/croptool.c
       t@@ -1,5 +1,5 @@
        /*
       - * Copyright (c) 2021 lumidify <nobody@lumidify.org>
       + * Copyright (c) 2022 lumidify <nobody@lumidify.org>
         *
         * Permission to use, copy, modify, and/or distribute this software for any
         * purpose with or without fee is hereby granted, provided that the above
       t@@ -152,7 +152,8 @@ static void change_picture(Imlib_Image new_image, int new_selection, int copy_bo
        static void get_scaled_size(int orig_w, int orig_h, int *scaled_w, int *scaled_h);
        static void set_selection(
            struct Selection *sel, int rect_x0, int rect_y0, int rect_x1,
       -    int rect_y1, int orig_w, int orig_h, int scaled_w, int scaled_h);
       +    int rect_y1, int orig_w, int orig_h, int scaled_w, int scaled_h
       +);
        static void queue_rectangle_redraw(int x0, int y0, int x1, int y1);
        static void set_cursor(struct Rect rect);
        static void drag_motion(XEvent event);
   DIR diff --git a/croptool_crop.c b/croptool_crop.c
       t@@ -1,5 +1,5 @@
        /*
       - * Copyright (c) 2021 lumidify <nobody@lumidify.org>
       + * Copyright (c) 2022 lumidify <nobody@lumidify.org>
         *
         * Permission to use, copy, modify, and/or distribute this software for any
         * purpose with or without fee is hereby granted, provided that the above
       t@@ -24,7 +24,7 @@ main(int argc, char *argv[]) {
                char *dst_filename;
                char *format;
                char alpha;
       -        int w, h, x, y;
       +        int w, h, x, y, n;
                int orig_w, orig_h;
                Imlib_Image src, dst;
                Imlib_Load_Error error;
       t@@ -39,8 +39,8 @@ main(int argc, char *argv[]) {
                        dst_filename = argv[3];
                else
                        dst_filename = argv[2];
       -        /* FIXME: proper error checking for this (don't use sscanf) */
       -        if (sscanf(argv[1], "%dx%d+%d+%d", &w, &h, &x, &y) < 4) {
       +        if (sscanf(argv[1], "%dx%d+%d+%d%n", &w, &h, &x, &y, &n) != 4 ||
       +            (unsigned)n != strlen(argv[1])) {
                        fprintf(stderr, "Invalid cropping rectangle specified.\n");
                        exit(1);
                }