[gnumeric] xls: prune unused code.



commit de509b93952958c9f46c10c318d1f0bbfc8d8ebe
Author: Morten Welinder <terra gnome org>
Date:   Fri May 15 10:55:12 2015 -0400

    xls: prune unused code.

 plugins/excel/md5.c |  205 +--------------------------------------------------
 plugins/excel/md5.h |   76 ++-----------------
 2 files changed, 9 insertions(+), 272 deletions(-)
---
diff --git a/plugins/excel/md5.c b/plugins/excel/md5.c
index 419861d..97a4304 100644
--- a/plugins/excel/md5.c
+++ b/plugins/excel/md5.c
@@ -21,6 +21,9 @@
 /* Written by Ulrich Drepper <drepper gnu ai mit edu>, 1995.  */
 
 
+/* API pruned by Morten Welinder, 2015  */
+
+
 
 #include "md5.h"
 
@@ -35,18 +38,6 @@
 # include "unlocked-io.h"
 #endif
 
-#ifdef _LIBC
-/* We need to keep the namespace clean so define the MD5 function
-   protected using leading __ .  */
-# define md5_init_ctx __md5_init_ctx
-# define md5_process_block __md5_process_block
-# define md5_process_bytes __md5_process_bytes
-# define md5_finish_ctx __md5_finish_ctx
-# define md5_read_ctx __md5_read_ctx
-# define md5_stream __md5_stream
-# define md5_buffer __md5_buffer
-#endif
-
 #if G_BYTE_ORDER == G_BIG_ENDIAN
 # define SWAP(n)                                                       \
     (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
@@ -56,16 +47,6 @@
 #error "There's something rotten in Denmark"
 #endif
 
-#define BLOCKSIZE 4096
-#if BLOCKSIZE % 64 != 0
-# error "invalid BLOCKSIZE"
-#endif
-
-/* This array contains the bytes used to pad the buffer to the next
-   64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
-static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
-
-
 /* Initialize structure containing state of computation.
    (RFC 1321, 3.3: Step 3)  */
 void
@@ -92,186 +73,6 @@ md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
        return resbuf;
 }
 
-/* Process the remaining bytes in the internal buffer and the usual
-   prolog according to the standard and write the result to RESBUF.  */
-void *
-md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
-{
-  /* Take yet unprocessed bytes into account.  */
-  uint32_t bytes = ctx->buflen;
-  size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
-
-  /* Now count remaining bytes.  */
-  ctx->total[0] += bytes;
-  if (ctx->total[0] < bytes)
-    ++ctx->total[1];
-
-  /* Put the 64-bit file length in *bits* at the end of the buffer.  */
-  ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3);
-  ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
-
-  memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
-
-  /* Process last bytes.  */
-  md5_process_block (ctx->buffer, size * 4, ctx);
-
-  return md5_read_ctx (ctx, resbuf);
-}
-
-/* Compute MD5 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 16 bytes
-   beginning at RESBLOCK.  */
-int
-md5_stream (FILE *stream, void *resblock)
-{
-  struct md5_ctx ctx;
-  char buffer[BLOCKSIZE + 72];
-  size_t sum;
-
-  /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
-
-  /* Iterate over full file contents.  */
-  while (1)
-    {
-      /* We read the file in blocks of BLOCKSIZE bytes.  One call of the
-         computation function processes the whole buffer so that with the
-         next round of the loop another block can be read.  */
-      size_t n;
-      sum = 0;
-
-      /* Read block.  Take care for partial reads.  */
-      while (1)
-       {
-         n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
-
-         sum += n;
-
-         if (sum == BLOCKSIZE)
-           break;
-
-         if (n == 0)
-           {
-             /* Check for the error flag IFF N == 0, so that we don't
-                exit the loop after a partial read due to e.g., EAGAIN
-                or EWOULDBLOCK.  */
-             if (ferror (stream))
-               return 1;
-             goto process_partial_block;
-           }
-
-         /* We've read at least one byte, so ignore errors.  But always
-            check for EOF, since feof may be true even though N > 0.
-            Otherwise, we could end up calling fread after EOF.  */
-         if (feof (stream))
-           goto process_partial_block;
-       }
-
-      /* Process buffer with BLOCKSIZE bytes.  Note that
-         BLOCKSIZE % 64 == 0
-       */
-      md5_process_block (buffer, BLOCKSIZE, &ctx);
-    }
-
-process_partial_block:
-
-  /* Process any remaining bytes.  */
-  if (sum > 0)
-    md5_process_bytes (buffer, sum, &ctx);
-
-  /* Construct result in desired memory.  */
-  md5_finish_ctx (&ctx, resblock);
-  return 0;
-}
-
-/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-void *
-md5_buffer (const char *buffer, size_t len, void *resblock)
-{
-  struct md5_ctx ctx;
-
-  /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
-
-  /* Process whole buffer but last len % 64 bytes.  */
-  md5_process_bytes (buffer, len, &ctx);
-
-  /* Put result in desired memory area.  */
-  return md5_finish_ctx (&ctx, resblock);
-}
-
-
-void
-md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
-{
-  /* When we already have some bits in our internal buffer concatenate
-     both inputs first.  */
-  if (ctx->buflen != 0)
-    {
-      size_t left_over = ctx->buflen;
-      size_t add = 128 - left_over > len ? len : 128 - left_over;
-
-      memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
-      ctx->buflen += add;
-
-      if (ctx->buflen > 64)
-       {
-         md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
-
-         ctx->buflen &= 63;
-         /* The regions in the following copy operation cannot overlap.  */
-         memcpy (ctx->buffer,
-                 &((char *) ctx->buffer)[(left_over + add) & ~63],
-                 ctx->buflen);
-       }
-
-      buffer = (const char *) buffer + add;
-      len -= add;
-    }
-
-  /* Process available complete blocks.  */
-  if (len >= 64)
-    {
-#if !_STRING_ARCH_unaligned
-# define alignof(type) offsetof (struct { char c; type x; }, x)
-# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
-      if (UNALIGNED_P (buffer))
-       while (len > 64)
-         {
-           md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
-           buffer = (const char *) buffer + 64;
-           len -= 64;
-         }
-      else
-#endif
-       {
-         md5_process_block (buffer, len & ~63, ctx);
-         buffer = (const char *) buffer + (len & ~63);
-         len &= 63;
-       }
-    }
-
-  /* Move remaining bytes in internal buffer.  */
-  if (len > 0)
-    {
-      size_t left_over = ctx->buflen;
-
-      memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
-      left_over += len;
-      if (left_over >= 64)
-       {
-         md5_process_block (ctx->buffer, 64, ctx);
-         left_over -= 64;
-         memcpy (ctx->buffer, &ctx->buffer[16], left_over);
-       }
-      ctx->buflen = left_over;
-    }
-}
-
-
 /* These are the four functions used in the four steps of the MD5 algorithm
    and defined in the RFC 1321.  The first function is a little bit optimized
    (as found in Colin Plumbs public domain implementation).  */
