Skip to content

Commit

Permalink
Merge pull request #3695 from masatake/main--revise-tagEntry-line
Browse files Browse the repository at this point in the history
main: revise bit fields in tagEntryInfo
  • Loading branch information
masatake committed Apr 8, 2023
2 parents c260d9e + 431338b commit 2149d23
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ static int makePatternStringCommon (const tagEntryInfo *const tag,
}

length += putc_func(searchChar, output);
if ((tag->boundaryInfo & BOUNDARY_START) == 0)
if ((tag->boundaryInfo & INPUT_BOUNDARY_START) == 0)
length += putc_func('^', output);
length += appendInputLine (putc_func, line, Option.patternLengthLimit,
output, &omitted);
Expand Down
19 changes: 15 additions & 4 deletions main/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,36 @@ typedef uint64_t roleBitsType;
/* Information about the current tag candidate.
*/
struct sTagEntryInfo {
/*
* the bit fields parsers may access for setting DIRECTLY
*/
unsigned int lineNumberEntry:1; /* pattern or line number entry */
unsigned int isFileScope :1; /* is tag visible only within input file? */
unsigned int isFileEntry :1; /* is this just an entry for a file name? */
unsigned int truncateLineAfterTag :1; /* truncate tag line at end of tag name? */
unsigned int skipAutoFQEmission:1; /* If a parser makes a fq tag for the
current tag by itself, set this. */

/*
* the bit fields parser may access for setting via accessor
*/
unsigned int placeholder :1; /* is used only for keeping corkIndex based scope chain.
Put this entry to cork queue but
don't print it to tags file. */
unsigned int skipAutoFQEmission:1; /* If a parser makes a fq tag for the
current tag by itself, set this. */

/*
* the bit fields only the main part can access.
*/
unsigned int isFileEntry :1; /* is this just an entry for a file name? */
unsigned int isPseudoTag:1; /* Used only in xref output.
If a tag is a pseudo, set this. */
unsigned int inCorkQueue:1;
unsigned int isInputFileNameShared: 1; /* shares the value for inputFileName.
* Set in the cork queue; don't touch this.*/
unsigned int boundaryInfo: 2; /* info about nested input stream */

unsigned long lineNumber; /* line number of tag */
const char* pattern; /* pattern for locating input line
* (may be NULL if not present) *//* */
unsigned int boundaryInfo; /* info about nested input stream */
MIOPos filePosition; /* file position of line containing tag */
langType langType; /* language of input file */
const char *inputFileName; /* name of input file.
Expand Down
27 changes: 14 additions & 13 deletions main/lregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ struct guestLangSpec {

struct guestSpec {
struct guestLangSpec lang;
#define BOUNDARY_START 0
#define BOUNDARY_END 1
#define GUEST_BOUNDARY_START 0
#define GUEST_BOUNDARY_END 1
struct boundarySpec boundary[2];
};

Expand Down Expand Up @@ -407,7 +407,7 @@ static void initRegexTag (tagEntryInfo *e,
else
initForeignRefTagEntry (e, name, foreign_lang, kindIndex, roleIndex);
e->extensionFields.scopeIndex = scopeIndex;
e->placeholder = !!placeholder;
markTagAsPlaceholder(e, placeholder);
if (line)
{
e->lineNumber = line;
Expand Down Expand Up @@ -871,9 +871,9 @@ static void pre_ptrn_flag_guest_long (const char* const s, const char* const v,
for (int i = 0; i < 2; i++)
{
current = guest->boundary + i;
const char *current_field_str = (i == BOUNDARY_START? "start": "end");
const char *current_field_str = (i == GUEST_BOUNDARY_START? "start": "end");

if (tmp [0] == ((i == BOUNDARY_START)? ',': '\0'))
if (tmp [0] == ((i == GUEST_BOUNDARY_START)? ',': '\0'))
{
if (type == REG_PARSER_MULTI_LINE)
error (WARNING,
Expand Down Expand Up @@ -1856,7 +1856,8 @@ static void printMessage(const langType language,
static bool isGuestRequestConsistent (struct guestRequest *guest_req)
{
return (guest_req->lang != LANG_IGNORE)
&& (guest_req->boundary[BOUNDARY_START].offset < guest_req->boundary[BOUNDARY_END].offset);
&& (guest_req->boundary[GUEST_BOUNDARY_START].offset
< guest_req->boundary[GUEST_BOUNDARY_END].offset);
}

static bool fillGuestRequest (const char *start,
Expand Down Expand Up @@ -3150,8 +3151,8 @@ static bool guestRequestIsFilled(struct guestRequest *r)
static void guestRequestClear (struct guestRequest *r)
{
r->lang_set = false;
r->boundary[BOUNDARY_START].offset_set = false;
r->boundary[BOUNDARY_END].offset_set = false;
r->boundary[GUEST_BOUNDARY_START].offset_set = false;
r->boundary[GUEST_BOUNDARY_END].offset_set = false;
}

static void guestRequestSubmit (struct guestRequest *r)
Expand All @@ -3160,11 +3161,11 @@ static void guestRequestSubmit (struct guestRequest *r)
verbose ("guestRequestSubmit: %s; "
"range: %"PRId64" - %"PRId64"\n",
langName,
(int64_t)r->boundary[BOUNDARY_START].offset,
(int64_t)r->boundary[BOUNDARY_END].offset);
(int64_t)r->boundary[GUEST_BOUNDARY_START].offset,
(int64_t)r->boundary[GUEST_BOUNDARY_END].offset);
makePromiseForAreaSpecifiedWithOffsets (langName,
r->boundary[BOUNDARY_START].offset,
r->boundary[BOUNDARY_END].offset);
r->boundary[GUEST_BOUNDARY_START].offset,
r->boundary[GUEST_BOUNDARY_END].offset);
}

/*
Expand Down Expand Up @@ -3344,7 +3345,7 @@ static EsObject* lrop_make_foreignreftag (OptVM *vm, EsObject *name)

tagEntryInfo *e = xMalloc (1, tagEntryInfo);
initRegexTag (e, eStrdup (n),
kind_index, role_index, CORK_NIL, 0,
kind_index, role_index, CORK_NIL, false,
loc? loc->line: 0, loc? &loc->pos: NULL,
role_index == ROLE_DEFINITION_INDEX
? XTAG_UNKNOWN
Expand Down
4 changes: 2 additions & 2 deletions main/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,10 +1194,10 @@ extern unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber)
info = 0;
if (File.nestedInputStreamInfo.startLine == lineNumber
&& File.nestedInputStreamInfo.startCharOffset != 0)
info |= BOUNDARY_START;
info |= INPUT_BOUNDARY_START;
if (File.nestedInputStreamInfo.endLine == lineNumber
&& File.nestedInputStreamInfo.endCharOffset != 0)
info |= BOUNDARY_END;
info |= INPUT_BOUNDARY_END;

return info;
}
Expand Down
4 changes: 2 additions & 2 deletions main/read_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/

enum nestedInputBoundaryFlag {
BOUNDARY_START = 1UL << 0,
BOUNDARY_END = 1UL << 1,
INPUT_BOUNDARY_START = 1UL << 0,
INPUT_BOUNDARY_END = 1UL << 1,
};

/*
Expand Down
2 changes: 1 addition & 1 deletion parsers/cpreprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ static void makeParamTag (vString *name, short nth, bool placeholder)
{
e->extensionFields.nth = nth;
if (placeholder)
e->placeholder = 1;
markTagAsPlaceholder (e, placeholder);
}
}

Expand Down
2 changes: 1 addition & 1 deletion parsers/r.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ static void parseRightSide (tokenInfo *const token, tokenInfo *const symbol, int
foreachEntriesInScope (corkIndex, NULL,
findNonPlaceholder, &any_non_placehoders);
if (!any_non_placehoders)
tag->placeholder = 1;
markTagAsPlaceholder (tag, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion parsers/ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ static void enterUnnamedScope (void)
{
tagEntryInfo e;
initTagEntry (&e, "", e_parent->kindIndex);
e.placeholder = 1;
markTagAsPlaceholder(&e, true);
r = makeTagEntry (&e);
}
nestingLevelsPush (nesting, r);
Expand Down

0 comments on commit 2149d23

Please sign in to comment.