Revision: 4846
http://geany.svn.sourceforge.net/geany/?rev=4846&view=rev
Author: ntrel
Date: 2010-04-21 17:16:27 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
Mention editor-notify signal in dox.
Modified Paths:
--------------
trunk/src/sciwrappers.c
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2010-04-21 17:04:31 UTC (rev 4845)
+++ trunk/src/sciwrappers.c 2010-04-21 17:16:27 UTC (rev 4846)
@@ -24,6 +24,9 @@
/** @file sciwrappers.h
* Wrapper functions for the Scintilla editor widget @c SCI_* messages.
* You should also check the http://scintilla.org documentation, as it is more detailed.
+ *
+ * To get Scintilla notifications, use the @c editor-notify @link signals Geany Signal @endlink.
+ *
* @note These functions were originally from the cssed project
* (http://cssed.sf.net, thanks).
* @see scintilla_send_message().
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4845
http://geany.svn.sourceforge.net/geany/?rev=4845&view=rev
Author: ntrel
Date: 2010-04-21 17:04:31 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
Fix Class Builder plugin to use correct indentation instead of
always tabs.
Make editor_insert_text_block() only replace leading tabs for the
'Tabs' indent type; also group edits for undo.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/classbuilder.c
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-04-21 16:58:02 UTC (rev 4844)
+++ trunk/ChangeLog 2010-04-21 17:04:31 UTC (rev 4845)
@@ -1,3 +1,16 @@
+2010-04-21 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/templates.c, doc/geany.txt, doc/geany.html:
+ Support {ob} and {cb} in fileheader and file templates; they are
+ replaced last with { and }. This allows 'escaping' of wildcard
+ strings (fixes #2937008).
+ * src/editor.c, plugins/classbuilder.c:
+ Fix Class Builder plugin to use correct indentation instead of
+ always tabs.
+ Make editor_insert_text_block() only replace leading tabs for the
+ 'Tabs' indent type; also group edits for undo.
+
+
2010-04-19 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* tagmanager/pascal.c:
Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c 2010-04-21 16:58:02 UTC (rev 4844)
+++ trunk/plugins/classbuilder.c 2010-04-21 17:04:31 UTC (rev 4845)
@@ -704,7 +704,7 @@
{
text = get_template_class_source(class_info);
doc = document_new_file(class_info->source, NULL, NULL);
- sci_set_text(doc->editor->sci, text);
+ editor_insert_text_block(doc->editor, text, 0, -1, 0, TRUE);
g_free(text);
}
@@ -712,7 +712,7 @@
{
text = get_template_class_header(class_info);
doc = document_new_file(class_info->header, NULL, NULL);
- sci_set_text(doc->editor->sci, text);
+ editor_insert_text_block(doc->editor, text, 0, -1, 0, TRUE);
g_free(text);
}
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2010-04-21 16:58:02 UTC (rev 4844)
+++ trunk/src/editor.c 2010-04-21 17:04:31 UTC (rev 4845)
@@ -44,6 +44,12 @@
#include "SciLexer.h"
#include "geany.h"
+#ifdef HAVE_REGEX_H
+# include <regex.h>
+#else
+# include "gnuregex.h"
+#endif
+
#include "support.h"
#include "editor.h"
#include "document.h"
@@ -2112,9 +2118,40 @@
}
-/** Inserts text, replacing \\t tab chars (@c 0x9) with the correct indent
- * width, and \\n newline chars (@c 0xA) with the correct line ending string
- * for the document.
+static void replace_leading_tabs(GString *str, const gchar *whitespace)
+{
+ regex_t regex;
+ gssize pos;
+ regmatch_t matches[2];
+ gchar *ptr;
+
+ if (regcomp(®ex, "^ *(\t)", 0) != 0)
+ {
+ g_return_if_fail(FALSE);
+ }
+ ptr = str->str;
+ while (ptr)
+ {
+ if (regexec(®ex, ptr,
+ G_N_ELEMENTS(matches), matches, 0) != 0)
+ break;
+
+ pos = matches[1].rm_so;
+ g_return_if_fail(pos >= 0);
+ pos += ptr - str->str;
+ g_string_erase(str, pos, 1);
+ g_string_insert(str, pos, whitespace);
+ ptr = str->str + pos + strlen(whitespace);
+ }
+ regfree(®ex);
+}
+
+
+/** Inserts text, replacing \\t tab chars (@c 0x9) and \\n newline chars (@c 0xA)
+ * accordingly for the document.
+ * - Leading tabs are replaced with the correct indentation.
+ * - Non-leading tabs are replaced with spaces (except when using 'Tabs' indent type).
+ * - Newline chars are replaced with the correct line ending string.
* This is very useful for inserting code without having to handle the indent
* type yourself (Tabs & Spaces mode can be tricky).
* @param editor Editor.
@@ -2123,11 +2160,10 @@
* @param cursor_index If >= 0, the index into @a text to place the cursor.
* @param newline_indent_size Indentation size (in spaces) to insert for each newline; use
* -1 to read the indent size from the line with @a insert_pos on it.
- * @param replace_newlines Whether to replace newlines in text or not. If
- * newlines have been replaced before, this should be false, to avoid multiple
- * replacements of newlines, which is error prone on Windows.
- * @warning Make sure all \\t tab chars in @a text are intended as indent widths,
- * not hard tabs, as these might not be preserved.
+ * @param replace_newlines Whether to replace newlines. If
+ * newlines have been replaced already, this should be false, to avoid errors e.g. on Windows.
+ * @warning Make sure all \\t tab chars in @a text are intended as indent widths or alignment,
+ * not hard tabs, as those won't be preserved.
* @note This doesn't scroll the cursor in view afterwards. **/
void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint insert_pos,
gint cursor_index, gint newline_indent_size, gboolean replace_newlines)
@@ -2139,6 +2175,7 @@
GString *buf;
const gchar cur_marker[] = "__GEANY_CURSOR_MARKER__";
const gchar *eol = editor_get_eol_char(editor);
+ const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
g_return_if_fail(text);
g_return_if_fail(editor != NULL);
@@ -2173,11 +2210,16 @@
if (replace_newlines)
utils_string_replace_all(buf, "\n", eol);
- /* transform tabs into indent widths (in spaces) */
- whitespace = g_strnfill(editor_get_indent_prefs(editor)->width, ' ');
- utils_string_replace_all(buf, "\t", whitespace);
+ /* transform leading tabs into indent widths (in spaces) */
+ whitespace = g_strnfill(iprefs->width, ' ');
+ replace_leading_tabs(buf, whitespace);
+ /* remaining tabs are for alignment */
+ if (iprefs->type != GEANY_INDENT_TYPE_TABS)
+ utils_string_replace_all(buf, "\t", whitespace);
g_free(whitespace);
+ sci_start_undo_action(sci);
+
if (cursor_index >= 0)
{
gint idx = utils_strpos(buf->str, cur_marker);
@@ -2195,6 +2237,7 @@
fix_line_indents(editor, line_start, line_end);
snippet_cursor_insert_pos = sci_get_current_position(sci);
+ sci_end_undo_action(sci);
g_string_free(buf, TRUE);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4844
http://geany.svn.sourceforge.net/geany/?rev=4844&view=rev
Author: ntrel
Date: 2010-04-21 16:58:02 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
Minor edits of Template Wildcards table:
s/filetype templates/file templates.
Add full stop for third column.
Modified Paths:
--------------
trunk/doc/geany.html
trunk/doc/geany.txt
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2010-04-21 16:47:54 UTC (rev 4843)
+++ trunk/doc/geany.html 2010-04-21 16:58:02 UTC (rev 4844)
@@ -6,7 +6,7 @@
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>Geany</title>
<meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" />
-<meta name="date" content="2010-04-19" />
+<meta name="date" content="2010-04-21" />
<style type="text/css">
/*
@@ -139,7 +139,7 @@
<br />Nick Treleaven
<br />Frank Lanitz</td></tr>
<tr><th class="docinfo-name">Date:</th>
-<td>2010-04-19</td></tr>
+<td>2010-04-21</td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.19</td></tr>
</tbody>
@@ -4889,112 +4889,112 @@
<tr><td>ob</td>
<td>Opening Brace (used to prevent other
wildcards being expanded).</td>
-<td>file templates, file header</td>
+<td>file templates, file header.</td>
</tr>
<tr><td>cb</td>
<td>Closing Brace.</td>
-<td>file templates, file header</td>
+<td>file templates, file header.</td>
</tr>
<tr><td>developer</td>
<td>The name of the developer.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>initial</td>
<td>The developer's initials, e.g. "ET" for
Enrico Tröger or "JFD" for John Foobar Doe.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>mail</td>
<td>The email address of the developer.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>company</td>
<td>The company the developer is working for.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>year <a class="footnote-reference" href="#id10" id="id7" name="id7">[1]</a></td>
<td>The current year. Default format is: YYYY.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>version</td>
<td>The initial version of a new file.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>date <a class="footnote-reference" href="#id10" id="id8" name="id8">[1]</a></td>
<td>The current date. Default format:
YYYY-MM-DD.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>untitled</td>
<td>The string "untitled" (this will be
translated to your locale), used in
-filetype templates.</td>
-<td>filetype templates, file header,
+file templates.</td>
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>geanyversion</td>
<td>The actual Geany version, e.g.
"Geany 0.19".</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>datetime <a class="footnote-reference" href="#id10" id="id9" name="id9">[1]</a></td>
<td>The current date and time. Default format:
DD.MM.YYYY HH:mm:ss ZZZZ.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
<tr><td>filename</td>
<td>The filename of the current file.</td>
-<td>file header, snippets</td>
+<td>file header, snippets.</td>
</tr>
<tr><td>gpl</td>
<td>This wildcard inserts a short GPL notice.</td>
-<td>file header</td>
+<td>file header.</td>
</tr>
<tr><td>bsd</td>
<td>This wildcard inserts a BSD licence notice.</td>
-<td>file header</td>
+<td>file header.</td>
</tr>
<tr><td>functionname</td>
<td>The function name of the function at the
-cursor position. This wildcard will only be
-replaced in the function description
+cursor position. This wildcard will only be.
+replaced in the function description.
template.</td>
-<td>function description</td>
+<td>function description.</td>
</tr>
<tr><td>fileheader</td>
<td>The file header template. This wildcard
will only be replaced in filetype
templates.</td>
-<td>file header, snippets, file
-templates</td>
+<td>file header, snippets, file.
+templates.</td>
</tr>
<tr><td>command:path</td>
<td>Executes the specified command and replace
the wildcard with the command's standard
output. See <a class="reference" href="#special-command-wildcard">Special {command:} wildcard</a>
for details.</td>
-<td>filetype templates, file header,
+<td>file templates, file header,
function description, ChangeLog entry,
-bsd, gpl, snippets</td>
+bsd, gpl, snippets.</td>
</tr>
</tbody>
</table>
@@ -5996,7 +5996,7 @@
<div class="footer">
<hr class="footer" />
<a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2010-04-21 16:38 UTC.
+Generated on: 2010-04-21 16:56 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2010-04-21 16:47:54 UTC (rev 4843)
+++ trunk/doc/geany.txt 2010-04-21 16:58:02 UTC (rev 4844)
@@ -4230,68 +4230,68 @@
============== ============================================= =======================================
Wildcard Description Available in
============== ============================================= =======================================
-ob Opening Brace (used to prevent other file templates, file header
+ob Opening Brace (used to prevent other file templates, file header.
wildcards being expanded).
-cb Closing Brace. file templates, file header
+cb Closing Brace. file templates, file header.
-developer The name of the developer. filetype templates, file header,
+developer The name of the developer. file templates, file header,
function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-initial The developer's initials, e.g. "ET" for filetype templates, file header,
+initial The developer's initials, e.g. "ET" for file templates, file header,
Enrico Tröger or "JFD" for John Foobar Doe. function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-mail The email address of the developer. filetype templates, file header,
+mail The email address of the developer. file templates, file header,
function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-company The company the developer is working for. filetype templates, file header,
+company The company the developer is working for. file templates, file header,
function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-year [1]_ The current year. Default format is: YYYY. filetype templates, file header,
+year [1]_ The current year. Default format is: YYYY. file templates, file header,
function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-version The initial version of a new file. filetype templates, file header,
+version The initial version of a new file. file templates, file header,
function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-date [1]_ The current date. Default format: filetype templates, file header,
+date [1]_ The current date. Default format: file templates, file header,
YYYY-MM-DD. function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-untitled The string "untitled" (this will be filetype templates, file header,
+untitled The string "untitled" (this will be file templates, file header,
translated to your locale), used in function description, ChangeLog entry,
- filetype templates. bsd, gpl, snippets
+ file templates. bsd, gpl, snippets.
-geanyversion The actual Geany version, e.g. filetype templates, file header,
+geanyversion The actual Geany version, e.g. file templates, file header,
"Geany |(version)|". function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-datetime [1]_ The current date and time. Default format: filetype templates, file header,
+datetime [1]_ The current date and time. Default format: file templates, file header,
DD.MM.YYYY HH:mm:ss ZZZZ. function description, ChangeLog entry,
- bsd, gpl, snippets
+ bsd, gpl, snippets.
-filename The filename of the current file. file header, snippets
+filename The filename of the current file. file header, snippets.
-gpl This wildcard inserts a short GPL notice. file header
+gpl This wildcard inserts a short GPL notice. file header.
-bsd This wildcard inserts a BSD licence notice. file header
+bsd This wildcard inserts a BSD licence notice. file header.
-functionname The function name of the function at the function description
- cursor position. This wildcard will only be
- replaced in the function description
+functionname The function name of the function at the function description.
+ cursor position. This wildcard will only be.
+ replaced in the function description.
template.
-fileheader The file header template. This wildcard file header, snippets, file
- will only be replaced in filetype templates
+fileheader The file header template. This wildcard file header, snippets, file.
+ will only be replaced in filetype templates.
templates.
-command:path Executes the specified command and replace filetype templates, file header,
+command:path Executes the specified command and replace file templates, file header,
the wildcard with the command's standard function description, ChangeLog entry,
- output. See `Special {command:} wildcard`_ bsd, gpl, snippets
+ output. See `Special {command:} wildcard`_ bsd, gpl, snippets.
for details.
============== ============================================= =======================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Geany Windows build failed at: waf build
See http://geany.nightlybuilds.org/win32/build_win32_stderr.log for details.
Error messages:
../../geany_svn/src/socket.c: In function `check_socket_permissions':
../../geany_svn/src/socket.c:217: error: storage size of 'socket_stat' isn't known
../../geany_svn/src/socket.c:219: warning: implicit declaration of function `g_lstat'
../../geany_svn/src/socket.c:222: warning: implicit declaration of function `getuid'
...
../../geany_svn/src/socket.c: In function `socket_fd_check_io':
../../geany_svn/src/socket.c:736: warning: comparison between signed and unsigned
../../geany_svn/src/socket.c: At top level:
../../geany_svn/src/socket.c:216: warning: 'check_socket_permissions' defined but not used
Build failed
-> task failed (err #1):
{task: cc socket.c -> socket_3.o}
http://geany.nightlybuilds.org/
Geany Windows build failed at: waf build
See http://geany.nightlybuilds.org/win32/build_win32_stderr.log for details.
Error messages:
../../geany_svn/src/socket.c: In function `check_socket_permissions':
../../geany_svn/src/socket.c:217: error: storage size of 'socket_stat' isn't known
../../geany_svn/src/socket.c:219: warning: implicit declaration of function `g_lstat'
../../geany_svn/src/socket.c:222: warning: implicit declaration of function `getuid'
...
../../geany_svn/src/socket.c: In function `socket_fd_check_io':
../../geany_svn/src/socket.c:736: warning: comparison between signed and unsigned
../../geany_svn/src/socket.c: At top level:
../../geany_svn/src/socket.c:216: warning: 'check_socket_permissions' defined but not used
Build failed
-> task failed (err #1):
{task: cc socket.c -> socket_3.o}
http://geany.nightlybuilds.org/
Revision: 4842
http://geany.svn.sourceforge.net/geany/?rev=4842&view=rev
Author: eht16
Date: 2010-04-19 21:20:15 +0000 (Mon, 19 Apr 2010)
Log Message:
-----------
When starting and trying to access the Unix Domain socket of a potentially running instance, first compare file ownership with the user id of the running process to prevent accessing a wrong socket file (part of #2985463, this might not yet be the final solution).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/socket.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-04-19 20:48:54 UTC (rev 4841)
+++ trunk/ChangeLog 2010-04-19 21:20:15 UTC (rev 4842)
@@ -10,6 +10,11 @@
Add a static global variable to monitor autocompletion mode in order
to prevent cancellation of the struct/class (C/C++) auto completion
list (patch by Thomas Martitz, thanks).
+ * src/socket.c:
+ When starting and trying to access the Unix Domain socket of a
+ potentially running instance, first compare file ownership with the
+ user id of the running process to prevent accessing a wrong socket
+ file (part of #2985463, this might not yet be the final solution).
2010-04-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2010-04-19 20:48:54 UTC (rev 4841)
+++ trunk/src/socket.c 2010-04-19 21:20:15 UTC (rev 4842)
@@ -86,6 +86,7 @@
#include "support.h"
#include "ui_utils.h"
#include "utils.h"
+#include "dialogs.h"
#include "encodings.h"
@@ -211,6 +212,27 @@
}
+static void check_socket_permissions(void)
+{
+ struct stat socket_stat;
+
+ if (g_lstat(socket_info.file_name, &socket_stat) == 0)
+ { /* If the user id of the process is not the same as the owner of the socket
+ * file, then ignore this socket and start a new session. */
+ if (socket_stat.st_uid != getuid())
+ {
+ const gchar *msg = _(
+ /* TODO maybe this message needs a rewording */
+ "Geany tried to access the Unix Domain socket of another instance running as another user.\n"
+ "This is a fatal error and Geany will now quit.");
+ g_warning("%s", msg);
+ dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", msg);
+ exit(1);
+ }
+ }
+}
+
+
/* (Unix domain) socket support to replace the old FIFO code
* (taken from Sylpheed, thanks)
* Returns the created socket, -1 if an error occurred or -2 if another socket exists and files
@@ -266,6 +288,9 @@
g_free(display_name);
g_free(hostname);
+ /* check whether the real user id is the same as this of the socket file */
+ check_socket_permissions();
+
sock = socket_fd_connect_unix(socket_info.file_name);
if (sock < 0)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.