static void listTags (void) { tagFileInfo info; tagEntry entry; tagFile *const file = tagsOpen (TagFileName, &info); if (file == NULL) { fprintf (stderr, "%s: cannot open tag file: %s: %s\n", ProgramName, strerror (info.status.error_number), TagFileName); exit (1); } else { while (tagsNext (file, &entry) == TagSuccess) { #ifdef QUALIFIER if (Qualifier) { int i = q_is_acceptable (Qualifier, &entry); switch (i) { case Q_REJECT: continue; case Q_ERROR: exit (1); } } #endif printTag (&entry); } tagsClose (file); } }
bool Parse::getScopeAndLocals(Scope * sc, const QString &expr, const QString &ident) { // initialize scope if nothing better is found sc->scope = ""; sc->localdef = ""; /* create a tags file for `expr' with function names only. * The function with the highest line number is our valid scope * --sort=no, because tags generation probably faster, and * so I just have to look for the last entry to find 'my' tag */ QString command = ctagsCmdPath + " --language-force=c++ --sort=no --fields=fKmnsz --c++-kinds=fn -o \"" + smallTagsFilePath + "\" \"" + parsedFilePath + '\"'; // I don't process any user input, so system() should be safe enough QProcess ctags; ctags.execute(command); QFile::remove (parsedFilePath); if (ctags.exitStatus() == QProcess::CrashExit) return false; /* find the last entry, this is our current scope */ tagFileInfo info; tagFile *tfile = tagsOpen(smallTagsFilePath.toAscii(), &info); tagEntry entry; const char *scope = NULL; if (tfile && info.status.opened) { if (tagsFirst(tfile, &entry) == TagSuccess) { do scope = tagsField(&entry, "class"); while (tagsNext(tfile, &entry) == TagSuccess); } tagsClose(tfile); } /* must be before the 'type = extract_type_qualifier()' code, which modifies scope */ if (scope) sc->scope = scope; /* get local definition (if any) */ if (ident!="") { QString type = extractTypeQualifier(expr, ident); if (type.length()) { sc->localdef = type; } else sc->localdef = ""; } QFile::remove (smallTagsFilePath); return true; }
static gboolean find_next(tagFile *tf, tagEntry *entry, MatchType match_type) { gboolean ret; if (match_type == MATCH_PATTERN) ret = tagsNext(tf, entry) == TagSuccess; else ret = tagsFindNext(tf, entry) == TagSuccess; return ret; }
static void listTags (void) { tagFileInfo info; tagEntry entry; tagFile *const file = tagsOpen (TagFileName, &info); if (file == NULL) { fprintf (stderr, "%s: cannot open tag file: %s: %s\n", ProgramName, strerror (info.status.error_number), TagFileName); exit (1); } else { while (tagsNext (file, &entry) == TagSuccess) printTag (&entry); tagsClose (file); } }
static tagResult findNext (tagFile *const file, tagEntry *const entry) { tagResult result = TagFailure; if ((file->sortMethod == TAG_SORTED && !file->search.ignorecase) || (file->sortMethod == TAG_FOLDSORTED && file->search.ignorecase)) { result = tagsNext (file, entry); if (result == TagSuccess && nameComparison (file) != 0) result = TagFailure; } else { result = findSequential (file); if (result == TagSuccess && entry != NULL) parseTagLine (file, entry); } return result; }