diff options
author | Mattias Andrée <maandree@kth.se> | 2016-08-05 00:27:00 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-08-05 00:27:00 +0200 |
commit | c3d835ee0963d433c451e6233e88eadc245369b8 (patch) | |
tree | 48605d31f87fca9102b5b5ebc9c5d79e426c44c3 /src | |
parent | Fixes to cg-base and work on cg-negative (diff) | |
download | cg-tools-c3d835ee0963d433c451e6233e88eadc245369b8.tar.gz cg-tools-c3d835ee0963d433c451e6233e88eadc245369b8.tar.bz2 cg-tools-c3d835ee0963d433c451e6233e88eadc245369b8.tar.xz |
Fix bugs
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/cg-base.c | 22 | ||||
-rw-r--r-- | src/cg-base.h | 3 | ||||
-rw-r--r-- | src/cg-negative.c | 12 |
3 files changed, 23 insertions, 14 deletions
diff --git a/src/cg-base.c b/src/cg-base.c index 77dfe67..9056e42 100644 --- a/src/cg-base.c +++ b/src/cg-base.c @@ -20,6 +20,8 @@ #include "cg-base.h" +#include <libclut.h> + #include <alloca.h> #include <errno.h> #include <inttypes.h> @@ -160,7 +162,10 @@ int make_slaves(void) } qsort(data, n, sizeof(*data), crtc_sort_data_cmp); + if (n == 0) + return 0; + master_i = data[0].index; for (i = 1; i < n; i++) if (memcmp(data + i, data + master, sizeof(*data) - sizeof(data->index))) { @@ -169,8 +174,8 @@ int make_slaves(void) crtc_updates[master_i].slaves = calloc(i - master, sizeof(size_t)); if (crtc_updates[master_i].slaves == NULL) return -1; - for (j = 0; master + j < i; j++) - crtc_updates[master_i].slaves[j] = data[master + j].index; + for (j = 1; master + j < i; j++) + crtc_updates[master_i].slaves[j - 1] = data[master + j].index; } master = i; master_i = data[master].index; @@ -187,8 +192,8 @@ int make_slaves(void) crtc_updates[master_i].slaves = calloc(i - master, sizeof(size_t)); if (crtc_updates[master_i].slaves == NULL) return -1; - for (j = 0; master + j < i; j++) - crtc_updates[master_i].slaves[j] = data[master + j].index; + for (j = 1; master + j < i; j++) + crtc_updates[master_i].slaves[j - 1] = data[master + j].index; } return 0; @@ -570,7 +575,7 @@ int main(int argc, char* argv[]) int at_end; opt[1] = *args++; arg = args + 1; - if ((at_end = !*arg)) + if ((at_end = !*args)) arg = argv[1]; if (!strcmp(opt, "-M")) { @@ -603,7 +608,7 @@ int main(int argc, char* argv[]) switch (handle_opt(opt, arg)) { case 0: - goto next_arg; + goto next_opt; case 1: break; default: @@ -611,9 +616,9 @@ int main(int argc, char* argv[]) } argv += at_end; argc -= at_end; - goto next_arg; + break; + next_opt:; } - next_arg:; } crtcs_n = crtcs_i; @@ -756,6 +761,7 @@ int main(int argc, char* argv[]) #define X(CONST, MEMBER, MAX, TYPE)\ case CONST:\ libcoopgamma_ramps_initialise(&(crtc_updates[crtcs_i].filter.ramps.MEMBER));\ + libclut_start_over(&(crtc_updates[crtcs_i].filter.ramps.MEMBER), MAX, TYPE, 1, 1, 1);\ break; LIST_DEPTHS #undef X diff --git a/src/cg-base.h b/src/cg-base.h index 848a202..269f2a3 100644 --- a/src/cg-base.h +++ b/src/cg-base.h @@ -51,7 +51,8 @@ typedef struct filter_update * `.filter.crtc`, `.filter.class`, and * `.filter.priority`, `.filter.depth` * are preconfigured, and `.filter.ramps` - * is preinitialised. + * is preinitialised and preset to an + * identity ramp */ libcoopgamma_filter_t filter; diff --git a/src/cg-negative.c b/src/cg-negative.c index 566b81a..b0c19ed 100644 --- a/src/cg-negative.c +++ b/src/cg-negative.c @@ -30,7 +30,7 @@ /** * The default filter priority for the program */ -const int64_t default_priority = ((int64_t)1) << 62; +const int64_t default_priority = ((int64_t)1) << 63; /** * The default class for the program @@ -151,13 +151,13 @@ int handle_opt(char* opt, char* arg) int handle_args(int argc, char* argv[], char* method, char* site, char** crtcs, char* prio, char* rule) { - int q = dflag + (xflag | rplus | gplus | bplus); + int q = xflag + (dflag | rplus | gplus | bplus); q += (method != NULL) && !strcmp(method, "?"); q += (prio != NULL) && !strcmp(prio, "?"); - q += (rule != NULL) && (!strcmp(method, "?") || !strcmp(method, "??")); + q += (rule != NULL) && (!strcmp(rule, "?") || !strcmp(rule, "??")); for (; *crtcs; crtcs++) q += !strcmp(*crtcs, "?"); - if (argc || q || (dflag && (prio != NULL))) + if (argc || (q > 1) || (xflag && (prio != NULL))) usage(); } @@ -229,12 +229,14 @@ int start(void) } while (r != 1) - if ((r = update_filter(i, -1)) < 0) + if ((r = synchronise(-1)) < 0) return r; if (!dflag) return 0; + if (libcoopgamma_set_nonblocking(&cg, 0) < 0) + return -1; for (;;) if (libcoopgamma_synchronise(&cg, NULL, 0, &j) < 0) switch (errno) |