1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

Build fix for macOS. (#574)

This commit is contained in:
Brenden Matthews 2018-08-06 18:09:20 -04:00 committed by GitHub
parent 0a9a46dd70
commit a78a750dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 39 deletions

View File

@ -31,7 +31,6 @@
#include "algebra.h" #include "algebra.h"
#include "bsdapm.h" #include "bsdapm.h"
#include "build.h" #include "build.h"
#include "misc.h"
#include "colours.h" #include "colours.h"
#include "combine.h" #include "combine.h"
#include "core.h" #include "core.h"
@ -39,6 +38,7 @@
#include "entropy.h" #include "entropy.h"
#include "exec.h" #include "exec.h"
#include "i8k.h" #include "i8k.h"
#include "misc.h"
#include "text_object.h" #include "text_object.h"
#ifdef BUILD_IMLIB2 #ifdef BUILD_IMLIB2
#include "imlib2.h" #include "imlib2.h"
@ -74,6 +74,8 @@
#ifdef BUILD_NVIDIA #ifdef BUILD_NVIDIA
#include "nvidia.h" #include "nvidia.h"
#endif #endif
#include <inttypes.h>
#include "cpu.h"
#include "read_tcpip.h" #include "read_tcpip.h"
#include "scroll.h" #include "scroll.h"
#include "specials.h" #include "specials.h"
@ -84,8 +86,6 @@
#include "top.h" #include "top.h"
#include "user.h" #include "user.h"
#include "users.h" #include "users.h"
#include <inttypes.h>
#include "cpu.h"
#ifdef BUILD_CURL #ifdef BUILD_CURL
#include "ccurl_thread.h" #include "ccurl_thread.h"
#endif /* BUILD_CURL */ #endif /* BUILD_CURL */
@ -427,8 +427,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
END OBJ(freq, nullptr) get_cpu_count(); END OBJ(freq, nullptr) get_cpu_count();
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) || strlen(arg) >= 3 || if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) { strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
atoi(&arg[0]) > info.cpu_count) {
obj->data.i = 1; obj->data.i = 1;
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! " /* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
"Displaying the clock for CPU 1."); */ "Displaying the clock for CPU 1."); */
@ -437,8 +438,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
} }
obj->callbacks.print = &print_freq; obj->callbacks.print = &print_freq;
END OBJ(freq_g, nullptr) get_cpu_count(); END OBJ(freq_g, nullptr) get_cpu_count();
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) || strlen(arg) >= 3 || if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) { strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
atoi(&arg[0]) > info.cpu_count) {
obj->data.i = 1; obj->data.i = 1;
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many " /* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
"CPUs! Displaying the clock for CPU 1."); */ "CPUs! Displaying the clock for CPU 1."); */
@ -463,8 +465,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.free = &free_tcp_ping; obj->callbacks.free = &free_tcp_ping;
#if defined(__linux__) #if defined(__linux__)
END OBJ(voltage_mv, 0) get_cpu_count(); END OBJ(voltage_mv, 0) get_cpu_count();
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 || if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 ||
atoi(&arg[0]) > info.cpu_count) { atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) {
obj->data.i = 1; obj->data.i = 1;
/* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many " /* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
"CPUs! Displaying voltage for CPU 1."); */ "CPUs! Displaying voltage for CPU 1."); */
@ -473,8 +475,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
} }
obj->callbacks.print = &print_voltage_mv; obj->callbacks.print = &print_voltage_mv;
END OBJ(voltage_v, 0) get_cpu_count(); END OBJ(voltage_v, 0) get_cpu_count();
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 || if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 ||
atoi(&arg[0]) > info.cpu_count) { atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) {
obj->data.i = 1; obj->data.i = 1;
/* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many " /* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
"CPUs! Displaying voltage for CPU 1."); */ "CPUs! Displaying voltage for CPU 1."); */
@ -781,11 +783,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(conky_build_date, nullptr) obj_be_plain_text(obj, BUILD_DATE); END OBJ(conky_build_date, nullptr) obj_be_plain_text(obj, BUILD_DATE);
END OBJ(conky_build_arch, nullptr) obj_be_plain_text(obj, BUILD_ARCH); END OBJ(conky_build_arch, nullptr) obj_be_plain_text(obj, BUILD_ARCH);
END OBJ(downspeed, &update_net_stats) END OBJ(downspeed, &update_net_stats)
update_gateway_info();
parse_net_stat_arg(obj, arg, free_at_crash); parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_downspeed; obj->callbacks.print = &print_downspeed;
END OBJ(downspeedf, &update_net_stats) END OBJ(downspeedf, &update_net_stats)
update_gateway_info();
parse_net_stat_arg(obj, arg, free_at_crash); parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_downspeedf; obj->callbacks.print = &print_downspeedf;
#ifdef BUILD_X11 #ifdef BUILD_X11
@ -815,41 +815,35 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
scan_no_update(obj, arg); scan_no_update(obj, arg);
obj->callbacks.print = &print_no_update; obj->callbacks.print = &print_no_update;
obj->callbacks.free = &free_no_update; obj->callbacks.free = &free_no_update;
END OBJ(cat, 0) END OBJ(cat, 0) obj->data.s =
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state)); strndup(arg ? arg : "", text_buffer_size.get(*state));
obj->callbacks.print = &print_cat; obj->callbacks.print = &print_cat;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
#ifdef BUILD_X11 #ifdef BUILD_X11
END OBJ(num_led, 0) END OBJ(num_led, 0) obj->callbacks.print = &print_num_led;
obj->callbacks.print = &print_num_led; END OBJ(caps_led, 0) obj->callbacks.print = &print_caps_led;
END OBJ(caps_led, 0) END OBJ(scroll_led, 0) obj->callbacks.print = &print_scroll_led;
obj->callbacks.print = &print_caps_led; END OBJ(kb_layout, 0) obj->callbacks.print = &print_kb_layout;
END OBJ(scroll_led, 0) END OBJ(mouse_speed, 0) obj->callbacks.print = &print_mouse_speed;
obj->callbacks.print = &print_scroll_led;
END OBJ(kb_layout, 0)
obj->callbacks.print = &print_kb_layout;
END OBJ(mouse_speed, 0)
obj->callbacks.print = &print_mouse_speed;
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
END OBJ(password, 0) END OBJ(password, 0) obj->data.s =
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state)); strndup(arg ? arg : "", text_buffer_size.get(*state));
obj->callbacks.print = &print_password; obj->callbacks.print = &print_password;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
#ifdef __x86_64__ #ifdef __x86_64__
END OBJ(freq2, 0) END OBJ(freq2, 0) obj->callbacks.print = &print_freq2;
obj->callbacks.print = &print_freq2;
#endif /* __x86_64__ */ #endif /* __x86_64__ */
END OBJ(cap, 0) END OBJ(cap, 0) obj->data.s =
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state)); strndup(arg ? arg : "", text_buffer_size.get(*state));
obj->callbacks.print = &print_cap; obj->callbacks.print = &print_cap;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ(catp, 0) END OBJ(catp, 0) obj->data.s =
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state)); strndup(arg ? arg : "", text_buffer_size.get(*state));
obj->callbacks.print = &print_catp; obj->callbacks.print = &print_catp;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ_ARG(exec, nullptr, "exec needs arguments: <command>") END OBJ_ARG(exec, nullptr, "exec needs arguments: <command>")
@ -1407,11 +1401,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(alignc, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 0; END OBJ(alignc, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 0;
obj->callbacks.print = &new_alignc; obj->callbacks.print = &new_alignc;
END OBJ(upspeed, &update_net_stats) END OBJ(upspeed, &update_net_stats)
update_gateway_info();
parse_net_stat_arg(obj, arg, free_at_crash); parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_upspeed; obj->callbacks.print = &print_upspeed;
END OBJ(upspeedf, &update_net_stats) END OBJ(upspeedf, &update_net_stats)
update_gateway_info();
parse_net_stat_arg(obj, arg, free_at_crash); parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_upspeedf; obj->callbacks.print = &print_upspeedf;
#ifdef BUILD_X11 #ifdef BUILD_X11

View File

@ -360,6 +360,7 @@ void print_gateway_ip(struct text_object *obj, char *p, int p_max_size) {
* if some error happened * if some error happened
**/ **/
int update_net_stats(void) { int update_net_stats(void) {
update_gateway_info();
FILE *net_dev_fp; FILE *net_dev_fp;
static int rep = 0; static int rep = 0;
/* variably to notify the parts averaging the download speed, that this /* variably to notify the parts averaging the download speed, that this