1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Removed the 80-char line formatting for ErrorMsg(), on dhr's suggestion.

FossilOrigin-Name: 132ea4e5d7f69fc307904f5086a72d8532e5aac6
This commit is contained in:
icculus
2010-02-15 00:01:04 +00:00
parent 9e44cf1a03
commit 1c11f74a8a
3 changed files with 25 additions and 92 deletions

View File

@ -1340,78 +1340,12 @@ void Configlist_eat(struct config *cfp)
** Code for printing error message.
*/
/* Find a good place to break "msg" so that its length is at least "min"
** but no more than "max". Make the point as close to max as possible.
*/
static int findbreak(char *msg, int min, int max)
{
int i,spot;
char c;
for(i=spot=min; i<=max; i++){
c = msg[i];
if( c=='\t' ) msg[i] = ' ';
if( c=='\n' ){ msg[i] = ' '; spot = i; break; }
if( c==0 ){ spot = i; break; }
if( c=='-' && i<max-1 ) spot = i+1;
if( c==' ' ) spot = i;
}
return spot;
}
/*
** The error message is split across multiple lines if necessary. The
** splits occur at a space, if there is a space available near the end
** of the line.
*/
#define ERRMSGSIZE 10000 /* Hope this is big enough. No way to error check */
#define LINEWIDTH 79 /* Max width of any output line */
#define PREFIXLIMIT 30 /* Max width of the prefix on each line */
static int noerrorclipping = 0;
void ErrorMsg(const char *filename, int lineno, const char *format, ...){
char errmsg[ERRMSGSIZE];
char prefix[PREFIXLIMIT+10];
int errmsgsize;
int prefixsize;
int availablewidth;
va_list ap;
int end, restart, base;
if( noerrorclipping ) {
fprintf(stderr, "%s:%d: ", filename, lineno);
va_start(ap, format);
vfprintf(stderr,format,ap);
va_end(ap);
fprintf(stderr, "\n");
}else{
va_start(ap, format);
/* Prepare a prefix to be prepended to every output line */
if( lineno>0 ){
sprintf(prefix,"%.*s:%d: ",PREFIXLIMIT-10,filename,lineno);
}else{
sprintf(prefix,"%.*s: ",PREFIXLIMIT-10,filename);
}
prefixsize = lemonStrlen(prefix);
availablewidth = LINEWIDTH - prefixsize;
/* Generate the error message */
vsprintf(errmsg,format,ap);
va_end(ap);
errmsgsize = lemonStrlen(errmsg);
/* Remove trailing '\n's from the error message. */
while( errmsgsize>0 && errmsg[errmsgsize-1]=='\n' ){
errmsg[--errmsgsize] = 0;
}
/* Print the error message */
base = 0;
while( errmsg[base]!=0 ){
end = restart = findbreak(&errmsg[base],0,availablewidth);
restart += base;
while( errmsg[restart]==' ' ) restart++;
fprintf(stdout,"%s%.*s\n",prefix,end,&errmsg[base]);
base = restart;
}
}
fprintf(stderr, "%s:%d: ", filename, lineno);
va_start(ap, format);
vfprintf(stderr,format,ap);
va_end(ap);
fprintf(stderr, "\n");
}
/**************** From the file "main.c" ************************************/
/*
@ -1473,7 +1407,6 @@ int main(int argc, char **argv)
static int nolinenosflag = 0;
static struct s_options options[] = {
{OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."},
{OPT_FLAG, "e", (char*)&noerrorclipping, "Don't clip error output."},
{OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
{OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
{OPT_FSTR, "T", (char*)handle_T_option, "Specify a template file."},