source:
patches/expect-5.43.0-spawn-2.patch@
5270a7f8
Last change on this file since 5270a7f8 was 69cde8d, checked in by , 19 years ago | |
---|---|
|
|
File size: 6.9 KB |
-
exp_chan.c
Submitted By: LFS Book <lfs-book@linuxfromscratch.org> Date: 2005-02-27 (originally submitted 2003-10-05) Initial Package Version: 5.38 Origin: Redhat RPM (Patch by HJ Lu); rediffed by Randy McMurchy Description: NA $LastChangedBy: randy $ $Date: 2005-03-24 21:05:48 -0700 (Thu, 24 Mar 2005) $ diff -Naur expect-5.43-orig/exp_chan.c expect-5.43/exp_chan.c
old new 622 622 esPtr->buffer = Tcl_NewStringObj("",0); 623 623 Tcl_IncrRefCount(esPtr->buffer); 624 624 esPtr->umsize = exp_default_match_max; 625 esPtr->umsize_changed = exp_default_match_max_changed; 625 626 /* this will reallocate object with an appropriate sized buffer */ 626 627 expAdjust(esPtr); 627 628 -
exp_command.h
diff -Naur expect-5.43-orig/exp_command.h expect-5.43/exp_command.h
old new 30 30 EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *)); 31 31 32 32 EXTERN int exp_default_match_max; 33 EXTERN int exp_default_match_max_changed; 33 34 EXTERN int exp_default_parity; 34 35 EXTERN int exp_default_rm_nulls; 35 36 EXTERN int exp_default_close_on_eof; … … 103 104 int msize; /* # of bytes that buffer can hold (max) */ 104 105 int umsize; /* # of bytes (min) that is guaranteed to match */ 105 106 /* this comes from match_max command */ 107 int umsize_changed; /* is umsize changed by user? */ 106 108 int printed; /* # of bytes written to stdout (if logging on) */ 107 109 /* but not actually returned via a match yet */ 108 110 int echoed; /* additional # of bytes (beyond "printed" above) */ -
expect.c
diff -Naur expect-5.43-orig/expect.c expect-5.43/expect.c
old new 41 41 #include "tcldbg.h" 42 42 #endif 43 43 44 /* The initial length is 2000. We increment it by 2000. The maximum 45 is 8MB (0x800000). */ 46 #define EXP_MATCH_MAX 2000 47 #define EXP_MATCH_INC 2000 48 #define EXP_MATCH_STEP_LIMIT 0x700000 49 #define EXP_MATCH_LIMIT 0x800000 50 #define EXP_MATCH_LIMIT_QUOTE "0x800000" 51 44 52 /* initial length of strings that we can guarantee patterns can match */ 45 int exp_default_match_max = 2000; 53 int exp_default_match_max = EXP_MATCH_MAX; 54 int exp_default_match_max_changed = 0; 46 55 #define INIT_EXPECT_TIMEOUT_LIT "10" /* seconds */ 47 56 #define INIT_EXPECT_TIMEOUT 10 /* seconds */ 48 57 int exp_default_parity = TRUE; … … 1619 1628 return newsize; 1620 1629 } 1621 1630 1631 /* returns # of bytes until we see a newline at the end or EOF. */ 1632 /*ARGSUSED*/ 1633 static int 1634 expReadNewLine(interp,esPtr,save_flags) /* INTL */ 1635 Tcl_Interp *interp; 1636 ExpState *esPtr; 1637 int save_flags; 1638 { 1639 int size; 1640 int exp_size; 1641 int full_size; 1642 int count; 1643 char *str; 1644 1645 count = 0; 1646 for (;;) { 1647 exp_size = expSizeGet(esPtr); 1648 1649 /* When we reach the limit, we will only read one char at a 1650 time. */ 1651 if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT) 1652 size = TCL_UTF_MAX; 1653 else 1654 size = exp_size; 1655 1656 if (exp_size + TCL_UTF_MAX >= esPtr->msize) { 1657 if (esPtr->umsize >= EXP_MATCH_LIMIT) { 1658 expDiagLogU("WARNING: interact buffer is full. probably your program\r\n"); 1659 expDiagLogU("is not interactive or has a very long output line. The\r\n"); 1660 expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n"); 1661 expDiagLogU("Dumping first half of buffer in order to continue\r\n"); 1662 expDiagLogU("Recommend you enlarge the buffer.\r\n"); 1663 exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect"); 1664 return count; 1665 } 1666 else { 1667 esPtr->umsize += EXP_MATCH_INC; 1668 expAdjust(esPtr); 1669 } 1670 } 1671 1672 full_size = esPtr->msize - (size / TCL_UTF_MAX); 1673 size = Tcl_ReadChars(esPtr->channel, 1674 esPtr->buffer, 1675 full_size, 1676 1 /* append */); 1677 if (size > 0) { 1678 count += size; 1679 /* We try again if there are more to read and we haven't 1680 seen a newline at the end. */ 1681 if (size == full_size) { 1682 str = Tcl_GetStringFromObj(esPtr->buffer, &size); 1683 if (str[size - 1] != '\n') 1684 continue; 1685 } 1686 } 1687 else { 1688 /* It is even trickier. We got an error from read. We have 1689 to recover from it. Let's make sure the size of 1690 buffer is correct. It can be corrupted. */ 1691 str = Tcl_GetString(esPtr->buffer); 1692 Tcl_SetObjLength(esPtr->buffer, strlen(str)); 1693 } 1694 1695 break; 1696 } 1697 1698 return count; 1699 } 1700 1622 1701 /* returns # of bytes read or (non-positive) error of form EXP_XXX */ 1623 1702 /* returns 0 for end of file */ 1624 1703 /* If timeout is non-zero, set an alarm before doing the read, else assume */ … … 1633 1712 { 1634 1713 int cc = EXP_TIMEOUT; 1635 1714 int size = expSizeGet(esPtr); 1715 int full_size; 1716 int count; 1636 1717 1637 1718 if (size + TCL_UTF_MAX >= esPtr->msize) 1638 1719 exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect"); … … 1649 1730 } 1650 1731 #endif 1651 1732 1652 1733 /* FIXME: If we ask less than what is available in the tcl buffer 1734 when tcl has seen EOF, we will throw away the remaining data 1735 since the next read will get EOF. Since expect is line-oriented, 1736 we exand our buffer to get EOF or the next newline at the end of 1737 the input buffer. I don't know if it is the right fix. H.J. */ 1738 count = 0; 1739 full_size = esPtr->msize - (size / TCL_UTF_MAX); 1653 1740 cc = Tcl_ReadChars(esPtr->channel, 1654 esPtr->buffer, 1655 esPtr->msize - (size / TCL_UTF_MAX), 1656 1 /* append */); 1741 esPtr->buffer, 1742 full_size, 1743 1 /* append */); 1744 if (cc > 0) { 1745 count += cc; 1746 /* It gets very tricky. There are more to read. We will expand 1747 our buffer and get EOF or a newline at the end unless the 1748 buffer length has been changed. */ 1749 if (cc == full_size) { 1750 char *str; 1751 str = Tcl_GetStringFromObj(esPtr->buffer, &size); 1752 if (str[size - 1] != '\n') { 1753 if (esPtr->umsize_changed) { 1754 char buf[20]; /* big enough for 64bit int in hex. */ 1755 snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize); 1756 expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n"); 1757 expDiagLogU("all output. probably your program is not interactive or\r\n"); 1758 expDiagLogU("has a very long output line. The current limit is "); 1759 expDiagLogU(buf); 1760 expDiagLogU(".\r\n"); 1761 } 1762 else { 1763 cc = expReadNewLine(interp,esPtr,save_flags); 1764 if (cc > 0) 1765 count += cc; 1766 } 1767 } 1768 } 1769 } 1657 1770 i_read_errno = errno; 1658 1771 1659 1772 #ifdef SIMPLE_EVENT … … 1674 1787 } 1675 1788 } 1676 1789 #endif 1677 return c c;1790 return count > 0 ? count : cc; 1678 1791 } 1679 1792 1680 1793 /* … … 2751 2864 return(TCL_ERROR); 2752 2865 } 2753 2866 2754 if (Default) exp_default_match_max = size; 2755 else esPtr->umsize = size; 2867 if (Default) { 2868 exp_default_match_max = size; 2869 exp_default_match_max_changed = 1; 2870 } 2871 else { 2872 esPtr->umsize = size; 2873 esPtr->umsize_changed = 1; 2874 } 2756 2875 2757 2876 return(TCL_OK); 2758 2877 }
Note:
See TracBrowser
for help on using the repository browser.