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

hts_str2dbl() (and hts_expr) can't parse hex by default on Illumos/OpenIndiana #1251

Open
jmarshall opened this issue Mar 9, 2021 · 0 comments
Assignees

Comments

@jmarshall
Copy link
Member

jmarshall commented Mar 9, 2021

This affects hts_expr and causes test/test_expr failures (e.g., for 16==0x10) as that uses hts_str2dbl() to parse integer hex constants. This is because hts_str2dbl() uses strtod() to parse hex constants like 0x10, and on Illumos,

In default mode for strtod(), only decimal, INF/INFINITY, and NAN/NAN(n-char-sequence) forms are recognized. In C99/SUSv3 mode, hexadecimal strings are also recognized.

So by default 0x10 returns 0.0 and leaves the trailing x10 unread.

Fortunately this problem is limited to Illumos. It can be worked around / solved by one of:

  1. Ensuring C99/SUSv3 mode by configuring with CC=c99 or CC='cc -xc99'. (See xpg6.h for the gritty details.)
  2. Reworking hts_str2dbl() to use a different standard library function (e.g. strtol()) to parse integer or hex constants.

Because the problem is limited to this platform only, and because workaround (1) is available (and can be automated in configure in future), there's probably no need to rework the code to avoid using strtod(). (So this issue can serve as information for any Illumos HTSlib users out there!)

@daviesrob daviesrob self-assigned this Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants