Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

#321 --skip and --until with fractional part somewhat incorrect

closed-fixed
7
2014-08-20
2007-12-25
ntim
No

flac silently drop fractional part of --skip and --until argument in case of decimal separator (. or ,) not match locale.

In locales with the comma as decimal separator it result in particular to multiple failures in test_flac.sh (bug: [ 1815517 ] "test_flac.sh makes locale assumptions").

In locales with the point as decimal separator it result for example to --skip 0:1,99 behave like --skip 0:1 with no warnings.

It seems that bug in local__parse_timecode_() function in src/utils.c:

74 /* parse [0-9]*[.,]?[0-9]* i.e. a sign-less rational number (. or , OK for fractional seconds, to support different locales) */
75 if(strspn(s, "1234567890.,") != strlen(s))
76 return false;
77 {
78 const char *p = strpbrk(s, ".,");
79 if(p && 0 != strpbrk(++p, ".,"))
80 return false;
81 }
82 ret += atof(s);

-- check on line 75 assume either '.' or ',' is OK, but later locale-dependant atof() on line 82 silently drop locale-incorrect fractional part!

Using atol() and simple pass around instead of atof() may solve the problem:

74 /* parse [0-9]*[.,]?[0-9]* i.e. a sign-less rational number (. or , OK for fractional seconds, to support different locales) */
75 if(strspn(s, "1234567890.,") != strlen(s))
76 return false;
77 {
78 const char *p = strpbrk(s, ".,");
79 if(p) {
if ( 0 != strpbrk(++p, ".,"))
80 return false;
long l=10;
while (0 != *p) {
ret += ((double)( *p - '0' )) / l;
l *= 10;
p++;
}
}
81 }
82 ret += atol(s);

Best wishes,
ntim

Discussion

  • Josh Coalson

    Josh Coalson - 2009-01-02
    • priority: 5 --> 7
    • assigned_to: nobody --> jcoalson
    • status: open --> open-accepted
     
  • Josh Coalson

    Josh Coalson - 2009-01-03

    thanks, fixed in cvs

     
  • Josh Coalson

    Josh Coalson - 2009-01-03
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.