1 /* $MirOS: contrib/code/jupp/utag.c,v 1.2 2008/05/13 13:08:30 tg Exp $ */
3 * tags file symbol lookup
5 * (C) 1992 Joseph H. Allen
7 * This file is part of JOE (Joe's Own Editor)
27 static int dotag(BW *bw, unsigned char *s, void *obj, int *notify)
29 unsigned char buf[512];
31 unsigned char *t = NULL;
37 t = vsncpy(t, 0, sz(bw->b->name));
38 t = vsncpy(sv(t), sc(":"));
39 t = vsncpy(sv(t), sv(s));
41 f = fopen("tags", "r");
43 msgnw(bw->parent, US "Couldn't open tags file");
48 while (fgets((char *)buf, 512, f)) {
51 for (x = 0; buf[x] && buf[x] != ' ' && buf[x] != '\t'; ++x) ;
54 if (!strcmp(s, buf) || (t && !strcmp(t, buf))) {
56 while (buf[x] == ' ' || buf[x] == '\t') {
59 for (y = x; buf[y] && buf[y] != ' ' && buf[y] != '\t' && buf[y] != '\n'; ++y) ;
63 if (doedit(bw, vsncpy(NULL, 0, sz(buf + x)), NULL, NULL)) {
69 bw = (BW *) maint->curwin->object;
71 while (buf[y] == ' ' || buf[y] == '\t') {
74 for (x = y; buf[x] && buf[x] != '\n'; ++x) ;
79 if (buf[y] >= '0' && buf[y] <= '9') {
80 sscanf((char *)(buf + y), "%ld", &line);
85 pline(bw->cursor, line - 1), bw->cursor->xcol = piscol(bw->cursor);
89 msgnw(bw->parent, US "Invalid line number");
92 if (buf[y] == '/' || buf[y] == '?') {
96 for (x = y+1; buf[x] && buf[x] != '\n' && buf[x-1] != '/'; ++x);
98 if (buf[x - 1] == '/' || buf[x - 1] == '?') {
101 if (buf[x - 1] == '$') {
112 return dopfnext(bw, mksrch(vsncpy(NULL, 0, sz(buf + y)), NULL, 0, 0, -1, 0, 0), NULL);
123 msgnw(bw->parent, US "Not found");
130 static B *taghist = NULL;
136 pbw = wmkpw(bw->parent, US "Tag search: ", &taghist, dotag, NULL, NULL, cmplt, NULL, NULL, locale_map);
137 if (pbw && joe_isalnum_(bw->b->o.charmap,brch(bw->cursor))) {
138 P *p = pdup(bw->cursor);
142 while (joe_isalnum_(bw->b->o.charmap,(c = prgetc(p))))
144 if (c != NO_MORE_DATA) {
148 while (joe_isalnum_(bw->b->o.charmap,(c = pgetc(q))))
150 if (c != NO_MORE_DATA) {
153 binsb(pbw->cursor, bcpy(p, q));
154 pset(pbw->cursor, pbw->b->eof);
155 pbw->cursor->xcol = piscol(pbw->cursor);