Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/regex regerror(3): Allow null errbuf if errbuf_size...



details:   https://anonhg.NetBSD.org/src/rev/3135dd139224
branches:  trunk
changeset: 372267:3135dd139224
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Nov 05 11:33:55 2022 +0000

description:
regerror(3): Allow null errbuf if errbuf_size is zero.

The man page says:

   If errbuf_size is 0, errbuf is ignored but the return value is still
   correct.

POSIX says:

   If errbuf_size is 0, regerror() shall ignore the errbuf argument,
   and return the size of the buffer needed to hold the generated
   string.

   https://pubs.opengroup.org/onlinepubs/9699919799/functions/regerror.html

from enh%google.com@localhost

diffstat:

 lib/libc/regex/regerror.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 2004c06404a6 -r 3135dd139224 lib/libc/regex/regerror.c
--- a/lib/libc/regex/regerror.c Sat Nov 05 10:04:35 2022 +0000
+++ b/lib/libc/regex/regerror.c Sat Nov 05 11:33:55 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: regerror.c,v 1.25 2021/02/26 19:24:47 christos Exp $   */
+/*     $NetBSD: regerror.c,v 1.26 2022/11/05 11:33:55 riastradh Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
@@ -46,7 +46,7 @@
 static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
 __FBSDID("$FreeBSD: head/lib/libc/regex/regerror.c 326025 2017-11-20 19:49:47Z pfg $");
 #endif
-__RCSID("$NetBSD: regerror.c,v 1.25 2021/02/26 19:24:47 christos Exp $");
+__RCSID("$NetBSD: regerror.c,v 1.26 2022/11/05 11:33:55 riastradh Exp $");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -139,7 +139,7 @@
        char convbuf[50];
 
        _DIAGASSERT(errcode != REG_ATOI || preg != NULL);
-       _DIAGASSERT(errbuf != NULL);
+       _DIAGASSERT(errbuf_size == 0 || errbuf != NULL);
 
        if (errcode == REG_ATOI) {
                s = regatoi(preg, convbuf, sizeof convbuf);



Home | Main Index | Thread Index | Old Index