static void addExtensionList ( stringList *const slist, const char *const elist, const boolean clear) { char *const extensionList = eStrdup (elist); const char *extension = NULL; boolean first = TRUE; if (clear) { verbose (" clearing\n"); stringListClear (slist); } verbose (" adding: "); if (elist != NULL && *elist != '\0') { extension = extensionList; if (elist [0] == EXTENSION_SEPARATOR) ++extension; } while (extension != NULL) { char *separator = strchr (extension, EXTENSION_SEPARATOR); if (separator != NULL) *separator = '\0'; verbose ("%s%s", first ? "" : ", ", *extension == '\0' ? "(NONE)" : extension); stringListAdd (slist, vStringNewInit (extension)); first = FALSE; if (separator == NULL) extension = NULL; else extension = separator + 1; } if (Option.verbose) { printf ("\n now: "); stringListPrint (slist); putchar ('\n'); } eFree (extensionList); }
static void setSourceFileParameters (vString *const fileName, const langType language) { if (File.source.name != NULL) vStringDelete (File.source.name); File.source.name = fileName; if (File.source.tagPath != NULL) eFree (File.source.tagPath); if (! Option.tagRelative || isAbsolutePath (vStringValue (fileName))) File.source.tagPath = eStrdup (vStringValue (fileName)); else File.source.tagPath = relativeFilename (vStringValue (fileName), TagFile.directory); if (vStringLength (fileName) > TagFile.max.file) TagFile.max.file = vStringLength (fileName); File.source.isHeader = isIncludeFile (vStringValue (fileName)); if (language != -1) File.source.language = language; else File.source.language = getFileLanguage (vStringValue (fileName)); }
/** * implementations in Obj-C look like: * * @implementation Class1 [ (CategoryName) ] * [ { * ... * } * ] * methods * @end */ static void implementationHandler(const char *keyword) { char *ident; int z; z = skipToNonWhite(); ident = readToNonIdentifier(0); if (ident && *ident) { ident = eStrdup(ident); } else { return; } recordPosition(); z = skipToNonWhite(); if (z == '(') { char *category; char *newIdent; category = readCategoryTag(); if (category) { newIdent = eMalloc(strlen(category) + strlen(ident) + 1); strcpy(newIdent, ident); strcat(newIdent, category); eFree(ident); ident = newIdent; } } emitObjCTag(ident, K_IMPLEMENTATION, 0, 0, TRUE); readObjCMethods(K_IMPMETHOD, ident, 0); eFree(ident); }
extern parserDefinition* parserNew (const char* name) { parserDefinition* result = xCalloc (1, parserDefinition); result->name = eStrdup (name); return result; }
static boolean loadPathKind (xcmdPath *const path, char* line, char *args[]) { const char* backup = line; char* off; vString *desc; kindOption *kind; if (line[0] == '\0') return FALSE; else if (!isblank(line[1])) { error (WARNING, "[%s] a space after letter is not found in kind description line: %s", args[0], backup); return FALSE; } path->kinds = xRealloc (path->kinds, path->n_kinds + 1, kindOption); kind = &path->kinds [path->n_kinds]; memset (kind, 0, sizeof (*kind)); kind->enabled = TRUE; kind->letter = line[0]; kind->name = NULL; kind->description = NULL; kind->referenceOnly = FALSE; kind->nRoles = 0; kind->roles = NULL; verbose (" kind letter: <%c>\n", kind->letter); for (line++; isblank(*line); line++) ; /* do nothing */ if (*line == '\0') { error (WARNING, "[%s] unexpectedly a kind description line is terminated: %s", args[0], backup); return FALSE; } Assert (!isblank (*line)); off = strrstr(line, "[off]"); if (off == line) { error (WARNING, "[%s] [off] is given but no kind description is found: %s", args[0], backup); return FALSE; } else if (off) { if (!isblank (*(off - 1))) { error (WARNING, "[%s] a whitespace must precede [off] flag: %s", args[0], backup); return FALSE; } kind->enabled = FALSE; *off = '\0'; } desc = vStringNewInit (line); vStringStripTrailing (desc); Assert (vStringLength (desc) > 0); kind->description = vStringDeleteUnwrap (desc); /* TODO: This conversion should be part of protocol. */ { char *tmp = eStrdup (kind->description); char *c; for (c = tmp; *c != '\0'; c++) { if (*c == ' ' || *c == '\t') *c = '_'; } kind->name = tmp; } path->n_kinds += 1; return TRUE; }
extern void openTagFile (void) { setDefaultTagFileName (); TagsToStdout = isDestinationStdout (); if (TagFile.vLine == NULL) TagFile.vLine = vStringNew (); /* Open the tags file. */ if (TagsToStdout) { /* Open a tempfile with read and write mode. Read mode is used when * write the result to stdout. */ TagFile.fp = tempFile ("w+", &TagFile.name); if (isXtagEnabled (XTAG_PSEUDO_TAGS)) addCommonPseudoTags (); } else { boolean fileExists; TagFile.name = eStrdup (Option.tagFileName); fileExists = doesFileExist (TagFile.name); if (fileExists && ! isTagFile (TagFile.name)) error (FATAL, "\"%s\" doesn't look like a tag file; I refuse to overwrite it.", TagFile.name); if (Option.etags) { if (Option.append && fileExists) TagFile.fp = fopen (TagFile.name, "a+b"); else TagFile.fp = fopen (TagFile.name, "w+b"); } else { if (Option.append && fileExists) { TagFile.fp = fopen (TagFile.name, "r+"); if (TagFile.fp != NULL) { TagFile.numTags.prev = updatePseudoTags (TagFile.fp); fclose (TagFile.fp); TagFile.fp = fopen (TagFile.name, "a+"); } } else { TagFile.fp = fopen (TagFile.name, "w"); if (TagFile.fp != NULL && isXtagEnabled (XTAG_PSEUDO_TAGS)) addCommonPseudoTags (); } } if (TagFile.fp == NULL) error (FATAL | PERROR, "cannot open tag file"); } if (TagsToStdout) TagFile.directory = eStrdup (CurrentDirectory); else TagFile.directory = absoluteDirname (TagFile.name); }
extern void openTagFile (void) { setDefaultTagFileName (); TagsToStdout = isDestinationStdout (); if (TagFile.vLine == NULL) TagFile.vLine = vStringNew (); /* Open the tags file. */ if (TagsToStdout) TagFile.fp = tempFile ("w", &TagFile.name); else { boolean fileExists; setDefaultTagFileName (); TagFile.name = eStrdup (Option.tagFileName); fileExists = doesFileExist (TagFile.name); if (fileExists && ! isTagFile (TagFile.name)) error (FATAL, "\"%s\" doesn't look like a tag file; I refuse to overwrite it.", TagFile.name); if (Option.etags) { if (Option.append && fileExists) TagFile.fp = fopen (TagFile.name, "a+b"); else TagFile.fp = fopen (TagFile.name, "w+b"); } else { if (Option.append && fileExists) { TagFile.fp = fopen (TagFile.name, "r+"); if (TagFile.fp != NULL) { TagFile.numTags.prev = updatePseudoTags (TagFile.fp); fclose (TagFile.fp); TagFile.fp = fopen (TagFile.name, "a+"); } } else { TagFile.fp = fopen (TagFile.name, "w"); if (TagFile.fp != NULL) addPseudoTags (); } } if (TagFile.fp == NULL) { error (FATAL | PERROR, "cannot open tag file"); exit (1); } } if (TagsToStdout) TagFile.directory = eStrdup (CurrentDirectory); else TagFile.directory = absoluteDirname (TagFile.name); }
extern void setDefaultTagFileName (void) { Option.tagFileName = eStrdup (CTAGS_FILE); }