On 21/12/18 14:41, Assaf Gordon wrote:
> Hello,
> 
> On 2018-11-23 2:26 p.m., Pádraig Brady wrote:
>> On 22/11/18 15:26, Assaf Gordon wrote:
>>> Hello all,
>>>
>>> I recently needed some less common binary encoding,
>>> and decided to try and implement it based on base64.c .
>>>
> 
>> A single program is definitely the way to go if we're considering adding 
>> more encodings.
>>
> [...]
>> I'd probably change to source file from base64.c to basenc.c
> [...]
>> Given the complexity this adds and the disparity
>> to the proposed alternatives, it seems useful enough to add.
> 
> Thanks for the comments and suggestions.
> 
> Attached improved patches.
> The first renames base64.c to basenc.c.
> The second implements basenc.
> 
> Major changes:
> 1. Program is now called "basenc".
> (I initially wanted to call it "basex", but sadly that name is already
> used in debian).
> 
> 2. Removed "base85" encoding (aka "ascii85") - there's already an
> existing utility with similar interface to base64, which is readily
> available: https://packages.debian.org/stretch/ruby-ascii85 .
> Also, the encoding is variable length, which does not neatly fit in the 
> current base64 implementation.
> 
> 3. Added base2lsbf/msbf (least or most significant bit first) encoding.
> 
> 4. Added test suite with high coverage.
> 
> 5. Added man page and texinfo documentation with few examples.
> 
> Comments welcomed,
>   - assaf

Great stuff.
Attached is some minor tweaks to pass `make syntax-check`,
after which this is ready to push.

thanks!
Pádraig

diff --git a/src/basenc.c b/src/basenc.c
index 5effa3f..fea4984 100644
--- a/src/basenc.c
+++ b/src/basenc.c
@@ -35,11 +35,11 @@
 #include "xbinary-io.h"
 
 #if BASE_TYPE == 42
-#define AUTHORS \
+# define AUTHORS \
   proper_name ("Simon Josefsson"), \
   proper_name ("Assaf Gordon")
 #else
-#define AUTHORS proper_name ("Simon Josefsson")
+# define AUTHORS proper_name ("Simon Josefsson")
 #endif
 
 #if BASE_TYPE == 32
@@ -51,11 +51,10 @@
 #elif BASE_TYPE == 42
 # include "base32.h"
 # include "base64.h"
-# include "xalloc.h"
 # include <assert.h>
 # define PROGRAM_NAME "basenc"
 #else
-#error missing/invalid BASE_TYPE definition
+# error missing/invalid BASE_TYPE definition
 #endif
 
 
@@ -213,7 +212,7 @@ verify (DEC_BLOCKSIZE % 12 == 0);  /* So complete encoded blocks are used.  */
 #elif BASE_TYPE == 42
 
 
-#define BASE_LENGTH base_length
+# define BASE_LENGTH base_length
 
 /* Note that increasing this may decrease performance if --ignore-garbage
    is used, because of the memmove operation below.  */
@@ -390,7 +389,7 @@ base32_decode_ctx_wrapper (struct base_decode_context *ctx,
 /* ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
      to
    0123456789ABCDEFGHIJKLMNOPQRSTUV */
-const char base32_norm_to_hex[32+9] = {
+static const char base32_norm_to_hex[32+9] = {
 /*0x32, 0x33, 0x34, 0x35, 0x36, 0x37, */
   'Q',  'R',  'S',  'T',  'U',  'V',
 
@@ -412,7 +411,7 @@ const char base32_norm_to_hex[32+9] = {
 /* 0123456789ABCDEFGHIJKLMNOPQRSTUV
      to
    ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 */
-const char base32_hex_to_norm[32+9] = {
+static const char base32_hex_to_norm[32+9] = {
   /* from: 0x30 .. 0x39 ('0' to '9') */
   /* to:*/ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
 
@@ -663,14 +662,14 @@ z85_decode_ctx_init (struct base_decode_context *ctx)
 }
 
 
-#define Z85_LO_CTX_TO_32BIT_VAL(ctx) \
+# define Z85_LO_CTX_TO_32BIT_VAL(ctx) \
   (((ctx)->z85ctx.octets[1] * 85 * 85 * 85) +   \
    ((ctx)->z85ctx.octets[2] * 85 * 85) +	    \
    ((ctx)->z85ctx.octets[3] * 85) +		    \
    ((ctx)->z85ctx.octets[4]))
 
 
-#define Z85_HI_CTX_TO_32BIT_VAL(ctx) \
+# define Z85_HI_CTX_TO_32BIT_VAL(ctx) \
   ((ctx)->z85ctx.octets[0] * 85 * 85 * 85 * 85 )
 
 /*

Reply via email to