Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Mon, 30 Jul 2012 22:32:53
Commit: fd40e4aa547b4fb8027bd9a5a8946afc7c93fd8d
https://github.com/geany/geany/commit/fd40e4aa547b4fb8027bd9a5a8946afc7c93f…
Log Message:
-----------
Mark a few things as static
Based on CTags r779: https://ctags.svn.sourceforge.net/svnroot/ctags@779
Modified Paths:
--------------
tagmanager/ctags/objc.c
Modified: tagmanager/ctags/objc.c
15 files changed, 8 insertions(+), 7 deletions(-)
===================================================================
@@ -431,16 +431,16 @@ static objcKeyword lex (lexingState * st)
/********** Helpers */
/* This variable hold the 'parser' which is going to
* handle the next token */
-parseNext toDoNext;
+static parseNext toDoNext;
/* Special variable used by parser eater to
* determine which action to put after their
* job is finished. */
-parseNext comeAfter;
+static parseNext comeAfter;
/* Used by some parsers detecting certain token
* to revert to previous parser. */
-parseNext fallback;
+static parseNext fallback;
/********** Grammar */
@@ -466,13 +466,13 @@ static void prepareTag (tagEntryInfo * tag, vString const *name, objcKind kind)
}
}
-void pushEnclosingContext (const vString * parent, objcKind type)
+static void pushEnclosingContext (const vString * parent, objcKind type)
{
vStringCopy (parentName, parent);
parentType = type;
}
-void popEnclosingContext (void)
+static void popEnclosingContext (void)
{
vStringClear (parentName);
}
@@ -486,7 +486,7 @@ static void addTag (vString * const ident, int kind)
makeTagEntry (&toCreate);
}
-objcToken waitedToken, fallBackToken;
+static objcToken waitedToken, fallBackToken;
/* Ignore everything till waitedToken and jump to comeAfter.
* If the "end" keyword is encountered break, doesn't remember
@@ -795,7 +795,8 @@ static void parseStructMembers (vString * const ident, objcToken what)
break;
/* some types are complex, the only one
- * we will loose is the function type. */
+ * we will loose is the function type.
+ */
case Tok_CurlL: /* '{' */
case Tok_PARL: /* '(' */
case Tok_SQUAREL: /* '[' */
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Mon, 30 Jul 2012 22:31:43
Commit: 3a460a2c5ba2de3aa01f2bea2a001c36dd01b839
https://github.com/geany/geany/commit/3a460a2c5ba2de3aa01f2bea2a001c36dd01b…
Log Message:
-----------
Remove and unused structure member
Based on CTags r769: https://ctags.svn.sourceforge.net/svnroot/ctags@769
Modified Paths:
--------------
tagmanager/ctags/read.c
tagmanager/ctags/read.h
Modified: tagmanager/ctags/read.c
2 files changed, 0 insertions(+), 2 deletions(-)
===================================================================
@@ -277,7 +277,6 @@ extern boolean fileOpen (const char *const fileName, const langType language)
mio_getpos (File.mio, &StartOfLine);
mio_getpos (File.mio, &File.filePosition);
File.currentLine = NULL;
- File.language = language;
File.lineNumber = 0L;
File.eof = FALSE;
File.newLine = TRUE;
@@ -324,7 +323,6 @@ extern boolean bufferOpen (unsigned char *buffer, int buffer_size,
mio_getpos (File.mio, &StartOfLine);
mio_getpos (File.mio, &File.filePosition);
File.currentLine = NULL;
- File.language = language;
File.lineNumber = 0L;
File.eof = FALSE;
File.newLine = TRUE;
Modified: tagmanager/ctags/read.h
1 files changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -79,7 +79,6 @@ enum eCharacters {
int ungetch; /* a single character that was ungotten */
boolean eof; /* have we reached the end of file? */
boolean newLine; /* will the next character begin a new line? */
- langType language; /* language of input file */
/* Contains data pertaining to the original source file in which the tag
* was defined. This may be different from the input file when #line
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Sat, 28 Jul 2012 17:23:37
Commit: 5110fab0e10b2f352ce4dbf66d991820a97079dd
https://github.com/geany/geany/commit/5110fab0e10b2f352ce4dbf66d991820a9707…
Log Message:
-----------
Fix search and replacement of empty matches (again)
f4eb89cd7d79738a9c6c45e29abdd9d15d22e4fd was partially wrong and
removed legitimate re-matches when two different matches ends at the
same position. Particularly, the replacement changes are reverted.
Interestingly, Perl and Python does not agree on how to do such
replacements. Python does what I did in the above-cited commit, e.g.
doesn't replace twice if the match end overlaps, but Perl does.
Perl looks more legitimate here since both Python and Perl does find
the overlapping matches when performing a search, so Python is the odd
guy here doing it differently on replace than it does upon search.
For example, replacing using the pattern "a?(?=b)" and the replacement
string "_":
Python: ababcdb -> _b_bcd_b
Perl: ababcdb -> __b__bcd_b
But finding using the same pattern on the same input gives the same
results on both:
Python: ababcdb -> ['a', '', 'a', '', '']
Perl: ababcdb -> ['a', '', 'a', '', '']
Anyway, GLib and us claim to support "Perl-compatible regular
expressions", so we gotta follow Perl, especially in such doubtful
situations.
Modified Paths:
--------------
src/search.c
Modified: src/search.c
47 files changed, 16 insertions(+), 31 deletions(-)
===================================================================
@@ -2028,7 +2028,6 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
struct Sci_TextToFind ttf;
gint count = 0;
gint prev_line = -1;
- gint prev_end = -1;
g_return_val_if_fail(doc != NULL, 0);
@@ -2045,27 +2044,22 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
if (pos == -1)
break; /* no more matches */
- /* avoid rematching with empty matches like "(?=[a-z])" or "^$".
- * note we cannot assume a match will always be empty or not, like with "a?(?=b)"*/
- if (ttf.chrgText.cpMax != prev_end)
+ count++;
+ line = sci_get_line_from_position(doc->editor->sci, pos);
+ if (line != prev_line)
{
- count++;
- line = sci_get_line_from_position(doc->editor->sci, pos);
- if (line != prev_line)
- {
- buffer = sci_get_line(doc->editor->sci, line);
- msgwin_msg_add(COLOR_BLACK, line + 1, doc,
- "%s:%d: %s", short_file_name, line + 1, g_strstrip(buffer));
- g_free(buffer);
- prev_line = line;
- }
+ buffer = sci_get_line(doc->editor->sci, line);
+ msgwin_msg_add(COLOR_BLACK, line + 1, doc,
+ "%s:%d: %s", short_file_name, line + 1, g_strstrip(buffer));
+ g_free(buffer);
+ prev_line = line;
}
- prev_end = ttf.chrgText.cpMax;
-
- if (ttf.chrg.cpMin < ttf.chrgText.cpMax)
- ttf.chrg.cpMin = ttf.chrgText.cpMax;
- else
+ ttf.chrg.cpMin = ttf.chrgText.cpMax;
+ /* avoid rematching with empty matches like "(?=[a-z])" or "^$".
+ * note we cannot assume a match will always be empty or not and then break out, since
+ * matches like "a?(?=b)" will me sometimes empty and sometimes not */
+ if ((ttf.chrgText.cpMax - ttf.chrgText.cpMin) == 0)
ttf.chrg.cpMin ++;
}
g_free(short_file_name);
@@ -2136,7 +2130,6 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
const gchar *find_text = ttf->lpstrText;
gint start = ttf->chrg.cpMin;
gint end = ttf->chrg.cpMax;
- gint prev_find_end = -1;
g_return_val_if_fail(sci != NULL && find_text != NULL && replace_text != NULL, 0);
if (! *find_text)
@@ -2168,14 +2161,9 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
if (chNext == '\r' || chNext == '\n')
movepastEOL = 1;
}
- /* make sure we don't replace the same position twice, in case of pattern
- * like "a?(?=b)" (would match "a"b and then ""b -- empty match the 2nd time) */
- if (prev_find_end != ttf->chrgText.cpMax)
- {
- replace_len = search_replace_target(sci, replace_text,
- flags & SCFIND_REGEXP);
- count++;
- }
+ replace_len = search_replace_target(sci, replace_text,
+ flags & SCFIND_REGEXP);
+ count++;
if (search_pos == end)
break; /* Prevent hang when replacing regex $ */
@@ -2186,9 +2174,6 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
ttf->chrg.cpMin = start;
end += replace_len - find_len; /* update end of range now text has changed */
ttf->chrg.cpMax = end;
-
- /* match end + replacement offset */
- prev_find_end = ttf->chrgText.cpMax + replace_len - find_len;
}
}
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Fri, 27 Jul 2012 22:32:26
Commit: a091238617a5461a2f5642e9589f15748f4e28ac
https://github.com/geany/geany/commit/a091238617a5461a2f5642e9589f15748f4e2…
Log Message:
-----------
Fix searching out of document range
If a search matched the very last character of the document, next
search attempt started out of the document bounds. This even lead
to an infinite loop due to an improper sanity check.
By the way, this fixes matching of contiguous results, as the next
search used to improperly skip one character after the result.
Although this looks like a huge issue, it was actually visible almost
only on the match count since the whole matching line was printed.
Modified Paths:
--------------
src/search.c
Modified: src/search.c
7 files changed, 3 insertions(+), 4 deletions(-)
===================================================================
@@ -1894,7 +1894,7 @@ static gint find_regex(ScintillaObject *sci, guint pos, GRegex *regex)
GMatchInfo *minfo;
gint ret = -1;
- g_return_val_if_fail(pos <= (guint)sci_get_length(sci), FALSE);
+ g_return_val_if_fail(pos <= (guint)sci_get_length(sci), -1);
/* clear old match */
SETPTR(regex_match_text, NULL);
@@ -2035,7 +2035,7 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
ttf.lpstrText = (gchar *)search_text;
while (1)
{
- gint pos, line, start, find_len;
+ gint pos, line, find_len;
pos = search_find_text(doc->editor->sci, flags, &ttf);
if (pos == -1)
@@ -2055,8 +2055,7 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
prev_line = line;
}
- start = ttf.chrgText.cpMax + 1;
- ttf.chrg.cpMin = start;
+ ttf.chrg.cpMin = ttf.chrgText.cpMax;
}
g_free(short_file_name);
return count;
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Fri, 27 Jul 2012 22:32:26
Commit: f4eb89cd7d79738a9c6c45e29abdd9d15d22e4fd
https://github.com/geany/geany/commit/f4eb89cd7d79738a9c6c45e29abdd9d15d22e…
Log Message:
-----------
Fix search and replacement of empty matches
Regular expressions might match empty ranges, which weren't handled
properly, but generally simply omitted.
For example, the regular expression "^$" (empty line) never matched
because we assumed empty results were not interesting, and actually
needed more care in the code. Alike, an expression matching only on
its lookahead part, like "a?(?=b)" against "b", would stop further
search, although it could even match a non-empty range if "ab" is
present later in the input. This last kind of expressions also lead
to double-replacement because they first matched "ab" and then "b"
alone when re-matching after the "a" replacement.
This commit fixes:
* searching when the matched range is empty;
* step-by-step search when matching an empty range;
* double replacement when the pattern re-matches an empty range
straight after a replacement;
* replacement to and empty string when the matching an empty range.
A know issue though is the step-by-step replacement that won't replace
an empty match but rather find the next match.
Modified Paths:
--------------
src/search.c
Modified: src/search.c
55 files changed, 37 insertions(+), 18 deletions(-)
===================================================================
@@ -1940,6 +1940,9 @@ gint search_find_next(ScintillaObject *sci, const gchar *str, gint flags)
pos = sci_get_current_position(sci);
ret = find_regex(sci, pos, regex);
+ /* avoid re-matching the same position in case of empty matches */
+ if (ret == pos && regex_matches[0].start == regex_matches[0].end)
+ ret = find_regex(sci, pos + 1, regex);
if (ret >= 0)
sci_set_selection(sci, ret, regex_matches[0].end);
@@ -2025,6 +2028,7 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
struct Sci_TextToFind ttf;
gint count = 0;
gint prev_line = -1;
+ gint prev_end = -1;
g_return_val_if_fail(doc != NULL, 0);
@@ -2035,27 +2039,34 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
ttf.lpstrText = (gchar *)search_text;
while (1)
{
- gint pos, line, find_len;
+ gint pos, line;
pos = search_find_text(doc->editor->sci, flags, &ttf);
if (pos == -1)
break; /* no more matches */
- find_len = ttf.chrgText.cpMax - ttf.chrgText.cpMin;
- if (find_len == 0)
- break; /* Ignore regex ^ or $ */
- count++;
- line = sci_get_line_from_position(doc->editor->sci, pos);
- if (line != prev_line)
+ /* avoid rematching with empty matches like "(?=[a-z])" or "^$".
+ * note we cannot assume a match will always be empty or not, like with "a?(?=b)"*/
+ if (ttf.chrgText.cpMax != prev_end)
{
- buffer = sci_get_line(doc->editor->sci, line);
- msgwin_msg_add(COLOR_BLACK, line + 1, doc,
- "%s:%d: %s", short_file_name, line + 1, g_strstrip(buffer));
- g_free(buffer);
- prev_line = line;
+ count++;
+ line = sci_get_line_from_position(doc->editor->sci, pos);
+ if (line != prev_line)
+ {
+ buffer = sci_get_line(doc->editor->sci, line);
+ msgwin_msg_add(COLOR_BLACK, line + 1, doc,
+ "%s:%d: %s", short_file_name, line + 1, g_strstrip(buffer));
+ g_free(buffer);
+ prev_line = line;
+ }
}
- ttf.chrg.cpMin = ttf.chrgText.cpMax;
+ prev_end = ttf.chrgText.cpMax;
+
+ if (ttf.chrg.cpMin < ttf.chrgText.cpMax)
+ ttf.chrg.cpMin = ttf.chrgText.cpMax;
+ else
+ ttf.chrg.cpMin ++;
}
g_free(short_file_name);
return count;
@@ -2125,6 +2136,7 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
const gchar *find_text = ttf->lpstrText;
gint start = ttf->chrg.cpMin;
gint end = ttf->chrg.cpMax;
+ gint prev_find_end = -1;
g_return_val_if_fail(sci != NULL && find_text != NULL && replace_text != NULL, 0);
if (! *find_text)
@@ -2139,8 +2151,6 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
find_len = ttf->chrgText.cpMax - ttf->chrgText.cpMin;
if (search_pos == -1)
break; /* no more matches */
- if (find_len == 0 && ! NZV(replace_text))
- break; /* nothing to do */
if (search_pos + find_len > end)
break; /* found text is partly out of range */
@@ -2158,9 +2168,14 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
if (chNext == '\r' || chNext == '\n')
movepastEOL = 1;
}
- replace_len = search_replace_target(sci, replace_text,
- flags & SCFIND_REGEXP);
- count++;
+ /* make sure we don't replace the same position twice, in case of pattern
+ * like "a?(?=b)" (would match "a"b and then ""b -- empty match the 2nd time) */
+ if (prev_find_end != ttf->chrgText.cpMax)
+ {
+ replace_len = search_replace_target(sci, replace_text,
+ flags & SCFIND_REGEXP);
+ count++;
+ }
if (search_pos == end)
break; /* Prevent hang when replacing regex $ */
@@ -2171,7 +2186,11 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
ttf->chrg.cpMin = start;
end += replace_len - find_len; /* update end of range now text has changed */
ttf->chrg.cpMax = end;
+
+ /* match end + replacement offset */
+ prev_find_end = ttf->chrgText.cpMax + replace_len - find_len;
}
+
}
return count;
}
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).