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

Bug#858866: libc6-dev: improve documentation for strchrnul



Package: libc6-dev
Version: 2.24-9
Severity: normal

Dear Maintainer,

See this code:

#include <stdio.h>
#define _GNU_SOURCE
#include <string.h>
int main() {
    const char * filename = "cia<o.txt ";
    const char *ptr = filename + strlen(filename);

    char *pos = strchrnul(filename, (int)'<');
    if (pos < ptr)
        ptr = pos;
    printf("%d\n", ptr == filename + strlen(filename));
}

It doesn't work because the _GNU_SOURCE define happens after an include.

The man page for strchrnul only specifies to define it before the string.h
include, but probably it would be best to mention that it needs to be before
any include, otherwise it's just undefined behaviour.

-- System Information:
Debian Release: 9.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libc6-dev depends on:
ii  libc-dev-bin    2.24-9
ii  libc6           2.24-9
ii  linux-libc-dev  4.9.16-1

libc6-dev recommends no packages.

Versions of packages libc6-dev suggests:
pn  glibc-doc     <none>
ii  manpages-dev  4.09-2

-- no debconf information


Reply to: