Changeset 229


Ignore:
Timestamp:
Jun 8, 2011 8:06:25 AM (8 years ago)
Author:
kulshres
Message:

Allow reading octal and hexadecimal numbers in .adolcrc

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/taping.c

    r208 r229  
    406406    FILE *configFile = NULL;
    407407    char inputLine[ADOLC_LINE_LENGTH + 1];
    408     char *pos1 = NULL, *pos2 = NULL, *pos3 = NULL, *pos4 = NULL, *end = NULL;
     408    char *pos1 = NULL, *pos2 = NULL, *pos3 = NULL, *pos4 = NULL, *start = NULL, *end = NULL;
     409    int base;
    409410    long int number = 0;
    410411    char *path = NULL;
     
    454455                            "in .adolcrc ignored!\n");
    455456            } else {
    456                 number = strtol(pos3 + 1, &end, 10);
    457                 if (end == (pos3 + 1)) {
     457                if (*(pos3 + 1) == '0' && (*(pos3 + 2) == 'x' || *(pos3 + 2) == 'X')) {
     458                    start = pos3 + 3;
     459                    base = 16;
     460                } else if (*(pos3 + 1) == '0') {
     461                    start = pos3 + 2;
     462                    base = 8;
     463                } else {
     464                    start = pos3 + 1;
     465                    base = 10;
     466                }
     467                number = strtol(start, &end, base);
     468                if (end == start) {
    458469                    *pos2 = 0;
    459470                    *pos4 = 0;
Note: See TracChangeset for help on using the changeset viewer.