From 09cb13b7e92f7e716b3781e642be0feb5898a041 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Wed, 23 Oct 2024 00:00:04 +0200 Subject: [PATCH] better formatting --- ambientd.c3 | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/ambientd.c3 b/ambientd.c3 index ec2ff57..c9bd470 100644 --- a/ambientd.c3 +++ b/ambientd.c3 @@ -20,23 +20,11 @@ const int MAX_LUMINANCE = 700; // minimum display brightness in percent const float MIN_BRIGHTNESS_PERCENT = 0.05; -macro abs(x) -{ - if (x < 0) { - return -x; - } else { - return x; - } -} +macro abs(x) { return x < 0 ? -x : x; } +macro clamp(x, l, h) { return max(min(x, h), l); } -// l <= x <= h -macro clamp(x, l, h) -{ - return max(min(x, h), l); -} - -// read a string to the buffer up until the end of the buffer or the first '\n' /** + * read a string to the buffer up until the end of the buffer or the first '\n' * @require fp != null **/ fn void! io::File.gets(&self, char[] buffer) @@ -57,9 +45,9 @@ fn void! io::File.gets(&self, char[] buffer) buffer[i] = '\0'; } -// read a string from a file and convert it to int, should only be used for -// positive numbers since negative numbers mean an error /** + * read a string from a file and convert it to int, should only be used for + * positive numbers since negative numbers mean an error * @ensure return > 0, return < 1000000 **/ fn int! read_int(String path) @@ -85,10 +73,7 @@ fn void! write_int(String path, int value) } // returns the luminance value in percentage between 0 and 1 -macro get_luminance_raw() -{ - return read_int(LUMINANCE_DEV); -} +macro get_luminance_raw() { return read_int(LUMINANCE_DEV); } fn float bezier(float t) {