Source:NetHack 5.0.0/src/pline.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to pline.c from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/src/pline.c#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	pline.c	$NHDT-Date: 1719819280 2024/07/01 07:34:40 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.130 $ */
2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3. /*-Copyright (c) Robert Patrick Rankin, 2018. */
4. /* NetHack may be freely redistributed.  See license for details. */
5. 
6. #include "hack.h"
7. 
8. #define BIGBUFSZ (5 * BUFSZ) /* big enough to format a 4*BUFSZ string (from
9.                               * config file parsing) with modest decoration;
10.                               * result will then be truncated to BUFSZ-1 */
11. 
12. staticfn void putmesg(const char *);
13. staticfn char *You_buf(int);
14. staticfn void execplinehandler(const char *);
15. #ifdef USER_SOUNDS
16. extern void maybe_play_sound(const char *);
17. #endif
18. #ifdef DUMPLOG_CORE
19. 
20. /* keep the most recent DUMPLOG_MSG_COUNT messages */
21. void
22. dumplogmsg(const char *line)
23. {
24.     /*
25.      * TODO:
26.      *  This essentially duplicates message history, which is
27.      *  currently implemented in an interface-specific manner.
28.      *  The core should take responsibility for that and have
29.      *  this share it.
30.      */
31.     unsigned indx = gs.saved_pline_index; /* next slot to use */
32.     char *oldest = gs.saved_plines[indx]; /* current content of that slot */
33. 
34.     if (!strncmp(line, "Unknown command", 15))
35.         return;
36.     if (oldest && strlen(oldest) >= strlen(line)) {
37.         /* this buffer will gradually shrink until the 'else' is needed;
38.            there's no pressing need to track allocation size instead */
39.         Strcpy(oldest, line);
40.     } else {
41.         if (oldest)
42.             free((genericptr_t) oldest);
43.         gs.saved_plines[indx] = dupstr(line);
44.     }
45.     gs.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
46. }
47. 
48. /* called during save (unlike the interface-specific message history,
49.    this data isn't saved and restored); end-of-game releases saved_plines[]
50.    while writing its contents to the final dump log */
51. void
52. dumplogfreemessages(void)
53. {
54.     unsigned i;
55. 
56.     for (i = 0; i < DUMPLOG_MSG_COUNT; ++i)
57.         if (gs.saved_plines[i])
58.             free((genericptr_t) gs.saved_plines[i]), gs.saved_plines[i] = 0;
59.     gs.saved_pline_index = 0;
60. }
61. #endif
62. 
63. /* keeps windowprocs usage out of pline() */
64. staticfn void
65. putmesg(const char *line)
66. {
67.     int attr = ATR_NONE;
68. 
69.     if (iflags.debug_prevent_pline)
70.         return;
71. 
72.     if ((gp.pline_flags & URGENT_MESSAGE) != 0
73.         && (windowprocs.wincap2 & WC2_URGENT_MESG) != 0)
74.         attr |= ATR_URGENT;
75.     if ((gp.pline_flags & SUPPRESS_HISTORY) != 0
76.         && (windowprocs.wincap2 & WC2_SUPPRESS_HIST) != 0)
77.         attr |= ATR_NOHISTORY;
78.     putstr(WIN_MESSAGE, attr, line);
79.     SoundSpeak(line);
80. }
81. 
82. /* set the direction where next message happens */
83. void
84. set_msg_dir(int dir)
85. {
86.     dirtocoord(&a11y.msg_loc, dir);
87.     a11y.msg_loc.x += u.ux;
88.     a11y.msg_loc.y += u.uy;
89. }
90. 
91. /* set the coordinate where next message happens */
92. void
93. set_msg_xy(coordxy x, coordxy y)
94. {
95.     a11y.msg_loc.x = x;
96.     a11y.msg_loc.y = y;
97. }
98. 
99. staticfn void vpline(const char *, va_list);
100. 
101. DISABLE_WARNING_FORMAT_NONLITERAL
102. 
103. void
104. pline(const char *line, ...)
105. {
106.     va_list the_args;
107. 
108.     va_start(the_args, line);
109.     vpline(line, the_args);
110.     va_end(the_args);
111. }
112. 
113. void
114. pline_dir(int dir, const char *line, ...)
115. {
116.     va_list the_args;
117. 
118.     set_msg_dir(dir);
119. 
120.     va_start(the_args, line);
121.     vpline(line, the_args);
122.     va_end(the_args);
123. }
124. 
125. void
126. pline_xy(coordxy x, coordxy y, const char *line, ...)
127. {
128.     va_list the_args;
129. 
130.     set_msg_xy(x, y);
131. 
132.     va_start(the_args, line);
133.     vpline(line, the_args);
134.     va_end(the_args);
135. }
136. 
137. void
138. pline_mon(struct monst *mtmp, const char *line, ...)
139. {
140.     va_list the_args;
141. 
142.     if (mtmp == &gy.youmonst)
143.         set_msg_xy(0, 0);
144.     else
145.         set_msg_xy(mtmp->mx, mtmp->my);
146. 
147.     va_start(the_args, line);
148.     vpline(line, the_args);
149.     va_end(the_args);
150. }
151. 
152. staticfn void
153. vpline(const char *line, va_list the_args)
154. {
155.     static int in_pline = 0;
156.     char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */
157.     int ln;
158.     int msgtyp;
159.     boolean no_repeat;
160.     coord a11y_mesgxy;
161. 
162.     a11y_mesgxy = a11y.msg_loc; /* save a11y.msg_loc before reseting it */
163.     /* always reset a11y.msg_loc whether we end up using it or not */
164.     a11y.msg_loc.x = a11y.msg_loc.y = 0;
165. 
166.     if (!line || !*line)
167.         return;
168. #ifdef HANGUPHANDLING
169.     if (program_state.done_hup)
170.         return;
171. #endif
172.     if (program_state.wizkit_wishing)
173.         return;
174. 
175.     /* when accessiblemsg is set and a11y.msg_loc is nonzero, use the latter
176.        to insert a location prefix in front of current message */
177.     if (a11y.accessiblemsg && isok(a11y_mesgxy.x, a11y_mesgxy.y)) {
178.         char *tmp, *dirstr, dirstrbuf[QBUFSZ];
179. 
180.         dirstr = coord_desc(a11y_mesgxy.x, a11y_mesgxy.y, dirstrbuf,
181.                             ((iflags.getpos_coords == GPCOORDS_NONE)
182.                              ? GPCOORDS_COMFULL : iflags.getpos_coords));
183.         tmp = (char *) alloc(strlen(line) + sizeof ": " + strlen(dirstr));
184.         Strcpy(tmp, dirstr);
185.         Strcat(tmp, ": ");
186.         Strcat(tmp, line);
187.         vpline(tmp, the_args);
188.         free((genericptr_t) tmp);
189.         return;
190.     }
191. 
192.     if (!strchr(line, '%')) {
193.         /* format does not specify any substitutions; use it as-is */
194.         ln = (int) strlen(line);
195.     } else if (line[0] == '%' && line[1] == 's' && !line[2]) {
196.         /* "%s" => single string; skip format and use its first argument;
197.            unlike with the format, it is irrelevant whether the argument
198.            contains any percent signs */
199.         line = va_arg(the_args, const char *); /*VA_NEXT(line,const char *);*/
200.         ln = (int) strlen(line);
201.     } else {
202.         /* perform printf() formatting */
203.         ln = vsnprintf(pbuf, sizeof pbuf, line, the_args);
204.         line = pbuf;
205.         /* note: 'ln' is number of characters attempted, not necessarily
206.            strlen(line); that matters for the overflow check; if we avoid
207.            the extremely-too-long panic then 'ln' will be actual length */
208.     }
209.     if (ln > (int) sizeof pbuf - 1) /* extremely too long */
210.         panic("pline attempting to print %d characters!", ln);
211. 
212.     if (ln > BUFSZ - 1) {
213.         /* too long but modestly so; allow but truncate, preserving final
214.            3 chars: "___ extremely long text" -> "___ extremely l...ext"
215.            (this may be suboptimal if overflow is less than 3) */
216.         if (line != pbuf) /* no '%' was present or format was just "%s" */
217.             (void) strncpy(pbuf, line, BUFSZ - 1); /* caveat: unterminated */
218.         pbuf[BUFSZ - 1 - 6] = pbuf[BUFSZ - 1 - 5] = pbuf[BUFSZ - 1 - 4] = '.';
219.         /* avoid strncpy; buffers could overlap if excess is small */
220.         pbuf[BUFSZ - 1 - 3] = line[ln - 3];
221.         pbuf[BUFSZ - 1 - 2] = line[ln - 2];
222.         pbuf[BUFSZ - 1 - 1] = line[ln - 1];
223.         pbuf[BUFSZ - 1] = '\0';
224.         line = pbuf;
225.     }
226.     msgtyp = MSGTYP_NORMAL;
227. 
228. #ifdef DUMPLOG_CORE
229.     /* We hook here early to have options-agnostic output.
230.      * Unfortunately, that means Norep() isn't honored (general issue) and
231.      * that short lines aren't combined into one longer one (tty behavior).
232.      */
233.     if ((gp.pline_flags & SUPPRESS_HISTORY) == 0)
234.         dumplogmsg(line);
235. #endif
236.     /* use raw_print() if we're called too early (or perhaps too late
237.        during shutdown) or if we're being called recursively (probably
238.        via debugpline() in the interface code) */
239.     if (in_pline++ || !iflags.window_inited) {
240.         /* [we should probably be using raw_printf("\n%s", line) here] */
241.         raw_print(line);
242.         iflags.last_msg = PLNMSG_UNKNOWN;
243.         goto pline_done;
244.     }
245. 
246.     no_repeat = (gp.pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
247.     if ((gp.pline_flags & OVERRIDE_MSGTYPE) == 0) {
248.         msgtyp = msgtype_type(line, no_repeat);
249. #ifdef USER_SOUNDS
250.         if (msgtyp == MSGTYP_NORMAL || msgtyp == MSGTYP_NOSHOW)
251.             maybe_play_sound(line);
252. #endif
253.         if ((gp.pline_flags & URGENT_MESSAGE) == 0
254.             && (msgtyp == MSGTYP_NOSHOW
255.                 || (msgtyp == MSGTYP_NOREP && !strcmp(line, gp.prevmsg))))
256.             /* FIXME: we need a way to tell our caller that this message
257.              * was suppressed so that caller doesn't set iflags.last_msg
258.              * for something that hasn't been shown, otherwise a subsequent
259.              * message which uses alternate wording based on that would be
260.              * doing so out of context and probably end up seeming silly.
261.              * (Not an issue for no-repeat but matters for no-show.)
262.              */
263.             goto pline_done;
264.     }
265. 
266.     if (gv.vision_full_recalc) {
267.         int tmp_in_pline = in_pline;
268. 
269.         in_pline = 0;
270.         vision_recalc(0);
271.         in_pline = tmp_in_pline;
272.     }
273.     if (u.ux)
274.         flush_screen((gp.pline_flags & NO_CURS_ON_U) ? 0 : 1); /* %% */
275. 
276.     putmesg(line);
277. 
278.     execplinehandler(line);
279. 
280.     /* this gets cleared after every pline message */
281.     iflags.last_msg = PLNMSG_UNKNOWN;
282.     (void) strncpy(gp.prevmsg, line, BUFSZ), gp.prevmsg[BUFSZ - 1] = '\0';
283.     if (msgtyp == MSGTYP_STOP)
284.         display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
285.  pline_done:
286. #ifdef SND_SPEECH
287.     /* clear the SPEECH flag so caller never has to */
288.     gp.pline_flags &= ~PLINE_SPEECH;
289. #endif
290.     --in_pline;
291. }
292. 
293. RESTORE_WARNING_FORMAT_NONLITERAL
294. 
295. /* pline() variant which can override MSGTYPE handling or suppress
296.    message history (tty interface uses pline() to issue prompts and
297.    they shouldn't be blockable via MSGTYPE=hide) */
298. void
299. custompline(unsigned pflags, const char *line, ...)
300. {
301.     va_list the_args;
302. 
303.     va_start(the_args, line);
304.     gp.pline_flags = pflags;
305.     vpline(line, the_args);
306.     gp.pline_flags = 0;
307.     va_end(the_args);
308. }
309. 
310. /* if player has dismissed --More-- with ESC to suppress further messages
311.    until next input request, tell the interface that it should override that
312.    and re-enable them; equivalent to custompline(URGENT_MESSAGE, line, ...)
313.    but slightly simpler to use */
314. void
315. urgent_pline(const char *line, ...)
316. {
317.     va_list the_args;
318. 
319.     va_start(the_args, line);
320.     gp.pline_flags = URGENT_MESSAGE;
321.     vpline(line, the_args);
322.     gp.pline_flags = 0;
323.     va_end(the_args);
324. }
325. 
326. void
327. Norep(const char *line, ...)
328. {
329.     va_list the_args;
330. 
331.     va_start(the_args, line);
332.     gp.pline_flags = PLINE_NOREPEAT;
333.     vpline(line, the_args);
334.     gp.pline_flags = 0;
335.     va_end(the_args);
336. }
337. 
338. staticfn char *
339. You_buf(int siz)
340. {
341.     if (siz > gy.you_buf_siz) {
342.         if (gy.you_buf)
343.             free((genericptr_t) gy.you_buf);
344.         gy.you_buf_siz = siz + 10;
345.         gy.you_buf = (char *) alloc((unsigned) gy.you_buf_siz);
346.     }
347.     return gy.you_buf;
348. }
349. 
350. void
351. free_youbuf(void)
352. {
353.     if (gy.you_buf)
354.         free((genericptr_t) gy.you_buf), gy.you_buf = (char *) 0;
355.     gy.you_buf_siz = 0;
356. }
357. 
358. /* `prefix' must be a string literal, not a pointer */
359. #define YouPrefix(pointer, prefix, text) \
360.     Strcpy((pointer = You_buf((int) (strlen(text) + sizeof prefix))), prefix)
361. 
362. #define YouMessage(pointer, prefix, text) \
363.     strcat((YouPrefix(pointer, prefix, text), pointer), text)
364. 
365. void
366. You(const char *line, ...)
367. {
368.     va_list the_args;
369.     char *tmp;
370. 
371.     va_start(the_args, line);
372.     vpline(YouMessage(tmp, "You ", line), the_args);
373.     va_end(the_args);
374. }
375. 
376. void
377. Your(const char *line, ...)
378. {
379.     va_list the_args;
380.     char *tmp;
381. 
382.     va_start(the_args, line);
383.     vpline(YouMessage(tmp, "Your ", line), the_args);
384.     va_end(the_args);
385. }
386. 
387. void
388. You_feel(const char *line, ...)
389. {
390.     va_list the_args;
391.     char *tmp;
392. 
393.     va_start(the_args, line);
394.     if (Unaware)
395.         YouPrefix(tmp, "You dream that you feel ", line);
396.     else
397.         YouPrefix(tmp, "You feel ", line);
398.     vpline(strcat(tmp, line), the_args);
399.     va_end(the_args);
400. }
401. 
402. void
403. You_cant(const char *line, ...)
404. {
405.     va_list the_args;
406.     char *tmp;
407. 
408.     va_start(the_args, line);
409.     vpline(YouMessage(tmp, "You can't ", line), the_args);
410.     va_end(the_args);
411. }
412. 
413. void
414. pline_The(const char *line, ...)
415. {
416.     va_list the_args;
417.     char *tmp;
418. 
419.     va_start(the_args, line);
420.     vpline(YouMessage(tmp, "The ", line), the_args);
421.     va_end(the_args);
422. }
423. 
424. void
425. There(const char *line, ...)
426. {
427.     va_list the_args;
428.     char *tmp;
429. 
430.     va_start(the_args, line);
431.     vpline(YouMessage(tmp, "There ", line), the_args);
432.     va_end(the_args);
433. }
434. 
435. void
436. You_hear(const char *line, ...)
437. {
438.     va_list the_args;
439.     char *tmp;
440. 
441.     if ((Deaf && !Unaware) || !flags.acoustics)
442.         return;
443.     va_start(the_args, line);
444.     if (Underwater)
445.         YouPrefix(tmp, "You barely hear ", line);
446.     else if (Unaware)
447.         YouPrefix(tmp, "You dream that you hear ", line);
448.     else
449.         YouPrefix(tmp, "You hear ", line);  /* Deaf-aware */
450.     vpline(strcat(tmp, line), the_args);
451.     va_end(the_args);
452. }
453. 
454. void
455. You_see(const char *line, ...)
456. {
457.     va_list the_args;
458.     char *tmp;
459. 
460.     va_start(the_args, line);
461.     if (Unaware)
462.         YouPrefix(tmp, "You dream that you see ", line);
463.     else if (Blind) /* caller should have caught this... */
464.         YouPrefix(tmp, "You sense ", line);
465.     else
466.         YouPrefix(tmp, "You see ", line);
467.     vpline(strcat(tmp, line), the_args);
468.     va_end(the_args);
469. }
470. 
471. /* Print a message inside double-quotes.
472.  * The caller is responsible for checking deafness.
473.  * Gods can speak directly to you in spite of deafness.
474.  */
475. void
476. verbalize(const char *line, ...)
477. {
478.     va_list the_args;
479.     char *tmp;
480. 
481.     va_start(the_args, line);
482.     gp.pline_flags |= PLINE_VERBALIZE;
483.     tmp = You_buf((int) strlen(line) + sizeof "\"\"");
484.     Strcpy(tmp, "\"");
485.     Strcat(tmp, line);
486.     Strcat(tmp, "\"");
487.     vpline(tmp, the_args);
488.     gp.pline_flags &= ~PLINE_VERBALIZE;
489.     va_end(the_args);
490. }
491. 
492. #ifdef CHRONICLE
493. 
494. void
495. gamelog_add(long glflags, long gltime, const char *str)
496. {
497.     struct gamelog_line *tmp;
498.     struct gamelog_line *lst = gg.gamelog;
499. 
500.     tmp = (struct gamelog_line *) alloc(sizeof (struct gamelog_line));
501.     tmp->turn = gltime;
502.     tmp->flags = glflags;
503.     tmp->text = dupstr(str);
504.     tmp->next = NULL;
505.     while (lst && lst->next)
506.         lst = lst->next;
507.     if (!lst)
508.         gg.gamelog = tmp;
509.     else
510.         lst->next = tmp;
511. }
512. 
513. void
514. livelog_printf(long ll_type, const char *line, ...)
515. {
516.     char gamelogbuf[BUFSZ * 2];
517.     va_list the_args;
518. 
519.     va_start(the_args, line);
520.     (void) vsnprintf(gamelogbuf, sizeof gamelogbuf, line, the_args);
521.     va_end(the_args);
522. 
523.     gamelog_add(ll_type, svm.moves, gamelogbuf);
524.     strNsubst(gamelogbuf, "\t", "_", 0);
525.     livelog_add(ll_type, gamelogbuf);
526. }
527. 
528. #else
529. 
530. void
531. gamelog_add(
532.     long glflags UNUSED, long gltime UNUSED, const char *msg UNUSED)
533. {
534.     ; /* nothing here */
535. }
536. 
537. void
538. livelog_printf(
539.     long ll_type UNUSED, const char *line UNUSED, ...)
540. {
541.     ; /* nothing here */
542. }
543. 
544. #endif /* !CHRONICLE */
545. 
546. staticfn void vraw_printf(const char *, va_list);
547. 
548. void
549. raw_printf(const char *line, ...)
550. {
551.     va_list the_args;
552. 
553.     va_start(the_args, line);
554.     vraw_printf(line, the_args);
555.     va_end(the_args);
556.     if (!program_state.beyond_savefile_load)
557.         ge.early_raw_messages++;
558. }
559. 
560. DISABLE_WARNING_FORMAT_NONLITERAL
561. 
562. staticfn void
563. vraw_printf(const char *line, va_list the_args)
564. {
565.     char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
566. 
567.     if (strchr(line, '%')) {
568.         (void) vsnprintf(pbuf, sizeof(pbuf), line, the_args);
569.         line = pbuf;
570.     }
571.     if ((int) strlen(line) > BUFSZ - 1) {
572.         if (line != pbuf)
573.             line = strncpy(pbuf, line, BUFSZ - 1);
574.         /* unlike pline, we don't futz around to keep last few chars */
575.         pbuf[BUFSZ - 1] = '\0'; /* terminate strncpy or truncate vsprintf */
576.     }
577.     raw_print(line);
578.     execplinehandler(line);
579.     if (!program_state.beyond_savefile_load)
580.         ge.early_raw_messages++;
581. }
582. 
583. void
584. impossible(const char *s, ...)
585. {
586.     va_list the_args;
587.     char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
588.     char pbuf2[BUFSZ];
589. 
590.     va_start(the_args, s);
591.     if (program_state.in_impossible)
592.         panic("impossible called impossible");
593. 
594.     program_state.in_impossible = 1;
595.     (void) vsnprintf(pbuf, sizeof pbuf, s, the_args);
596.     va_end(the_args);
597.     pbuf[BUFSZ - 1] = '\0'; /* sanity */
598.     paniclog("impossible", pbuf);
599.     if (iflags.debug_fuzzer == fuzzer_impossible_panic)
600.         panic("%s", pbuf);
601. 
602.     gp.pline_flags = URGENT_MESSAGE;
603.     pline("%s", pbuf);
604.     gp.pline_flags = 0;
605. 
606.     if (program_state.in_sanity_check) {
607.         /* skip rest of multi-line feedback */
608.         program_state.in_impossible = 0;
609.         return;
610.     }
611. 
612.     Strcpy(pbuf2, "Program in disorder!");
613.     if (program_state.something_worth_saving)
614.         Strcat(pbuf2, "  (Saving and reloading may fix this problem.)");
615.     pline("%s", pbuf2);
616.     pline("Please report these messages to %s.", DEVTEAM_EMAIL);
617.     if (sysopt.support) {
618.         pline("Alternatively, contact local support: %s", sysopt.support);
619.     }
620. 
621. #ifdef CRASHREPORT
622.     if (sysopt.crashreporturl) {
623.         boolean report = ('y' == yn_function("Report now?", ynchars,
624.                                              'n', FALSE));
625. 
626.         raw_print(""); /* prove to the user the character was accepted */
627.         if (report) {
628.             submit_web_report(1, "Impossible", pbuf);
629.         }
630.     }
631. #endif
632. 
633.     program_state.in_impossible = 0;
634. }
635. 
636. RESTORE_WARNING_FORMAT_NONLITERAL
637. 
638. static boolean use_pline_handler = TRUE;
639. 
640. staticfn void
641. execplinehandler(const char *line)
642. {
643. #if defined(UNIX) && (defined(POSIX_TYPES) || defined(__GNUC__))
644.     int f;
645. #endif
646.     const char *args[3];
647. 
648.     if (!use_pline_handler || !sysopt.msghandler)
649.         return;
650. 
651. #if defined(UNIX) && (defined(POSIX_TYPES) || defined(__GNUC__))
652.     f = fork();
653.     if (f == 0) { /* child */
654.         args[0] = sysopt.msghandler;
655.         args[1] = line;
656.         args[2] = NULL;
657.         (void) setgid(getgid());
658.         (void) setuid(getuid());
659.         (void) execv(args[0], (char *const *) args);
660.         perror((char *) 0);
661.         (void) fprintf(stderr, "Exec to message handler %s failed.\n", sysopt.msghandler);
662.         nh_terminate(EXIT_FAILURE);
663.     } else if (f > 0) {
664.         int status;
665. 
666.         waitpid(f, &status, 0);
667.     } else if (f == -1) {
668.         perror((char *) 0);
669.         use_pline_handler = FALSE;
670.         pline("%s", "Fork to message handler failed.");
671.     }
672. #elif defined(WIN32)
673.     {
674.         intptr_t ret;
675.         args[0] = sysopt.msghandler;
676.         args[1] = line;
677.         args[2] = NULL;
678.         ret = _spawnv(_P_NOWAIT, sysopt.msghandler, args);
679.         nhUse(ret);  /* -Wunused-but-set-variable */
680.     }
681. #else
682.     use_pline_handler = FALSE;
683.     nhUse(args);
684.     nhUse(line);
685. #endif
686. }
687. 
688. /* nhassert_failed is called when an nhassert's condition is false */
689. void
690. nhassert_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*/