Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 14 Jun 2015 15:57:18 UTC Commit: b975c2652da201c9e84f4b817c18408814364f36 https://github.com/geany/geany/commit/b975c2652da201c9e84f4b817c18408814364f...
Log Message: ----------- read: Allow to unget up to 3 characters
Some parsers need to unget more than one characters, so add support for this.
X-Universal-CTags-Commit-ID: 956af0555d3a8ef33304c5ae6ed873f22b4e4284
Modified Paths: -------------- tagmanager/ctags/read.c tagmanager/ctags/read.h
Modified: tagmanager/ctags/read.c 12 lines changed, 8 insertions(+), 4 deletions(-) =================================================================== @@ -428,7 +428,12 @@ static int iFileGetc (void)
extern void fileUngetc (int c) { - File.ungetch = c; + const size_t len = sizeof File.ungetchBuf / sizeof File.ungetchBuf[0]; + + Assert (File.ungetchIdx < len); + /* we cannot rely on the assertion that might be disabled in non-debug mode */ + if (File.ungetchIdx < len) + File.ungetchBuf[File.ungetchIdx++] = c; }
static vString *iFileGetLine (void) @@ -468,10 +473,9 @@ extern int fileGetc (void) * other processing on it, though, because we already did that the * first time it was read through fileGetc (). */ - if (File.ungetch != '\0') + if (File.ungetchIdx > 0) { - c = File.ungetch; - File.ungetch = '\0'; + c = File.ungetchBuf[--File.ungetchIdx]; return c; /* return here to avoid re-calling debugPutc () */ } do
Modified: tagmanager/ctags/read.h 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -70,7 +70,8 @@ typedef struct sInputFile { MIO *mio; /* stream used for reading the file */ unsigned long lineNumber; /* line number in the input file */ MIOPos filePosition; /* file position of current line */ - int ungetch; /* a single character that was ungotten */ + unsigned int ungetchIdx; + int ungetchBuf[3]; /* characters that were ungotten */ boolean eof; /* have we reached the end of file? */ boolean newLine; /* will the next character begin a new line? */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).