home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 4 / 4010 < prev    next >
Encoding:
Text File  |  1991-09-09  |  39.9 KB  |  1,206 lines

  1. Newsgroups: alt.sources
  2. Path: wupost!zaphod.mps.ohio-state.edu!think.com!news.bbn.com!mips2!bubba!jtsillas
  3. From: jtsillas@bubba.ma30.bull.com (James Tsillas)
  4. Subject: mxgdb 1.0.3 (part 8/10)
  5. Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
  6. Distribution: alt
  7. Date: 6 Sep 91 14:39:26
  8. Message-ID: <JTSILLAS.91Sep6143926@bubba.ma30.bull.com>
  9. Sender: news@mips2.ma30.bull.com (Usenet News Manager)
  10.  
  11. ---- Cut Here and feed the following to sh ----
  12. #!/bin/sh
  13. # this is mxgdb.08 (part 8 of a multipart archive)
  14. # do not concatenate these parts, unpack them in order with /bin/sh
  15. # file mxgdb/regex.c continued
  16. #
  17. if test ! -r _shar_seq_.tmp; then
  18.     echo 'Please unpack part 1 first!'
  19.     exit 1
  20. fi
  21. (read Scheck
  22.  if test "$Scheck" != 8; then
  23.     echo Please unpack part "$Scheck" next!
  24.     exit 1
  25.  else
  26.     exit 0
  27.  fi
  28. ) < _shar_seq_.tmp || exit 1
  29. if test ! -f _shar_wnt_.tmp; then
  30.     echo 'x - still skipping mxgdb/regex.c'
  31. else
  32. echo 'x - continuing file mxgdb/regex.c'
  33. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/regex.c' &&
  34. X      if (d == string1  /* Points to first char */
  35. X          || SYNTAX (((unsigned char *)d)[-1]) != Sword) 
  36. X        break;
  37. X      goto fail;
  38. X
  39. X    case wordend:
  40. X      if (d == string1  /* Points to first char */
  41. X          || SYNTAX (((unsigned char *)d)[-1]) != 
  42. X          Sword)  /* prev char not letter */
  43. X        goto fail;
  44. X      if (d == end2  /* Points to end */
  45. X          || (d == end1 && size2 == 0) /* Points to end */
  46. X          || SYNTAX (d == end1 ? *(unsigned char *)string2 : 
  47. X             *(unsigned char *)d) != 
  48. X          Sword) /* Next char not a letter */
  49. X        break;
  50. X      goto fail;
  51. X
  52. #ifdef emacs
  53. X    case before_dot:
  54. X      if (((d - string2 <= (unsigned) size2)
  55. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  56. X          <= point)
  57. X        goto fail;
  58. X      break;
  59. X
  60. X    case at_dot:
  61. X      if (((d - string2 <= (unsigned) size2)
  62. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  63. X          == point)
  64. X        goto fail;
  65. X      break;
  66. X
  67. X    case after_dot:
  68. X      if (((d - string2 <= (unsigned) size2)
  69. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  70. X          >= point)
  71. X        goto fail;
  72. X      break;
  73. X
  74. X    case wordchar:
  75. X      mcnt = (int) Sword;
  76. X      goto matchsyntax;
  77. X
  78. X    case syntaxspec:
  79. X      mcnt = *p++;
  80. X    matchsyntax:
  81. X      PREFETCH;
  82. X      if (SYNTAX (*(unsigned char *)d++) != (enum syntaxcode) mcnt) goto fail;
  83. X      break;
  84. X      
  85. X    case notwordchar:
  86. X      mcnt = (int) Sword;
  87. X      goto matchnotsyntax;
  88. X
  89. X    case notsyntaxspec:
  90. X      mcnt = *p++;
  91. X    matchnotsyntax:
  92. X      PREFETCH;
  93. X      if (SYNTAX (*(unsigned char *)d++) == (enum syntaxcode) mcnt) goto fail;
  94. X      break;
  95. #else
  96. X    case wordchar:
  97. X      PREFETCH;
  98. X      if (SYNTAX (*(unsigned char *)d++) == 0) goto fail;
  99. X      break;
  100. X      
  101. X    case notwordchar:
  102. X      PREFETCH;
  103. X      if (SYNTAX (*(unsigned char *)d++) != 0) goto fail;
  104. X      break;
  105. #endif not emacs
  106. X
  107. X    case begbuf:
  108. X      if (d == string1)    /* Note, d cannot equal string2 */
  109. X        break;        /* unless string1 == string2.  */
  110. X      goto fail;
  111. X
  112. X    case endbuf:
  113. X      if (d == end2 || (d == end1 && size2 == 0))
  114. X        break;
  115. X      goto fail;
  116. X
  117. X    case exactn:
  118. X      /* Match the next few pattern characters exactly.
  119. X         mcnt is how many characters to match. */
  120. X      mcnt = *p++;
  121. X      if (translate)
  122. X        {
  123. X          do
  124. X        {
  125. X          PREFETCH;
  126. X          if (translate[*(unsigned char *)d++] != *p++) goto fail;
  127. X        }
  128. X          while (--mcnt);
  129. X        }
  130. X      else
  131. X        {
  132. X          do
  133. X        {
  134. X          PREFETCH;
  135. X          if (*d++ != *p++) goto fail;
  136. X        }
  137. X          while (--mcnt);
  138. X        }
  139. X      break;
  140. X    }
  141. X      continue;    /* Successfully matched one pattern command; keep matching */
  142. X
  143. X      /* Jump here if any matching operation fails. */
  144. X    fail:
  145. X      if (stackp != stackb)
  146. X    /* A restart point is known.  Restart there and pop it. */
  147. X    {
  148. X      if (!stackp[-2])
  149. X        {   /* If innermost failure point is dormant, flush it and keep looking */
  150. X          stackp -= 2;
  151. X          goto fail;
  152. X        }
  153. X      d = *--stackp;
  154. X      p = *--stackp;
  155. X      if (d >= string1 && d <= end1)
  156. X        dend = end_match_1;
  157. X    }
  158. X      else break;   /* Matching at this starting point really fails! */
  159. X    }
  160. X  return -1;         /* Failure to match */
  161. }
  162. X
  163. int
  164. bcmp_translate (s1, s2, len, translate)
  165. X     unsigned char *s1, *s2;
  166. X     register int len;
  167. X     unsigned char *translate;
  168. {
  169. X  register unsigned char *p1 = s1, *p2 = s2;
  170. X  while (len)
  171. X    {
  172. X      if (translate [*p1++] != translate [*p2++]) return 1;
  173. X      len--;
  174. X    }
  175. X  return 0;
  176. }
  177. X
  178. /* Entry points compatible with bsd4.2 regex library */
  179. X
  180. #ifndef emacs
  181. X
  182. static struct re_pattern_buffer re_comp_buf;
  183. X
  184. char *
  185. re_comp (s)
  186. X     char *s;
  187. {
  188. X  if (!s)
  189. X    {
  190. X      if (!re_comp_buf.buffer)
  191. X    return "No previous regular expression";
  192. X      return 0;
  193. X    }
  194. X
  195. X  if (!re_comp_buf.buffer)
  196. X    {
  197. X      if (!(re_comp_buf.buffer = (char *) malloc (200)))
  198. X    return "Memory exhausted";
  199. X      re_comp_buf.allocated = 200;
  200. X      if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
  201. X    return "Memory exhausted";
  202. X    }
  203. X  return re_compile_pattern (s, strlen (s), &re_comp_buf);
  204. }
  205. X
  206. int
  207. re_exec (s)
  208. X     char *s;
  209. {
  210. X  int len = strlen (s);
  211. X  return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0);
  212. }
  213. X
  214. #endif /* emacs */
  215. X
  216. #ifdef test
  217. X
  218. #include <stdio.h>
  219. X
  220. /* Indexed by a character, gives the upper case equivalent of the character */
  221. X
  222. static char upcase[0400] = 
  223. X  { 000, 001, 002, 003, 004, 005, 006, 007,
  224. X    010, 011, 012, 013, 014, 015, 016, 017,
  225. X    020, 021, 022, 023, 024, 025, 026, 027,
  226. X    030, 031, 032, 033, 034, 035, 036, 037,
  227. X    040, 041, 042, 043, 044, 045, 046, 047,
  228. X    050, 051, 052, 053, 054, 055, 056, 057,
  229. X    060, 061, 062, 063, 064, 065, 066, 067,
  230. X    070, 071, 072, 073, 074, 075, 076, 077,
  231. X    0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
  232. X    0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
  233. X    0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
  234. X    0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137,
  235. X    0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
  236. X    0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
  237. X    0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
  238. X    0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177,
  239. X    0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
  240. X    0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
  241. X    0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
  242. X    0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
  243. X    0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
  244. X    0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
  245. X    0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
  246. X    0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
  247. X    0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
  248. X    0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
  249. X    0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
  250. X    0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
  251. X    0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
  252. X    0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
  253. X    0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
  254. X    0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
  255. X  };
  256. X
  257. main ()
  258. {
  259. X  char pat[80];
  260. X  struct re_pattern_buffer buf;
  261. X  int i;
  262. X  char c;
  263. X  char fastmap[(1 << BYTEWIDTH)];
  264. X
  265. X  buf.allocated = 40;
  266. X  buf.buffer = (char *) malloc (buf.allocated);
  267. X  buf.fastmap = fastmap;
  268. X  buf.translate = upcase;
  269. X
  270. X  while (1)
  271. X    {
  272. X      gets (pat);
  273. X
  274. X      if (*pat)
  275. X    {
  276. X          re_compile_pattern (pat, strlen(pat), &buf);
  277. X
  278. X      for (i = 0; i < buf.used; i++)
  279. X        printchar (buf.buffer[i]);
  280. X
  281. X      putchar ('\n');
  282. X
  283. X      printf ("%d allocated, %d used.\n", buf.allocated, buf.used);
  284. X
  285. X      re_compile_fastmap (&buf);
  286. X      printf ("Allowed by fastmap: ");
  287. X      for (i = 0; i < (1 << BYTEWIDTH); i++)
  288. X        if (fastmap[i]) printchar (i);
  289. X      putchar ('\n');
  290. X    }
  291. X
  292. X      gets (pat);    /* Now read the string to match against */
  293. X
  294. X      i = re_match (&buf, pat, strlen (pat), 0, 0);
  295. X      printf ("Match value %d.\n", i);
  296. X    }
  297. }
  298. X
  299. #ifdef NOTDEF
  300. print_buf (bufp)
  301. X     struct re_pattern_buffer *bufp;
  302. {
  303. X  int i;
  304. X
  305. X  printf ("buf is :\n----------------\n");
  306. X  for (i = 0; i < bufp->used; i++)
  307. X    printchar (bufp->buffer[i]);
  308. X  
  309. X  printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used);
  310. X  
  311. X  printf ("Allowed by fastmap: ");
  312. X  for (i = 0; i < (1 << BYTEWIDTH); i++)
  313. X    if (bufp->fastmap[i])
  314. X      printchar (i);
  315. X  printf ("\nAllowed by translate: ");
  316. X  if (bufp->translate)
  317. X    for (i = 0; i < (1 << BYTEWIDTH); i++)
  318. X      if (bufp->translate[i])
  319. X    printchar (i);
  320. X  printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't");
  321. X  printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not");
  322. }
  323. #endif
  324. X
  325. printchar (c)
  326. X     char c;
  327. {
  328. X  if (c < 041 || c >= 0177)
  329. X    {
  330. X      putchar ('\\');
  331. X      putchar (((c >> 6) & 3) + '0');
  332. X      putchar (((c >> 3) & 7) + '0');
  333. X      putchar ((c & 7) + '0');
  334. X    }
  335. X  else
  336. X    putchar (c);
  337. }
  338. X
  339. error (string)
  340. X     char *string;
  341. {
  342. X  puts (string);
  343. X  exit (1);
  344. }
  345. X
  346. #endif test
  347. SHAR_EOF
  348. echo 'File mxgdb/regex.c is complete' &&
  349. chmod 0644 mxgdb/regex.c ||
  350. echo 'restore of mxgdb/regex.c failed'
  351. Wc_c="`wc -c < 'mxgdb/regex.c'`"
  352. test 46422 -eq "$Wc_c" ||
  353.     echo 'mxgdb/regex.c: original size 46422, current size' "$Wc_c"
  354. rm -f _shar_wnt_.tmp
  355. fi
  356. # ============= mxgdb/regex.h ==============
  357. if test -f 'mxgdb/regex.h' -a X"$1" != X"-c"; then
  358.     echo 'x - skipping mxgdb/regex.h (File already exists)'
  359.     rm -f _shar_wnt_.tmp
  360. else
  361. > _shar_wnt_.tmp
  362. echo 'x - extracting mxgdb/regex.h (Text)'
  363. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/regex.h' &&
  364. /* $Id: regex.h,v 1.1.1.1 1991/05/16 21:42:41 jtsillas Exp $ */
  365. X
  366. /* Definitions for data structures callers pass the regex library.
  367. X   Copyright (C) 1985 Free Software Foundation, Inc.
  368. X
  369. X               NO WARRANTY
  370. X
  371. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  372. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  373. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  374. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  375. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  376. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  377. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  378. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  379. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  380. CORRECTION.
  381. X
  382. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  383. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  384. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  385. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  386. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  387. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  388. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  389. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  390. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  391. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  392. X
  393. X        GENERAL PUBLIC LICENSE TO COPY
  394. X
  395. X  1. You may copy and distribute verbatim copies of this source file
  396. as you receive it, in any medium, provided that you conspicuously and
  397. appropriately publish on each copy a valid copyright notice "Copyright
  398. (C) 1985 Free Software Foundation, Inc."; and include following the
  399. copyright notice a verbatim copy of the above disclaimer of warranty
  400. and of this License.  You may charge a distribution fee for the
  401. physical act of transferring a copy.
  402. X
  403. X  2. You may modify your copy or copies of this source file or
  404. any portion of it, and copy and distribute such modifications under
  405. the terms of Paragraph 1 above, provided that you also do the following:
  406. X
  407. X    a) cause the modified files to carry prominent notices stating
  408. X    that you changed the files and the date of any change; and
  409. X
  410. X    b) cause the whole of any work that you distribute or publish,
  411. X    that in whole or in part contains or is a derivative of this
  412. X    program or any part thereof, to be licensed at no charge to all
  413. X    third parties on terms identical to those contained in this
  414. X    License Agreement (except that you may choose to grant more extensive
  415. X    warranty protection to some or all third parties, at your option).
  416. X
  417. X    c) You may charge a distribution fee for the physical act of
  418. X    transferring a copy, and you may at your option offer warranty
  419. X    protection in exchange for a fee.
  420. X
  421. Mere aggregation of another unrelated program with this program (or its
  422. derivative) on a volume of a storage or distribution medium does not bring
  423. the other program under the scope of these terms.
  424. X
  425. X  3. You may copy and distribute this program (or a portion or derivative
  426. of it, under Paragraph 2) in object code or executable form under the terms
  427. of Paragraphs 1 and 2 above provided that you also do one of the following:
  428. X
  429. X    a) accompany it with the complete corresponding machine-readable
  430. X    source code, which must be distributed under the terms of
  431. X    Paragraphs 1 and 2 above; or,
  432. X
  433. X    b) accompany it with a written offer, valid for at least three
  434. X    years, to give any third party free (except for a nominal
  435. X    shipping charge) a complete machine-readable copy of the
  436. X    corresponding source code, to be distributed under the terms of
  437. X    Paragraphs 1 and 2 above; or,
  438. X
  439. X    c) accompany it with the information you received as to where the
  440. X    corresponding source code may be obtained.  (This alternative is
  441. X    allowed only for noncommercial distribution and only if you
  442. X    received the program in object code or executable form alone.)
  443. X
  444. For an executable file, complete source code means all the source code for
  445. all modules it contains; but, as a special exception, it need not include
  446. source code for modules which are standard libraries that accompany the
  447. operating system on which the executable file runs.
  448. X
  449. X  4. You may not copy, sublicense, distribute or transfer this program
  450. except as expressly provided under this License Agreement.  Any attempt
  451. otherwise to copy, sublicense, distribute or transfer this program is void and
  452. your rights to use the program under this License agreement shall be
  453. automatically terminated.  However, parties who have received computer
  454. software programs from you with this License Agreement will not have
  455. their licenses terminated so long as such parties remain in full compliance.
  456. X
  457. X  5. If you wish to incorporate parts of this program into other free
  458. programs whose distribution conditions are different, write to the Free
  459. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  460. worked out a simple rule that can be stated here, but we will often permit
  461. this.  We will be guided by the two goals of preserving the free status of
  462. all derivatives of our free software and of promoting the sharing and reuse of
  463. software.
  464. X
  465. X
  466. In other words, you are welcome to use, share and improve this program.
  467. You are forbidden to forbid anyone else to use, share and improve
  468. what you give them.   Help stamp out software-hoarding!  */
  469. X
  470. X
  471. #ifndef RE_NREGS
  472. #define RE_NREGS 10
  473. #endif
  474. X
  475. /* This data structure is used to represent a compiled pattern. */
  476. X
  477. struct re_pattern_buffer
  478. X  {
  479. X    char *buffer;    /* Space holding the compiled pattern commands. */
  480. X    int allocated;    /* Size of space that  buffer  points to */
  481. X    int used;        /* Length of portion of buffer actually occupied */
  482. X    char *fastmap;    /* Pointer to fastmap, if any, or zero if none. */
  483. X            /* re_search uses the fastmap, if there is one,
  484. X               to skip quickly over totally implausible characters */
  485. X    char *translate;    /* Translate table to apply to all characters 
  486. X                           before comparing.
  487. X               Or zero for no translation.
  488. X               The translation is applied to a pattern when it is compiled
  489. X               and to data when it is matched. */
  490. X    char fastmap_accurate;
  491. X            /* Set to zero when a new pattern is stored,
  492. X               set to one when the fastmap is updated from it. */
  493. X    char can_be_null;   /* Set to one by compiling fastmap
  494. X               if this pattern might match the null string.
  495. X               It does not necessarily match the null string
  496. X               in that case, but if this is zero, it cannot.
  497. X               2 as value means can match null string
  498. X               but at end of range or before a character
  499. X               listed in the fastmap.  */
  500. X  };
  501. X
  502. /* Structure to store "register" contents data in.
  503. X
  504. X   Pass the address of such a structure as an argument to re_match, etc.,
  505. X   if you want this information back.
  506. X
  507. X   start[i] and end[i] record the string matched by \( ... \) grouping i,
  508. X   for i from 1 to RE_NREGS - 1.
  509. X   start[0] and end[0] record the entire string matched. */
  510. X
  511. struct re_registers
  512. X  {
  513. X    int start[RE_NREGS];
  514. X    int end[RE_NREGS];
  515. X  };
  516. X
  517. /* These are the command codes that appear in compiled regular expressions, 
  518. X  one per byte.
  519. X  Some command codes are followed by argument bytes.
  520. X  A command code can specify any interpretation whatever for its arguments.
  521. X  Zero-bytes may appear in the compiled regular expression. */
  522. X
  523. enum regexpcode
  524. X  {
  525. X    unused,
  526. X    exactn,    /* followed by one byte giving n, and then by n literal bytes */
  527. X    begline,   /* fails unless at beginning of line */
  528. X    endline,   /* fails unless at end of line */
  529. X    jump,     /* followed by two bytes giving relative address to jump to */
  530. X    on_failure_jump,     /* followed by two bytes giving relative address of place
  531. X                    to resume at in case of failure. */
  532. X    finalize_jump,     /* Throw away latest failure point and then 
  533. X                jump to address. */
  534. X    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
  535. X                This is used to jump back to the beginning
  536. X                of a repeat.  If the command that follows
  537. X                this jump is clearly incompatible with the
  538. X                one at the beginning of the repeat, such that
  539. X                we can be sure that there is no use backtracking
  540. X                out of repetitions already completed,
  541. X                then we finalize. */
  542. X    dummy_failure_jump,  /* jump, and push a dummy failure point.
  543. X                This failure point will be thrown away
  544. X                if an attempt is made to use it for a failure.
  545. X                A + construct makes this before the first repeat.  */
  546. X    anychar,     /* matches any one character */
  547. X    charset,     /* matches any one char belonging to specified set.
  548. X            First following byte is # bitmap bytes.
  549. X            Then come bytes for a bit-map saying which chars are in.
  550. X            Bits in each byte are ordered low-bit-first.
  551. X            A character is in the set if its bit is 1.
  552. X            A character too large to have a bit in the map
  553. X            is automatically not in the set */
  554. X    charset_not, /* similar but match any character that is NOT one 
  555. X                    of those specified */
  556. X    start_memory, /* starts remembering the text that is matched
  557. X            and stores it in a memory register.
  558. X            followed by one byte containing the register number.
  559. X            Register numbers must be in the range 0 through NREGS. */
  560. X    stop_memory, /* stops remembering the text that is matched
  561. X            and stores it in a memory register.
  562. X            followed by one byte containing the register number.
  563. X            Register numbers must be in the range 0 through NREGS. */
  564. X    duplicate,    /* match a duplicate of something remembered.
  565. X            Followed by one byte containing the index of the memory register. */
  566. X    before_dot,     /* Succeeds if before dot */
  567. X    at_dot,     /* Succeeds if at dot */
  568. X    after_dot,     /* Succeeds if after dot */
  569. X    begbuf,      /* Succeeds if at beginning of buffer */
  570. X    endbuf,      /* Succeeds if at end of buffer */
  571. X    wordchar,    /* Matches any word-constituent character */
  572. X    notwordchar, /* Matches any char that is not a word-constituent */
  573. X    wordbeg,     /* Succeeds if at word beginning */
  574. X    wordend,     /* Succeeds if at word end */
  575. X    wordbound,   /* Succeeds if at a word boundary */
  576. X    notwordbound, /* Succeeds if not at a word boundary */
  577. X    syntaxspec,  /* Matches any character whose syntax is specified.
  578. X            followed by a byte which contains a syntax code, Sword 
  579. X                or such like */
  580. X    notsyntaxspec /* Matches any character whose syntax differs from 
  581. X                     the specified. */
  582. X  };
  583. X
  584. extern char *re_compile_pattern ();
  585. /* Is this really advertised? */
  586. extern void re_compile_fastmap ();
  587. extern int re_search (), re_search_2 ();
  588. extern int re_match (), re_match_2 ();
  589. X
  590. /* 4.2 bsd compatibility (yuck) */
  591. extern char *re_comp ();
  592. extern int re_exec ();
  593. X
  594. #ifdef SYNTAX_TABLE
  595. extern char *re_syntax_table;
  596. #endif
  597. SHAR_EOF
  598. chmod 0644 mxgdb/regex.h ||
  599. echo 'restore of mxgdb/regex.h failed'
  600. Wc_c="`wc -c < 'mxgdb/regex.h'`"
  601. test 10897 -eq "$Wc_c" ||
  602.     echo 'mxgdb/regex.h: original size 10897, current size' "$Wc_c"
  603. rm -f _shar_wnt_.tmp
  604. fi
  605. # ============= mxgdb/dialog.c ==============
  606. if test -f 'mxgdb/dialog.c' -a X"$1" != X"-c"; then
  607.     echo 'x - skipping mxgdb/dialog.c (File already exists)'
  608.     rm -f _shar_wnt_.tmp
  609. else
  610. > _shar_wnt_.tmp
  611. echo 'x - extracting mxgdb/dialog.c (Text)'
  612. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/dialog.c' &&
  613. static char rcsid[] = "$Id: dialog.c,v 1.5 1991/08/14 17:51:46 jtsillas Exp $";
  614. X
  615. /*****************************************************************************
  616. X *
  617. X *  xdbx - X Window System interface to the dbx debugger
  618. X *
  619. X *  Copyright 1989 The University of Texas at Austin
  620. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  621. X *
  622. X *  Permission to use, copy, modify, and distribute this software and its
  623. X *  documentation for any purpose and without fee is hereby granted,
  624. X *  provided that the above copyright notice appear in all copies and that
  625. X *  both that copyright notice and this permission notice appear in
  626. X *  supporting documentation, and that the name of The University of Texas
  627. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  628. X *  used in advertising or publicity pertaining to distribution of
  629. X *  the software without specific, written prior permission.  The
  630. X *  University of Texas and MCC makes no representations about the 
  631. X *  suitability of this software for any purpose.  It is provided "as is" 
  632. X *  without express or implied warranty.
  633. X *
  634. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  635. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  636. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  637. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  638. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  639. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  640. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  641. X *
  642. X *  Author:      Po Cheung
  643. X *  Created:       March 10, 1989
  644. X * 
  645. X *****************************************************************************
  646. X * 
  647. X *  xxgdb - X Window System interface to the gdb debugger
  648. X *  
  649. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  650. X *  
  651. X *  Permission to use, copy, modify, and distribute this software and its
  652. X *  documentation for any purpose and without fee is hereby granted,
  653. X *  provided that the above copyright notice appear in all copies and that
  654. X *  both that copyright notice and this permission notice appear in
  655. X *  supporting documentation, and that the name of Thomson Consumer
  656. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  657. X *  to distribution of the software without specific, written prior
  658. X *  permission.  TCE makes no representations about the suitability of
  659. X *  this software for any purpose.  It is provided "as is" without express
  660. X *  or implied warranty.
  661. X *
  662. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  663. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  664. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  665. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  666. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  667. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  668. X *  SOFTWARE.
  669. X *
  670. X *  Adaptation to GDB:  Pierre Willard
  671. X *  XXGDB Created:       December, 1990
  672. X *
  673. X *****************************************************************************/
  674. X
  675. /*  dialog.c
  676. X *
  677. X *    Create the dialogue window where the user enter dbx commands, and
  678. X *    provide action procs to make a text widget behave like a terminal.
  679. X *
  680. X *    InsertSpace():    Prevent user from deleting past the prompt (action proc
  681. X *            for DELETE or BACKSPACE).
  682. X *    Dispatch():    Send an input command line to dbx. (action proc for CR).
  683. X *    SigInt():        Send SIGINT to dbx (action proc for Ctrl-C).
  684. X *    SigEof():        Send an EOF signal to dbx (action proc for Ctrl-D).
  685. X *    SigQuit():    Send SIGQUIT to dbx (action proc for Ctrl-\).
  686. X *    CreateDialogWindow(): Create dialog window and install action table.
  687. X *    AppendDialogText():       Append string to dialog window.
  688. X */
  689. X
  690. #include <signal.h>
  691. #include "global.h"
  692. #include <Xm/Xm.h>
  693. #include <Xm/Text.h>
  694. X
  695. Widget    dialogWindow;            /* text window as a dbx terminal */
  696. Boolean FalseSignal = FALSE;        /* set to TRUE before self-generated
  697. X                       interrupt/quit signals */
  698. static XmTextPosition  StartPos;          /* starting position of input text */
  699. X
  700. X
  701. /*  This procedure prevents the user from deleting past the prompt, or
  702. X *  any text appended by AppendDialogText() to the dialog window.
  703. X *  It checks the last position of text, if it matches StartPos, set
  704. X *  by AppendDialogText(), it inserts a space so that delete-previous-
  705. X *  character() can only delete the space character.
  706. X */
  707. /* ARGSUSED */
  708. static void InsertSpace(w, event, params, num_params)
  709. X    Widget w;
  710. X    XEvent *event;
  711. X    String *params;
  712. X    Cardinal *num_params;
  713. {
  714. X  XmTextPosition lastPos;
  715. X
  716. X  if (XmTextGetInsertionPosition(w) <= StartPos) {
  717. X    lastPos = TextGetLastPos(w);
  718. X    if (lastPos == StartPos) 
  719. X      XmTextInsert(w, lastPos, " ");
  720. X    }
  721. }
  722. X
  723. static void InsertSelection(w, event, params, num_params)
  724. X    Widget w;
  725. X    XEvent *event;
  726. X    String *params;
  727. X    Cardinal *num_params;
  728. {
  729. X  XmTextSetInsertionPosition(w, XmTextGetLastPosition(w));
  730. }
  731. X
  732. X
  733. /*  Dispatch() is invoked on every <CR>.
  734. X *  It collects text from the dialog window and sends it to dbx.
  735. X *  If the string is a command to dbx (Prompt would be TRUE),
  736. X *  it is stored in the global variable, Command.
  737. X */
  738. /* ARGSUSED */
  739. static void Dispatch(w, event, params, num_params)
  740. X    Widget w;
  741. X    XEvent *event;
  742. X    String *params;
  743. X    Cardinal *num_params; 
  744. {
  745. X  char *DialogText;
  746. X    /* 
  747. X    For GDB, '\n' means exec previous command again.
  748. X    default command is space+CR, so that we never send
  749. X    CR to gdb (the repeat is managed here)
  750. X    */
  751. X    static char gdb_command[LINESIZ] = " \n";
  752. X    char s[LINESIZ];
  753. X
  754. X  DialogText = XmTextGetString(dialogWindow);
  755. X  strcpy(s, DialogText + StartPos);
  756. X    /* (PW)18DEC90 : bug xdbx : without the following line,
  757. X    xdbx sends several times the same lines when Prompt is false */
  758. X    StartPos = TextGetLastPos(dialogWindow);
  759. X
  760. X    if (Prompt) {
  761. X    if (gdb_source_command(s,FALSE))    /* filter source command (& do not display source command) */
  762. X        {
  763. X        strcpy(gdb_command," \n");    /* do not execute anything if next command is '\n' */
  764. X        return;
  765. X        }
  766. X    /* When we send \n to gdb, it executes the last command,
  767. X    so better tell xxgdb what gdb is doing */
  768. X    if (strcmp(s, "\n"))
  769. X        strcpy(gdb_command,s);
  770. X    else
  771. X        strcpy(s,gdb_command);
  772. X    send_command(s);
  773. X    }
  774. X    else {
  775. X        write_dbx(s);
  776. X    }
  777. X  XtFree(DialogText);
  778. }
  779. X
  780. X
  781. /*  Sends an interrupt signal, SIGINT, to dbx.
  782. X *  Simulates the action of the INTR character (ctrl-C).
  783. X */
  784. /* ARGSUSED */
  785. static void SigInt(w, event, params, num_params)
  786. X    Widget w;
  787. X    XEvent *event;
  788. X    String *params;
  789. X    Cardinal *num_params;
  790. {
  791. X  FalseSignal = TRUE;
  792. #if defined(SYSV) && !defined(SUNOS4)
  793. X  kill(dbxpid, SIGINT);
  794. #else
  795. X  write_dbx("\03");
  796. #endif
  797. }
  798. X
  799. X
  800. /*  Sends an EOF signal to dbx. (ctrl-D) */
  801. /* ARGSUSED */
  802. static void SigEof(w, event, params, num_params)
  803. X    Widget w;
  804. X    XEvent *event;
  805. X    String *params;
  806. X    Cardinal *num_params;
  807. {
  808. X    write_dbx("\04");
  809. }
  810. X
  811. X
  812. /*  Sends a QUIT signal, SIGQUIT, to dbx. 
  813. X *  Simulates the action of the QUIT character (ctrl-\) 
  814. X */
  815. /* ARGSUSED */
  816. static void SigQuit(w, event, params, num_params)
  817. X    Widget w;
  818. X    XEvent *event;
  819. X    String *params;
  820. X    Cardinal *num_params;
  821. {
  822. X  FalseSignal = TRUE;
  823. #if defined(SYSV) && !defined(SUNOS4)
  824. X  kill(dbxpid, SIGQUIT);
  825. #else
  826. X  write_dbx("\034");
  827. #endif
  828. }
  829. X
  830. X
  831. /* 
  832. X *  Dialog window has its own set of translations for editing.
  833. X *  Special action procedures for keys Delete/Backspace, Carriage Return,
  834. X *  Ctrl-U, Ctrl-C, Ctrl-D, Ctrl-\, and word selection.
  835. X */
  836. void CreateDialogWindow(parent)
  837. Widget parent;
  838. {
  839. X    Arg     args[MAXARGS];
  840. X    Cardinal     n;
  841. X
  842. X    static XtActionsRec dialog_actions[] = {
  843. X    {"SigInt",     (XtActionProc) SigInt},
  844. X    {"SigEof",     (XtActionProc) SigEof},
  845. X    {"SigQuit",     (XtActionProc) SigQuit},
  846. X    {"InsertSpace", (XtActionProc) InsertSpace},
  847. X    {"InsertSelection", (XtActionProc) InsertSelection},
  848. X    {"Dispatch",     (XtActionProc) Dispatch},
  849. X        {NULL, NULL}
  850. X    };
  851. X
  852. X    static Arg dialogargs[] = {
  853. X      { XmNeditMode, XmMULTI_LINE_EDIT },
  854. X      { XmNautoShowCursorPosition, True },
  855. X      { XmNscrollingPolicy, XmAUTOMATIC },
  856. X      { XmNscrollLeftSide, True },
  857. X      { XmNwordWrap, True },
  858. X      { XmNhighlightOnEnter, True },
  859. X    };
  860. X
  861. X    dialogWindow = XmCreateScrolledText(parent, "dialogWindow",
  862. X                                          dialogargs, 6);
  863. X    XtManageChild(dialogWindow);
  864. X
  865. X    XtAppAddActions(app_context, dialog_actions, XtNumber(dialog_actions));
  866. }
  867. X
  868. static void TextSetLastPos(w, lastPos)
  869. Widget w;
  870. XXmTextPosition lastPos;
  871. {
  872. X    Arg         args[MAXARGS];
  873. X    XtSetArg(args[0], XmNcursorPosition, lastPos);
  874. X    XtSetValues(w, args, 1);
  875. }
  876. void AppendDialogText(s)
  877. X    char   *s;
  878. {
  879. X    XmTextPosition     i, lastPos;
  880. X    XmTextBlockRec        textblock, nullblock;
  881. X    Arg         args[MAXARGS];
  882. X    Cardinal         n;
  883. X
  884. X    if (!s || !strcmp(s, "")) return;
  885. X
  886. X    textblock.length   = strlen(s);
  887. X    textblock.ptr      = s;
  888. X
  889. X    lastPos = XmTextGetLastPosition(dialogWindow);
  890. X
  891. X    XmTextInsert(dialogWindow, lastPos,
  892. X          textblock.ptr);
  893. X    StartPos = TextGetLastPos(dialogWindow);
  894. X    XmTextSetInsertionPosition(dialogWindow, 
  895. X                   XmTextGetLastPosition(dialogWindow));
  896. }
  897. SHAR_EOF
  898. chmod 0644 mxgdb/dialog.c ||
  899. echo 'restore of mxgdb/dialog.c failed'
  900. Wc_c="`wc -c < 'mxgdb/dialog.c'`"
  901. test 9190 -eq "$Wc_c" ||
  902.     echo 'mxgdb/dialog.c: original size 9190, current size' "$Wc_c"
  903. rm -f _shar_wnt_.tmp
  904. fi
  905. # ============= mxgdb/utils.c ==============
  906. if test -f 'mxgdb/utils.c' -a X"$1" != X"-c"; then
  907.     echo 'x - skipping mxgdb/utils.c (File already exists)'
  908.     rm -f _shar_wnt_.tmp
  909. else
  910. > _shar_wnt_.tmp
  911. echo 'x - extracting mxgdb/utils.c (Text)'
  912. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/utils.c' &&
  913. static char rcsid[] = "$Id: utils.c,v 1.1.1.1 1991/05/16 21:42:53 jtsillas Exp $";
  914. X
  915. /*****************************************************************************
  916. X *
  917. X *  xdbx - X Window System interface to the dbx debugger
  918. X *
  919. X *  Copyright 1989 The University of Texas at Austin
  920. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  921. X *
  922. X *  Permission to use, copy, modify, and distribute this software and its
  923. X *  documentation for any purpose and without fee is hereby granted,
  924. X *  provided that the above copyright notice appear in all copies and that
  925. X *  both that copyright notice and this permission notice appear in
  926. X *  supporting documentation, and that the name of The University of Texas
  927. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  928. X *  used in advertising or publicity pertaining to distribution of
  929. X *  the software without specific, written prior permission.  The
  930. X *  University of Texas and MCC makes no representations about the 
  931. X *  suitability of this software for any purpose.  It is provided "as is" 
  932. X *  without express or implied warranty.
  933. X *
  934. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  935. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  936. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  937. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  938. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  939. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  940. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  941. X *
  942. X *  Author:      Po Cheung
  943. X *  Created:       March 10, 1989
  944. X *
  945. X *****************************************************************************/
  946. X
  947. /*  utils.c
  948. X *
  949. X *    Contain common routines used by other functions.
  950. X *
  951. X *    TextGetLastPos():        Get the last insertion position of text.
  952. X *    TextPositionToLine():     Return text position give a line number.
  953. X *    LineToStopNo():        Return the stop number given a line number.
  954. X *    DisableWindowResize():    Fix the size of a window inside vpane.
  955. X *    bell():            Ring the bell.
  956. X *    concat():            Concatenate two strings together
  957. X */
  958. X
  959. #include "global.h"
  960. #include <Xm/Xm.h>
  961. #include <Xm/Text.h>
  962. X
  963. X
  964. XXmTextPosition TextGetLastPos(w)
  965. X    Widget w;
  966. {
  967. X    Arg    args[MAXARGS];
  968. X    XmTextPosition cursorPos;
  969. X
  970. X    XtSetArg(args[0], XmNcursorPosition, &cursorPos);
  971. X    XtGetValues(w, args, 1);
  972. X    return(cursorPos);    
  973. }
  974. X
  975. /*
  976. X * Get the line number where the caret is.
  977. X */
  978. int TextPositionToLine(pos)
  979. XXmTextPosition pos;
  980. {
  981. X    int line;
  982. X
  983. X    if (displayedFile) {
  984. X    if (pos >= displayedFile->linepos[displayedFile->topline]) {
  985. X        for (line = displayedFile->topline;
  986. X         pos > displayedFile->linepos[line]; line++);
  987. X        return (pos == displayedFile->linepos[line] ? line : line-1);
  988. X    }
  989. X    else {
  990. X        for (line = 1; pos > displayedFile->linepos[line]; line++);
  991. X        return (pos == displayedFile->linepos[line] ? line : line-1);
  992. X    }
  993. X    }
  994. X    else
  995. X        return 0;
  996. }
  997. X
  998. /*
  999. X *  Return the stop number associated with a given line number.
  1000. X *  Return 0 if stop number not found.
  1001. X */
  1002. int LineToStop_no(line)
  1003. int line;
  1004. {
  1005. X    int i;
  1006. X
  1007. X    for (i=1; i <= nstops; i++)
  1008. X        if (stops[i].line == line && stops[i].file && displayedFile &&
  1009. X            !strcmp(stops[i].file, displayedFile->pathname)) {
  1010. X            return i;
  1011. X        }
  1012. X    return 0;
  1013. }
  1014. X
  1015. void bell(volume)
  1016. int volume;
  1017. {
  1018. X    XBell(XtDisplay(toplevel), volume);
  1019. }
  1020. X
  1021. /* append string s2 to end of string s1 and return the result */
  1022. X
  1023. char *concat(s1, s2)
  1024. char *s1, *s2;
  1025. {
  1026. X    if (s2) {
  1027. X        if (s1 == NULL) {
  1028. X            s1 = XtMalloc((strlen(s2)+1)*sizeof(char));
  1029. X            strcpy(s1, s2);
  1030. X        }
  1031. X        else {
  1032. X            s1 = XtRealloc(s1, strlen(s1)+strlen(s2)+2);
  1033. X            strcat(s1, s2);
  1034. X        }
  1035. X    }
  1036. #if 0    /*(PW)4DEC90 : bug ! if s2 is null, there is no reason to set s1 to 0 */
  1037. X    else
  1038. X        s1 = NULL;
  1039. #endif
  1040. X    return (s1);
  1041. }
  1042. SHAR_EOF
  1043. chmod 0644 mxgdb/utils.c ||
  1044. echo 'restore of mxgdb/utils.c failed'
  1045. Wc_c="`wc -c < 'mxgdb/utils.c'`"
  1046. test 3928 -eq "$Wc_c" ||
  1047.     echo 'mxgdb/utils.c: original size 3928, current size' "$Wc_c"
  1048. rm -f _shar_wnt_.tmp
  1049. fi
  1050. # ============= mxgdb/callgdb.o ==============
  1051. if test -f 'mxgdb/callgdb.o' -a X"$1" != X"-c"; then
  1052.     echo 'x - skipping mxgdb/callgdb.o (File already exists)'
  1053.     rm -f _shar_wnt_.tmp
  1054. else
  1055. > _shar_wnt_.tmp
  1056. echo 'x - extracting mxgdb/callgdb.o (Text)'
  1057. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/callgdb.o' &&
  1058. X`XXXXXXXXXXXXXXXXXXXXdX╪XXXXtExtents16UnrealizeWidgetpleRadioBoxXXX)8FV_izXìXùXóX¡X╣X╚X╪XµX≥XXXXXX
  1059. SHAR_EOF
  1060. chmod 0644 mxgdb/callgdb.o ||
  1061. echo 'restore of mxgdb/callgdb.o failed'
  1062. Wc_c="`wc -c < 'mxgdb/callgdb.o'`"
  1063. test 32812 -eq "$Wc_c" ||
  1064.     echo 'mxgdb/callgdb.o: original size 32812, current size' "$Wc_c"
  1065. rm -f _shar_wnt_.tmp
  1066. fi
  1067. # ============= mxgdb/gdb.c ==============
  1068. if test -f 'mxgdb/gdb.c' -a X"$1" != X"-c"; then
  1069.     echo 'x - skipping mxgdb/gdb.c (File already exists)'
  1070.     rm -f _shar_wnt_.tmp
  1071. else
  1072. > _shar_wnt_.tmp
  1073. echo 'x - extracting mxgdb/gdb.c (Text)'
  1074. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb.c' &&
  1075. static char rcsid[] = "$Id: gdb.c,v 1.1 1991/08/23 16:34:21 jtsillas Exp $";
  1076. X
  1077. /*****************************************************************************
  1078. X *
  1079. X *  xdbx - X Window System interface to the dbx debugger
  1080. X *
  1081. X *  Copyright 1989 The University of Texas at Austin
  1082. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  1083. X *
  1084. X *  Permission to use, copy, modify, and distribute this software and its
  1085. X *  documentation for any purpose and without fee is hereby granted,
  1086. X *  provided that the above copyright notice appear in all copies and that
  1087. X *  both that copyright notice and this permission notice appear in
  1088. X *  supporting documentation, and that the name of The University of Texas
  1089. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  1090. X *  used in advertising or publicity pertaining to distribution of
  1091. X *  the software without specific, written prior permission.  The
  1092. X *  University of Texas and MCC makes no representations about the 
  1093. X *  suitability of this software for any purpose.  It is provided "as is" 
  1094. X *  without express or implied warranty.
  1095. X *
  1096. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1097. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1098. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  1099. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1100. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1101. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1102. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1103. X *
  1104. X *  Author:      Po Cheung
  1105. X *  Created:       March 10, 1989
  1106. X * 
  1107. X *****************************************************************************
  1108. X * 
  1109. X *  xxgdb - X Window System interface to the gdb debugger
  1110. X *  
  1111. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  1112. X *  
  1113. X *  Permission to use, copy, modify, and distribute this software and its
  1114. X *  documentation for any purpose and without fee is hereby granted,
  1115. X *  provided that the above copyright notice appear in all copies and that
  1116. X *  both that copyright notice and this permission notice appear in
  1117. X *  supporting documentation, and that the name of Thomson Consumer
  1118. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  1119. X *  to distribution of the software without specific, written prior
  1120. X *  permission.  TCE makes no representations about the suitability of
  1121. X *  this software for any purpose.  It is provided "as is" without express
  1122. X *  or implied warranty.
  1123. X *
  1124. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1125. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  1126. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  1127. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1128. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1129. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1130. X *  SOFTWARE.
  1131. X *
  1132. X *  Adaptation to GDB:  Pierre Willard
  1133. X *  XXGDB Created:       December, 1990
  1134. X *
  1135. X *****************************************************************************/
  1136. X
  1137. /*
  1138. X *  dbx.c
  1139. X *
  1140. X *    Handle dbx command initialization file (.dbxinit) and communication 
  1141. X *    between dbx and xdbx.
  1142. X *
  1143. X *    dbx_init():    Handle .dbxinit
  1144. X *    debug_init():    
  1145. X *    read_dbx():    Read dbx output, parse and filter it before displaying
  1146. X *            onto the dialog window.
  1147. X *    write_dbx():    Send a command to dbx.
  1148. X *    query_dbx():    Send a command to dbx and process it.
  1149. X */
  1150. X
  1151. #include "global.h"
  1152. X
  1153. Boolean    Prompt;            /* True when dbx prompt arrives */
  1154. char     *concat();
  1155. char    *dbxprompt; 
  1156. char    *xdbxprompt;
  1157. X
  1158. /*  Given a dbx command initialization file, this routine executes each dbx 
  1159. X *  command in the file.  It sends the command to dbx, and calls read_dbx() 
  1160. X *  directly to process output returned from dbx.
  1161. X */
  1162. static void dbx_init(xdbxinit)
  1163. char *xdbxinit;
  1164. {
  1165. X    FILE *fp;
  1166. X    char s[LINESIZ];
  1167. X
  1168. X    if (!strcmp(xdbxinit, ""))
  1169. X    return;
  1170. X    if (fp = fopen(xdbxinit, "r")) {
  1171. X    while (fgets(s, LINESIZ, fp)) {
  1172. X        /* if GDB:
  1173. X            Check for comment line,
  1174. X            DO NOT SEND '\n',
  1175. X            Take care of source command.
  1176. X        */
  1177. X        if ((*s != '#') && strcmp(s,"\n"))
  1178. X          {
  1179. X            if ((!gdb_source_command(s,TRUE)) && 
  1180. X            (!gdb_define_command(s,fp))) 
  1181. X              {
  1182. X            write_dbx(s);
  1183. X            insert_command(s);
  1184. X            AppendDialogText(s);
  1185. X              }
  1186. X        Prompt = False;
  1187. X        while (!Prompt)
  1188. X        read_dbx();
  1189. X        }
  1190. X    }
  1191. X    close((int)fp);
  1192. X    }
  1193. }
  1194. X
  1195. /*
  1196. X *  This routine is called after getting the first dbx prompt.  
  1197. SHAR_EOF
  1198. true || echo 'restore of mxgdb/gdb.c failed'
  1199. fi
  1200. echo 'End of  part 8'
  1201. echo 'File mxgdb/gdb.c is continued in part 9'
  1202. echo 9 > _shar_seq_.tmp
  1203. exit 0
  1204.