Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Fri, 25 Oct 2024 21:33:35 UTC
Commit: 7296fbcc2ae88cd30dcb7ad8fe289e9654bf1d8c
https://github.com/geany/geany/commit/7296fbcc2ae88cd30dcb7ad8fe289e9654bf1…
Log Message:
-----------
Recognize shell scripts when using busybox
Pretty much stolen patch from Colomban Wendling from
https://github.com/geany/geany/issues/3884
and converted to a pull request. Also tested, seems to work as expected.
Modified Paths:
--------------
src/filetypes.c
Modified: src/filetypes.c
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -635,6 +635,10 @@ static GeanyFiletype *find_shebang(const gchar *utf8_filename, const gchar *line
{ /* skip "env" and read the following interpreter */
basename_interpreter += 4;
}
+ else if (g_str_has_prefix(tmp, "busybox "))
+ {
+ basename_interpreter += 8;
+ }
for (i = 0; ! ft && i < G_N_ELEMENTS(intepreter_map); i++)
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 08 Jun 2024 21:11:01 UTC
Commit: d267fa2d92b069a9c0c19675a0b88a842d967181
https://github.com/geany/geany/commit/d267fa2d92b069a9c0c19675a0b88a842d967…
Log Message:
-----------
Fix a problem when multiple project opens clear the default session
Steps to reproduce:
1. With no project open, open some files
2. Open project A
3. Without closing project A first, open project B
4. Close project B
5. The originally open files from (1) are gone
The problem is that when project A closes and all its files are closed,
load_config() gets called which contains
configuration_save_default_session();
This saves the session with all files closed and replaces the original
session.
This patch modifies the code to call configuration_save_default_session()
only when there are some open tabs so the above problem gets solved.
Even though I was worried that this would break saving default session
when all its files get closed and then a project is loaded, it
doesn't seem to be the case (I haven't investigated deep enough why).
An alternative to this approach would be to pass a boolean as a parameter
of quite many functions and propagate the information whether
project close preceded its opening but it introduces a much bigger diff
and makes the complicated session opening stuff even wilder.
Fixes #3897.
Modified Paths:
--------------
src/project.c
Modified: src/project.c
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -1100,7 +1100,8 @@ static gboolean load_config(const gchar *filename)
/* save current (non-project) session (it could have been changed since program startup) */
if (!main_status.opening_session_files)
{
- configuration_save_default_session();
+ if (have_session_docs())
+ configuration_save_default_session();
/* now close all open files */
document_close_all();
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Thu, 20 Jun 2024 10:46:20 UTC
Commit: 6c1fdf6f8e78512bd43ba2e84169f0321979eebf
https://github.com/geany/geany/commit/6c1fdf6f8e78512bd43ba2e84169f0321979e…
Log Message:
-----------
Add an explanation comment
Modified Paths:
--------------
src/project.c
Modified: src/project.c
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -1100,6 +1100,11 @@ static gboolean load_config(const gchar *filename)
/* save current (non-project) session (it could have been changed since program startup) */
if (!main_status.opening_session_files)
{
+ /* Opening another project while some project is already opene causes
+ * that upon closing the first project, empty session is saved here.
+ * The check below prevents that but has a side-effect that when
+ * save_config_on_file_change=FALSE, the session with all closed files
+ * isn't saved when opening a project. */
if (have_session_docs())
configuration_save_default_session();
/* now close all open files */
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: Thu, 24 Oct 2024 15:47:02 UTC
Commit: 7e6b83594847b32df4b7cf15bd5cd12643925eec
https://github.com/geany/geany/commit/7e6b83594847b32df4b7cf15bd5cd12643925…
Log Message:
-----------
Merge pull request #3898 from techee/session_fix2
Fix a problem when multiple project opens clear the default session
Modified Paths:
--------------
src/project.c
Modified: src/project.c
8 lines changed, 7 insertions(+), 1 deletions(-)
===================================================================
@@ -1118,7 +1118,13 @@ static gboolean load_config(const gchar *filename)
/* save current (non-project) session (it could have been changed since program startup) */
if (!main_status.opening_session_files)
{
- configuration_save_default_session();
+ /* Opening another project while some project is already opene causes
+ * that upon closing the first project, empty session is saved here.
+ * The check below prevents that but has a side-effect that when
+ * save_config_on_file_change=FALSE, the session with all closed files
+ * isn't saved when opening a project. */
+ if (have_session_docs())
+ configuration_save_default_session();
/* now close all open files */
document_close_all();
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Fri, 13 Sep 2024 12:04:54 UTC
Commit: 458a77adb0a7c7b3d649bcaedfcbd07604c5dd5f
https://github.com/geany/geany/commit/458a77adb0a7c7b3d649bcaedfcbd07604c5d…
Log Message:
-----------
Modify utils_write_file() to always use g_file_replace_contents()
From having a look at where this function is used, by Geany it's
used only to store configuration files in the .config directory and
some auxiliary functions like writing the export file by the exporter
plugin. In the geany-plugins project this function is used only for
saving configuration files.
Before this patch, the fwrite() method was used by default for saving
configuration files (because g_file_replace_contents() normally used
by Geany wasn't used in this function) which wasn't very safe and could
lead to configuration file loss under some extreme conditions.
The documentation of this function was changed to reflect the situation
better than now - the previous comment made the impression that file
permissions were always preserved with this method but it wasn't the
case and depended on the exact configuration.
Modified Paths:
--------------
src/utils.c
Modified: src/utils.c
69 lines changed, 23 insertions(+), 46 deletions(-)
===================================================================
@@ -208,9 +208,12 @@ gboolean utils_is_opening_brace(gchar c, gboolean include_angles)
* If the file doesn't exist, it will be created.
* If it already exists, it will be overwritten.
*
- * @warning You should use @c g_file_set_contents() instead if you don't need
- * file permissions and other metadata to be preserved, as that always handles
- * disk exhaustion safely.
+ * @warning Currently, this function uses g_file_replace_contents() to save
+ * files which offers a reasonable balence between data safety during save
+ * and other factors such as handling symlinks, remote files, or platform-
+ * dependent aspects. However, plugins with special requirements should
+ * not rely on the exact implementation of this function and should rather
+ * implement file saving by themselves.
*
* @param filename The filename of the file to write, in locale encoding.
* @param text The text to write into the file.
@@ -221,55 +224,29 @@ gboolean utils_is_opening_brace(gchar c, gboolean include_angles)
GEANY_API_SYMBOL
gint utils_write_file(const gchar *filename, const gchar *text)
{
+ GError *error = NULL;
+ gboolean success;
+ GFile *fp;
+
g_return_val_if_fail(filename != NULL, ENOENT);
g_return_val_if_fail(text != NULL, EINVAL);
- if (file_prefs.use_safe_file_saving)
+ fp = g_file_new_for_path(filename);
+
+ success = g_file_replace_contents(fp, text, strlen(text), NULL, FALSE,
+ G_FILE_CREATE_NONE, NULL, NULL, &error);
+
+ g_object_unref(fp);
+
+ if (error)
{
- GError *error = NULL;
- if (! g_file_set_contents(filename, text, -1, &error))
- {
- geany_debug("%s: could not write to file %s (%s)", G_STRFUNC, filename, error->message);
- g_error_free(error);
- return EIO;
- }
+ geany_debug("%s: could not write to file %s (%s)", G_STRFUNC, filename, error->message);
+ g_error_free(error);
}
- else
- {
- FILE *fp;
- gsize bytes_written, len;
- gboolean fail = FALSE;
-
- if (filename == NULL)
- return ENOENT;
-
- len = strlen(text);
- errno = 0;
- fp = g_fopen(filename, "w");
- if (fp == NULL)
- fail = TRUE;
- else
- {
- bytes_written = fwrite(text, sizeof(gchar), len, fp);
+ else if (!success)
+ geany_debug("%s: could not write to file %s", G_STRFUNC, filename);
- if (len != bytes_written)
- {
- fail = TRUE;
- geany_debug(
- "utils_write_file(): written only %"G_GSIZE_FORMAT" bytes, had to write %"G_GSIZE_FORMAT" bytes to %s",
- bytes_written, len, filename);
- }
- if (fclose(fp) != 0)
- fail = TRUE;
- }
- if (fail)
- {
- geany_debug("utils_write_file(): could not write to file %s (%s)",
- filename, g_strerror(errno));
- return FALLBACK(errno, EIO);
- }
- }
- return 0;
+ return success ? 0 : EIO;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: Thu, 24 Oct 2024 15:45:45 UTC
Commit: 2973111fae8f6d743b94e0ae9b22bae8875846c0
https://github.com/geany/geany/commit/2973111fae8f6d743b94e0ae9b22bae887584…
Log Message:
-----------
Merge pull request #3950 from techee/file_save2
Modify utils_write_file() to always use g_file_replace_contents()
Modified Paths:
--------------
src/utils.c
Modified: src/utils.c
69 lines changed, 23 insertions(+), 46 deletions(-)
===================================================================
@@ -208,9 +208,12 @@ gboolean utils_is_opening_brace(gchar c, gboolean include_angles)
* If the file doesn't exist, it will be created.
* If it already exists, it will be overwritten.
*
- * @warning You should use @c g_file_set_contents() instead if you don't need
- * file permissions and other metadata to be preserved, as that always handles
- * disk exhaustion safely.
+ * @warning Currently, this function uses g_file_replace_contents() to save
+ * files which offers a reasonable balence between data safety during save
+ * and other factors such as handling symlinks, remote files, or platform-
+ * dependent aspects. However, plugins with special requirements should
+ * not rely on the exact implementation of this function and should rather
+ * implement file saving by themselves.
*
* @param filename The filename of the file to write, in locale encoding.
* @param text The text to write into the file.
@@ -221,55 +224,29 @@ gboolean utils_is_opening_brace(gchar c, gboolean include_angles)
GEANY_API_SYMBOL
gint utils_write_file(const gchar *filename, const gchar *text)
{
+ GError *error = NULL;
+ gboolean success;
+ GFile *fp;
+
g_return_val_if_fail(filename != NULL, ENOENT);
g_return_val_if_fail(text != NULL, EINVAL);
- if (file_prefs.use_safe_file_saving)
+ fp = g_file_new_for_path(filename);
+
+ success = g_file_replace_contents(fp, text, strlen(text), NULL, FALSE,
+ G_FILE_CREATE_NONE, NULL, NULL, &error);
+
+ g_object_unref(fp);
+
+ if (error)
{
- GError *error = NULL;
- if (! g_file_set_contents(filename, text, -1, &error))
- {
- geany_debug("%s: could not write to file %s (%s)", G_STRFUNC, filename, error->message);
- g_error_free(error);
- return EIO;
- }
+ geany_debug("%s: could not write to file %s (%s)", G_STRFUNC, filename, error->message);
+ g_error_free(error);
}
- else
- {
- FILE *fp;
- gsize bytes_written, len;
- gboolean fail = FALSE;
-
- if (filename == NULL)
- return ENOENT;
-
- len = strlen(text);
- errno = 0;
- fp = g_fopen(filename, "w");
- if (fp == NULL)
- fail = TRUE;
- else
- {
- bytes_written = fwrite(text, sizeof(gchar), len, fp);
+ else if (!success)
+ geany_debug("%s: could not write to file %s", G_STRFUNC, filename);
- if (len != bytes_written)
- {
- fail = TRUE;
- geany_debug(
- "utils_write_file(): written only %"G_GSIZE_FORMAT" bytes, had to write %"G_GSIZE_FORMAT" bytes to %s",
- bytes_written, len, filename);
- }
- if (fclose(fp) != 0)
- fail = TRUE;
- }
- if (fail)
- {
- geany_debug("utils_write_file(): could not write to file %s (%s)",
- filename, g_strerror(errno));
- return FALLBACK(errno, EIO);
- }
- }
- return 0;
+ return success ? 0 : EIO;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Fri, 11 Oct 2024 18:56:20 UTC
Commit: 55c83ade67f7cee741c94e27ae6c3c7e6f53f413
https://github.com/geany/geany/commit/55c83ade67f7cee741c94e27ae6c3c7e6f53f…
Log Message:
-----------
Update HACKING to better describe what has to be changed in scintilla_changes.patch
Modified Paths:
--------------
HACKING
Modified: HACKING
5 lines changed, 3 insertions(+), 2 deletions(-)
===================================================================
@@ -585,8 +585,9 @@ LexFoo.cxx. Try the official Scintilla project first.
When adding a lexer:
* add LexFoo.cxx to scintilla/lexilla/lexers
-* add `&lmFoo` to scintilla/lexilla/src/Lexilla.cxx and
- scintilla/scintilla_changes.patch
+* add ``&lmFoo`` to scintilla/lexilla/src/Lexilla.cxx
+* update scintilla/scintilla_changes.patch to contain ``+ &lmFoo,`` and
+ increment ``s`` in the hunk header ``@@ -R,r +S,s @@`` above the added line
* update scintilla/Makefile.am and meson.build
For syntax highlighting, you will need to edit highlighting.c and
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).