OSDN Git Service

removed DOS-related codes.
[putex/putex.git] / src / texsourc / yandytex.c
1 /* Copyright 1992 Karl Berry\r
2    Copyright 2007 TeX Users Group\r
3    Copyright 2014 Clerk Ma\r
4 \r
5    This program is free software; you can redistribute it and/or modify\r
6    it under the terms of the GNU General Public License as published by\r
7    the Free Software Foundation; either version 2 of the License, or\r
8    (at your option) any later version.\r
9 \r
10    This program is distributed in the hope that it will be useful, but\r
11    WITHOUT ANY WARRANTY; without even the implied warranty of\r
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
13    General Public License for more details.\r
14 \r
15    You should have received a copy of the GNU General Public License\r
16    along with this program; if not, write to the Free Software\r
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
18    02110-1301 USA.  */\r
19 \r
20 #define EXTERN\r
21 \r
22 #include "yandytex.h"\r
23 \r
24 #define dump_ext_length 4\r
25 #define edit_value      tex_edit_value\r
26 \r
27 extern char * replacement[];\r
28 int    gargc;\r
29 char **gargv;\r
30 \r
31 int jump_used = 0;\r
32 \r
33 jmp_buf jumpbuffer;\r
34 \r
35 int main (int ac, char *av[])\r
36 {\r
37   int flag = 0, ret = 0;\r
38 \r
39   gargc = ac;\r
40   gargv = av;\r
41 \r
42   if (main_init(gargc, gargv))\r
43     return -1;\r
44 \r
45   TEX_format_default = " plain.fmt";\r
46   format_default_length = strlen(TEX_format_default + 1);\r
47 \r
48   jump_used = 0;\r
49 \r
50   ret = setjmp(jumpbuffer);\r
51 \r
52   if (ret == 0)\r
53   {\r
54     flag = main_program();\r
55 \r
56     if (trace_flag)\r
57       printf("EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "main", flag, ret, jump_used);\r
58   }\r
59   else\r
60   {\r
61     if (trace_flag)\r
62       printf("EXITING at %s: flag = %d, ret = %d, jump_used =  %d\n", "jump_out", flag, ret, jump_used);\r
63   }\r
64 \r
65   if (endit(flag) != 0)\r
66     flag = 1; /* do final clean up in local.c */\r
67 \r
68   if (flag == 0)\r
69     return 0;\r
70   else\r
71     exit (flag);\r
72 }\r
73 \r
74 /* texk/web2c/lib/texmfmp.c */\r
75 void t_open_in (void)\r
76 {\r
77   int i;\r
78 \r
79   buffer[first] = 0;\r
80 \r
81   if (gargc > optind && optind > 0)\r
82   {\r
83     for (i = optind; i < gargc; i++)\r
84     {\r
85       if (allow_quoted_names && strchr(gargv[i], ' ') != NULL)\r
86       {\r
87         (void) strcat ((char *) &buffer[first], "\"");\r
88         (void) strcat ((char *) &buffer[first], gargv[i]);\r
89         (void) strcat ((char *) &buffer[first], "\"");\r
90       }\r
91       else\r
92         (void) strcat ((char *) &buffer[first], gargv[i]);\r
93 \r
94       (void) strcat ((char *) &buffer[first], " ");\r
95     }\r
96     \r
97     gargc = 0;\r
98   }\r
99 \r
100   /* Find the end of the buffer.  */\r
101   for (last = first; buffer[last]; ++last)\r
102     do_nothing();\r
103 \r
104   for (--last; last >= first && ISBLANK (buffer[last]) && buffer[last] != '\r'; --last)\r
105     do_nothing();\r
106 \r
107   last++;\r
108 \r
109 /* One more time, this time converting to TeX's internal character\r
110    representation.  */ /* for command line input in this case */\r
111   if (non_ascii)\r
112   {\r
113     for (i = first; i < last; i++)\r
114       buffer[i] = xord[buffer[i]];\r
115   }\r
116 }\r
117 \r
118 static void catch_interrupt (int err)\r
119 {\r
120   (void) err;\r
121   (void) signal(SIGINT, SIG_IGN);\r
122 \r
123   if (interrupt++ >= 3)\r
124     exit(1);\r
125 \r
126   (void) signal(SIGINT, catch_interrupt);\r
127 }\r
128 \r
129 void fix_date_and_time (void)\r
130 {\r
131   time_t clock;\r
132   struct tm *tmptr;\r
133 \r
134   (void) time(&clock);\r
135 \r
136   if (trace_flag)\r
137     printf("The time is %lld\n", (long long)clock);\r
138 \r
139   if (clock < 0)\r
140     puts("Time not available!");\r
141 \r
142   tmptr = localtime (&clock);\r
143 \r
144   if (tmptr == NULL)\r
145   {\r
146     printf("Cannot convert time (%0lld)!\n", (long long)clock);\r
147     year     = 2038;\r
148     month    = 1;\r
149     day      = 18;\r
150     tex_time = 22 * 60 + 14;\r
151   }\r
152   else\r
153   {\r
154     tex_time = tmptr->tm_hour * 60 + tmptr->tm_min;\r
155     day      = tmptr->tm_mday;\r
156     month    = tmptr->tm_mon + 1;\r
157     year     = tmptr->tm_year + 1900;\r
158 \r
159     if (trace_flag)\r
160       printf("%d-%d-%d %d:%d\n",\r
161         tmptr->tm_year + 1900,\r
162         tmptr->tm_mon + 1,\r
163         tmptr->tm_mday,\r
164         tmptr->tm_hour,\r
165         tmptr->tm_min);\r
166   }\r
167 \r
168   {\r
169 #ifdef _WIN32\r
170     if (signal(SIGINT, catch_interrupt) == SIG_ERR)\r
171     {\r
172       puts(" CTRL-C handler not installed");\r
173       uexit(EXIT_FAILURE);\r
174     }\r
175 #else\r
176     void (*old_handler)();\r
177 \r
178     old_handler = signal(SIGINT, catch_interrupt);\r
179 \r
180     if (old_handler != SIG_DFL)\r
181       (void) signal(SIGINT, old_handler);\r
182 #endif\r
183   }\r
184 }\r
185 \r
186 /* I/O for TeX and Metafont. */\r
187 void complain_line (FILE * output)\r
188 {\r
189   show_line("\n", 0);\r
190 \r
191 #ifdef ALLOCATEBUFFER\r
192   sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", current_buf_size);\r
193 #else\r
194   sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", buf_size);\r
195 #endif\r
196 \r
197   fputs(log_line, output);\r
198   puts("  (File may have a line termination problem.)");\r
199 }\r
200 \r
201 void show_bad_line (FILE * output, int first, int last)\r
202 {\r
203   int i, c, d, ch;\r
204   char *s = log_line;\r
205 \r
206   for (i = first; i <= last; i++)\r
207   {\r
208     ch = buffer[i];\r
209 \r
210     if (show_in_hex && (ch > 127))\r
211     {\r
212       c = ch >> 4;\r
213       d = ch & 15;\r
214 \r
215       if (c > 9)\r
216         c = c + 'a' - 10;\r
217       else\r
218         c = c + '0';\r
219 \r
220       if (d > 9)\r
221         d = d + 'a' - 10;\r
222       else\r
223         d = d + '0';\r
224 \r
225       *s++ = '^';\r
226       *s++ = '^';\r
227 \r
228       *s++ = (char) c;\r
229       *s++ = (char) d;\r
230     }\r
231     else if (ch < 32)\r
232     {\r
233       *s++ = '^';\r
234       *s++ = '^';\r
235       *s++ = (char) (ch + 64);\r
236     }\r
237     else if (ch == 127)\r
238     {\r
239       *s++ = '^';\r
240       *s++ = '^';\r
241       *s++ = (char) (ch - 64);\r
242     }\r
243     else\r
244     {\r
245       *s++ = (char) ch;\r
246     }\r
247   }\r
248 \r
249   *s++ = ' ';\r
250   *s++ = '\0';\r
251 \r
252   fputs(log_line, output);   // log_file\r
253 }\r
254 \r
255 boolean input_line_finish (void)\r
256 {\r
257   int i = '\0';\r
258   int ch, flag;\r
259 \r
260   buffer[last] = ' ';\r
261 \r
262   if (last >= max_buf_stack)\r
263     max_buf_stack = last;\r
264 \r
265   while (last > first)\r
266   {\r
267     i = buffer[last - 1];\r
268 \r
269     if (i == ' ' || i == '\t')\r
270       --last;\r
271     else\r
272       break;\r
273   }\r
274 \r
275   if (restrict_to_ascii)\r
276   {\r
277     flag = 0;\r
278 \r
279     for (i = first; i <= last; i++)\r
280     {\r
281       ch = buffer[i];\r
282 \r
283       if (ch > 126 ||  (ch < ' ' && ch != '\t' && ch != '\f' && ch != '\r' && ch != '\n'))\r
284       {\r
285         sprintf(log_line, "\n! non ASCII char (%d) in line: ", ch);\r
286         show_line(log_line, 1);\r
287 \r
288         if (log_opened)\r
289           fprintf(log_file, "\n! non ASCII char (%d) in line: ", ch);\r
290 \r
291         flag = 1;\r
292         break;\r
293       }\r
294     }\r
295 \r
296     if (flag)\r
297     {\r
298       show_bad_line(errout, first, last);\r
299 \r
300       if (log_opened)\r
301         show_bad_line(log_file, first, last);\r
302     }\r
303   }\r
304 \r
305   if (non_ascii)\r
306   {\r
307     for (i = first; i <= last; i++)\r
308       buffer[i] = xord[buffer[i]];\r
309   }\r
310 \r
311   return true;\r
312 }\r
313 \r
314 /* Read a line of input into buffer as efficiently as possible (ha ha)\r
315    while still looking like Pascal.\r
316    We set `last' to `first' and return `false' if we get to eof.\r
317    Otherwise, we return `true' and set last = first +\r
318    length(line except trailing whitespace).  */\r
319 \r
320 boolean input_line (FILE * f)\r
321 {\r
322   char * u;        /* 1994/July/3 for key_replace */\r
323   int i = '\0';\r
324 \r
325   last = first;\r
326 /*  following is new version with tab expansion and key replacement */\r
327 /*  may want to expand out separately for speed 1994/July/3 */\r
328 /*  different versions depending on return_flag / tabexpand / key_replace */\r
329 /*  while (last < buf_size && (i = getc (f)) != EOF)  */\r
330 #ifdef ALLOCATEBUFFER\r
331   for ( ; ; ) \r
332 #else\r
333   while (last < buf_size) \r
334 #endif\r
335   {\r
336     i = getc(f);\r
337 \r
338     if (i < ' ')\r
339     {\r
340       if (i == EOF || i == '\n' || (i == '\r' && return_flag))\r
341         break;\r
342       else if (i == '\t' && tab_step != 0)\r
343       {\r
344         buffer[last++] = (ASCII_code) ' ';\r
345 \r
346 #ifdef ALLOCATEBUFFER\r
347         if (last >= current_buf_size)\r
348         {\r
349           buffer = realloc_buffer(increment_buf_size);  \r
350 \r
351           if (last >= current_buf_size)\r
352             break;\r
353         }\r
354 #endif\r
355 \r
356 #ifdef ALLOCATEBUFFER\r
357         while ((last - first) % tab_step != 0) \r
358 #else\r
359         while (last < buf_size && (last - first) % tab_step != 0)\r
360 #endif\r
361         {\r
362 \r
363           buffer[last++] = (ASCII_code) ' ';\r
364 \r
365 #ifdef ALLOCATEBUFFER\r
366           if (last >= current_buf_size)\r
367           {\r
368             buffer = realloc_buffer(increment_buf_size);\r
369 \r
370             if (last >= current_buf_size)\r
371               break;\r
372           }\r
373 #endif\r
374         }\r
375 \r
376         continue;\r
377       }\r
378     }\r
379 \r
380     if (key_replace && (u = replacement[i]) != NULL)\r
381     {\r
382 #ifdef ALLOCATEBUFFER\r
383       while (*u != '\0') \r
384 #else\r
385       while (last < buf_size && *u != '\0')  \r
386 #endif\r
387       {\r
388         buffer[last++] = (ASCII_code) *u++;\r
389 \r
390 #ifdef ALLOCATEBUFFER\r
391         if (last >= current_buf_size)\r
392         {\r
393           buffer = realloc_buffer(increment_buf_size);\r
394 \r
395           if (last >= current_buf_size)\r
396             break;\r
397         }\r
398 #endif\r
399       }\r
400     }\r
401     else       /* normal case */\r
402     {\r
403       buffer[last++] = (ASCII_code) i;\r
404 \r
405 #ifdef ALLOCATEBUFFER\r
406       if (last >= current_buf_size)\r
407       {\r
408         buffer = realloc_buffer(increment_buf_size);\r
409 \r
410         if (last >= current_buf_size)\r
411           break;\r
412       }\r
413 #endif\r
414     }\r
415   }\r
416 \r
417   if (return_flag)    /* let return terminate line as well as newline */\r
418   {\r
419     if (i == '\r')      /* see whether return followed by newline */\r
420     {\r
421       i = getc (f);       /* in which case throw away the newline */\r
422 \r
423       if (i != '\n')\r
424       {\r
425         ungetc (i, f);\r
426         i = '\r';\r
427       }\r
428 /*      else  buffer[last-1] = (ASCII_code) i; */\r
429     }\r
430   }\r
431 \r
432   //  Turn Ctrl-Z at end of file into newline 2000 June 22\r
433   if (i == EOF && trimeof && buffer[last - 1] == 26)\r
434   {\r
435     last--;\r
436   }\r
437 \r
438   if (i == EOF && last == first)\r
439     return false;\r
440 \r
441 /*  Didn't get the whole line because buffer was too small?  */\r
442 /*  This shouldn't happen anymore 99/Jan/23 */\r
443   if (i != EOF && i != '\n' && i != '\r')\r
444   {\r
445     complain_line(errout);\r
446 \r
447     if (log_opened)\r
448       complain_line(log_file);\r
449 \r
450     /* This may no longer be needed ... now that we grow it */\r
451     if (truncate_long_lines)\r
452     {\r
453       while (i != EOF && i != '\n' && i != '\r')\r
454       {\r
455         i = getc (f);     // discard rest of line\r
456       }\r
457 \r
458       last--;       /* just in case */\r
459     }\r
460     else\r
461       uexit(EXIT_FAILURE);      /* line too long */\r
462   }\r
463 \r
464   return input_line_finish();\r
465 }\r
466 \r
467 static char * edit_value = "c:\\yandy\\WinEdt\\WinEdt.exe [Open('%s');SelLine(%d,7)]";\r
468 \r
469 static inline int Isspace (char c)\r
470 {\r
471   return (c == ' ' || c == '\t');\r
472 }\r
473 \r
474 void call_edit (ASCII_code * filename, pool_pointer fnstart, integer fnlength, integer linenumber)\r
475 {\r
476   char *temp, *command, *fullcmd;\r
477   char c;\r
478   int sdone, ddone, i;\r
479 \r
480 #ifdef WIN32\r
481   char *fp, *ffp, *env, editorname[256], buffer[256];\r
482   int cnt = 0;\r
483   int dontchange = 0;\r
484 #endif\r
485 \r
486   sdone = ddone = 0;\r
487   filename += fnstart;\r
488 \r
489   /* Close any open input files, since we're going to kill the job.  */\r
490   for (i = 1; i <= in_open; i++)\r
491 #ifdef XeTeX\r
492     xfclose (input_file[i]->f, "inputfile");\r
493 #else\r
494     xfclose (input_file[i], "inputfile");\r
495 #endif\r
496 \r
497   /* Replace the default with the value of the appropriate environment\r
498      variable or config file value, if it's set.  */\r
499   temp = kpse_var_value("TEXEDIT");\r
500 \r
501   if (temp != NULL)\r
502     edit_value = temp;\r
503 \r
504   /* Construct the command string.  The `11' is the maximum length an\r
505      integer might be.  */\r
506   command = (char *) xmalloc (strlen (edit_value) + fnlength + 11);\r
507 \r
508   /* So we can construct it as we go.  */\r
509   temp = command;\r
510 \r
511 #ifdef WIN32\r
512   fp = editorname;\r
513   if ((isalpha(*edit_value) && *(edit_value + 1) == ':'\r
514         && IS_DIR_SEP (*(edit_value + 2)))\r
515       || (*edit_value == '"' && isalpha(*(edit_value + 1))\r
516         && *(edit_value + 2) == ':'\r
517         && IS_DIR_SEP (*(edit_value + 3)))\r
518      )\r
519     dontchange = 1;\r
520 #endif\r
521 \r
522   while ((c = *edit_value++) != 0)\r
523   {\r
524     if (c == '%')\r
525     {\r
526       switch (c = *edit_value++)\r
527       {\r
528         case 'd':\r
529           if (ddone)\r
530             FATAL ("call_edit: `%%d' appears twice in editor command");\r
531           sprintf (temp, "%ld", (long int)linenumber);\r
532           while (*temp != '\0')\r
533             temp++;\r
534           ddone = 1;\r
535           break;\r
536         \r
537         case 's':\r
538           if (sdone)\r
539             FATAL ("call_edit: `%%s' appears twice in editor command");\r
540           for (i = 0; i < fnlength; i++)\r
541             *temp++ = xchr[(filename[i])];\r
542           sdone = 1;\r
543           break;\r
544         \r
545         case '\0':\r
546           *temp++ = '%';\r
547           /* Back up to the null to force termination.  */\r
548           edit_value--;\r
549           break;\r
550         \r
551         default:\r
552           *temp++ = '%';\r
553           *temp++ = c;\r
554           break;\r
555       }\r
556     }\r
557     else\r
558     {\r
559 #ifdef WIN32\r
560       if (dontchange)\r
561         *temp++ = c;\r
562       else \r
563       { \r
564         if(Isspace(c) && cnt == 0)\r
565         {\r
566           cnt++;\r
567           temp = command;\r
568           *temp++ = c;\r
569           *fp = '\0';\r
570         }\r
571         else if(!Isspace(c) && cnt == 0)\r
572         {\r
573           *fp++ = c;\r
574         }\r
575         else\r
576         {\r
577           *temp++ = c;\r
578         }\r
579       }\r
580 #else\r
581       *temp++ = c;\r
582 #endif\r
583     }\r
584   }\r
585 \r
586   *temp = 0;\r
587 \r
588 #ifdef WIN32\r
589   if (dontchange == 0) {\r
590     if(editorname[0] == '.' ||\r
591        editorname[0] == '/' ||\r
592        editorname[0] == '\\') {\r
593       fprintf(stderr, "%s is not allowed to execute.\n", editorname);\r
594       uexit(1);\r
595     }\r
596     env = (char *)getenv("PATH");\r
597     if(SearchPath(env, editorname, ".exe", 256, buffer, &ffp)==0) {\r
598       if(SearchPath(env, editorname, ".bat", 256, buffer, &ffp)==0) {\r
599         fprintf(stderr, "I cannot find %s in the PATH.\n", editorname);\r
600         uexit(1);\r
601       }\r
602     }\r
603     fullcmd = (char *)xmalloc(strlen(buffer)+strlen(command)+5);\r
604     strcpy(fullcmd, "\"");\r
605     strcat(fullcmd, buffer);\r
606     strcat(fullcmd, "\"");\r
607     strcat(fullcmd, command);\r
608   } else\r
609 #endif\r
610   fullcmd = command;\r
611 \r
612   /* Execute the command.  */\r
613   if (system (fullcmd) != 0)\r
614     fprintf(stderr, "! Trouble executing `%s'.\n", command);\r
615 \r
616   /* Quit, since we found an error.  */\r
617   uexit(1);\r
618 }\r
619 \r
620 \r
621 #if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
622 \r
623 /* We don't REALLY care what `endian' the machine is after all ! */\r
624 \r
625 // #ifdef MYDEBUG\r
626 // char swapmarkerstring="ERROR: SWAPPING - NOT BigEndian AND NOT NoFmtBaseSwap";\r
627 // #endif\r
628 \r
629 /* This macro is always invoked as a statement.  It assumes a variable\r
630    `temp'.  */\r
631    \r
632 #define SWAP(x, y) temp = (x); (x) = (y); (y) = temp;\r
633 \r
634 \r
635 /* Make the NITEMS items pointed at by P, each of size SIZE, be the\r
636    opposite-endianness of whatever they are now.  */\r
637 \r
638 static int swap_items (char *p, int nitems, int size)\r
639 {\r
640   char temp;\r
641 \r
642   /* Since `size' does not change, we can write a while loop for each\r
643      case, and avoid testing `size' for each time.  */\r
644   switch (size)\r
645   {\r
646     case 8:\r
647       while (nitems--)\r
648       {\r
649         SWAP (p[0], p[7]);\r
650         SWAP (p[1], p[6]);\r
651         SWAP (p[2], p[5]);\r
652         SWAP (p[3], p[4]);\r
653         p += size;\r
654       }\r
655       break;\r
656 \r
657     case 4:\r
658       while (nitems--)\r
659       {\r
660         SWAP (p[0], p[3]);\r
661         SWAP (p[1], p[2]);\r
662         p += size;\r
663       }\r
664       break;\r
665 \r
666     case 2:\r
667       while (nitems--)\r
668       {\r
669         SWAP (p[0], p[1]);\r
670         p += size;\r
671       }\r
672       break;\r
673 \r
674     case 1:\r
675     /* Nothing to do.  */\r
676       break;\r
677 \r
678     default:\r
679       show_line("\n", 0);\r
680       sprintf(log_line, "! I can't (un)dump a %d byte item.\n", size);\r
681       show_line(log_line, 1);\r
682       uexit(EXIT_FAILURE);\r
683   }\r
684   return 0;\r
685 }\r
686 #endif /* not WORDS_BIGENDIAN and not NO_FMTBASE_SWAP */\r
687 \r
688 #ifdef COMPACTFORMAT\r
689 int do_dump (char *p, int item_size, int nitems, gzFile out_file)\r
690 #else\r
691 int do_dump (char *p, int item_size, int nitems, FILE *out_file)\r
692 #endif\r
693 {\r
694 #if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
695   swap_items (p, nitems, item_size);\r
696 #endif\r
697 \r
698 #ifdef COMPACTFORMAT\r
699   if (gzwrite(out_file, p, (item_size * nitems)) != (item_size * nitems))\r
700 #else\r
701   if ((int) fwrite(p, item_size, nitems, out_file) != nitems)\r
702 #endif\r
703   {\r
704     printf("\n! Could not write %d %d-byte item%s.\n",\r
705                nitems, item_size, (nitems > 1) ? "s" : "");\r
706     uexit(EXIT_FAILURE);\r
707   }\r
708 \r
709 /* Have to restore the old contents of memory, since some of it might get used again.  */\r
710 #if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
711   swap_items (p, nitems, item_size);\r
712 #endif\r
713 \r
714   return 0;\r
715 }\r
716 \r
717 #ifdef COMPACTFORMAT\r
718 int do_undump (char *p, int item_size, int nitems, gzFile in_file)\r
719 #else\r
720 int do_undump (char *p, int item_size, int nitems, FILE *in_file)\r
721 #endif\r
722 {\r
723 #ifdef COMPACTFORMAT\r
724   if (gzread(in_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)\r
725 #else\r
726   if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)\r
727 #endif\r
728   {\r
729     printf("\n! Could not read %d %d-byte item%s.\n",\r
730                nitems, item_size, (nitems > 1) ? "s" : "");\r
731     uexit(EXIT_FAILURE);\r
732   }\r
733 \r
734 #if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
735   swap_items (p, nitems, item_size);\r
736 #endif\r
737 \r
738   return 0;\r
739 }\r
740 \r
741 #ifdef FUNNY_CORE_DUMP\r
742 \r
743 void funny_core_dump (void)\r
744 {\r
745   int pid, w;\r
746   union wait status;\r
747 \r
748   switch (pid = vfork ())\r
749   {\r
750     case -1:\r
751       perrormod ("vfork");\r
752       exit (-1);\r
753 \r
754     case 0:\r
755        (void) signal (SIGQUIT, SIG_DFL);\r
756        (void) kill (getpid (), SIGQUIT);\r
757        (void) write (2, "how did we get here?\n", 21);\r
758        exit (1);\r
759 \r
760     default:\r
761       while ((w = wait (&status)) != pid && w != -1)\r
762         ;\r
763 \r
764       if (status.w_coredump)\r
765         exit (0);\r
766 \r
767       (void) write (2, "attempt to dump core failed\n", 28);\r
768       exit (1);\r
769   }\r
770 }\r
771 #endif /* FUNNY_CORE_DUMP */