blob: cfce5fb4e9d5681249566d4d58c7287e88956f6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "different.h"
#include "gripes.h"
#include "man-config.h"
#include "util.h"
static struct filelist {
char *pathname;
struct filelist *next;
} cat_list, man_list;
static int
is_different(const char *file, struct filelist *p) {
char *command;
const char *cmp = getval("CMP");
int ret;
if (cmp) {
while (p->next) {
command = my_xsprintf("%s %S %S\n", cmp, file, p->pathname);
ret = do_system_command (command, 1);
if (ret == 0) {
gripe(IDENTICAL, file, p->pathname);
return 0;
}
p = p->next;
}
p->next = (struct filelist *) my_malloc(sizeof(struct filelist));
p->pathname = my_strdup(file);
p->next->next = 0;
}
return 1;
}
static int
free_filelist (struct filelist *list){
struct filelist *current, *next;
current = list;
if (current != list)
do {
next = current->next;
if (current != list)
free(current);
current = next;
} while (current->next != NULL);
list->next = NULL;
return 0;
}
int
different_cat_file (const char *file) {
return is_different (file, &cat_list);
}
int
different_man_file (const char *file) {
return is_different (file, &man_list);
}
int
free_catman_filelists (void){
free_filelist(&man_list);
free_filelist(&cat_list);
return 0;
}
|