/ Check-in [132ea4e5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed the 80-char line formatting for ErrorMsg(), on dhr's suggestion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lemon-update-2010
Files: files | file ages | folders
SHA1: 132ea4e5d7f69fc307904f5086a72d8532e5aac6
User & Date: icculus 2010-02-15 00:01:04
Context
2010-02-16
16:07
Patched to compile. Accidentally removed va_list declaration. check-in: 673d470c user: icculus tags: lemon-update-2010
2010-02-15
00:01
Removed the 80-char line formatting for ErrorMsg(), on dhr's suggestion. check-in: 132ea4e5 user: icculus tags: lemon-update-2010
2010-02-14
17:14
Make Lemon able to compile as C++ code. check-in: 75a1060b user: icculus tags: lemon-update-2010
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tool/lemon.c.

1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
....
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
  return;
}
/***************** From the file "error.c" *********************************/
/*
** 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;
    }
  }
}
/**************** From the file "main.c" ************************************/
/*
** Main program file for the LEMON parser generator.
*/

/* Report an out-of-memory condition and abort.  This function
................................................................................
  static int compress = 0;
  static int quiet = 0;
  static int statistics = 0;
  static int mhflag = 0;
  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."},
    {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
    {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."},
    {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."},
    {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<
<
<
<
<
<
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<







1336
1337
1338
1339
1340
1341
1342



























1343









1344
1345
1346
1347
1348






























1349
1350
1351
1352
1353
1354
1355
....
1403
1404
1405
1406
1407
1408
1409

1410
1411
1412
1413
1414
1415
1416
  return;
}
/***************** From the file "error.c" *********************************/
/*
** Code for printing error message.
*/




























void ErrorMsg(const char *filename, int lineno, const char *format, ...){









  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" ************************************/
/*
** Main program file for the LEMON parser generator.
*/

/* Report an out-of-memory condition and abort.  This function
................................................................................
  static int compress = 0;
  static int quiet = 0;
  static int statistics = 0;
  static int mhflag = 0;
  static int nolinenosflag = 0;
  static struct s_options options[] = {
    {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."},

    {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."},
    {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
    {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."},
    {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."},
    {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},