Skip to content

Commit

Permalink
Merge pull request #1863 from masatake/remove-dead-code
Browse files Browse the repository at this point in the history
Remove dead code related to xcmd feature
  • Loading branch information
masatake authored Aug 31, 2018
2 parents 2ee5ac8 + c8c97f1 commit f9bbb35
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 122 deletions.
14 changes: 4 additions & 10 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,17 +717,11 @@ static bool isPosSet(MIOPos pos)
return r;
}

extern char *readLineFromBypassAnyway (vString *const vLine, const tagEntryInfo *const tag,
extern char *readLineFromBypassForTag (vString *const vLine, const tagEntryInfo *const tag,
long *const pSeekValue)
{
char * line;

if (isPosSet (tag->filePosition) || (tag->pattern == NULL))
line = readLineFromBypass (vLine, tag->filePosition, pSeekValue);
else
line = readLineFromBypassSlow (vLine, tag->lineNumber, tag->pattern, pSeekValue);

return line;
Assert (isPosSet (tag->filePosition) || (tag->pattern == NULL));
return readLineFromBypass (vLine, tag->filePosition, pSeekValue);
}

/* Truncates the text line containing the tag at the character following the
Expand Down Expand Up @@ -859,7 +853,7 @@ static int makePatternStringCommon (const tagEntryInfo *const tag,
&& (memcmp (&tag->filePosition, &cached_location, sizeof(MIOPos)) == 0))
return puts_func (vStringValue (cached_pattern), output);

line = readLineFromBypass (TagFile.vLine, tag->filePosition, NULL);
line = readLineFromBypassForTag (TagFile.vLine, tag, NULL);
if (line == NULL)
{
/* This can be occurs if the size of input file is zero, and
Expand Down
2 changes: 1 addition & 1 deletion main/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extern void getTagScopeInformation (tagEntryInfo *const tag,
const char **kind, const char **name);

/* Getting line associated with tag */
extern char *readLineFromBypassAnyway (vString *const vLine, const tagEntryInfo *const tag,
extern char *readLineFromBypassForTag (vString *const vLine, const tagEntryInfo *const tag,
long *const pSeekValue);

/* Generating pattern associated tag, caller must do eFree for the returned value. */
Expand Down
2 changes: 1 addition & 1 deletion main/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ static const char *renderFieldCompactInputLine (const tagEntryInfo *const tag,

tmp = vStringNewOrClearWithAutoRelease (tmp);

line = readLineFromBypassAnyway (tmp, tag, NULL);
line = readLineFromBypassForTag (tmp, tag, NULL);
if (line)
renderCompactInputLine (b, line);
else
Expand Down
107 changes: 0 additions & 107 deletions main/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
# include "mbcs.h"
#endif

#include <ctype.h>
#include <stddef.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> /* declare off_t (not known to regex.h on FreeBSD) */
#endif
#include <regex.h>

/*
* DATA DECLARATIONS
*/
Expand Down Expand Up @@ -1009,106 +1002,6 @@ extern char *readLineFromBypass (
return result;
}

/* If a xcmd parser is used, ctags cannot know the location for a tag.
* In the other hand, etags output and cross reference output require the
* line after the location.
*
* readLineFromBypassSlow retrieves the line for (lineNumber and pattern of a tag).
*/

extern char *readLineFromBypassSlow (vString *const vLine,
unsigned long lineNumber,
const char *pattern,
long *const pSeekValue)
{
char *result = NULL;


MIOPos originalPosition;
char *line;
size_t len;
long pos;

regex_t patbuf;
char lastc;


/*
* Compile the pattern
*/
{
char *pat;
int errcode;
char errmsg[256];

pat = eStrdup (pattern);
pat[strlen(pat) - 1] = '\0';
errcode = regcomp (&patbuf, pat + 1, 0);
eFree (pat);

if (errcode != 0)
{
regerror (errcode, &patbuf, errmsg, 256);
error (WARNING, "regcomp %s in readLineFromBypassSlow: %s", pattern, errmsg);
regfree (&patbuf);
return NULL;
}
}

/*
* Get the line for lineNumber
*/
{
unsigned long n;

mio_getpos (File.mio, &originalPosition);
rewindInputFile (&File);
line = NULL;
pos = 0;
for (n = 0; n < lineNumber; n++)
{
pos = mio_tell (File.mio);
line = readLineRaw (vLine, File.mio);
if (line == NULL)
break;
}
if (line == NULL)
goto out;
else
len = strlen(line);

if (len == 0)
goto out;

lastc = line[len - 1];
if (lastc == '\n')
line[len - 1] = '\0';
}

/*
* Match
*/
{
regmatch_t pmatch;
int after_newline = 0;
if (regexec (&patbuf, line, 1, &pmatch, 0) == 0)
{
line[len - 1] = lastc;
result = line + pmatch.rm_so;
if (pSeekValue)
{
after_newline = ((lineNumber == 1)? 0: 1);
*pSeekValue = pos + after_newline + pmatch.rm_so;
}
}
}

out:
regfree (&patbuf);
mio_setpos (File.mio, &originalPosition);
return result;
}

extern void pushNarrowedInputStream (
unsigned long startLine, long startCharOffset,
unsigned long endLine, long endCharOffset,
Expand Down
2 changes: 0 additions & 2 deletions main/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ extern char *readLineRaw (vString *const vLine, MIO *const mio);

/* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */
extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue);
extern char *readLineFromBypassSlow (vString *const vLine, unsigned long lineNumber,
const char *pattern, long *const pSeekValue);

extern void pushNarrowedInputStream (
unsigned long startLine, long startCharOffset,
Expand Down
2 changes: 1 addition & 1 deletion main/writer-etags.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int writeEtagsEntry (tagWriter *writer,
size_t len;
long seekValue;
char *const line =
readLineFromBypassAnyway (etags->vLine, tag, &seekValue);
readLineFromBypassForTag (etags->vLine, tag, &seekValue);
if (line == NULL || line [0] == '\0')
return 0;

Expand Down

0 comments on commit f9bbb35

Please sign in to comment.