From 138b4cf5dabea5360c94040c179d1a6062c6dd51 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Jun 2018 09:17:18 +0530 Subject: [PATCH] Fix build breakage caused by FreeBSD support Also move the changes to the glfw files to glfw.py --- glfw/glfw.py | 15 ++++++++++----- glfw/source-info.json | 16 +++++++++++----- kitty/parser.c | 6 +++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/glfw/glfw.py b/glfw/glfw.py index b37de3286..304384cd2 100755 --- a/glfw/glfw.py +++ b/glfw/glfw.py @@ -43,7 +43,12 @@ def init_env(env, pkg_config, at_least_version, module='x11'): else: ans.ldpaths.extend('-lrt -lm -ldl'.split()) sinfo = json.load(open(os.path.join(base, 'source-info.json'))) - ans.sources = sinfo['common']['sources'] + sinfo[module]['sources'] + module_sources = list(sinfo[module]['sources']) + if module in ('x11', 'wayland'): + remove = 'linux_joystick.c' if is_bsd else 'null_joystick.c' + module_sources.remove(remove) + + ans.sources = sinfo['common']['sources'] + module_sources ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')] if module in ('x11', 'wayland'): @@ -107,13 +112,13 @@ def collect_source_information(): 'common': dict(extract_sources('common')), 'wayland_protocols': wayland_protocols, } - joystick = 'null' if is_bsd else 'linux' for group in 'cocoa win32 x11 wayland osmesa'.split(): m = re.search('_GLFW_' + group.upper(), raw) ans[group] = dict(extract_sources('glfw', m.start())) if group in ('x11', 'wayland'): - ans[group]['headers'].append('{}_joystick.h'.format(joystick)) - ans[group]['sources'].append('{}_joystick.c'.format(joystick)) + for joystick in ('linux', 'null'): + ans[group]['headers'].append('{}_joystick.h'.format(joystick)) + ans[group]['sources'].append('{}_joystick.c'.format(joystick)) if group == 'wayland': ans[group]['protocols'] = p = [] for m in re.finditer(r'WAYLAND_PROTOCOLS_PKGDATADIR\}/(.+?)"?$', raw, flags=re.M): @@ -224,9 +229,9 @@ const char* load_glfw(const char* path); f.write(header) code = ''' -#include #include "data-types.h" #include "glfw-wrapper.h" +#include static void* handle = NULL; diff --git a/glfw/source-info.json b/glfw/source-info.json index ee48cae69..7a3e5800d 100644 --- a/glfw/source-info.json +++ b/glfw/source-info.json @@ -60,7 +60,8 @@ "xkb_glfw.h", "egl_context.h", "osmesa_context.h", - "linux_joystick.h" + "linux_joystick.h", + "null_joystick.h" ], "protocols": [ "stable/xdg-shell/xdg-shell.xml", @@ -78,7 +79,8 @@ "xkb_glfw.c", "egl_context.c", "osmesa_context.c", - "linux_joystick.c" + "linux_joystick.c", + "null_joystick.c" ] }, "wayland_protocols": [ @@ -113,7 +115,9 @@ "posix_thread.h", "glx_context.h", "egl_context.h", - "osmesa_context.h" + "osmesa_context.h", + "linux_joystick.h", + "null_joystick.h" ], "sources": [ "x11_init.c", @@ -124,7 +128,9 @@ "posix_thread.c", "glx_context.c", "egl_context.c", - "osmesa_context.c" + "osmesa_context.c", + "linux_joystick.c", + "null_joystick.c" ] } -} +} \ No newline at end of file diff --git a/kitty/parser.c b/kitty/parser.c index 0776949b9..47a56faa2 100644 --- a/kitty/parser.c +++ b/kitty/parser.c @@ -13,7 +13,7 @@ extern PyTypeObject Screen_Type; // utils {{{ -static uint64_t pow10[] = { +static uint64_t pow10_array[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000 }; @@ -26,9 +26,9 @@ utoi(uint32_t *buf, unsigned int sz) { if (*p == '0') { p++; sz--; } else break; } - if (sz < sizeof(pow10)/sizeof(pow10[0])) { + if (sz < sizeof(pow10_array)/sizeof(pow10_array[0])) { for (int i = sz-1, j=0; i >= 0; i--, j++) { - ans += (p[i] - '0') * pow10[j]; + ans += (p[i] - '0') * pow10_array[j]; } } return ans;