Skip to content

Commit

Permalink
Allow whitespace before directives in the Preamble
Browse files Browse the repository at this point in the history
Resolves: #2927
  • Loading branch information
ffesti authored and pmatilai committed Mar 14, 2024
1 parent 86cc005 commit 7c593bc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
11 changes: 7 additions & 4 deletions build/parsePreamble.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ int addSource(rpmSpec spec, int specline, const char *srcname, rpmTagVal tag)
}

if (specline) {
nonum = parseTagNumber(spec->line + strlen(name), &num);
char * s = spec->line;
SKIPSPACE(s);
nonum = parseTagNumber(s + strlen(name), &num);
if (nonum < 0) {
rpmlog(RPMLOG_ERR, _("line %d: Bad %s number: %s\n"),
spec->lineNum, name, spec->line);
Expand Down Expand Up @@ -1133,10 +1135,11 @@ static struct PreambleRec_s const preambleList[] = {
static int findPreambleTag(rpmSpec spec, PreambleRec * pr, const char ** macro, char * lang)
{
PreambleRec p;
char *s;
char *s = spec->line;
SKIPSPACE(s);

for (p = preambleList; p->token != NULL; p++) {
if (!(p->token && !rstrncasecmp(spec->line, p->token, p->len)))
if (!(p->token && !rstrncasecmp(s, p->token, p->len)))
continue;
if (p->deprecated) {
rpmlog(RPMLOG_WARNING, _("line %d: %s is deprecated: %s\n"),
Expand All @@ -1147,7 +1150,7 @@ static int findPreambleTag(rpmSpec spec, PreambleRec * pr, const char ** macro,
if (p == NULL || p->token == NULL)
return 1;

s = spec->line + p->len;
s = s + p->len;
SKIPSPACE(s);

switch (p->type) {
Expand Down
4 changes: 4 additions & 0 deletions docs/manual/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ if used in them.

### Preamble tags

Since RPM 4.20 preamble tags can be indented with white space. Older
versions require the Tags to be at the beginning of a line. Comments
and empty lines are allowed.

#### Name

The Name tag contains the proper name of the package. Names must not
Expand Down
10 changes: 5 additions & 5 deletions tests/data/SPECS/hello.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# package which can be built under runroot in the test-suite.

Summary: hello -- hello, world rpm
Name: hello
Name: hello
Version: 1.0
Release: 1
Group: Utilities
Release: 1
Group: Utilities
License: GPL
SourceLicense: GPL, ASL 1.0
Distribution: RPM test suite.
URL: http://rpm.org
Source0: hello-1.0.tar.gz
Patch0: hello-1.0-modernize.patch
Source0: hello-1.0.tar.gz
Patch0: hello-1.0-modernize.patch
Prefix: /usr

%description
Expand Down
10 changes: 5 additions & 5 deletions tests/rpmspec.at
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,16 @@ runroot rpmspec --parse \


Summary: hello -- hello, world rpm
Name: hello
Name: hello
Version: 1.0
Release: 1
Group: Utilities
Release: 1
Group: Utilities
License: GPL
SourceLicense: GPL, ASL 1.0
Distribution: RPM test suite.
URL: http://rpm.org
Source0: hello-1.0.tar.gz
Patch0: hello-1.0-modernize.patch
Source0: hello-1.0.tar.gz
Patch0: hello-1.0-modernize.patch
Prefix: /usr

%description
Expand Down

0 comments on commit 7c593bc

Please sign in to comment.