[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp

Reid Spencer reid at x10sys.com
Mon Aug 1 18:15:27 PDT 2005


While I don't know anything about "D", the "d" control character is used for 
signed decimal integers the same as %i. If you pass a float in there to sprintf 
and friends, you're going to get garbage at best and a crash at worst.

Reid.

Chris Lattner wrote:
> Changes in directory llvm/lib/Support:
> 
> FileUtilities.cpp updated: 1.45 -> 1.46
> ---
> Log message:
> 
> 200.sixtrack prints FP numbers with a very strange notation that uses D
> instead of E for exponentials (e.g. 1.234D-43).  Add support for this
> notation.
> 
> 
> 
> ---
> Diffs of the changes:  (+21 -3)
> 
>  FileUtilities.cpp |   24 +++++++++++++++++++++---
>  1 files changed, 21 insertions(+), 3 deletions(-)
> 
> 
> Index: llvm/lib/Support/FileUtilities.cpp
> diff -u llvm/lib/Support/FileUtilities.cpp:1.45 llvm/lib/Support/FileUtilities.cpp:1.46
> --- llvm/lib/Support/FileUtilities.cpp:1.45	Thu Apr 21 17:52:05 2005
> +++ llvm/lib/Support/FileUtilities.cpp	Mon Aug  1 19:11:53 2005
> @@ -26,6 +26,8 @@
>    case '0': case '1': case '2': case '3': case '4':
>    case '5': case '6': case '7': case '8': case '9':
>    case '.': case '+': case '-':
> +  case 'D':  // Strange exponential notation.
> +  case 'd':  // Strange exponential notation.
>    case 'e':
>    case 'E': return true;
>    default: return false;
> @@ -56,10 +58,26 @@
>    while (isspace(*F2P) && F2P != F2End)
>      ++F2P;
>  
> -  // If we stop on numbers, compare their difference.
> +  // If we stop on numbers, compare their difference.  Note that some ugliness
> +  // is built into this to permit support for numbers that use "D" or "d" as
> +  // their exponential marker, e.g. "1.234D45".  This occurs in 200.sixtrack in
> +  // spec2k.
>    if (isNumberChar(*F1P) && isNumberChar(*F2P)) {
> -    V1 = strtod(F1P, &F1NumEnd);
> -    V2 = strtod(F2P, &F2NumEnd);
> +    bool isDNotation;
> +    do {
> +      isDNotation = false;
> +      V1 = strtod(F1P, &F1NumEnd);
> +      V2 = strtod(F2P, &F2NumEnd);
> +
> +      if (*F1NumEnd == 'D' || *F1NumEnd == 'd') {
> +        *F1NumEnd = 'e';  // Strange exponential notation!
> +        isDNotation = true;
> +      }
> +      if (*F2NumEnd == 'D' || *F2NumEnd == 'd') {
> +        *F2NumEnd = 'e';  // Strange exponential notation!
> +        isDNotation = true;
> +      }
> +    } while (isDNotation);
>    } else {
>      // Otherwise, the diff failed.
>      F1NumEnd = F1P;
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 




More information about the llvm-commits mailing list