This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年04月07日 00:19 by py.user, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (8) | |||
|---|---|---|---|
| msg157711 - (view) | Author: py.user (py.user) * | Date: 2012年04月07日 00:19 | |
http://docs.python.org/py3k/library/re.html#simulating-scanf 0[xX][\dA-Fa-f]+ -> (0[xX])?[\dA-Fa-f]+ |
|||
| msg157716 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年04月07日 02:53 | |
The documentation appears to be correct to me. Can you demonstrate your suggestion with some examples? |
|||
| msg157717 - (view) | Author: py.user (py.user) * | Date: 2012年04月07日 03:17 | |
the prefix "0x" is not necessary for the %x specifier in C if the pattern will see "ABC", it will not match with it, but it should match |
|||
| msg157718 - (view) | Author: py.user (py.user) * | Date: 2012年04月07日 03:19 | |
#include <stdio.h>
int main(void)
{
unsigned n;
scanf("%x", &n);
printf("%u\n", n);
return 0;
}
[guest@localhost c]$ .ansi t.c -o t
[guest@localhost c]$ ./t
0xa
10
[guest@localhost c]$ ./t
a
10
[guest@localhost c]$
[guest@localhost c]$ alias .ansi
alias .ansi='gcc -ansi -pedantic -Wall'
[guest@localhost c]$
|
|||
| msg158212 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年04月13日 17:02 | |
I checked Standard C by Plauger & Brodie and as I read it, it agrees with py.user and his C compiler. For stdlib strtol() and strtoul(), the 0x/0X prefixes are accepted but optional for explicit base 16. If base is given as 0, they are accepted and set the base to 16 (which is otherwise 10). Except for %i, Xscanf functions apparently call either of the above with an explicit base, which is 16 for the %x specifiers. |
|||
| msg158310 - (view) | Author: py.user (py.user) * | Date: 2012年04月15日 03:58 | |
the same problem in the %o analog valid strings for the %x specifier of scanf(): "+0xabc" "-0xabc" "+abc" "-abc" valid strings for the %o specifier of scanf(): "+0123" "-0123" "+123" "-123" how to patch the %x specifier: 0[xX][\dA-Fa-f]+ -> [-+]?(0[xX])?[\dA-Fa-f]+ the %o specifier: 0[0-7]* -> [-+]?[0-7]+ |
|||
| msg159588 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年04月29日 08:49 | |
New changeset b26471a2a115 by Ezio Melotti in branch '2.7': #14519: fix the regex used in the scanf example. http://hg.python.org/cpython/rev/b26471a2a115 New changeset e317d651ccf8 by Ezio Melotti in branch '3.2': #14519: fix the regex used in the scanf example. http://hg.python.org/cpython/rev/e317d651ccf8 New changeset 7cc1cddb378d by Ezio Melotti in branch 'default': #14519: merge with 3.2. http://hg.python.org/cpython/rev/7cc1cddb378d |
|||
| msg159589 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2012年04月29日 08:50 | |
Fixed, thanks for the report and the suggestions! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:28 | admin | set | github: 58724 |
| 2012年04月29日 08:50:58 | ezio.melotti | set | status: open -> closed type: enhancement messages: + msg159589 assignee: docs@python -> ezio.melotti resolution: fixed stage: needs patch -> resolved |
| 2012年04月29日 08:49:03 | python-dev | set | nosy:
+ python-dev messages: + msg159588 |
| 2012年04月15日 03:58:31 | py.user | set | messages: + msg158310 |
| 2012年04月13日 17:02:37 | terry.reedy | set | versions:
+ Python 2.7, Python 3.3 nosy: + terry.reedy messages: + msg158212 keywords: + patch, easy stage: needs patch |
| 2012年04月07日 03:19:40 | py.user | set | messages: + msg157718 |
| 2012年04月07日 03:17:38 | py.user | set | messages: + msg157717 |
| 2012年04月07日 02:53:29 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg157716 |
| 2012年04月07日 00:19:55 | py.user | create | |