Thanks to John Cummings.
This commit is contained in:
parent
cd37451963
commit
5cdb17983a
94 changed files with 26853 additions and 0 deletions
48
src/cmd/upas/unesc/unesc.c
Normal file
48
src/cmd/upas/unesc/unesc.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* upas/unesc - interpret =?foo?bar?=char?= escapes
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
hex(int c)
|
||||
{
|
||||
if('0' <= c && c <= '9')
|
||||
return c - '0';
|
||||
if('A' <= c && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
if('a' <= c && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
while((c=getchar()) != EOF){
|
||||
if(c == '='){
|
||||
if((c=getchar()) == '?'){
|
||||
while((c=getchar()) != EOF && c != '?')
|
||||
continue;
|
||||
while((c=getchar()) != EOF && c != '?')
|
||||
continue;
|
||||
while((c=getchar()) != EOF && c != '?'){
|
||||
if(c == '='){
|
||||
c = hex(getchar()) << 4;
|
||||
c |= hex(getchar());
|
||||
}
|
||||
putchar(c);
|
||||
}
|
||||
(void) getchar(); /* consume '=' */
|
||||
}else{
|
||||
putchar('=');
|
||||
putchar(c);
|
||||
}
|
||||
}else
|
||||
putchar(c);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue