www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21177] New: printf check does not recognize GNU extensions


          Issue ID: 21177
           Summary: printf check does not recognize GNU extensions
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

I have some platform-specific server code (it only runs on Ubuntu / Glibc).
In this code, the `%m` format is used with fscanf:
                 * Special fscanf format tokens:
                 *   - The leading ' ' skips leading white space.
                 *   - %n stores the current position in the input string in
                 *     argument so that
                 *     channel_name.length = name_end - name_start.
                 *   - %m matches a string, stores it in a buffer allocated by
                 *     malloc and stores a pointer to that buffer in the
                 *     argument.
                 *   - [_0-9a-zA-Z-] makes %m match only strings that consist
                 *     the characters '_', '0'-'9', 'a'-'z', 'A'-'Z' or '-',
                 *     which ensures the string is a valid dls channel name.
                n = fscanf(this.stream,
                           " %n%m[_0-9a-zA-Z-]%n %lu %lu".ptr,
                           &name_start, &channel_name, &name_end,
                           &bucket_start, &bucket_offset)

While trying to update to the latest DMD, I get a deprecation message.
From a quick google search, I could find the following extension:
- `%m` for printf => Print output of strerror(errno) (no argument) - `%a` for scanf - `%m` for scanf Note that a "smart" fix would only warn about those when not using `CRuntime_Glibc`. Or just accept that GNU extensions are widespread and let those slide. --
Aug 18 2020