http://en.wikipedia.org/wiki/Brainfuck
char *
OrgUnit::formatSql(char *iStr) {
char *rSql = new char[1024];
char *str = iStr;
strcpy(rSql,sqlInsPrefix);
char *ptr = rSql+strlen(rSql);
*ptr++ = '\'';
int iCnt = 1;
while( (*str != NULL) && iCnt <= 5 ) {
switch(*str) {
case '\'':
str++;
break;
case ',':
iCnt++;
str++;
break;
default:
*ptr = *str;
ptr++;
str++;
break;
}
}
*ptr++ = '\'';
*ptr++ = ',';
*ptr++ = '\0';
strcat(rSql,iStr);
switch(iCnt) {
case 1:
strcat(rSql,",\'\',\'\',\'\'");
break;
case 2:
strcat(rSql,",\'\',\'\'");
break;
case 3:
strcat(rSql,",\'\'");
break;
default:
break;
}
strcat(rSql,sqlInsPostfix);
return rSql;
}
沒有留言:
張貼留言