Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for suffixes with multiple dots #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,20 +723,23 @@ target_type(char *s)
return s_type[ret];

// Check for an inference rule
ret = T_NORMAL;
sfx = suffix(s);
if (is_suffix(sfx)) {
if (s == sfx) { // Single suffix rule
ret = T_INFERENCE | T_NOPREREQ | T_COMMAND;
} else {
// Suffix is valid, check that prefix is too
*sfx = '\0';
if (is_suffix(s))
ret = T_INFERENCE | T_NOPREREQ | T_COMMAND;
*sfx = '.';
}
for (sfx = s; (sfx = strchr(sfx + 1, '.'));) {
if (!is_suffix(sfx))
continue;

// Suffix is valid, check that prefix is too
*sfx = '\0';
ret = is_suffix(s);
*sfx = '.';

if (ret)
return T_INFERENCE | T_NOPREREQ | T_COMMAND;
}
return ret;

if (is_suffix(s)) // Single suffix rule
return T_INFERENCE | T_NOPREREQ | T_COMMAND;

return T_NORMAL;
}

#if ENABLE_FEATURE_MAKE_EXTENSIONS
Expand Down
2 changes: 1 addition & 1 deletion rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
char *
suffix(const char *name)
{
char *p = strrchr(name, '.');
char *p = strchr(name, '.');
return p ? p : (char *)name + strlen(name);
}

Expand Down
13 changes: 13 additions & 0 deletions testsuite/make.tests
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ x.p:
'
cd .. || exit 1; rm -rf make.tempdir 2>/dev/null

# Suffixes with multiple dots are supported
mkdir make.tempdir && cd make.tempdir || exit 1
testing "Support multi-dot suffixes" \
"make -f -" "touch x.c.c\ncat x.c.c >x.o.o\n" "" '
.SUFFIXES: .c.c .o.o
x.o.o:
x.c.c:
touch $@
.c.c.o.o:
cat $< >$@
'
cd .. || exit 1; rm -rf make.tempdir 2>/dev/null

# Austin Group defect report 875 clarifies certain aspects of the
# behaviour of inference rules. Study of this resulted in a number
# of changes to pdpmake, though this test passed anyway.
Expand Down