MCPcopy Create free account
hub / github.com/Kitware/VTK / resolve_backslashes

Function resolve_backslashes

ThirdParty/sqlite/vtksqlite/shell.c:25754–25805  ·  view source on GitHub ↗

** Do C-language style dequoting. ** ** \a -> alarm ** \b -> backspace ** \t -> tab ** \n -> newline ** \v -> vertical tab ** \f -> form feed ** \r -> carriage return ** \s -> space ** \" -> " ** \' -> ' ** \\ -> backslash ** \NNN -> ascii character NNN in octal ** \xHH -> ascii character HH in hexadecimal */

Source from the content-addressed store, hash-verified

25752** \xHH -> ascii character HH in hexadecimal
25753*/
25754static void resolve_backslashes(char *z){
25755 int i, j;
25756 char c;
25757 while( *z && *z!='\\' ) z++;
25758 for(i=j=0; (c = z[i])!=0; i++, j++){
25759 if( c=='\\' && z[i+1]!=0 ){
25760 c = z[++i];
25761 if( c=='a' ){
25762 c = '\a';
25763 }else if( c=='b' ){
25764 c = '\b';
25765 }else if( c=='t' ){
25766 c = '\t';
25767 }else if( c=='n' ){
25768 c = '\n';
25769 }else if( c=='v' ){
25770 c = '\v';
25771 }else if( c=='f' ){
25772 c = '\f';
25773 }else if( c=='r' ){
25774 c = '\r';
25775 }else if( c=='"' ){
25776 c = '"';
25777 }else if( c=='\'' ){
25778 c = '\'';
25779 }else if( c=='\\' ){
25780 c = '\\';
25781 }else if( c=='x' ){
25782 int nhd = 0, hdv;
25783 u8 hv = 0;
25784 while( nhd<2 && (c=z[i+1+nhd])!=0 && (hdv=hexDigitValue(c))>=0 ){
25785 hv = (u8)((hv<<4)|hdv);
25786 ++nhd;
25787 }
25788 i += nhd;
25789 c = (u8)hv;
25790 }else if( c>='0' && c<='7' ){
25791 c -= '0';
25792 if( z[i+1]>='0' && z[i+1]<='7' ){
25793 i++;
25794 c = (c<<3) + z[i] - '0';
25795 if( z[i+1]>='0' && z[i+1]<='7' ){
25796 i++;
25797 c = (c<<3) + z[i] - '0';
25798 }
25799 }
25800 }
25801 }
25802 z[j] = c;
25803 }
25804 if( j<i ) z[j] = 0;
25805}
25806
25807/*
25808** Interpret zArg as either an integer or a boolean value. Return 1 or 0

Callers 2

do_meta_commandFunction · 0.85
runOneSqlLineFunction · 0.85

Calls 1

hexDigitValueFunction · 0.85

Tested by

no test coverage detected