From dfafc08fdea99e6d4a56101fe27205ecbe040757 Mon Sep 17 00:00:00 2001 From: HuntedByTheIRS Date: Thu, 2 Jul 2026 02:09:00 -0400 Subject: [PATCH] refactor(peachmsg): migrate to nullptr, -std=c23; docs: update C references to C23 --- CONTRIBUTING.md | 2 +- Makefile | 2 +- README.md | 2 +- peachmsg/arg.h | 4 ++-- peachmsg/peachmsg.c | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22d91f3..17d97b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,7 @@ PeachWM follows a consistent style throughout the codebase. Please match it. ### Build and Compiler -- The project uses **C11** (`-std=c11`). +- The project uses **C23** (`-std=c23`). - The **Makefile** is POSIX make. Do not introduce autotools, CMake, or meson. - Ensure your code compiles cleanly with `make debug` and `make release` -- CI checks both targets. diff --git a/Makefile b/Makefile index df54515..6654469 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ CFLAGS = `$(PKG_CONFIG) --cflags $(PKGS) wlroots-0.20` \ $(XWAYLAND) -g -Wall -Wextra -Wno-unused-parameter -O2 -std=c23 LDLIBS = `$(PKG_CONFIG) --libs $(PKGS) wlroots-0.20` -lm $(LIBS) -SMSG_CFLAGS = `$(PKG_CONFIG) --cflags wayland-client` -Wall -Wextra -Wno-unused-parameter +SMSG_CFLAGS = `$(PKG_CONFIG) --cflags wayland-client` -Wall -Wextra -Wno-unused-parameter -std=c23 SMSG_LDLIBS = `$(PKG_CONFIG) --libs wayland-client` SCANNER = $(shell $(PKG_CONFIG) --variable=wayland_scanner wayland-scanner) diff --git a/README.md b/README.md index 5c8b535..7fea973 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ PeachWM is maintained by [HuntedByTheIRS](https://github.com/HuntedByTheIRS). - xkbcommon - wayland-protocols (compile-time only) - pkg-config (compile-time only) -- a C compiler (clang recommended) +- a C23 compiler — GCC 14+ or Clang 18+ (clang recommended) Install these (and their `-devel` versions if your distro has separate development packages) and run `make` followed by `doas/sudo make install`, diff --git a/peachmsg/arg.h b/peachmsg/arg.h index 45adfc8..1047709 100644 --- a/peachmsg/arg.h +++ b/peachmsg/arg.h @@ -41,13 +41,13 @@ extern char *argv0; #define ARGNUMF() (brk_ = 1, estrtonum(argv[0], 0, INT_MAX)) -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ +#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == nullptr)?\ ((x), abort(), (char *)0) :\ (brk_ = 1, (argv[0][1] != '\0')?\ (&argv[0][1]) :\ (argc--, argv++, argv[0]))) -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ +#define ARGF() ((argv[0][1] == '\0' && argv[1] == nullptr)?\ (char *)0 :\ (brk_ = 1, (argv[0][1] != '\0')?\ (&argv[0][1]) :\ diff --git a/peachmsg/peachmsg.c b/peachmsg/peachmsg.c index d4f9a5f..0058c9c 100644 --- a/peachmsg/peachmsg.c +++ b/peachmsg/peachmsg.c @@ -98,7 +98,7 @@ peachwm_ipc_output_active(void *data, struct zpeachwm_ipc_output_v2 *peachwm_ipc } if (active) { free(focused_output); - focused_output = NULL; + focused_output = nullptr; if (data) { focused_output = strdup(data); if (!focused_output) @@ -309,7 +309,7 @@ wl_output_name(void *data, struct wl_output *output, const char *name) struct zpeachwm_ipc_output_v2 *peachwm_ipc_output = zpeachwm_ipc_manager_v2_get_output(peachwm_ipc_manager, output); zpeachwm_ipc_output_v2_add_listener(peachwm_ipc_output, &peachwm_ipc_output_listener, - output_name && *output_name ? NULL : strdup(name)); + output_name && *output_name ? nullptr : strdup(name)); } } @@ -354,7 +354,7 @@ global_add(void *data, struct wl_registry *wl_registry, struct wl_output *o = wl_registry_bind( wl_registry, name, &wl_output_interface, WL_OUTPUT_NAME_SINCE_VERSION); - wl_output_add_listener(o, &output_listener, outputs ? &outputs[outputcount] : NULL); + wl_output_add_listener(o, &output_listener, outputs ? &outputs[outputcount] : nullptr); if (!outputs) return; if (outputcount >= outputs_buflen) { outputs_buflen *= 2; @@ -370,7 +370,7 @@ global_add(void *data, struct wl_registry *wl_registry, } else if (strcmp(interface, zpeachwm_ipc_manager_v2_interface.name) == 0) { peachwm_ipc_manager = wl_registry_bind(wl_registry, name, &zpeachwm_ipc_manager_v2_interface, version < 2 ? version : 2); - zpeachwm_ipc_manager_v2_add_listener(peachwm_ipc_manager, &peachwm_ipc_listener, NULL); + zpeachwm_ipc_manager_v2_add_listener(peachwm_ipc_manager, &peachwm_ipc_listener, nullptr); } } @@ -504,7 +504,7 @@ main(int argc, char *argv[]) if (mode & GET && !(oflag || tflag || lflag || Oflag || Tflag || Lflag || Pflag || Fflag || cflag || vflag || mflag || fflag)) oflag = tflag = lflag = cflag = vflag = mflag = fflag = Fflag = 1; - display = wl_display_connect(NULL); + display = wl_display_connect(nullptr); if (!display) die("bad display"); if (Pflag) { @@ -519,7 +519,7 @@ main(int argc, char *argv[]) registry = wl_display_get_registry(display); if (!registry) die("bad registry"); - wl_registry_add_listener(registry, ®istry_listener, NULL); + wl_registry_add_listener(registry, ®istry_listener, nullptr); wl_display_dispatch(display); wl_display_roundtrip(display);