Hello community,

here is the log from the commit of package slurp for openSUSE:Factory checked 
in at 2020-11-05 21:55:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/slurp (Old)
 and      /work/SRC/openSUSE:Factory/.slurp.new.11331 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "slurp"

Thu Nov  5 21:55:55 2020 rev:6 rq:846224 version:1.3.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/slurp/slurp.changes      2020-10-18 
16:33:31.812814190 +0200
+++ /work/SRC/openSUSE:Factory/.slurp.new.11331/slurp.changes   2020-11-05 
21:56:34.295961368 +0100
@@ -1,0 +2,10 @@
+Thu Nov  5 12:49:35 UTC 2020 - Michael Vetter <mvet...@suse.com>
+
+- Update to 1.3.1:
+  * Fix off-by-one error in in_box function
+  * Print output into buffer, print result late
+  * Safe printf usage
+  * readme: simplify "select output" example
+  * readme: clarify that -f "%o" prints the output name
+
+-------------------------------------------------------------------

Old:
----
  v1.3.0.tar.gz

New:
----
  v1.3.1.tar.gz

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

Other differences:
------------------
++++++ slurp.spec ++++++
--- /var/tmp/diff_new_pack.D2wCR5/_old  2020-11-05 21:56:34.855960109 +0100
+++ /var/tmp/diff_new_pack.D2wCR5/_new  2020-11-05 21:56:34.859960100 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           slurp
-Version:        1.3.0
+Version:        1.3.1
 Release:        0
 Summary:        Wayland region selector
 License:        MIT

++++++ v1.3.0.tar.gz -> v1.3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/slurp-1.3.0/README.md new/slurp-1.3.1/README.md
--- old/slurp-1.3.0/README.md   2020-10-16 16:55:45.000000000 +0200
+++ new/slurp-1.3.1/README.md   2020-11-05 12:19:37.000000000 +0100
@@ -38,10 +38,10 @@
 slurp -p
 ```
 
-Select an output under Sway, using `swaymsg` and `jq`:
+Select an output and print its name:
 
 ```sh
-swaymsg -t get_outputs | jq -r '.[] | select(.active) | .rect | "\(.x),\(.y) 
\(.width)x\(.height)"' | slurp
+slurp -o -f "%o"
 ```
 
 Select a window under Sway, using `swaymsg` and `jq`:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/slurp-1.3.0/main.c new/slurp-1.3.1/main.c
--- old/slurp-1.3.0/main.c      2020-10-16 16:55:45.000000000 +0200
+++ new/slurp-1.3.1/main.c      2020-11-05 12:19:37.000000000 +0100
@@ -32,9 +32,9 @@
 
 static bool in_box(const struct slurp_box *box, int32_t x, int32_t y) {
        return box->x <= x
-               && box->x + box->width >= x
+               && box->x + box->width > x
                && box->y <= y
-               && box->y + box->height >= y;
+               && box->y + box->height > y;
 }
 
 static int32_t box_size(const struct slurp_box *box) {
@@ -671,23 +671,23 @@
        return res;
 }
 
-static void print_output_name(const struct slurp_box *result, struct wl_list 
*outputs) {
+static void print_output_name(FILE *stream, const struct slurp_box *result, 
struct wl_list *outputs) {
        struct slurp_output *output;
        wl_list_for_each(output, outputs, link) {
                // For now just use the top-left corner
                struct slurp_box *geometry = &output->logical_geometry;
                if (in_box(geometry, result->x, result->y)) {
                        if (geometry->label) {
-                               printf("%s", geometry->label);
+                               fprintf(stream, "%s", geometry->label);
                                return;
                        }
                        break;
                }
        }
-       printf("<unknown>");
+       fprintf(stream, "<unknown>");
 }
 
-static void print_formatted_result(const struct slurp_box *result, struct 
wl_list *outputs,
+static void print_formatted_result(FILE *stream, const struct slurp_box 
*result, struct wl_list *outputs,
                const char *format) {
        for (size_t i = 0; format[i] != '\0'; i++) {
                char c = format[i];
@@ -697,24 +697,24 @@
                        i++; // Skip the next character (x, y, w or h)
                        switch (next) {
                        case 'x':
-                               printf("%d", result->x);
+                               fprintf(stream, "%d", result->x);
                                continue;
                        case 'y':
-                               printf("%d", result->y);
+                               fprintf(stream, "%d", result->y);
                                continue;
                        case 'w':
-                               printf("%d", result->width);
+                               fprintf(stream, "%d", result->width);
                                continue;
                        case 'h':
-                               printf("%d", result->height);
+                               fprintf(stream, "%d", result->height);
                                continue;
                        case 'l':
                                if (result->label) {
-                                       printf("%s", result->label);
+                                       fprintf(stream, "%s", result->label);
                                }
                                continue;
                        case 'o':
-                               print_output_name(result, outputs);
+                               print_output_name(stream, result, outputs);
                                continue;
                        default:
                                // If no case was executed, revert i back - we 
don't need to
@@ -722,9 +722,8 @@
                                i--;
                        }
                }
-               printf("%c", c);
+               fprintf(stream, "%c", c);
        }
-    fflush(stdout);
 }
 
 static void add_choice_box(struct slurp_state *state,
@@ -745,6 +744,10 @@
 int main(int argc, char *argv[]) {
        int status = EXIT_SUCCESS;
 
+       char *result_str = 0;
+       size_t length;
+       FILE *stream = open_memstream(&result_str, &length);
+
        struct slurp_state state = {
                .colors = {
                        .background = BG_COLOR,
@@ -953,12 +956,12 @@
                // This space intentionally left blank
        }
 
-
        if (state.result.width == 0 && state.result.height == 0) {
                fprintf(stderr, "selection cancelled\n");
                status = EXIT_FAILURE;
        } else {
-               print_formatted_result(&state.result, &state.outputs, format);
+               print_formatted_result(stream, &state.result, &state.outputs, 
format);
+               fclose(stream);
        }
 
        struct slurp_output *output_tmp;
@@ -990,5 +993,10 @@
                free(box);
        }
 
+       if (result_str) {
+               printf("%s", result_str);
+               free(result_str);
+       }
+
        return status;
 }


Reply via email to