Overview
| Artifact ID: | 3599ceec6edc4cc0f9d4fa7573549aea95b5b0bfd0f4a5082cac14252aa853ba |
|---|---|
| Ticket: | 85b7226da1ecf6194342f802ff4361bfc75b8a34
scan of data containing 0x, 0b treated differently to 0d,0o |
| User & Date: | griffin 2023-09-21 17:10:44 |
Changes
- icomment:
The scan man page states that scan functions "... in a fashion similar to the ANSI C sscanf procedure ...", with a few explicitly identified exceptions. With this in mind, I conclude that the scan is functioning as designed, matching C's sscanf behavior as shown in these results: ``` usage: ./cscan <string-value> <format-string> <value-type:(i|b|d|f|c)> Uninitialized variables have value of -777, -7.77, or "BAAD" sscanf("0o110", "%o%s", &i, &remainder) -> returned 2, results i=0 remainder="o110" scan "0o110" "%o%s" i remainder -> returned 2, results i=0 remainder="o110" sscanf("0d110", "%d%s", &i, &remainder) -> returned 2, results i=0 remainder="d110" scan "0d110" "%d%s" i remainder -> returned 2, results i=0 remainder="d110" sscanf("0x110", "%x%s", &i, &remainder) -> returned 1, results i=272 remainder="BAAD" scan "0x110" "%x%s" i remainder -> returned 1, results i=272 remainder="BAAD" sscanf("0b110", "%b%s", &i, &remainder) -> returned 0, results i=-777 remainder="BAAD" scan "0b110" "%b%s" i remainder -> returned 1, results i=6 remainder="BAAD" sscanf("true", "%b%s", &i, &remainder) -> returned 0, results i=-777 remainder="BAAD" scan "true" "%b%s" i remainder -> returned 0, results i=-777 remainder="BAAD" sscanf("0", "%b%s", &i, &remainder) -> returned 0, results i=-777 remainder="BAAD" scan "0" "%b%s" i remainder -> returned 1, results i=0 remainder="BAAD" sscanf("0110", "%o%s", &i, &remainder) -> returned 1, results i=72 remainder="BAAD" scan "0110" "%o%s" i remainder -> returned 1, results i=72 remainder="BAAD" sscanf("110", "%o%s", &i, &remainder) -> returned 1, results i=72 remainder="BAAD" scan "110" "%o%s" i remainder -> returned 1, results i=72 remainder="BAAD" sscanf("110", "%i%s", &i, &remainder) -> returned 1, results i=110 remainder="BAAD" scan "110" "%i%s" i remainder -> returned 1, results i=110 remainder="BAAD" sscanf("110.3ms", "%lg%s", &d, &remainder) -> returned 2, results d=110.300000 remainder="ms" scan "110.3ms" "%lg%s" d remainder -> returned 2, results d=110.3 remainder="ms" sscanf("0d10", "%x%s", &i, &remainder) -> returned 1, results i=3344 remainder="BAAD" scan "0d10" "%x%s" i remainder -> returned 1, results i=3344 remainder="BAAD" sscanf("0b10", "%x%s", &i, &remainder) -> returned 1, results i=2832 remainder="BAAD" scan "0b10" "%x%s" i remainder -> returned 1, results i=2832 remainder="BAAD" sscanf("0x10", "%x%s", &i, &remainder) -> returned 1, results i=16 remainder="BAAD" scan "0x10" "%x%s" i remainder -> returned 1, results i=16 remainder="BAAD" ``` See the attached files to reproduce these results. I am closing this as "wont fixed", works as intended. - login: "griffin"
- mimetype: "text/x-markdown"