diff --git a/plugins/excel/md5.h b/plugins/excel/md5.h
index c737040..2b9ef75 100644
--- a/plugins/excel/md5.h
+++ b/plugins/excel/md5.h
@@ -21,39 +21,12 @@
 #ifndef _MD5_H
 #define _MD5_H 1
 
-#include <stdio.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #define MD5_DIGEST_SIZE 16
 #define MD5_BLOCK_SIZE 64
 
-#ifndef __GNUC_PREREQ
-# if defined __GNUC__ && defined __GNUC_MINOR__
-#  define __GNUC_PREREQ(maj, min)                                      \
-  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-# else
-#  define __GNUC_PREREQ(maj, min) 0
-# endif
-#endif
-
-#ifndef __THROW
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
-#  define __THROW      throw ()
-# else
-#  define __THROW
-# endif
-#endif
-
-#ifndef _LIBC
-# define __md5_buffer md5_buffer
-# define __md5_finish_ctx md5_finish_ctx
-# define __md5_init_ctx md5_init_ctx
-# define __md5_process_block md5_process_block
-# define __md5_process_bytes md5_process_bytes
-# define __md5_read_ctx md5_read_ctx
-# define __md5_stream md5_stream
-#endif
-
 /* Structure to save state of computation between the single steps.  */
 struct md5_ctx
 {
@@ -67,58 +40,21 @@ struct md5_ctx
   uint32_t buffer[32];
 };
 
-/*
- * The following three functions are build up the low level used in
- * the functions `md5_stream' and `md5_buffer'.
- */
-
 /* Initialize structure containing state of computation.
    (RFC 1321, 3.3: Step 3)  */
-extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
+extern void md5_init_ctx (struct md5_ctx *ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void __md5_process_block (const void *buffer, size_t len,
-                                struct md5_ctx *ctx) __THROW;
-
-/* Starting with the result of former calls of this function (or the
-   initialization function update the context for the next LEN bytes
-   starting at BUFFER.
-   It is NOT required that LEN is a multiple of 64.  */
-extern void __md5_process_bytes (const void *buffer, size_t len,
-                                struct md5_ctx *ctx) __THROW;
-
-/* Process the remaining bytes in the buffer and put result from CTX
-   in first 16 bytes following RESBUF.  The result is always in little
-   endian byte order, so that a byte-wise output yields to the wanted
-   ASCII representation of the message digest.
-
-   IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
-   boundary. */
-extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
-
+extern void md5_process_block (const void *buffer, size_t len,
+                              struct md5_ctx *ctx);
 
 /* Put result from CTX in first 16 bytes following RESBUF.  The result is
    always in little endian byte order, so that a byte-wise output yields
-   to the wanted ASCII representation of the message digest.
-
-   IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
-   boundary. */
-extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
-
-
-/* Compute MD5 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 16 bytes
-   beginning at RESBLOCK.  */
-extern int __md5_stream (FILE *stream, void *resblock) __THROW;
+   to the wanted ASCII representation of the message digest.  */
+extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
 
-/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-extern void *__md5_buffer (const char *buffer, size_t len,
-                          void *resblock) __THROW;
 
 #endif /* md5.h */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]