Subject: bug#49271: 28.0.50: native-comp: Signing macOS self-contained .app bundle fails due to new *.eln location

From: Eli Zaretskii <[email-masked]>
Date: Thu, 01 Jul 2021 10:13:04 +0300

> Date: Wed, 30 Jun 2021 20:05:50 +0100
> From: Alan Third <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> 
> Eli, is this an acceptable way of modifying a lisp string, or is there
> a better way?
> [...]
> +#ifdef NS_SELF_CONTAINED
> +  /* MacOS self contained app bundles do not like having dots in the
> +     directory names under the Contents/Frameworks directory, so
> +     convert them to underscores.  */
> +
> +  char *str = xstrdup (SSDATA(version));
> +
> +  for (ptrdiff_t c = 0 ; c < SBYTES (version) ; c++)
> +    if (*(str + c) == '.')
> +      *(str + c) = '_';
> +
> +  version = build_string (str);
> +  xfree (str);
> +#endif

It should work, although I'd prefer writing such code the other way
around: first create an uninitialized Lisp string (with
make_uninit_multibyte_string or make_uninit_string), then copy the
bytes while making the conversions.  The reason for this preference is
that you could then make sure the produced string has the same
multibyte-ness as the original, whereas the way you did it relies on
whatever build_string decides, which is not necessarily the same.

Thanks.