  Show the line number at which a parse error occured

  This patch counts the number of newlines from the start of the source buffer
  whose parse has failed. This will be the line number in a macro or macro file
  where the error was detected. If an error is found in the parsing of the
  NEdit configuration (nedit.rc), the line number is that of the unit being
  parsed, not the whole file.

diff -U6 -r nedit_official nedit_mod
diff -U6 -r nedit_official/source/preferences.c nedit_mod/source/preferences.c
--- nedit_official/source/preferences.c	2006-08-15 23:16:01.000000000 +0200
+++ nedit_mod/source/preferences.c	2006-09-21 00:20:19.252772800 +0200
@@ -5160,35 +5160,44 @@
 int ParseError(Widget toDialog, const char *stringStart, const char *stoppedAt,
 	const char *errorIn, const char *message)
 {
     int len, nNonWhite = 0;
     const char *c;
     char *errorLine;
-    
+    int lineNo = 1;
+
     for (c=stoppedAt; c>=stringStart; c--) {
     	if (c == stringStart)
     	    break;
     	else if (*c == '\n' && nNonWhite >= 5)
     	    break;
     	else if (*c != ' ' && *c != '\t')
     	    nNonWhite++;
     }
+
+    for (; stringStart <= c; ++stringStart) {
+        if (*stringStart == '\n')
+            ++lineNo;
+    }
+
     len = stoppedAt - c + (*stoppedAt == '\0' ? 0 : 1);
     errorLine = XtMalloc(len+4);
     strncpy(errorLine, c, len);
     errorLine[len++] = '<';
     errorLine[len++] = '=';
     errorLine[len++] = '=';
     errorLine[len] = '\0';
     if (toDialog == NULL)
     {
-        fprintf(stderr, "NEdit: %s in %s:\n%s\n", message, errorIn, errorLine);
+        fprintf(stderr, "NEdit: %s in %s:\n%s\n(line %d)\n",
+                message, errorIn, errorLine, lineNo);
     } else
     {
-        DialogF(DF_WARN, toDialog, 1, "Parse Error", "%s in %s:\n%s", "OK",
-                message, errorIn, errorLine);
+        DialogF(DF_WARN, toDialog, 1,
+                "Parse Error", "%s in %s:\n%s\n(line %d)", "OK",
+                message, errorIn, errorLine, lineNo);
     }
     XtFree(errorLine);
     return False;
 }
 
 /*
