Skip to content

Commit

Permalink
(the return from notspecial() was reversed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Orc committed Feb 5, 2017
1 parent 903a76e commit dfa77ba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile.in
Expand Up @@ -22,7 +22,7 @@ OBJS=mkdio.o markdown.o dumptree.o generate.o \
TESTFRAMEWORK=echo cols branch

# modules that markdown, makepage, mkd2html, &tc use
COMMON=pgm_options.o gethopt.o
COMMON=pgm_options.o gethopt.o notspecial.o

MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3

Expand Down Expand Up @@ -104,6 +104,9 @@ makepage: makepage.c $(COMMON) $(MKDLIB) mkdio.h
pgm_options.o: pgm_options.c mkdio.h config.h
$(CC) $(CFLAGS) -I. -c pgm_options.c

notspecial.o: notspecial.c
$(CC) $(CFLAGS) -I. -c notspecial.c

gethopt.o: gethopt.c
$(CC) $(CFLAGS) -I. -c gethopt.c

Expand Down Expand Up @@ -159,3 +162,4 @@ setup.o: setup.c config.h cstring.h amalloc.h markdown.h
github_flavoured.o: github_flavoured.c config.h cstring.h amalloc.h markdown.h
gethopt.o: gethopt.c gethopt.h
h1title.o: h1title.c markdown.h
notspecial.o: notspecial.c config.h
1 change: 1 addition & 0 deletions configure.sh
Expand Up @@ -112,6 +112,7 @@ AC_CHECK_BASENAME
AC_CHECK_ALLOCA

AC_CHECK_HEADERS sys/types.h pwd.h && AC_CHECK_FUNCS getpwuid
AC_CHECK_HEADERS sys/stat.h && AC_CHECK_FUNCS stat

if AC_CHECK_FUNCS srandom; then
AC_DEFINE 'INITRNG(x)' 'srandom((unsigned int)x)'
Expand Down
10 changes: 7 additions & 3 deletions mkd2html.c
Expand Up @@ -41,6 +41,8 @@

char *pgm = "mkd2html";

extern int notspecial(char *filename);

#ifndef HAVE_BASENAME
char *
basename(char *path)
Expand Down Expand Up @@ -154,9 +156,11 @@ char **argv;
}
strcpy(dest, source);

if (( dot = strrchr(dest, '.') ))
*dot = 0;
strcat(dest, ".html");
if ( notspecial(dest) ) {
if (( dot = strrchr(dest, '.') ))
*dot = 0;
strcat(dest, ".html");
}

if ( (output = fopen(dest, "w")) == 0 )
fail("can't write to %s", dest);
Expand Down
6 changes: 3 additions & 3 deletions notspecial.c
Expand Up @@ -15,14 +15,14 @@ notspecial(char *file)
struct stat info;

if ( stat(file, &info) != 0 )
return 0;
return 1;

return (info.st_flags & (S_IFIFO|S_IFCHR|S_IFSOCK));
return !(info.st_flags & (S_IFIFO|S_IFCHR|S_IFSOCK));
}
#else
int
notspecial(char *file)
{
return 0;
return 1;
}
#endif
6 changes: 4 additions & 2 deletions theme.c
Expand Up @@ -53,6 +53,7 @@ struct stat *infop = 0;
extern char* mkd_h1_title(MMIOT*);
#endif

extern int notspecial(char *filename);

#define INTAG 0x01
#define INHEAD 0x02
Expand Down Expand Up @@ -626,10 +627,11 @@ char **argv;
}
}
if ( output && strcmp(output, "-") ) {
if ( force )
if ( force && notspecial(output) )
unlink(output);
if ( !freopen(output, "w", stdout) )
if ( !freopen(output, "w", stdout) ) {
fail("can't write to %s", output);
}
}

if ( !pagename )
Expand Down

0 comments on commit dfa77ba

Please sign in to comment.