| 1845 | |
| 1846 | |
| 1847 | static int read_next_command(void) |
| 1848 | { |
| 1849 | static int stdin_eof = 0; |
| 1850 | |
| 1851 | if (stdin_eof) { |
| 1852 | unread_command_buf = 0; |
| 1853 | return EOF; |
| 1854 | } |
| 1855 | |
| 1856 | for (;;) { |
| 1857 | if (unread_command_buf) { |
| 1858 | unread_command_buf = 0; |
| 1859 | } else { |
| 1860 | struct recent_command *rc; |
| 1861 | |
| 1862 | stdin_eof = strbuf_getline_lf(&command_buf, stdin); |
| 1863 | if (stdin_eof) |
| 1864 | return EOF; |
| 1865 | |
| 1866 | if (!seen_data_command |
| 1867 | && !starts_with(command_buf.buf, "feature ") |
| 1868 | && !starts_with(command_buf.buf, "option ")) { |
| 1869 | parse_argv(); |
| 1870 | } |
| 1871 | |
| 1872 | rc = rc_free; |
| 1873 | if (rc) |
| 1874 | rc_free = rc->next; |
| 1875 | else { |
| 1876 | rc = cmd_hist.next; |
| 1877 | cmd_hist.next = rc->next; |
| 1878 | cmd_hist.next->prev = &cmd_hist; |
| 1879 | free(rc->buf); |
| 1880 | } |
| 1881 | |
| 1882 | rc->buf = xstrdup(command_buf.buf); |
| 1883 | rc->prev = cmd_tail; |
| 1884 | rc->next = cmd_hist.prev; |
| 1885 | rc->prev->next = rc; |
| 1886 | cmd_tail = rc; |
| 1887 | } |
| 1888 | if (command_buf.buf[0] == '#') |
| 1889 | continue; |
| 1890 | return 0; |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | static void skip_optional_lf(void) |
| 1895 | { |
no test coverage detected