Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pure Python code for scanf #166

Merged
merged 5 commits into from
Mar 29, 2024
Merged

Use pure Python code for scanf #166

merged 5 commits into from
Mar 29, 2024

Conversation

olebole
Copy link
Member

@olebole olebole commented Mar 18, 2024

The sscanf module is the only module that needs to be compiled on macOS, and this module requires to have a C compiler installed (or to build wheels) to install PyRAF there. To simplify this, we switch to pure Python for the scanf module.

The module is taken from joshburnett/scanf and modified to behave similarly to the sscanf C module. The only major difference is the missing "n" format switch, which gives the number of characters read in so far. Not sure if this is ever needed.

Compared with the CL scanf documentation, the new Python module is compliant (except for the h modifier, which was also not in the old C module):

A field format specification has the form "%[][W][lh]C", where '' indicates the field should be skipped, W is the field width, 'l' indicates longword output, 'h' indicates halfword output, and C is the format code. The format codes C are as follows:

c    single character (c or '\c' or '\0nnn')
d    decimal integer
e    exponential format
f    fixed format
g    general format
o    octal integer
s    string
x    hexadecimal integer

@olebole olebole changed the title Use Python code for scanf Use pure Python code for scanf Mar 18, 2024
@olebole olebole merged commit 80939c3 into main Mar 29, 2024
5 checks passed
@olebole olebole deleted the python-scanf branch March 29, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant