-char *strlwr(s)
-char *s;
-{
- char *t;
-
- for (t = s; *t; t++)
- *t = tolow(*t);
- return s;
-}
-
-#if defined(NO_STRING_H) && !defined(STDC_HEADERS)
-
-/* Provide missing strspn and strcspn functions. */
-
-int strspn (const char *s, const char *accept);
-int strcspn (const char *s, const char *reject);
-
-/* ========================================================================
- * Return the length of the maximum initial segment
- * of s which contains only characters in accept.
- */
-int strspn(s, accept)
-const char *s;
-const char *accept;
-{
- register const char *p;
- register const char *a;
- register int count = 0;
-
- for (p = s; *p != '\0'; ++p) {
- for (a = accept; *a != '\0'; ++a) {
- if (*p == *a)
- break;
- }
- if (*a == '\0')
- return count;
- ++count;
- }
- return count;
-}
-
-/* ========================================================================
- * Return the length of the maximum inital segment of s
- * which contains no characters from reject.
- */
-int strcspn(s, reject)
-const char *s;
-const char *reject;
-{
- register int count = 0;
-
- while (*s != '\0') {
- if (strchr(reject, *s++) != NULL)
- return count;
- ++count;
- }
- return count;
-}
-
-#endif /* NO_STRING_H */
-
-/* ========================================================================
- * Add an environment variable (if any) before argv, and update argc.
- * Return the expanded environment variable to be freed later, or NULL
- * if no options were added to argv.
- */
-#define SEPARATOR " \t" /* separators in env variable */
-
-char *add_envopt(argcp, argvp, env)
-int *argcp; /* pointer to argc */
-char ***argvp; /* pointer to argv */
-char *env; /* name of environment variable */
-{
- char *p; /* running pointer through env variable */
- char **oargv; /* runs through old argv array */
- char **nargv; /* runs through new argv array */
- int oargc = *argcp; /* old argc */
- int nargc = 0; /* number of arguments in env variable */
-
- env = (char *) getenv(env);
- if (env == NULL)
- return NULL;
-
- p = (char *) xmalloc(strlen(env) + 1);
- env = strcpy(p, env); /* keep env variable intact */
-
- for (p = env; *p; nargc++) { /* move through env */
- p += strspn(p, SEPARATOR); /* skip leading separators */
- if (*p == '\0')
- break;
-
- p += strcspn(p, SEPARATOR); /* find end of word */
- if (*p)
- *p++ = '\0'; /* mark it */
- }
- if (nargc == 0) {
- free(env);
- return NULL;
- }
- *argcp += nargc;
- /* Allocate the new argv array, with an extra element just in case
- * the original arg list did not end with a NULL.
- */
- nargv = (char **) calloc(*argcp + 1, sizeof(char *));
-
- if (nargv == NULL)
- error_msg(memory_exhausted);
- oargv = *argvp;
- *argvp = nargv;
-
- /* Copy the program name first */
- if (oargc-- < 0)
- error_msg("argc<=0");
- *(nargv++) = *(oargv++);
-
- /* Then copy the environment args */
- for (p = env; nargc > 0; nargc--) {
- p += strspn(p, SEPARATOR); /* skip separators */
- *(nargv++) = p; /* store start */
- while (*p++); /* skip over word */
- }
-
- /* Finally copy the old args and add a NULL (usual convention) */
- while (oargc--)
- *(nargv++) = *(oargv++);
- *nargv = NULL;
- return env;
-}
-
-/* ========================================================================
- * Display compression ratio on the given stream on 6 characters.
- */
-void display_ratio(num, den, file)
-long num;
-long den;
-FILE *file;
-{
- long ratio; /* 1000 times the compression ratio */
-
- if (den == 0) {
- ratio = 0; /* no compression */
- } else if (den < 2147483L) { /* (2**31 -1)/1000 */
- ratio = 1000L * num / den;
- } else {
- ratio = num / (den / 1000L);
- }
- if (ratio < 0) {
- putc('-', file);
- ratio = -ratio;
- } else {
- putc(' ', file);
- }
- fprintf(file, "%2ld.%1ld%%", ratio / 10L, ratio % 10L);
-}
-
-
-/* zip.c -- compress files to the gzip or pkzip format
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#include <ctype.h>
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifndef NO_FCNTL_H
-# include <fcntl.h>
-#endif
-
-local ulg crc; /* crc on uncompressed file data */
-long header_bytes; /* number of bytes in gzip header */