blob: 7e99e349e2e457dc97d794b49f09a26629ccc358 (
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
|
#include "system.h"
#include "rpmbuild.h"
int parseNum(const char *line, int *res)
{
char *s1;
s1 = NULL;
*res = strtoul(line, &s1, 10);
if ((*s1) || (s1 == line) || (*res == ULONG_MAX)) {
return 1;
}
return 0;
}
const char *cleanFileName(const char *name)
{
static char res[BUFSIZ]; /* XXX yuk */
char *copyTo, copied;
const char *copyFrom;
/* Copy to fileName, eliminate duplicate "/" and trailing "/" */
copyTo = res;
copied = '\0';
copyFrom = name;
while (*copyFrom) {
if (*copyFrom != '/' || copied != '/') {
*copyTo++ = copied = *copyFrom;
}
copyFrom++;
}
*copyTo = '\0';
copyTo--;
if ((copyTo != res) && (*copyTo == '/')) {
*copyTo = '\0';
}
return res;
}
|