Exemple #1
0
/*
 * Function: manualCase()
 * --------------------
 * THis function takes the user input for a manual case and checks to make sure that the
 * input string will product a valid board
 *
 * Preconditions:
 *
 *  @param: word: the word to check
 *  @return: boolean true if valid word
 */
string manualCase() {
    string manualString;
    bool reloopFlag = true;

    while(reloopFlag){
        manualString = getLine("Type the 16 letters to appear on the board:");

        if((manualString.length())==boardSize) {
            reloopFlag = false;

            for(int i=0;i<manualString.length();i++){
                if(stringIsInteger(manualString.substr(i,i))) {
                        reloopFlag=true;
                        break;
                } else {
                    reloopFlag = false;
                }
            }
        }

        if(reloopFlag) {
            cout << "That is not a valid 16-letter board string. Try again." << endl;
        }
        else {
            break;
        }
    }
    return manualString;
}
// line = "ZNK6VectorIiE3getEi at vector.h:587"
//         <FUNCTION> at <LINESTR>
void injectAddr2lineInfo(entry& ent, const std::string& line) {
    ent.line     = 0;
    int atIndex = stringIndexOf(line, " at ");
    if (atIndex >= 0) {
        if (ent.function.empty()) {
            ent.function = line.substr(0, atIndex);
        }
        ent.lineStr  = line.substr(atIndex + 4);

        int colonIndex = stringIndexOf(ent.lineStr, ":");
        if (colonIndex >= 0) {
            ent.file = ent.lineStr.substr(0, colonIndex);
            std::string rest = ent.lineStr.substr(colonIndex + 1);
            if (stringIsInteger(rest)) {
                ent.line = stringToInteger(rest);
            }
        }
    } else {
        if (ent.function.empty()) {
            ent.function = line;
        }
    }

    // demangle function name if necessary
    if (startsWith(ent.function, "Z")) {
        ent.function = "_" + ent.function;
    }

    if (startsWith(ent.function, "_Z")) {
        int status;
        char* demangled = abi::__cxa_demangle(ent.function.c_str(), NULL, 0, &status);
        if (status == 0 && demangled) {
            ent.function = demangled;
        }
    }
}