sig_handler(): Split a long line in two
[privoxy.git] / encode.c
index 954e452..6cb57cf 100644 (file)
--- a/encode.c
+++ b/encode.c
@@ -1,4 +1,3 @@
-const char encode_rcs[] = "$Id: encode.c,v 1.23 2011/11/06 11:44:56 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/encode.c,v $
@@ -7,7 +6,7 @@ const char encode_rcs[] = "$Id: encode.c,v 1.23 2011/11/06 11:44:56 fabiankeil E
  *                encode cookies and HTML text.
  *
  * Copyright   :  Written by and Copyright (C) 2001 the
- *                Privoxy team. http://www.privoxy.org/
+ *                Privoxy team. https://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
  *                by and Copyright (C) 1997 Anonymous Coders and
@@ -44,10 +43,8 @@ const char encode_rcs[] = "$Id: encode.c,v 1.23 2011/11/06 11:44:56 fabiankeil E
 #include "miscutil.h"
 #include "encode.h"
 
-const char encode_h_rcs[] = ENCODE_H_VERSION;
-
 /* Maps special characters in a URL to their equivalent % codes. */
-static const char const url_code_map[256][4] = {
+static const char url_code_map[256][4] = {
    "",    "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09",
    "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13",
    "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D",
@@ -142,10 +139,10 @@ char * html_encode(const char *s)
    {
       char c;
       char * p = buf;
-      while ( (c = *s++) != '\0')
+      while ((c = *s++) != '\0')
       {
          const char * replace_with = html_code_map[(unsigned char) c];
-         if(replace_with != NULL)
+         if (replace_with != NULL)
          {
             const size_t bytes_written = (size_t)(p - buf);
             assert(bytes_written < buf_size);
@@ -158,9 +155,10 @@ char * html_encode(const char *s)
       }
 
       *p = '\0';
+
+      assert(strlen(buf) < buf_size);
    }
 
-   assert(strlen(buf) < buf_size);
    return(buf);
 }
 
@@ -236,7 +234,7 @@ char * url_encode(const char *s)
    {
       char c;
       char * p = buf;
-      while( (c = *s++) != '\0')
+      while((c = *s++) != '\0')
       {
          const char *replace_with = url_code_map[(unsigned char) c];
          if (*replace_with != '\0')
@@ -253,9 +251,9 @@ char * url_encode(const char *s)
 
       *p = '\0';
 
+      assert(strlen(buf) < buf_size);
    }
 
-   assert(strlen(buf) < buf_size);
    return(buf);
 }
 
@@ -311,10 +309,10 @@ int xtoi(const char *s)
    int d1;
 
    d1 = xdtoi(*s);
-   if(d1 >= 0)
+   if (d1 >= 0)
    {
       int d2 = xdtoi(*(s+1));
-      if(d2 >= 0)
+      if (d2 >= 0)
       {
          return (d1 << 4) + d2;
       }
@@ -428,7 +426,7 @@ char *percent_encode_url(const char *s)
    {
       char c;
       char *p = buf;
-      while((c = *s++) != '\0')
+      while ((c = *s++) != '\0')
       {
          const unsigned int i = (unsigned char)c;
          if (i >= sizeof(allowed_characters) || '\0' == allowed_characters[i])
@@ -448,9 +446,9 @@ char *percent_encode_url(const char *s)
          }
       }
       *p = '\0';
-   }
 
-   assert(strlen(buf) < buf_size);
+      assert(strlen(buf) < buf_size);
+   }
 
    return(buf);