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.11 2017/12/07 02:10:19 tg Exp $");
26 static int dotag(BW *bw, unsigned char *s, void *obj, int *notify)
28 unsigned char buf[512];
30 unsigned char *t = NULL;
36 t = vsncpy(t, 0, sz(bw->b->name));
37 t = vsncpy(sv(t), sc(":"));
38 t = vsncpy(sv(t), sv(s));
40 f = fopen("tags", "r");
42 msgnw(bw->parent, UC "Couldn't open tags file");
47 while (fgets((char *)buf, 512, f)) {
50 for (x = 0; buf[x] && buf[x] != ' ' && buf[x] != '\t'; ++x) ;
53 if (!strcmp(s, buf) || (t && !strcmp(t, buf))) {
55 while (buf[x] == ' ' || buf[x] == '\t') {
58 for (y = x; buf[y] && buf[y] != ' ' && buf[y] != '\t' && buf[y] != '\n'; ++y) ;
62 if (doswitch(bw, vsncpy(NULL, 0, sz(buf + x)), NULL, NULL)) {
68 bw = maint->curwin->object.bw;
70 while (buf[y] == ' ' || buf[y] == '\t') {
73 for (x = y; buf[x] && buf[x] != '\n'; ++x) ;
78 if (buf[y] >= '0' && buf[y] <= '9') {
79 line = ustol(buf + y, NULL, USTOL_AUTO);
84 pline(bw->cursor, line - 1), bw->cursor->xcol = piscol(bw->cursor);
88 msgnw(bw->parent, UC "Invalid line number");
91 if (buf[y] == '/' || buf[y] == '?') {
95 for (x = y+1; buf[x] && buf[x] != '\n' && buf[x-1] != '/'; ++x);
97 if (buf[x - 1] == '/' || buf[x - 1] == '?') {
100 if (buf[x - 1] == '$') {
111 return dopfnext(bw, mksrch(vsncpy(NULL, 0, sz(buf + y)), NULL, 0, 0, -1, 0, 0), NULL);
122 msgnw(bw->parent, UC "Not found");
129 static B *taghist = NULL;
135 pbw = wmkpw(bw->parent, UC "Tag search: ", &taghist, dotag, NULL, NULL, cmplt, NULL, NULL, locale_map);
136 if (pbw && joe_isalnux(bw->b->o.charmap,brch(bw->cursor))) {
137 P *p = pdup(bw->cursor);
141 while (joe_isalnux(bw->b->o.charmap,(c = prgetc(p))))
143 if (c != NO_MORE_DATA) {
147 while (joe_isalnux(bw->b->o.charmap,(c = pgetc(q))))
149 if (c != NO_MORE_DATA) {
152 binsb(pbw->cursor, bcpy(p, q));
153 pset(pbw->cursor, pbw->b->eof);
154 pbw->cursor->xcol = piscol(pbw->cursor);