mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-21 19:51:27 +00:00
Lemon update 2010-02-15 00:01:04 on branch lemon-update-2010
- Removed the 80-char line formatting for ErrorMsg(), on dhr's suggestion. (user: icculus)
This commit is contained in:
parent
2e8d5e763b
commit
031cebb138
1 changed files with 7 additions and 62 deletions
|
@ -1332,81 +1332,26 @@ 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 */
|
||||
#if _MSC_VER
|
||||
#define LINEWIDTH 10000 /* Max width of any output line */
|
||||
#else
|
||||
#define LINEWIDTH 79 /* Max width of any output line */
|
||||
#endif
|
||||
#define PREFIXLIMIT 3000 /* Max width of the prefix on each line */
|
||||
void ErrorMsg(const char *filename, int lineno, const char *format, ...){
|
||||
char errmsg[ERRMSGSIZE];
|
||||
char prefix[PREFIXLIMIT+10];
|
||||
size_t errmsgsize;
|
||||
size_t prefixsize;
|
||||
size_t availablewidth;
|
||||
va_list ap;
|
||||
int end, restart, base;
|
||||
|
||||
va_start(ap, format);
|
||||
/* Prepare a prefix to be prepended to every output line */
|
||||
#if _MSC_VER
|
||||
if( lineno>0 ){
|
||||
sprintf(prefix,"%.*s(%d) : error : ",PREFIXLIMIT-10,filename,lineno);
|
||||
fprintf(stderr,"%s(%d) : error : ",filename,lineno);
|
||||
}else{
|
||||
sprintf(prefix,"%.*s : error : ",PREFIXLIMIT-10,filename);
|
||||
fprintf(stderr,"%s : error : ",filename);
|
||||
}
|
||||
#else
|
||||
if( lineno>0 ){
|
||||
sprintf(prefix,"%.*s:%d: ",PREFIXLIMIT-10,filename,lineno);
|
||||
fprintf(stderr,"%s:%d: ",filename,lineno);
|
||||
}else{
|
||||
sprintf(prefix,"%.*s: ",PREFIXLIMIT-10,filename);
|
||||
fprintf(stderr,"%s: ",filename);
|
||||
}
|
||||
#endif
|
||||
prefixsize = lemonStrlen(prefix);
|
||||
availablewidth = LINEWIDTH - prefixsize;
|
||||
|
||||
/* Generate the error message */
|
||||
vsprintf(errmsg,format,ap);
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr,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, "\n");
|
||||
}
|
||||
/**************** From the file "main.c" ************************************/
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue