[llvm-commits] [llvm] r46455 - /llvm/trunk/lib/Support/FileUtilities.cpp

Evan Cheng evan.cheng at apple.com
Mon Jan 28 10:56:58 PST 2008


On Jan 28, 2008, at 10:23 AM, Lauro Ramos Venancio wrote:

> Author: laurov
> Date: Mon Jan 28 12:23:23 2008
> New Revision: 46455
>
> URL: http://llvm.org/viewvc/llvm-project?rev=46455&view=rev
> Log:
> Fix fpcmp infinite loop when comparing "29-266" with "29-268".
>
>
> Modified:
>    llvm/trunk/lib/Support/FileUtilities.cpp
>
> Modified: llvm/trunk/lib/Support/FileUtilities.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileUtilities.cpp?rev=46455&r1=46454&r2=46455&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Support/FileUtilities.cpp (original)
> +++ llvm/trunk/lib/Support/FileUtilities.cpp Mon Jan 28 12:23:23 2008
> @@ -20,11 +20,15 @@
> #include <cctype>
> using namespace llvm;
>
> -static bool isNumberChar(char C) {
> +static bool isSignedChar(char C) {
> +  if (C == '+' || C == '-')
> +    return true;
> +  else
> +    return false;
> +}

How about just
   return (C == '+' || C == '-');

Thanks.

Evan

>
> +
> +static bool isExpoentChar(char C) {
>   switch (C) {
> -  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':
> @@ -33,13 +37,25 @@
>   }
> }
>
> +static bool isNumberChar(char C) {
> +  switch (C) {
> +  case '0': case '1': case '2': case '3': case '4':
> +  case '5': case '6': case '7': case '8': case '9':
> +  case '.': return true;
> +  default: return isSignedChar(C) || isExpoentChar(C);
> +  }
> +}
> +
> static char *BackupNumber(char *Pos, char *FirstChar) {
>   // If we didn't stop in the middle of a number, don't backup.
>   if (!isNumberChar(*Pos)) return Pos;
>
>   // Otherwise, return to the start of the number.
> -  while (Pos > FirstChar && isNumberChar(Pos[-1]))
> +  while (Pos > FirstChar && isNumberChar(Pos[-1])) {
>     --Pos;
> +    if (Pos > FirstChar && isSignedChar(Pos[0]) && ! 
> isExpoentChar(Pos[-1]))
> +      break;
> +  }
>   return Pos;
> }
>
>
>
> _______________________________________________
> 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