Commit 0adbb545 authored by Konstantin Kharlamov's avatar Konstantin Kharlamov

anjuta-ctags: store an index in filePosition

It's not simple to retrieve the actual index from fpos_t, even more so
in case of parsers written in Vala.

In addition, the filePosition usually means just that, the offset in
file, so let's store it in an according type.
Signed-off-by: Konstantin Kharlamov's avatarKonstantin Kharlamov <Hi-Angel@yandex.ru>
parent def618d2
......@@ -176,7 +176,7 @@ typedef struct sTokenInfo {
keywordId keyword;
vString* name; /* the name of the token */
unsigned long lineNumber; /* line number of tag */
fpos_t filePosition; /* file position of line containing name */
long filePosition; /* file position of line containing name */
} tokenInfo;
typedef enum eImplementation {
......
......@@ -19,7 +19,7 @@
#include "ctags-utils.h"
void
get_file_pos (gint line, fpos_t *fpos, FILE *f)
get_file_pos (gint line, long *fpos, FILE *f)
{
vString * str = vStringNew ();
gint i;
......@@ -35,7 +35,8 @@ get_file_pos (gint line, fpos_t *fpos, FILE *f)
}
vStringDelete (str);
g_assert (fgetpos (f, fpos) == 0);
*fpos = ftell(f);
g_assert (*fpos != -1);
}
......@@ -34,5 +34,5 @@
*/
void get_file_pos (gint line, fpos_t *fpos, FILE *f);
void get_file_pos (gint line, long *fpos, FILE *f);
......@@ -56,7 +56,7 @@ typedef struct sTagFields {
typedef struct sTagEntryInfo {
boolean lineNumberEntry; /* pattern or line number entry */
unsigned long lineNumber; /* line number of tag */
fpos_t filePosition; /* file position of line containing tag */
long filePosition; /* file position of line containing tag */
const char* language; /* language of source file */
boolean isFileScope; /* is tag visibile only within source file? */
boolean isFileEntry; /* is this just an entry for a file name? */
......
......@@ -126,7 +126,7 @@ typedef struct sTokenInfo {
vString * string;
vString * scope;
unsigned long lineNumber;
fpos_t filePosition;
long filePosition;
int nestLevel;
boolean ignoreTag;
boolean isClass;
......
......@@ -183,7 +183,7 @@ typedef struct sTokenInfo {
vString* string;
struct sTokenInfo *secondary;
unsigned long lineNumber;
fpos_t filePosition;
long filePosition;
} tokenInfo;
/*
......
......@@ -540,17 +540,27 @@ extern char *readLine (vString *const vLine, FILE *const fp)
return result;
}
long getInputFilePosition() {
fpos_t originalPosition;
long ret;
fgetpos (File.fp, &originalPosition);
fsetpos (File.fp, &File.filePosition);
ret = ftell(File.fp);
fsetpos (File.fp, &originalPosition);
return ret;
}
/* Places into the line buffer the contents of the line referenced by
* "location".
*/
extern char *readSourceLine (
vString *const vLine, fpos_t location, long *const pSeekValue)
vString *const vLine, long location, long *const pSeekValue)
{
fpos_t orignalPosition;
char *result;
fgetpos (File.fp, &orignalPosition);
fsetpos (File.fp, &location);
fseek (File.fp, location, SEEK_SET);
if (pSeekValue != NULL)
*pSeekValue = ftell (File.fp);
result = readLine (vLine, File.fp);
......
......@@ -33,7 +33,6 @@
*/
#define getInputLineNumber() File.lineNumber
#define getInputFileName() vStringValue (File.source.name)
#define getInputFilePosition() File.filePosition
#define getSourceFileName() vStringValue (File.source.name)
#define getSourceFileTagPath() File.source.tagPath
#define getSourceLanguage() File.source.language
......@@ -109,7 +108,8 @@ extern int fileSkipToCharacter (int c);
extern void fileUngetc (int c);
extern const unsigned char *fileReadLine (void);
extern char *readLine (vString *const vLine, FILE *const fp);
extern char *readSourceLine (vString *const vLine, fpos_t location, long *const pSeekValue);
extern char *readSourceLine (vString *const vLine, long location, long *const pSeekValue);
extern long getInputFilePosition(void);
#endif /* _READ_H */
......
......@@ -172,7 +172,7 @@ typedef struct sTokenInfoSQL {
vString * scope;
int begin_end_nest_lvl;
unsigned long lineNumber;
fpos_t filePosition;
long filePosition;
} tokenInfo;
/*
......
......@@ -88,7 +88,7 @@ typedef struct sTokenInfo {
vString * string;
vString * scope;
unsigned long lineNumber;
fpos_t filePosition;
long filePosition;
} tokenInfo;
/*
......
......@@ -166,7 +166,7 @@ typedef struct sTokenInfo {
vString *string; /* the name of the token */
vString *scope;
unsigned long lineNumber; /* line number of tag */
fpos_t filePosition; /* file position of line containing name */
long filePosition; /* file position of line containing name */
} tokenInfo;
/*
......
......@@ -35,7 +35,7 @@ typedef struct sLineInfo {
vString * string;
vString * scope;
unsigned long lineNumber;
fpos_t filePosition;
long filePosition;
} lineInfo;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment