pkgsrc/misc/cksfv/patches/patch-ac
wiz bfb46ee889 Update to 1.2, provided by Dieter Baron.
Changes: new sfv were not zero padded; handle ' ' and '_' the same in
insensitive matching.
2001-02-28 15:44:15 +00:00

81 lines
2.1 KiB
Text

$NetBSD: patch-ac,v 1.2 2001/02/28 15:44:16 wiz Exp $
--- src/readsfv.c.orig Fri Dec 29 01:34:33 2000
+++ src/readsfv.c Wed Feb 28 15:25:54 2001
@@ -34,11 +34,12 @@
int find_file(char*, char*);
extern int quiet;
-int readsfv(char *fn, char *dir, int nocase)
+int readsfv(char *fn, char *dir, int nocase, int argc, char **argv)
{
FILE *fd;
char buf[512], *end, filename[512], crc[9], path[256];
int file, rval = 0;
+ int i, check;
unsigned long len, val, sfvcrc;
if (quiet == 0) {
@@ -63,7 +64,7 @@
if (buf[0] != ';' && buf[0] != '\n' && buf[0] != '\r') {
/* build filename and crc from the sfv file */
end = strrchr(buf, ' ');
- if (end == NULL) {
+ if (end == NULL || end-buf > 512-10) {
fprintf(stderr, "cksfv: %s: incorrect sfv file format\n", fn);
exit(1);
}
@@ -71,7 +72,24 @@
*(end+9) = '\0';
strncpy(crc, ++end, 9);
strncpy(filename, buf, 512);
- sfvcrc = strtoul(crc, '\0', 16);
+ sfvcrc = strtoul(crc, NULL, 16);
+
+ if (argc) {
+ check = 0;
+ for (i=0; i<argc; i++) {
+ if (argv[i] == NULL)
+ continue;
+ if ((nocase == 1 && strcasecmp(argv[i], filename) == 0)
+ || (nocase == 0 && strcmp(argv[i], filename) == 0)) {
+ check = 1;
+ break;
+ }
+ }
+ if (check == 0)
+ continue;
+ else
+ argv[i] = NULL;
+ }
if (quiet == 0)
fprintf(stderr, "%-49s ", filename);
@@ -120,6 +138,18 @@
}
fclose(fd);
+ if (argc) {
+ for (i=0; i<argc; i++) {
+ if (argv[i]) {
+ if (quiet == 0)
+ fprintf(stderr, "%-49s not found in sfv\n", argv[i]);
+ else
+ fprintf(stderr, "cksfv: %s: not found in sfv\n", argv[i]);
+ rval = 1;
+ }
+ }
+ }
+
if (quiet == 0) {
if (rval == 0) {
printf("--------------------------------------------------------------------------------\nEverything OK\a\n");
@@ -166,7 +196,7 @@
strcpy(filename, dirinfo->d_name);
}
- rewinddir(dirp);
+ closedir(dirp);
return 1;