MCPcopy Create free account
hub / github.com/NetHack/NetHack / regularize

Function regularize

util/sfctool.c:745–774  ·  view source on GitHub ↗

normalize file name - we don't like .'s, /'s, spaces */

Source from the content-addressed store, hash-verified

743#ifdef UNIX
744/* normalize file name - we don't like .'s, /'s, spaces */
745void
746regularize(char *s)
747{
748 register char *lp;
749
750 while ((lp = strchr(s, '.')) != 0 || (lp = strchr(s, '/')) != 0
751 || (lp = strchr(s, ' ')) != 0)
752 *lp = '_';
753#if defined(SYSV) && !defined(AIX_31) && !defined(SVR4) && !defined(LINUX) \
754 && !defined(__APPLE__)
755/* avoid problems with 14 character file name limit */
756#ifdef COMPRESS
757 /* leave room for .e from error and .Z from compress appended to
758 * save files */
759 {
760#ifdef COMPRESS_EXTENSION
761 int i = 12 - strlen(COMPRESS_EXTENSION);
762#else
763 int i = 10; /* should never happen... */
764#endif
765 if (strlen(s) > i)
766 s[i] = '\0';
767 }
768#else
769 if (strlen(s) > 11)
770 /* leave room for .nn appended to level files */
771 s[11] = '\0';
772#endif
773#endif
774}
775#endif /* UNIX */
776
777int

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected