[Privoxy-commits] [privoxy] 02/10: Factor out newer_privoxy_version_required() and improve the logic
User Git
git at git.privoxy.org
Sun Jan 5 08:45:30 CET 2025
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository privoxy.
commit 30b7b0ddbe67b5667c9d05c698e48566b3518f4b
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Sat Jan 4 06:48:04 2025 +0100
Factor out newer_privoxy_version_required() and improve the logic
Previously 3.0.11 was considered newer than 4.0.0.
---
actions.c | 43 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/actions.c b/actions.c
index 9fd3249c..00c38b6e 100644
--- a/actions.c
+++ b/actions.c
@@ -1210,6 +1210,45 @@ static int action_spec_is_valid(struct client_state *csp, const struct action_sp
}
+/*********************************************************************
+ *
+ * Function : newer_privoxy_version_required
+ *
+ * Description : Figures out whether or not an action file requires
+ * a more recent Privoxy version.
+ *
+ * Parameters :
+ * 1 : required_major = Required major version.
+ * 2 : required_minor = Required minor version, or NULL.
+ * 3 : required_point = Required point release, or NULL.
+ *
+ * Returns : 1 => Yes, 0 => No.
+ *
+ *********************************************************************/
+static int newer_privoxy_version_required(const char *required_major,
+ const char *required_minor, const char *required_point)
+{
+ if (atoi(required_major) > VERSION_MAJOR)
+ {
+ return 1;
+ }
+ if (atoi(required_major) < VERSION_MAJOR)
+ {
+ return 0;
+ }
+ if ((required_minor == NULL) || (atoi(required_minor) < VERSION_MINOR))
+ {
+ return 0;
+ }
+ if ((required_point == NULL) || (atoi(required_point) <= VERSION_POINT))
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+
/*********************************************************************
*
* Function : load_one_actions_file
@@ -1489,9 +1528,7 @@ int load_one_actions_file(struct client_state *csp, int fileid)
"While loading actions file '%s': invalid line (%lu): %s",
csp->config->actions_file[fileid], linenum, buf);
}
- else if ( (atoi(fields[0]) > VERSION_MAJOR)
- || ((num_fields > 1) && (atoi(fields[1]) > VERSION_MINOR))
- || ((num_fields > 2) && (atoi(fields[2]) > VERSION_POINT)))
+ else if (newer_privoxy_version_required(fields[0], fields[1], fields[2]))
{
fclose(fp);
log_error(LOG_LEVEL_FATAL,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Privoxy-commits
mailing list