Added a private implementation of strrchr(3) for systems that lack it.
authorDavid Griffith <dave@661.org>
Sun, 30 Aug 2015 22:43:15 +0000 (15:43 -0700)
committerDavid Griffith <dave@661.org>
Sun, 30 Aug 2015 22:43:15 +0000 (15:43 -0700)
Makefile
src/curses/ux_frotz.h
src/curses/ux_init.c

index ec38050165caea3b5f1cb9220f2d644bb609b442..507cc5810fc0fe32fc01b8bd786e98006df42ab2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,12 @@ CURSES = -lcurses
 #
 #CURSES_DEF = -DUSE_NCURSES_H
 
+# Uncomment this if youy're compiling Unix Frotz on a machine that lacks 
+# the strrchr() libc library call.  If you don't know what this means,
+# leave it alone.
+#
+#STRRCHR_DEF = -DNO_STRRCHR
+
 # Uncomment this if you're compiling Unix Frotz on a machine that lacks
 # the memmove(3) system call.  If you don't know what this means, leave it
 # alone.
@@ -187,7 +193,7 @@ OPT_DEFS = -DCONFIG_DIR="\"$(CONFIG_DIR)\"" $(CURSES_DEF) \
        -DVERSION="\"$(VERSION)\"" -DSOUND_DEV="\"$(SOUND_DEV)\""
 
 CURSES_DEFS = $(OPT_DEFS) $(COLOR_DEFS) $(SOUND_DEFS) $(SOUNDCARD) \
-       $(MEMMOVE_DEF)
+       $(MEMMOVE_DEF) $(STRRCHR_DEF)
 
 
 $(NAME): $(NAME)-curses
index c780e36619ea393bf7a9f839d44ed5f05603a67f..19850539879c8ea609b2762d1278e9e2ed2532b1 100644 (file)
@@ -95,6 +95,10 @@ void unix_do_scrollback(void);               /* ux_screen.c */
 
 FILE   *pathopen(const char *, const char *, const char *, char *);
 
+#ifdef NO_STRRCHR
+char *strrchr(const char *, int);
+#endif
+
 #ifdef NO_MEMMOVE
 void *memmove(void *, void *);
 #endif
index b1d3faca8c0bb6aba852c0809f7a781d87c2b7ad..57f154d3518a7132a93ce1846970925a653fe90d 100644 (file)
@@ -1087,3 +1087,23 @@ int ux_init_blorb(void)
        return blorb_err;
     }
 }
+
+#ifdef NO_STRRCHR
+/*
+ * This is for operating systems that lack strrchr(3).
+ *
+ */
+char *strrchr(const char *s, int c)
+{
+    const char *save;
+
+    if (c == 0) return (char *)s + strlen(s);
+    save = 0;
+    while (*s) {
+       if (*s == c)
+           save = s;
+       s++;
+    }
+    return (char *)save;
+}
+#endif