1 Show the line number at which a parse error occured
3 This patch counts the number of newlines from the start of the source buffer
4 whose parse has failed. This will be the line number in a macro or macro file
5 where the error was detected. If an error is found in the parsing of the
6 NEdit configuration (nedit.rc), the line number is that of the unit being
7 parsed, not the whole file.
11 source/preferences.c | 17 +++++++++++++----
12 1 files changed, 13 insertions(+), 4 deletions(-)
14 diff --quilt old/source/preferences.c new/source/preferences.c
15 --- old/source/preferences.c
16 +++ new/source/preferences.c
17 @@ -5668,33 +5668,42 @@ int ParseError(Widget toDialog, const ch
18 const char *errorIn, const char *message)
20 int len, nNonWhite = 0;
26 for (c=stoppedAt; c>=stringStart; c--) {
29 else if (*c == '\n' && nNonWhite >= 5)
31 else if (*c != ' ' && *c != '\t')
35 + for (; stringStart <= c; ++stringStart) {
36 + if (*stringStart == '\n')
40 len = stoppedAt - c + (*stoppedAt == '\0' ? 0 : 1);
41 errorLine = XtMalloc(len+4);
42 strncpy(errorLine, c, len);
43 errorLine[len++] = '<';
44 errorLine[len++] = '=';
45 errorLine[len++] = '=';
46 errorLine[len] = '\0';
49 - fprintf(stderr, "NEdit: %s in %s:\n%s\n", message, errorIn, errorLine);
50 + fprintf(stderr, "NEdit: %s in %s:%d:\n%s\n",
51 + message, errorIn, lineNo, errorLine);
54 - DialogF(DF_WARN, toDialog, 1, "Parse Error", "%s in %s:\n%s", "OK",
55 - message, errorIn, errorLine);
56 + DialogF(DF_WARN, toDialog, 1,
57 + "Parse Error", "%s in %s:%d:\n%s", "OK",
58 + message, errorIn, lineNo, errorLine);