-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.cpp
More file actions
79 lines (72 loc) · 1.47 KB
/
Copy pathutility.cpp
File metadata and controls
79 lines (72 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <string>
#include <cstdlib>
#include <iostream>
#include "utility.h"
#include "lexer.h"
#include <sstream>
using namespace std;
void error(string msg)
{
cerr<<msg<<endl;
exit(-1);
return;
}
string IntToString(int number)
{
stringstream ss;
ss << number;
return ss.str();
}
string escape_str(string str){
string escaped=str;
int result;
//改行
while(true){
result=escaped.find("\\n",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\n");
}
//¥
while(true){
result=escaped.find("\\\\",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\\");
}
//水平タブ
while(true){
result=escaped.find("\\t",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\t");
}
//垂直タブ
while(true){
result=escaped.find("\\v",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\v");
}
//バックスペース
while(true){
result=escaped.find("\\b",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\b");
}
//シングルクォーテーション
while(true){
result=escaped.find("\\\'",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\'");
}
//ダブルクォーテーション
while(true){
result=escaped.find("\\\"",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\"");
}
//ベル文字
while(true){
result=escaped.find("\\a",0);
if(result==string::npos){break;}
escaped.replace(result,2,"\a");
}
return escaped;
}