push up calltip_ignore_arg.patch
[nedit-bw.git] / parseErrorLineNo.diff
blob91bbbb5240faa67253c96b4a43773edd74911c91
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.
9 ---
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;
21 const char *c;
22 char *errorLine;
24 + int lineNo = 1;
26 for (c=stoppedAt; c>=stringStart; c--) {
27 if (c == stringStart)
28 break;
29 else if (*c == '\n' && nNonWhite >= 5)
30 break;
31 else if (*c != ' ' && *c != '\t')
32 nNonWhite++;
35 + for (; stringStart <= c; ++stringStart) {
36 + if (*stringStart == '\n')
37 + ++lineNo;
38 + }
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';
47 if (toDialog == NULL)
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);
52 } else
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);
60 XtFree(errorLine);
61 return False;