← board

sscanf had no %[...] and no %n

Symptom

char a[16] = "", b[16] = "";
int n = sscanf("abc123", "%[a-z]%[0-9]", a, b);   /* gcc: 2 [abc] [123] */
                                                  /* pxx: 0 []    []    */
int v = 0, consumed = -1;
n = sscanf("42abc", "%d%n", &v, &consumed);       /* gcc: 1 42 2 */
                                                  /* pxx: 1 42 -1 (untouched) */

Both fell into the else break "unsupported conversion" arm.

Why each one is worse than a missing feature

Fix

Both implemented in vsscanf, with the edges the standard actually specifies:

Regression cover

sscanf-scanset-edges and sscanf-percent-n-positions in tools/gcc_diff_probe.sh, both byte-matched against gcc.

Gate

gcc_diff_probe clean on native/i386/arm32/aarch64, gate.sh lib green, c-testsuite 219/0/1.