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

Function nhassert_failed

src/pline.c:689–717  ·  view source on GitHub ↗

nhassert_failed is called when an nhassert's condition is false */

Source from the content-addressed store, hash-verified

687
688/* nhassert_failed is called when an nhassert's condition is false */
689void
690nhassert_failed(const char *expression, const char *filepath, int line)
691{
692 const char *filename, *p;
693
694 /* Attempt to get filename from path.
695 TODO: we really need a port provided function to return a filename
696 from a path. */
697 filename = filepath;
698 if ((p = strrchr(filename, '/')) != 0)
699 filename = p + 1;
700 if ((p = strrchr(filename, '\\')) != 0)
701 filename = p + 1;
702#ifdef VMS
703 /* usually "device:[directory]name"
704 but might be "device:[root.][directory]name"
705 and either "[directory]" or "[root.]" or both can be delimited
706 by <> rather than by []; find the last of ']', '>', and ':' */
707 if ((p = strrchr(filename, ']')) != 0)
708 filename = p + 1;
709 if ((p = strrchr(filename, '>')) != 0)
710 filename = p + 1;
711 if ((p = strrchr(filename, ':')) != 0)
712 filename = p + 1;
713#endif
714
715 impossible("nhassert(%s) failed in file '%s' at line %d",
716 expression, filename, line);
717}
718
719/*pline.c*/

Callers

nothing calls this directly

Calls 2

strrchrFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected