2 * tags file symbol lookup
4 * (C) 1992 Joseph H. Allen
6 * This file is part of JOE (Joe's Own Editor)
11 __RCSID("$MirOS: contrib/code/jupp/utag.c,v 1.5 2017/12/02 04:32:43 tg Exp $");
25 static int dotag(BW *bw, unsigned char *s, void *obj, int *notify)
27 unsigned char buf[512];
29 unsigned char *t = NULL;
35 t = vsncpy(t, 0, sz(bw->b->name));
36 t = vsncpy(sv(t), sc(":"));
37 t = vsncpy(sv(t), sv(s));
39 f = fopen("tags", "r");
41 msgnw(bw->parent, US "Couldn't open tags file");
46 while (fgets((char *)buf, 512, f)) {
49 for (x = 0; buf[x] && buf[x] != ' ' && buf[x] != '\t'; ++x) ;
52 if (!strcmp(s, buf) || (t && !strcmp(t, buf))) {
54 while (buf[x] == ' ' || buf[x] == '\t') {
57 for (y = x; buf[y] && buf[y] != ' ' && buf[y] != '\t' && buf[y] != '\n'; ++y) ;
61 if (doswitch(bw, vsncpy(NULL, 0, sz(buf + x)), NULL, NULL)) {
67 bw = (BW *) maint->curwin->object;
69 while (buf[y] == ' ' || buf[y] == '\t') {
72 for (x = y; buf[x] && buf[x] != '\n'; ++x) ;
77 if (buf[y] >= '0' && buf[y] <= '9') {
78 sscanf((char *)(buf + y), "%ld", &line);
83 pline(bw->cursor, line - 1), bw->cursor->xcol = piscol(bw->cursor);
87 msgnw(bw->parent, US "Invalid line number");
90 if (buf[y] == '/' || buf[y] == '?') {
94 for (x = y+1; buf[x] && buf[x] != '\n' && buf[x-1] != '/'; ++x);
96 if (buf[x - 1] == '/' || buf[x - 1] == '?') {
99 if (buf[x - 1] == '$') {
110 return dopfnext(bw, mksrch(vsncpy(NULL, 0, sz(buf + y)), NULL, 0, 0, -1, 0, 0), NULL);
121 msgnw(bw->parent, US "Not found");
128 static B *taghist = NULL;
134 pbw = wmkpw(bw->parent, US "Tag search: ", &taghist, dotag, NULL, NULL, cmplt, NULL, NULL, locale_map);
135 if (pbw && joe_isalnum_(bw->b->o.charmap,brch(bw->cursor))) {
136 P *p = pdup(bw->cursor);
140 while (joe_isalnum_(bw->b->o.charmap,(c = prgetc(p))))
142 if (c != NO_MORE_DATA) {
146 while (joe_isalnum_(bw->b->o.charmap,(c = pgetc(q))))
148 if (c != NO_MORE_DATA) {
151 binsb(pbw->cursor, bcpy(p, q));
152 pset(pbw->cursor, pbw->b->eof);
153 pbw->cursor->xcol = piscol(pbw->cursor);