]> granicus.if.org Git - fortune-mod/commitdiff
add the NO_OFFENSIVE compile-time option.
authorShlomi Fish <shlomif@shlomifish.org>
Thu, 9 Feb 2017 17:57:45 +0000 (19:57 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Thu, 9 Feb 2017 17:57:45 +0000 (19:57 +0200)
Inspired by the Fedora patches. It's still somewhat incomplete.

fortune-mod/CMakeLists.txt
fortune-mod/fortune/fortune.c

index 4550d7820b27f95dc92cb362c83f17d2a0cc2982..c44be2606fafc190fe7cfd169b1144d4051e0875 100644 (file)
@@ -86,6 +86,7 @@ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 
 SET (WITH_TEST_SUITE CACHE BOOL "")
+SET (NO_OFFENSIVE CACHE BOOL "Exclude the offensive option.")
 SET (LOCALDIR "${CMAKE_INSTALL_PREFIX}/local/share/games/fortunes" CACHE STRING "LOCALDIR fortunes dir")
 SET (LOCALODIR "${LOCALDIR}/off" CACHE STRING "offensive fortunes localdir")
 SET (COOKIEDIR "${CMAKE_INSTALL_PREFIX}/share/games/fortunes" CACHE STRING  "cookie dir not under /usr/local")
@@ -135,6 +136,10 @@ ADD_DEFINITIONS("-DLOCFORTDIR=\"${LOCALDIR}\"")
 ADD_DEFINITIONS("-DOFFDIR=\"${OCOOKIEDIR}\"")
 ADD_DEFINITIONS("-DFORTDIR=\"${COOKIEDIR}\"")
 
+IF ("${NO_OFFENSIVE}")
+    ADD_DEFINITIONS("-DNO_OFFENSIVE=1")
+ENDIF()
+
 INCLUDE(CheckIncludeFile)
 CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H)
 
index 2b20f1358d396a152fb76e2e1544e3e3366eb99f..639572ecda72bd030e933675fdebe080e0c2d7a9 100644 (file)
@@ -253,7 +253,11 @@ static void __attribute__((noreturn)) usage(void)
 #ifndef NO_REGEX
     (void) fprintf(stderr, "i");
 #endif /* NO_REGEX */
-    (void) fprintf(stderr, "losw]");
+    (void) fprintf(stderr, "l");
+#ifndef NO_OFFENSIVE
+    (void) fprintf(stderr, "o");
+#endif
+    (void) fprintf(stderr, "sw]");
 #ifndef NO_REGEX
     (void) fprintf(stderr, " [-m pattern]");
 #endif /* NO_REGEX */
@@ -1005,10 +1009,18 @@ static void getargs(int argc, char **argv)
     ignore_case = FALSE;
 
 #ifdef DEBUG
-    while ((ch = getopt(argc, argv, "acDefilm:n:osvw")) != EOF)
+#define DEBUG_GETOPT "D"
 #else
-    while ((ch = getopt(argc, argv, "acefilm:n:osvw")) != EOF)
-#endif /* DEBUG */
+#define DEBUG_GETOPT
+#endif
+
+#ifdef NO_OFFENSIVE
+#define OFFENSIVE_GETOPT
+#else
+#define OFFENSIVE_GETOPT "o"
+#endif
+
+    while ((ch = getopt(argc, argv, "ac" DEBUG_GETOPT "efilm:n:" OFFENSIVE_GETOPT "svw")) != EOF)
         switch (ch)
           {
           case 'a':             /* any fortune */
@@ -1032,9 +1044,11 @@ static void getargs(int argc, char **argv)
           case 'n':
               SLEN = atoi(optarg);
               break;
+#ifndef NO_OFFENSIVE
           case 'o':             /* offensive ones only */
               Offend++;
               break;
+#endif
           case 's':             /* short ones only */
               Short_only++;
               Long_only = FALSE;