diff mbox series

[2/2] libiberty/reconcat: Add note about append string to NULL

Message ID 20231218034422.2668628-2-syq@gcc.gnu.org
State New
Headers show
Series [1/2] MIPS: host_detect_local_cpu, init ret with concat [PR112759] | expand

Commit Message

YunQiang Su Dec. 18, 2023, 3:44 a.m. UTC
For reconcat, if the `optr` can only be used as the last one
of string list, aka, we cannot append something to it.
Let's add some note into the document.

libiberty:
	* concat.c (reconcat): Add note about append string to NULL
	into document.
---
 libiberty/concat.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jakub Jelinek Dec. 18, 2023, 7:56 a.m. UTC | #1
On Mon, Dec 18, 2023 at 11:44:22AM +0800, YunQiang Su wrote:
> For reconcat, if the `optr` can only be used as the last one
> of string list, aka, we cannot append something to it.
> Let's add some note into the document.
> 
> libiberty:
> 	* concat.c (reconcat): Add note about append string to NULL
> 	into document.
> ---
>  libiberty/concat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libiberty/concat.c b/libiberty/concat.c
> index 4cb1df3baf3..3a6b4ca71e8 100644
> --- a/libiberty/concat.c
> +++ b/libiberty/concat.c
> @@ -169,6 +169,9 @@ loop:
>    str = reconcat (str, "pre-", str, NULL);
>  @end example
>  
> +Note: don't try to append string(s) to the a NULL string,
> +as the process will stop at the first NULL argument.
> +
>  @end deftypefn

I think this is unnecessary and misleading.
The fact that NULL is the variable argument terminator is already clearly
documented, and first argument to reconcat can be NULL just fine,
so one just needs to be careful.

	Jakub
diff mbox series

Patch

diff --git a/libiberty/concat.c b/libiberty/concat.c
index 4cb1df3baf3..3a6b4ca71e8 100644
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -169,6 +169,9 @@  loop:
   str = reconcat (str, "pre-", str, NULL);
 @end example
 
+Note: don't try to append string(s) to the a NULL string,
+as the process will stop at the first NULL argument.
+
 @end deftypefn
 
 */