INFO: The new Git default branch name is "main". Details here: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

Commit f9ec4196 authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Added function convert_escape_sequence()

parent 828c29c6
......@@ -426,6 +426,55 @@ char *read_string_from_file(char *fname) {
}
/* http://stackoverflow.com/questions/17015970/how-does-c-compiler-convert-escape-sequence-to-actual-bytes */
char *convert_escape_sequence(char *in_str) {
char *p=in_str;
size_t len=strlen(in_str);
int num;
int numlen;
while (NULL!=(p=strchr(p,'\\'))) {
numlen=1;
switch (p[1]) {
case '\\':
break;
case 'r':
*p = '\r';
break;
case 'n':
*p = '\n';
break;
case 't':
*p = '\t';
break;
case 'v':
*p = '\v';
break;
case 'a':
*p = '\a';
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
numlen = sscanf(p,"%o",&num);
*p = (char)num;
break;
case 'x':
numlen = sscanf(p,"%x",&num);
*p = (char) num;
break;
}
num = p - in_str + numlen;
p++;
memmove(p,p+numlen,len-num );
}
return in_str;
}
/*
* str_format can contains definition of %s like printf, for example:
......@@ -465,6 +514,8 @@ int fprintf_str_format(FILE *f, char *str_format, char delimiter, MYSQL_ROW *row
p[(i_field*mult)+1] = 0;
}
p = convert_escape_sequence(p);
len = strlen(p);
sub_format = (char *) malloc(sizeof(char)*(len+1));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment