1 From: Joerg Fischer <jf505@gmx.de>
2 Subject: fix return of calltipID
6 source/tags.c | 63 ++++++++++++++++++++++++++++++++++++----------------------
7 1 file changed, 40 insertions(+), 23 deletions(-)
9 diff --quilt old/source/tags.c new/source/tags.c
12 @@ -123,7 +123,7 @@ static void findAllCB(Widget parent, XtP
13 static Widget createSelectMenu(Widget parent, char *label, int nArgs,
15 static void editTaggedLocation( Widget parent, int i );
16 -static void showMatchingCalltip( Widget parent, int i );
17 +static int showMatchingCalltip( Widget parent, int i );
19 static const char *rcs_strdup(const char *str);
20 static void rcs_free(const char *str);
21 @@ -856,6 +856,11 @@ int LookupTag(const char *name, const ch
23 ** This code path is followed if the request came from either
24 ** FindDefinition or FindDefCalltip. This should probably be refactored.
26 +** If search_type = TAG,
27 +** returns <= 0 on errors or when no Def found, > 0 when Def found.
29 +** returns the calltip ID, or 0 on failure.
31 static int findDef(WindowInfo *window, const char *value, int search_type) {
32 static char tagText[MAX_TAG_LEN + 1];
33 @@ -875,15 +880,19 @@ static int findDef(WindowInfo *window, c
35 /* See if we can find the tip/tag */
36 status = findAllMatches(window, tagText);
37 + if (search_type == TAG && status == 0) {
41 /* If we didn't find a requested calltip, see if we can use a tag */
42 - if (status == 0 && search_type == TIP && TagsFileList != NULL) {
43 + if (status == -1 && search_type == TIP && TagsFileList != NULL) {
44 searchMode = TIP_FROM_TAG;
45 status = findAllMatches(window, tagText);
50 /* Didn't find any matches */
52 if (searchMode == TIP_FROM_TAG || searchMode == TIP) {
53 sprintf(message, "No match for \"%s\" in calltips or tags.",
55 @@ -1112,7 +1121,11 @@ static int fakeRegExSearch(WindowInfo *w
57 /* Finds all matches and handles tag "collisions". Prompts user with a
58 list of collided tags in the hash table and allows the user to select
62 + Returns -2 on error condition, -1 if no matches found and a
63 + number >= 0 if matches were found.
64 + (Note: the value is *not* the number of matches.) */
65 static int findAllMatches(WindowInfo *window, const char *string)
67 Widget dialogParent = window->textArea;
68 @@ -1125,7 +1138,7 @@ static int findAllMatches(WindowInfo *wi
69 /* verify that the string is reasonable as a tag */
70 if (*string == '\0' || strlen(string) > MAX_TAG_LEN) {
77 @@ -1175,7 +1188,7 @@ static int findAllMatches(WindowInfo *wi
79 /* Did we find any matches? */
85 /* Only one of the matches is in the same dir. as this file. Use it. */
86 @@ -1200,7 +1213,7 @@ static int findAllMatches(WindowInfo *wi
87 if (!(dupTagsList = (char **) malloc(sizeof(char *) * nMatches))) {
88 fprintf(stderr, "nedit: findAllMatches(): out of heap space!\n");
94 for (i=0; i<nMatches; i++) {
95 @@ -1232,7 +1245,7 @@ static int findAllMatches(WindowInfo *wi
103 strcpy(dupTagsList[i],temp);
104 @@ -1241,18 +1254,20 @@ static int findAllMatches(WindowInfo *wi
105 for (i=0; i<nMatches; i++)
106 free(dupTagsList[i]);
113 ** No need for a dialog list, there is only one tag matching --
114 ** Go directly to the tag
116 - if (searchMode == TAG)
117 + if (searchMode == TAG) {
118 editTaggedLocation( dialogParent, 0 );
120 - showMatchingCalltip( dialogParent, 0 );
125 + return showMatchingCalltip( dialogParent, 0 );
129 /* Callback function for the FindAll widget. Process the users response. */
130 @@ -1315,11 +1330,12 @@ static int moveAheadNLines( char *str, i
131 ** Show the calltip specified by tagFiles[i], tagSearch[i], tagPosInf[i]
132 ** This reads from either a source code file (if searchMode == TIP_FROM_TAG)
133 ** or a calltips file (if searchMode == TIP).
134 +** Returns the calltip ID or 0 in case of failure.
136 -static void showMatchingCalltip( Widget parent, int i )
137 +static int showMatchingCalltip( Widget parent, int i )
139 int startPos=0, fileLen, readLen, tipLen;
141 + int endPos=0, calltipID = 0;
145 @@ -1331,13 +1347,13 @@ static void showMatchingCalltip( Widget
147 DialogF(DF_ERR, parent, 1, "Error opening File", "Error opening %s",
152 if (fstat(fileno(fp), &statbuf) != 0) {
154 DialogF(DF_ERR, parent, 1, "Error opening File", "Error opening %s",
160 /* 2. Read the target file */
161 @@ -1348,7 +1364,7 @@ static void showMatchingCalltip( Widget
163 DialogF(DF_ERR, parent, 1, "File too large",
164 "File is too large to load", "OK");
169 /* Read the file into fileString and terminate with a null */
170 @@ -1358,7 +1374,7 @@ static void showMatchingCalltip( Widget
171 DialogF(DF_ERR, parent, 1, "Error reading File", "Error reading %s",
177 fileString[readLen] = 0;
179 @@ -1378,7 +1394,7 @@ static void showMatchingCalltip( Widget
180 "%s\n not long enough for definition to be on line %d",
181 "OK", tagFiles[i], tagPosInf[i]);
187 startPos = tagPosInf[i];
188 @@ -1388,7 +1404,7 @@ static void showMatchingCalltip( Widget
189 "Definition for %s\nnot found in %s", "OK", tagName,
197 @@ -1423,15 +1439,16 @@ static void showMatchingCalltip( Widget
198 DialogF(DF_ERR, parent, 1, "Out of Memory",
199 "Can't allocate memory for calltip message", "OK");
204 strncpy( message, &fileString[startPos], tipLen );
208 - tagsShowCalltip( WidgetToWindow(parent), message );
209 + calltipID = tagsShowCalltip( WidgetToWindow(parent), message );
215 /* Open a new (or existing) editor window to the location specified in