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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
diff -ur libpaper-1.1.24+nmu2.orig/lib/paper.c libpaper-1.1.24+nmu2/lib/paper.c
--- libpaper-1.1.24+nmu2.orig/lib/paper.c 2010-04-24 14:12:11.000000000 +0200
+++ libpaper-1.1.24+nmu2/lib/paper.c 2013-10-24 15:45:37.955710461 +0200
@@ -87,24 +87,11 @@
}
const char* defaultpapersizefile(void) {
- return PAPERCONF;
+ return NULL;
}
const char* systempapersizefile(void) {
- const char* paperconf = getenv(PAPERCONFVAR);
-/*
-Previously PAPERCONFVAR used to contain a paper name and PAPERSIZEVAR
-contained a file path. Now they're reversed. If we don't find a '/'
-in PAPERCONFVAR, fall-back to the old behaviour.
-*/
-
- if ((paperconf != NULL) && (strchr(paperconf, '/') == NULL)) {
- paperconf = getenv(PAPERSIZEVAR);
- if ((paperconf != NULL) && (strchr(paperconf, '/') == NULL))
- paperconf = NULL;
- }
-
- return paperconf ? paperconf : defaultpapersizefile();
+ return NULL;
}
const char* defaultpapername(void) {
@@ -112,26 +99,14 @@
}
char* systempapername(void) {
- const char* paperconf;
char* paperstr;
char* paperenv;
const char* paperdef;
- FILE* ps;
- struct stat statbuf;
const struct paper* pp;
- int c;
-
-/*
-Previously PAPERSIZEVAR used to contain a file path and PAPERCONFVAR
-contained a paper name. Now they're reversed. If we find a '/' in
-PAPERSIZEVAR, fall-back to the old behaviour.
-*/
paperenv = getenv(PAPERSIZEVAR);
if ((paperenv != NULL) && (strchr(paperenv, '/') != NULL)) {
- paperenv = getenv(PAPERCONFVAR);
- if ((paperenv != NULL) && (strchr(paperenv, '/') != NULL))
- paperenv = NULL;
+ paperenv = NULL;
}
if (paperenv) {
@@ -145,61 +120,6 @@
return strcpy(paperstr, paperenv);
}
- paperconf = systempapersizefile();
- if (paperconf && stat(paperconf, &statbuf) == -1) return 0;
-
- if (!paperconf) paperconf = defaultpapersizefile();
-
- if ((stat(paperconf, &statbuf) != -1) &&
- (ps = fopen(paperconf, "r"))) {
-
- while ((c = getc(ps)) != EOF) {
- if (c == '#') {
- while ((c = getc(ps)) != EOF && c != '\n');
- if (c == EOF) {
- break;
- }
- } else if (!isspace(c)) {
- unsigned n = 0, m = 64;
- char* papername = malloc(m * sizeof(char));
-
- if (!papername) {
- fclose(ps);
- return 0;
- }
-
- do {
- if (n == m-1) {
- char* newpaper = realloc(papername,
- (m *= 2) * sizeof(char));
- if (!newpaper) {
- free(papername);
- fclose(ps);
- return 0;
- }
- papername = newpaper;
- }
- papername[n++] = c;
- } while ((c = getc(ps)) != EOF && !isspace(c));
-
- papername[n] = 0;
-
- fclose(ps);
-
- paperstr = malloc((strlen(papername) + 1) * sizeof(char));
- if (! paperstr) return 0;
-
- strcpy(paperstr, papername);
- free(papername);
-
- if ((pp = paperinfo(paperstr)))
- return strcpy(paperstr, pp->name);
- else
- return paperstr;
- }
- }
- }
-
paperdef = defaultpapername();
paperstr = malloc((strlen(paperdef) + 1) * sizeof(char));
|