llvm.org GIT mirror llvm / 9bd3460
Move UnescapeString to a static function for its sole client; its inefficient and broken. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84358 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
3 changed file(s) with 23 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
216216 std::vector &OutFragments,
217217 const char *Delimiters = " \t\n\v\f\r");
218218
219 /// UnescapeString - Modify the argument string, turning two character sequences
220 /// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and
221 /// \num (where num is a 1-3 byte octal value).
222 void UnescapeString(std::string &Str);
223
224219 /// HashString - Hash funtion for strings.
225220 ///
226221 /// This is the Bernstein hash function.
5555 S2 = getToken(S, Delimiters);
5656 }
5757 }
58
59
60
61 /// UnescapeString - Modify the argument string, turning two character sequences
62 /// @verbatim
63 /// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \ and
64 /// \num (where num is a 1-3 byte octal value).
65 /// @endverbatim
66 void llvm::UnescapeString(std::string &Str) {
67 for (unsigned i = 0; i != Str.size(); ++i) {
68 if (Str[i] == '\\' && i != Str.size()-1) {
69 switch (Str[i+1]) {
70 default: continue; // Don't execute the code after the switch.
71 case 'a': Str[i] = '\a'; break;
72 case 'b': Str[i] = '\b'; break;
73 case 'e': Str[i] = 27; break;
74 case 'f': Str[i] = '\f'; break;
75 case 'n': Str[i] = '\n'; break;
76 case 'r': Str[i] = '\r'; break;
77 case 't': Str[i] = '\t'; break;
78 case 'v': Str[i] = '\v'; break;
79 case '"': Str[i] = '\"'; break;
80 case '\'': Str[i] = '\''; break;
81 case '\\': Str[i] = '\\'; break;
82 }
83 // Nuke the second character.
84 Str.erase(Str.begin()+i+1);
85 }
86 }
87 }
537537 }
538538
539539
540 static void UnescapeString(std::string &Str) {
541 for (unsigned i = 0; i != Str.size(); ++i) {
542 if (Str[i] == '\\' && i != Str.size()-1) {
543 switch (Str[i+1]) {
544 default: continue; // Don't execute the code after the switch.
545 case 'a': Str[i] = '\a'; break;
546 case 'b': Str[i] = '\b'; break;
547 case 'e': Str[i] = 27; break;
548 case 'f': Str[i] = '\f'; break;
549 case 'n': Str[i] = '\n'; break;
550 case 'r': Str[i] = '\r'; break;
551 case 't': Str[i] = '\t'; break;
552 case 'v': Str[i] = '\v'; break;
553 case '"': Str[i] = '\"'; break;
554 case '\'': Str[i] = '\''; break;
555 case '\\': Str[i] = '\\'; break;
556 }
557 // Nuke the second character.
558 Str.erase(Str.begin()+i+1);
559 }
560 }
561 }
562
540563 /// EmitPrintInstruction - Generate the code for the "printInstruction" method
541564 /// implementation.
542565 void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {