Consolidate i18n baggage into AM_GNU_GETTEXT and system.h.
[platform/upstream/rpm.git] / build / parseBuildInstallClean.c
1 #include "system.h"
2
3 #include "rpmbuild.h"
4
5 int parseBuildInstallClean(Spec spec, int parsePart)
6 {
7     int nextPart, rc;
8     StringBuf *sbp = NULL;
9     char *name = NULL;
10
11     switch (parsePart) {
12       case PART_BUILD:
13         sbp = &(spec->build);
14         name = "%build";
15         break;
16       case PART_INSTALL:
17         sbp = &(spec->install);
18         name = "%install";
19         break;
20       case PART_CLEAN:
21         sbp = &(spec->clean);
22         name = "%clean";
23         break;
24     }
25     
26     if (*sbp) {
27         rpmError(RPMERR_BADSPEC, _("line %d: second %s"), spec->lineNum, name);
28         return RPMERR_BADSPEC;
29     }
30     
31     *sbp = newStringBuf();
32
33     /* There are no options to %build, %install, or %clean */
34     if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
35         return PART_NONE;
36     }
37     if (rc) {
38         return rc;
39     }
40     
41     while (! (nextPart = isPart(spec->line))) {
42         appendStringBuf(*sbp, spec->line);
43         if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
44             return PART_NONE;
45         }
46         if (rc) {
47             return rc;
48         }
49     }
50
51     return nextPart;
52 }