The standard shell behaves very badly if you accidentally
select some BLOB data or excessively long strings.  I recommend
this change:


#define MAX_STRING_SIZE 200

static void cautious_print_string(FILE *f,char *str)
{       char buffer[MAX_STRING_SIZE+3];
        int i;
        int exit = 0;
        for(i=0; !exit && (i<sizeof(buffer)); i++)
        {
        char ch = str[i];
                switch(ch)
                {
                case '\t':
                case '\r':
                case '\n':
                        break;
                case 0: exit=1;
                        break;
                default:
                        if((ch<' ') || (ch>=127)) { ch = '.'; };
                        break;
                }
                buffer[i]=ch;
        }

        if(i>=sizeof(buffer))   // filled the max buffer
        {       i = sizeof(buffer)-1;
                buffer[i--] = 0;
                buffer[i--] = '.';
                buffer[i--] = '.';
                buffer[i--] = '.';
        }
       fprintf(f, "%s", buffer);
}

and substitute

        cautious_print_string(p->out,z);

for the fprintf in the display loop.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to