test subdirectory
This commit is contained in:
parent
b4dbce76cf
commit
bf7f456967
31 changed files with 19 additions and 13 deletions
34
test/old/escape.c
Normal file
34
test/old/escape.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
int getchar();
|
||||
int putchar(int ch);
|
||||
int fprintf(void* file, char* format, ...);
|
||||
extern void* stdout;
|
||||
|
||||
|
||||
int main() {
|
||||
char ch = 0["\t\r\""];;
|
||||
while ((ch = getchar()) != -1) {
|
||||
if (ch == '\\') {
|
||||
ch = getchar();
|
||||
if (ch == 'n') {
|
||||
ch = '\n';
|
||||
} else if (ch == 't') {
|
||||
ch = '\t';
|
||||
} else if (ch == 'r') {
|
||||
ch = '\r';
|
||||
} else if (ch == '0') {
|
||||
ch = '\0';
|
||||
} else if (ch == '\\') {
|
||||
ch = '\\';
|
||||
} else if (ch == '\'') {
|
||||
ch = '\'';
|
||||
} else if (ch == '\"') {
|
||||
ch = '\"';
|
||||
} else {
|
||||
fprintf(stdout, "unexpected escaped character: '\\%c'\n", ch);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
putchar(ch);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue