[Lldb-commits] [Bug 8262] New: String to Octal conversion

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 30 14:18:29 PDT 2010


           Summary: String to Octal conversion
           Product: lldb
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: lldb-commits at cs.uiuc.edu
        ReportedBy: wlynch at wlynch.cx

Created an attachment (id=5543)
 --> (http://llvm.org/bugs/attachment.cgi?id=5543)
The referenced patch


In source/Core/Debugger.cpp, there is a piece of code which takes a string
containing an octal number ("01231" for example), and returns it as an integer.
This code currently does not work properly due to order of operations.

Within a for loop, iterating over characters, this currently happens:

octal_value = octal_value << 3 + (((uint8_t)*p) - '0');

The problem, however, is that it computes (3 + *p - '0') to shift with.
Instead, we'd like to shift by 3, and then add (*p - '0'). I've written this

octal_value = octal_value * 8 + (((uint8_t)*p) - '0');

The attached patch implements this.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the lldb-commits mailing list