[anjuta] anjuta-ctags: store an index in filePosition



commit 0adbb5451148027bc6cb283acbfd98c5dc79aad0
Author: Konstantin Kharlamov <Hi-Angel yandex ru>
Date:   Thu Feb 28 01:53:35 2019 +0300

    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 <Hi-Angel yandex ru>

 plugins/symbol-db/anjuta-tags/c.c           |  2 +-
 plugins/symbol-db/anjuta-tags/ctags-utils.c |  5 +++--
 plugins/symbol-db/anjuta-tags/ctags-utils.h |  2 +-
 plugins/symbol-db/anjuta-tags/entry.h       |  2 +-
 plugins/symbol-db/anjuta-tags/flex.c        |  2 +-
 plugins/symbol-db/anjuta-tags/fortran.c     |  2 +-
 plugins/symbol-db/anjuta-tags/read.c        | 14 ++++++++++++--
 plugins/symbol-db/anjuta-tags/read.h        |  4 ++--
 plugins/symbol-db/anjuta-tags/sql.c         |  2 +-
 plugins/symbol-db/anjuta-tags/tex.c         |  2 +-
 plugins/symbol-db/anjuta-tags/vhdl.c        |  2 +-
 plugins/symbol-db/anjuta-tags/vim.c         |  2 +-
 12 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/plugins/symbol-db/anjuta-tags/c.c b/plugins/symbol-db/anjuta-tags/c.c
index 6f9b634c8..1d65b1872 100644
--- a/plugins/symbol-db/anjuta-tags/c.c
+++ b/plugins/symbol-db/anjuta-tags/c.c
@@ -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 {
diff --git a/plugins/symbol-db/anjuta-tags/ctags-utils.c b/plugins/symbol-db/anjuta-tags/ctags-utils.c
index 0db7745f2..3b17a8434 100644
--- a/plugins/symbol-db/anjuta-tags/ctags-utils.c
+++ b/plugins/symbol-db/anjuta-tags/ctags-utils.c
@@ -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);
 }
 
 
diff --git a/plugins/symbol-db/anjuta-tags/ctags-utils.h b/plugins/symbol-db/anjuta-tags/ctags-utils.h
index 41283bf3c..e2e01ce5b 100644
--- a/plugins/symbol-db/anjuta-tags/ctags-utils.h
+++ b/plugins/symbol-db/anjuta-tags/ctags-utils.h
@@ -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);
 
diff --git a/plugins/symbol-db/anjuta-tags/entry.h b/plugins/symbol-db/anjuta-tags/entry.h
index 323c1c579..7dbb2d258 100644
--- a/plugins/symbol-db/anjuta-tags/entry.h
+++ b/plugins/symbol-db/anjuta-tags/entry.h
@@ -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? */
diff --git a/plugins/symbol-db/anjuta-tags/flex.c b/plugins/symbol-db/anjuta-tags/flex.c
index 038ac4eb1..dcb9dcf9c 100644
--- a/plugins/symbol-db/anjuta-tags/flex.c
+++ b/plugins/symbol-db/anjuta-tags/flex.c
@@ -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;
diff --git a/plugins/symbol-db/anjuta-tags/fortran.c b/plugins/symbol-db/anjuta-tags/fortran.c
index 2a6f85ca1..9497bfb3b 100644
--- a/plugins/symbol-db/anjuta-tags/fortran.c
+++ b/plugins/symbol-db/anjuta-tags/fortran.c
@@ -183,7 +183,7 @@ typedef struct sTokenInfo {
        vString* string;
        struct sTokenInfo *secondary;
        unsigned long lineNumber;
-       fpos_t filePosition;
+       long filePosition;
 } tokenInfo;
 
 /*
diff --git a/plugins/symbol-db/anjuta-tags/read.c b/plugins/symbol-db/anjuta-tags/read.c
index 7940c8687..302aaa9d8 100644
--- a/plugins/symbol-db/anjuta-tags/read.c
+++ b/plugins/symbol-db/anjuta-tags/read.c
@@ -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);
diff --git a/plugins/symbol-db/anjuta-tags/read.h b/plugins/symbol-db/anjuta-tags/read.h
index ad49a828f..ed872ed3d 100644
--- a/plugins/symbol-db/anjuta-tags/read.h
+++ b/plugins/symbol-db/anjuta-tags/read.h
@@ -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 */
 
diff --git a/plugins/symbol-db/anjuta-tags/sql.c b/plugins/symbol-db/anjuta-tags/sql.c
index 6c0c76a58..b3c6cd9a2 100644
--- a/plugins/symbol-db/anjuta-tags/sql.c
+++ b/plugins/symbol-db/anjuta-tags/sql.c
@@ -172,7 +172,7 @@ typedef struct sTokenInfoSQL {
        vString *       scope;
        int         begin_end_nest_lvl;
        unsigned long lineNumber;
-       fpos_t filePosition;
+       long filePosition;
 } tokenInfo;
 
 /*
diff --git a/plugins/symbol-db/anjuta-tags/tex.c b/plugins/symbol-db/anjuta-tags/tex.c
index 0c6714ea3..0a7c77a82 100644
--- a/plugins/symbol-db/anjuta-tags/tex.c
+++ b/plugins/symbol-db/anjuta-tags/tex.c
@@ -88,7 +88,7 @@ typedef struct sTokenInfo {
        vString *               string;
        vString *               scope;
        unsigned long   lineNumber;
-       fpos_t                  filePosition;
+       long                    filePosition;
 } tokenInfo;
 
 /*
diff --git a/plugins/symbol-db/anjuta-tags/vhdl.c b/plugins/symbol-db/anjuta-tags/vhdl.c
index 994d2e142..5b8f2d49c 100644
--- a/plugins/symbol-db/anjuta-tags/vhdl.c
+++ b/plugins/symbol-db/anjuta-tags/vhdl.c
@@ -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;
 
 /*
diff --git a/plugins/symbol-db/anjuta-tags/vim.c b/plugins/symbol-db/anjuta-tags/vim.c
index 951ee5f6d..3b02f8542 100644
--- a/plugins/symbol-db/anjuta-tags/vim.c
+++ b/plugins/symbol-db/anjuta-tags/vim.c
@@ -35,7 +35,7 @@ typedef struct sLineInfo {
        vString *       string;
        vString *       scope;
        unsigned long lineNumber;
-       fpos_t filePosition;
+       long filePosition;
 } lineInfo;
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]