[Privoxy-commits] [privoxy] 01/11: Use stringify() instead of section_target()

User Git git at git.privoxy.org
Thu Nov 16 14:27:10 CET 2023


This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository privoxy.

commit 71afa37537b25f106716f060958f918eb67c5c57
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Sun Sep 10 09:44:10 2023 +0200

    Use stringify() instead of section_target()
    
    ... and remove section_target(). Like the XXX comment suggested
    this could be done my moving the hash into the templates which
    seems preferable anyway.
---
 cgiedit.c                              | 36 ++--------------------------------
 templates/edit-actions-remove-url-form |  4 ++--
 templates/edit-actions-url-form        |  4 ++--
 3 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/cgiedit.c b/cgiedit.c
index ab05d79b..6450eec0 100644
--- a/cgiedit.c
+++ b/cgiedit.c
@@ -369,38 +369,6 @@ static jb_err get_file_name_param(struct client_state *csp,
 	                                   const char *param_name,
 	                                   const char **pfilename);
 
-/* Internal convenience functions */
-static char *section_target(const unsigned sectionid);
-
-/*********************************************************************
- *
- * Function    :  section_target
- *
- * Description :  Given an unsigned (section id) n, produce a dynamically
- *                allocated string of the form #l<n>, for use in link
- *                targets.
- *
- *                XXX: The hash should be moved into the templates
- *                to make this function more generic and render
- *                stringify() obsolete.
- *
- * Parameters  :
- *          1  :  sectionid = start line number of section
- *
- * Returns     :  String with link target, or NULL if out of
- *                memory
- *
- *********************************************************************/
-static char *section_target(const unsigned sectionid)
-{
-   char buf[30];
-
-   snprintf(buf, sizeof(buf), "#l%u", sectionid);
-   return(strdup(buf));
-
-}
-
-
 /*********************************************************************
  *
  * Function    :  stringify
@@ -558,7 +526,7 @@ jb_err cgi_edit_actions_url_form(struct client_state *csp,
    if (!err) err = map(exports, "v", 1, file->version_str, 1);
    if (!err) err = map(exports, "p", 1, url_encode(lookup(parameters, "p")), 0);
    if (!err) err = map(exports, "u", 1, html_encode(cur_line->unprocessed), 0);
-   if (!err) err = map(exports, "jumptarget", 1, section_target(section_start_line_number), 0);
+   if (!err) err = map(exports, "jumptarget", 1, stringify(section_start_line_number), 0);
 
    edit_free_file(file);
 
@@ -718,7 +686,7 @@ jb_err cgi_edit_actions_remove_url_form(struct client_state *csp,
    if (!err) err = map(exports, "v", 1, file->version_str, 1);
    if (!err) err = map(exports, "p", 1, url_encode(lookup(parameters, "p")), 0);
    if (!err) err = map(exports, "u", 1, html_encode(cur_line->unprocessed), 0);
-   if (!err) err = map(exports, "jumptarget", 1, section_target(section_start_line_number), 0);
+   if (!err) err = map(exports, "jumptarget", 1, stringify(section_start_line_number), 0);
    if (!err) err = map(exports, "actions-file", 1, html_encode(file->filename), 0);
 
    edit_free_file(file);
diff --git a/templates/edit-actions-remove-url-form b/templates/edit-actions-remove-url-form
index 297d2bd2..2e741c96 100644
--- a/templates/edit-actions-remove-url-form
+++ b/templates/edit-actions-remove-url-form
@@ -49,7 +49,7 @@
 # section
 # pattern
 # oldval
-# jumptarget - append to eal URL to jump to relevant section
+# jumptarget - append anchor to eal URL to jump to relevant section
 #
 #############################################################################
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -96,7 +96,7 @@
         <p>
           <a class="cmd" href="edit-actions-remove-url?f=@f@&v=@v@&p=@p@">OK</a>
            
-          <a class="cmd" href="edit-actions-list?f=@f@@jumptarget@">Cancel</a>
+          <a class="cmd" href="edit-actions-list?f=@f@#@jumptarget@">Cancel</a>
         </p>
       </td>
     </tr>
diff --git a/templates/edit-actions-url-form b/templates/edit-actions-url-form
index 1f499244..4af848ed 100644
--- a/templates/edit-actions-url-form
+++ b/templates/edit-actions-url-form
@@ -47,7 +47,7 @@
 # s - section
 # p - pattern
 # u - old value of URL
-# jumptarget - append to eal URL to jump to relevant section
+# jumptarget - append anchor to eal URL to jump to relevant section
 #
 #############################################################################
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -113,7 +113,7 @@ function validate(text)
             <input type="text" name="u" value="@u@" size="78" class="pattern"><br>
             <input type="submit" value="Submit">  
             <input type="reset" value="Reset">  
-            <a class="cmd" href="edit-actions-list?f=@f@@jumptarget@">Cancel</a>
+            <a class="cmd" href="edit-actions-list?f=@f@#@jumptarget@">Cancel</a>
           </p>
         </form>
       </td>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Privoxy-commits mailing list