Deleted Added
full compact
compress.c (227236) compress.c (229403)
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35
36#if 0
37#ifndef lint
38static char sccsid[] = "@(#)compress.c 8.2 (Berkeley) 1/7/94";
39#endif
40#endif
41
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35
36#if 0
37#ifndef lint
38static char sccsid[] = "@(#)compress.c 8.2 (Berkeley) 1/7/94";
39#endif
40#endif
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/usr.bin/compress/compress.c 227236 2011-11-06 18:49:16Z ed $");
43__FBSDID("$FreeBSD: head/usr.bin/compress/compress.c 229403 2012-01-03 18:51:58Z ed $");
44
45#include <sys/param.h>
46#include <sys/stat.h>
47#include <sys/time.h>
48
49#include <err.h>
50#include <errno.h>
51#include <stdarg.h>

--- 18 unchanged lines hidden (view full) ---

70main(int argc, char *argv[])
71{
72 enum {COMPRESS, DECOMPRESS} style;
73 size_t len;
74 int bits, cat, ch;
75 char *p, newname[MAXPATHLEN];
76
77 cat = 0;
44
45#include <sys/param.h>
46#include <sys/stat.h>
47#include <sys/time.h>
48
49#include <err.h>
50#include <errno.h>
51#include <stdarg.h>

--- 18 unchanged lines hidden (view full) ---

70main(int argc, char *argv[])
71{
72 enum {COMPRESS, DECOMPRESS} style;
73 size_t len;
74 int bits, cat, ch;
75 char *p, newname[MAXPATHLEN];
76
77 cat = 0;
78 if ((p = rindex(argv[0], '/')) == NULL)
78 if ((p = strrchr(argv[0], '/')) == NULL)
79 p = argv[0];
80 else
81 ++p;
82 if (!strcmp(p, "uncompress"))
83 style = DECOMPRESS;
84 else if (!strcmp(p, "compress"))
85 style = COMPRESS;
86 else if (!strcmp(p, "zcat")) {

--- 49 unchanged lines hidden (view full) ---

136 case COMPRESS:
137 if (strcmp(*argv, "-") == 0) {
138 compress("/dev/stdin", "/dev/stdout", bits);
139 break;
140 } else if (cat) {
141 compress(*argv, "/dev/stdout", bits);
142 break;
143 }
79 p = argv[0];
80 else
81 ++p;
82 if (!strcmp(p, "uncompress"))
83 style = DECOMPRESS;
84 else if (!strcmp(p, "compress"))
85 style = COMPRESS;
86 else if (!strcmp(p, "zcat")) {

--- 49 unchanged lines hidden (view full) ---

136 case COMPRESS:
137 if (strcmp(*argv, "-") == 0) {
138 compress("/dev/stdin", "/dev/stdout", bits);
139 break;
140 } else if (cat) {
141 compress(*argv, "/dev/stdout", bits);
142 break;
143 }
144 if ((p = rindex(*argv, '.')) != NULL &&
144 if ((p = strrchr(*argv, '.')) != NULL &&
145 !strcmp(p, ".Z")) {
146 cwarnx("%s: name already has trailing .Z",
147 *argv);
148 break;
149 }
150 len = strlen(*argv);
151 if (len > sizeof(newname) - 3) {
152 cwarnx("%s: name too long", *argv);

--- 6 unchanged lines hidden (view full) ---

159 compress(*argv, newname, bits);
160 break;
161 case DECOMPRESS:
162 if (strcmp(*argv, "-") == 0) {
163 decompress("/dev/stdin", "/dev/stdout", bits);
164 break;
165 }
166 len = strlen(*argv);
145 !strcmp(p, ".Z")) {
146 cwarnx("%s: name already has trailing .Z",
147 *argv);
148 break;
149 }
150 len = strlen(*argv);
151 if (len > sizeof(newname) - 3) {
152 cwarnx("%s: name too long", *argv);

--- 6 unchanged lines hidden (view full) ---

159 compress(*argv, newname, bits);
160 break;
161 case DECOMPRESS:
162 if (strcmp(*argv, "-") == 0) {
163 decompress("/dev/stdin", "/dev/stdout", bits);
164 break;
165 }
166 len = strlen(*argv);
167 if ((p = rindex(*argv, '.')) == NULL ||
167 if ((p = strrchr(*argv, '.')) == NULL ||
168 strcmp(p, ".Z")) {
169 if (len > sizeof(newname) - 3) {
170 cwarnx("%s: name too long", *argv);
171 break;
172 }
173 memmove(newname, *argv, len);
174 newname[len] = '.';
175 newname[len + 1] = 'Z';

--- 261 unchanged lines hidden ---
168 strcmp(p, ".Z")) {
169 if (len > sizeof(newname) - 3) {
170 cwarnx("%s: name too long", *argv);
171 break;
172 }
173 memmove(newname, *argv, len);
174 newname[len] = '.';
175 newname[len + 1] = 'Z';

--- 261 unchanged lines hidden ---