Changeset 3457 in kBuild for trunk/src/kash/parser.c
- Timestamp:
- Sep 14, 2020 5:34:28 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/parser.c
r3456 r3457 133 133 union node *ret; 134 134 int t; 135 135 136 TRACE2((psh, "parsecmd(%d)\n", interact)); 136 137 #ifdef KASH_SEPARATE_PARSER_ALLOCATOR 138 pstackpush(psh); 139 #endif 137 140 psh->tokpushback = 0; 138 141 psh->doprompt = interact; … … 1785 1788 } 1786 1789 1790 static union node *copyparsetreeint(shinstance *psh, union node *src); 1791 1787 1792 /* 1788 * Helper to copyparsetree .1793 * Helper to copyparsetreeint. 1789 1794 */ 1790 1795 static struct nodelist * … … 1799 1804 *ppnext = dst; 1800 1805 ppnext = &dst->next; 1801 dst->n = copyparsetree (psh, src->n);1806 dst->n = copyparsetreeint(psh, src->n); 1802 1807 src = src->next; 1803 1808 } … … 1811 1816 * Note! This could probably be generated from nodelist. 1812 1817 */ 1813 union node *1814 copyparsetree (shinstance *psh, union node *src)1818 static union node * 1819 copyparsetreeint(shinstance *psh, union node *src) 1815 1820 { 1816 1821 /** @todo Try avoid recursion for one of the sub-nodes, esp. when there … … 1827 1832 ret = pstallocnode(psh, sizeof(src->nbinary)); 1828 1833 ret->nbinary.type = type; 1829 ret->nbinary.ch1 = copyparsetree (psh, src->nbinary.ch1);1830 ret->nbinary.ch2 = copyparsetree (psh, src->nbinary.ch2);1834 ret->nbinary.ch1 = copyparsetreeint(psh, src->nbinary.ch1); 1835 ret->nbinary.ch2 = copyparsetreeint(psh, src->nbinary.ch2); 1831 1836 break; 1832 1837 … … 1835 1840 ret->ncmd.type = NCMD; 1836 1841 ret->ncmd.backgnd = src->ncmd.backgnd; 1837 ret->ncmd.args = copyparsetree (psh, src->ncmd.args);1838 ret->ncmd.redirect = copyparsetree (psh, src->ncmd.redirect);1842 ret->ncmd.args = copyparsetreeint(psh, src->ncmd.args); 1843 ret->ncmd.redirect = copyparsetreeint(psh, src->ncmd.redirect); 1839 1844 break; 1840 1845 … … 1851 1856 ret = pstallocnode(psh, sizeof(src->nredir)); 1852 1857 ret->nredir.type = type; 1853 ret->nredir.n = copyparsetree (psh, src->nredir.n);1854 ret->nredir.redirect = copyparsetree (psh, src->nredir.redirect);1858 ret->nredir.n = copyparsetreeint(psh, src->nredir.n); 1859 ret->nredir.redirect = copyparsetreeint(psh, src->nredir.redirect); 1855 1860 break; 1856 1861 … … 1858 1863 ret = pstallocnode(psh, sizeof(src->nif)); 1859 1864 ret->nif.type = NIF; 1860 ret->nif.test = copyparsetree (psh, src->nif.test);1861 ret->nif.ifpart = copyparsetree (psh, src->nif.ifpart);1862 ret->nif.elsepart = copyparsetree (psh, src->nif.elsepart);1865 ret->nif.test = copyparsetreeint(psh, src->nif.test); 1866 ret->nif.ifpart = copyparsetreeint(psh, src->nif.ifpart); 1867 ret->nif.elsepart = copyparsetreeint(psh, src->nif.elsepart); 1863 1868 break; 1864 1869 … … 1866 1871 ret = pstallocnode(psh, sizeof(src->nfor)); 1867 1872 ret->nfor.type = NFOR; 1868 ret->nfor.args = copyparsetree (psh, src->nfor.args);1869 ret->nfor.body = copyparsetree (psh, src->nfor.body);1873 ret->nfor.args = copyparsetreeint(psh, src->nfor.args); 1874 ret->nfor.body = copyparsetreeint(psh, src->nfor.body); 1870 1875 ret->nfor.var = pstsavestr(psh, src->nfor.var); 1871 1876 break; … … 1874 1879 ret = pstallocnode(psh, sizeof(src->ncase)); 1875 1880 ret->ncase.type = NCASE; 1876 ret->ncase.expr = copyparsetree (psh, src->ncase.expr);1877 ret->ncase.cases = copyparsetree (psh, src->ncase.cases);1881 ret->ncase.expr = copyparsetreeint(psh, src->ncase.expr); 1882 ret->ncase.cases = copyparsetreeint(psh, src->ncase.cases); 1878 1883 break; 1879 1884 … … 1881 1886 ret = pstallocnode(psh, sizeof(src->nclist)); 1882 1887 ret->nclist.type = NCLIST; 1883 ret->nclist.next = copyparsetree (psh, src->nclist.next);1884 ret->nclist.pattern = copyparsetree (psh, src->nclist.pattern);1885 ret->nclist.body = copyparsetree (psh, src->nclist.body);1888 ret->nclist.next = copyparsetreeint(psh, src->nclist.next); 1889 ret->nclist.pattern = copyparsetreeint(psh, src->nclist.pattern); 1890 ret->nclist.body = copyparsetreeint(psh, src->nclist.body); 1886 1891 break; 1887 1892 … … 1890 1895 ret = pstallocnode(psh, sizeof(src->narg)); 1891 1896 ret->narg.type = type; 1892 ret->narg.next = copyparsetree (psh, src->narg.next);1897 ret->narg.next = copyparsetreeint(psh, src->narg.next); 1893 1898 ret->narg.text = pstsavestr(psh, src->narg.text); 1894 1899 ret->narg.backquote = copynodelist(psh, src->narg.backquote); … … 1903 1908 ret->nfile.type = type; 1904 1909 ret->nfile.fd = src->nfile.fd; 1905 ret->nfile.next = copyparsetree (psh, src->nfile.next);1906 ret->nfile.fname = copyparsetree (psh, src->nfile.fname);1910 ret->nfile.next = copyparsetreeint(psh, src->nfile.next); 1911 ret->nfile.fname = copyparsetreeint(psh, src->nfile.fname); 1907 1912 break; 1908 1913 … … 1912 1917 ret->ndup.type = type; 1913 1918 ret->ndup.fd = src->ndup.fd; 1914 ret->ndup.next = copyparsetree (psh, src->ndup.next);1919 ret->ndup.next = copyparsetreeint(psh, src->ndup.next); 1915 1920 ret->ndup.dupfd = src->ndup.dupfd; 1916 ret->ndup.vname = copyparsetree (psh, src->ndup.vname);1921 ret->ndup.vname = copyparsetreeint(psh, src->ndup.vname); 1917 1922 break; 1918 1923 … … 1922 1927 ret->nhere.type = type; 1923 1928 ret->nhere.fd = src->nhere.fd; 1924 ret->nhere.next = copyparsetree (psh, src->nhere.next);1925 ret->nhere.doc = copyparsetree (psh, src->nhere.doc);1929 ret->nhere.next = copyparsetreeint(psh, src->nhere.next); 1930 ret->nhere.doc = copyparsetreeint(psh, src->nhere.doc); 1926 1931 break; 1927 1932 … … 1929 1934 ret = pstallocnode(psh, sizeof(src->nnot)); 1930 1935 ret->nnot.type = NNOT; 1931 ret->nnot.com = copyparsetree (psh, src->nnot.com);1936 ret->nnot.com = copyparsetreeint(psh, src->nnot.com); 1932 1937 break; 1933 1938 … … 1942 1947 } 1943 1948 1949 union node *copyparsetree(shinstance *psh, union node *src) 1950 { 1951 #ifdef KASH_SEPARATE_PARSER_ALLOCATOR 1952 pstackpush(psh); 1953 #endif 1954 return copyparsetreeint(psh, src); 1955 } 1956
Note:
See TracChangeset
for help on using the changeset viewer.