On Thu, Aug 18, 2022 at 10:12:35PM +0600, NRK wrote:
> also changes Layout.symbol to be `char [16]` similar to Monitor.ltsymbol
> this should allow the compiler to emit a warning if the symbol exceeds
> 17 bytes.
> ---
>  config.def.h | 4 ++++
>  dwm.c        | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/config.def.h b/config.def.h
> index a2ac963..f4cd153 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -37,6 +37,10 @@ static const int nmaster     = 1;    /* number of clients 
> in master area */
>  static const int resizehints = 1;    /* 1 means respect size hints in tiled 
> resizals */
>  static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen 
> window */
>  
> +/* NOTE: the symbol must not exceed 15 bytes. also note that a single unicode
> + * character can be multiple bytes long. to properly count the bytes, use:
> + *   $ printf "%s" "(∩`-´)⊃━☆゚.*・。゚" | wc -c
> + */
>  static const Layout layouts[] = {
>       /* symbol     arrange function */
>       { "[]=",      tile },    /* first entry is default */
> diff --git a/dwm.c b/dwm.c
> index 967c9e8..88a7e85 100644
> --- a/dwm.c
> +++ b/dwm.c
> @@ -107,12 +107,12 @@ typedef struct {
>  } Key;
>  
>  typedef struct {
> -     const char *symbol;
> +     const char symbol[16];
>       void (*arrange)(Monitor *);
>  } Layout;
>  
>  struct Monitor {
> -     char ltsymbol[16];
> +     char ltsymbol[sizeof ((Layout *)0)->symbol];
>       float mfact;
>       int nmaster;
>       int num;
> -- 
> 2.35.1
> 
> 

I already said I disagree with the second part of the patch.

-- 
Kind regards,
Hiltjo

Reply via email to