X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftemphelper.c;h=c577a1c2e74d6d9d79a018e863d6bd67d5077dc9;hb=6526b47b2c63c9f46b63d3a5e72cbe71b04d60ac;hp=9e94cfd4c6a3362d76743033963a6b98919545b8;hpb=e6a9c02d112fee796e6d04bc012305c0879d9244;p=monky diff --git a/src/temphelper.c b/src/temphelper.c index 9e94cfd..c577a1c 100644 --- a/src/temphelper.c +++ b/src/temphelper.c @@ -1,4 +1,7 @@ -/* temphelper.c: aid in converting temperature units +/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=c + * + * temphelper.c: aid in converting temperature units * * Copyright (C) 2008 Phil Sutter * @@ -30,22 +33,19 @@ /* default to output in celsius */ static enum TEMP_UNIT output_unit = TEMP_CELSIUS; -static double -fahrenheit_to_celsius(double n) +static double fahrenheit_to_celsius(double n) { return ((n - 32) * 5 / 9); } -static double -celsius_to_fahrenheit(double n) +static double celsius_to_fahrenheit(double n) { return ((n * 9 / 5) + 32); } -int -set_temp_output_unit(const char *name) +int set_temp_output_unit(const char *name) { - size_t i; + long i; int rc = 0; char *buf; @@ -53,7 +53,7 @@ set_temp_output_unit(const char *name) return 1; buf = strdup(name); - for (i = 0; i < strlen(name); i++) + for (i = 0; i < (long)strlen(name); i++) buf[i] = tolower(name[i]); if (!strcmp(buf, "celsius")) @@ -66,8 +66,7 @@ set_temp_output_unit(const char *name) return rc; } -static double -convert_temp_output(double n, enum TEMP_UNIT input_unit) +static double convert_temp_output(double n, enum TEMP_UNIT input_unit) { if (input_unit == output_unit) return n; @@ -87,7 +86,7 @@ int temp_print(char *p, size_t p_max_size, double n, enum TEMP_UNIT input_unit) int out; size_t plen; - out = round_to_int(convert_temp_output(n, input_unit)); + out = round_to_int_temp(convert_temp_output(n, input_unit)); plen = spaced_print(p, p_max_size, "%d", 3, out); return !(plen >= p_max_size);