From dfa77baba7b449c3bf23b84a4c6a0ed29a86a88a Mon Sep 17 00:00:00 2001 From: david parsons Date: Sat, 4 Feb 2017 23:56:46 -0800 Subject: [PATCH] (the return from notspecial() was reversed) --- Makefile.in | 6 +++++- configure.sh | 1 + mkd2html.c | 10 +++++++--- notspecial.c | 6 +++--- theme.c | 6 ++++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3d72dfc..4f1b6b0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 @@ -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 @@ -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 diff --git a/configure.sh b/configure.sh index ef297c4..ee6606a 100755 --- a/configure.sh +++ b/configure.sh @@ -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)' diff --git a/mkd2html.c b/mkd2html.c index 355a532..89afe17 100644 --- a/mkd2html.c +++ b/mkd2html.c @@ -41,6 +41,8 @@ char *pgm = "mkd2html"; +extern int notspecial(char *filename); + #ifndef HAVE_BASENAME char * basename(char *path) @@ -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); diff --git a/notspecial.c b/notspecial.c index e865d21..b4cebb3 100644 --- a/notspecial.c +++ b/notspecial.c @@ -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 diff --git a/theme.c b/theme.c index a9c0306..529e115 100644 --- a/theme.c +++ b/theme.c @@ -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 @@ -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 )