summaryrefslogtreecommitdiffabout
path: root/libkcal/versit/vcc.c
Unidiff
Diffstat (limited to 'libkcal/versit/vcc.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/versit/vcc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/versit/vcc.c b/libkcal/versit/vcc.c
index 9be752d..5413813 100644
--- a/libkcal/versit/vcc.c
+++ b/libkcal/versit/vcc.c
@@ -1717,97 +1717,98 @@ static int lexGetc() {
1717 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; 1717 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
1718 lexBuf.len--; 1718 lexBuf.len--;
1719 } 1719 }
1720 return c; 1720 return c;
1721 } 1721 }
1722 1722
1723static void lexSkipLookaheadWord() { 1723static void lexSkipLookaheadWord() {
1724 if (lexBuf.strsLen <= lexBuf.len) { 1724 if (lexBuf.strsLen <= lexBuf.len) {
1725 lexBuf.len -= lexBuf.strsLen; 1725 lexBuf.len -= lexBuf.strsLen;
1726 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; 1726 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
1727 } 1727 }
1728 } 1728 }
1729 1729
1730static void lexClearToken() 1730static void lexClearToken()
1731 { 1731 {
1732 lexBuf.strsLen = 0; 1732 lexBuf.strsLen = 0;
1733 } 1733 }
1734 1734
1735static void lexAppendc(int c) 1735static void lexAppendc(int c)
1736 { 1736 {
1737 lexBuf.strs[lexBuf.strsLen] = c; 1737 lexBuf.strs[lexBuf.strsLen] = c;
1738 /* append up to zero termination */ 1738 /* append up to zero termination */
1739 if (c == 0) return; 1739 if (c == 0) return;
1740 lexBuf.strsLen++; 1740 lexBuf.strsLen++;
1741 if (lexBuf.strsLen > lexBuf.maxToken) { 1741 if (lexBuf.strsLen > lexBuf.maxToken) {
1742 /* double the token string size */ 1742 /* double the token string size */
1743 lexBuf.maxToken <<= 1; 1743 lexBuf.maxToken <<= 1;
1744 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); 1744 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
1745 } 1745 }
1746 } 1746 }
1747 1747
1748static char* lexStr() { 1748static char* lexStr() {
1749 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); 1749 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
1750 } 1750 }
1751 1751
1752static void lexSkipWhite() { 1752static void lexSkipWhite() {
1753 int c = lexLookahead(); 1753 int c = lexLookahead();
1754 while (c == ' ' || c == '\t') { 1754 while (c == ' ' || c == '\t') {
1755 lexSkipLookahead(); 1755 lexSkipLookahead();
1756 c = lexLookahead(); 1756 c = lexLookahead();
1757 } 1757 }
1758 } 1758 }
1759 1759
1760static char* lexGetWord() { 1760static char* lexGetWord() {
1761 int c; 1761 int c;
1762 lexSkipWhite(); 1762 lexSkipWhite();
1763 lexClearToken(); 1763 lexClearToken();
1764 c = lexLookahead(); 1764 c = lexLookahead();
1765 while (c != EOF && !strchr("\t\n ;:=",c)) { 1765 // LR while (c != EOF && !strchr("\t\n ;:=",c)) {
1766 while (c != EOF && !strchr("\t\n;:=",c)) {
1766 lexAppendc(c); 1767 lexAppendc(c);
1767 lexSkipLookahead(); 1768 lexSkipLookahead();
1768 c = lexLookahead(); 1769 c = lexLookahead();
1769 } 1770 }
1770 lexAppendc(0); 1771 lexAppendc(0);
1771 return lexStr(); 1772 return lexStr();
1772 } 1773 }
1773 1774
1774static void lexPushLookaheadc(int c) { 1775static void lexPushLookaheadc(int c) {
1775 int putptr; 1776 int putptr;
1776 /* can't putback EOF, because it never leaves lookahead buffer */ 1777 /* can't putback EOF, because it never leaves lookahead buffer */
1777 if (c == EOF) return; 1778 if (c == EOF) return;
1778 putptr = (int)lexBuf.getPtr - 1; 1779 putptr = (int)lexBuf.getPtr - 1;
1779 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; 1780 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
1780 lexBuf.getPtr = putptr; 1781 lexBuf.getPtr = putptr;
1781 lexBuf.buf[putptr] = c; 1782 lexBuf.buf[putptr] = c;
1782 lexBuf.len += 1; 1783 lexBuf.len += 1;
1783 } 1784 }
1784 1785
1785static char* lexLookaheadWord() { 1786static char* lexLookaheadWord() {
1786 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 1787 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
1787 / and thing bigger than that will stop the lookahead and return 0; 1788 / and thing bigger than that will stop the lookahead and return 0;
1788 / leading white spaces are not recoverable. 1789 / leading white spaces are not recoverable.
1789 */ 1790 */
1790 int c; 1791 int c;
1791 int len = 0; 1792 int len = 0;
1792 int curgetptr = 0; 1793 int curgetptr = 0;
1793 lexSkipWhite(); 1794 lexSkipWhite();
1794 lexClearToken(); 1795 lexClearToken();
1795 curgetptr = (int)lexBuf.getPtr;/* remember! */ 1796 curgetptr = (int)lexBuf.getPtr;/* remember! */
1796 while (len < (MAX_LEX_LOOKAHEAD_0)) { 1797 while (len < (MAX_LEX_LOOKAHEAD_0)) {
1797 c = lexGetc(); 1798 c = lexGetc();
1798 len++; 1799 len++;
1799 if (c == EOF || strchr("\t\n ;:=", c)) { 1800 if (c == EOF || strchr("\t\n ;:=", c)) {
1800 lexAppendc(0); 1801 lexAppendc(0);
1801 /* restore lookahead buf. */ 1802 /* restore lookahead buf. */
1802 lexBuf.len += len; 1803 lexBuf.len += len;
1803 lexBuf.getPtr = curgetptr; 1804 lexBuf.getPtr = curgetptr;
1804 return lexStr(); 1805 return lexStr();
1805 } 1806 }
1806 else 1807 else
1807 lexAppendc(c); 1808 lexAppendc(c);
1808 } 1809 }
1809 lexBuf.len += len;/* char that has been moved to lookahead buffer */ 1810 lexBuf.len += len;/* char that has been moved to lookahead buffer */
1810 lexBuf.getPtr = curgetptr; 1811 lexBuf.getPtr = curgetptr;
1811 return 0; 1812 return 0;
1812 } 1813 }
1813 1814