diff options
| author | Andreas Schwab | 2012-03-11 12:49:59 +0100 |
|---|---|---|
| committer | Andreas Schwab | 2012-03-11 12:49:59 +0100 |
| commit | 2b84f674cce046d8155dd8098286800b471f0f4c (patch) | |
| tree | ce6d5c4e4d6db2c40361b81971548a16cc2414d2 /lib-src | |
| parent | 6b0c89847a6291b41f73658a4a9c5d54761b2ab9 (diff) | |
| download | emacs-2b84f674cce046d8155dd8098286800b471f0f4c.tar.gz emacs-2b84f674cce046d8155dd8098286800b471f0f4c.zip | |
* emacsclient.c (main): Handle multiple messages in a single
datagram.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 3 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 109 |
2 files changed, 59 insertions, 53 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index b349533f87f..1478b3715f1 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2012-03-11 Andreas Schwab <schwab@linux-m68k.org> | 1 | 2012-03-11 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 2 | ||
| 3 | * emacsclient.c (main): Handle multiple messages in a single | ||
| 4 | datagram. | ||
| 5 | |||
| 3 | * emacsclient.c (socket_name): Add const. | 6 | * emacsclient.c (socket_name): Add const. |
| 4 | (get_server_config): Add parameter config_file, use it instead of | 7 | (get_server_config): Add parameter config_file, use it instead of |
| 5 | global server_file. | 8 | global server_file. |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 8779309f9b3..97ae029751d 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -1768,7 +1768,7 @@ main (int argc, char **argv) | |||
| 1768 | /* Now, wait for an answer and print any messages. */ | 1768 | /* Now, wait for an answer and print any messages. */ |
| 1769 | while (exit_status == EXIT_SUCCESS) | 1769 | while (exit_status == EXIT_SUCCESS) |
| 1770 | { | 1770 | { |
| 1771 | char *p; | 1771 | char *p, *end_p; |
| 1772 | do | 1772 | do |
| 1773 | { | 1773 | { |
| 1774 | errno = 0; | 1774 | errno = 0; |
| @@ -1783,61 +1783,64 @@ main (int argc, char **argv) | |||
| 1783 | 1783 | ||
| 1784 | string[rl] = '\0'; | 1784 | string[rl] = '\0'; |
| 1785 | 1785 | ||
| 1786 | p = string + strlen (string) - 1; | 1786 | /* Loop over all NL-terminated messages. */ |
| 1787 | while (p > string && *p == '\n') | 1787 | for (end_p = p = string; end_p != NULL && *end_p != '\0'; p = end_p) |
| 1788 | *p-- = 0; | 1788 | { |
| 1789 | end_p = strchr (p, '\n'); | ||
| 1790 | if (end_p != NULL) | ||
| 1791 | *end_p++ = '\0'; | ||
| 1789 | 1792 | ||
| 1790 | if (strprefix ("-emacs-pid ", string)) | 1793 | if (strprefix ("-emacs-pid ", p)) |
| 1791 | { | 1794 | { |
| 1792 | /* -emacs-pid PID: The process id of the Emacs process. */ | 1795 | /* -emacs-pid PID: The process id of the Emacs process. */ |
| 1793 | emacs_pid = strtol (string + strlen ("-emacs-pid"), NULL, 10); | 1796 | emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10); |
| 1794 | } | 1797 | } |
| 1795 | else if (strprefix ("-window-system-unsupported ", string)) | 1798 | else if (strprefix ("-window-system-unsupported ", p)) |
| 1796 | { | 1799 | { |
| 1797 | /* -window-system-unsupported: Emacs was compiled without X | 1800 | /* -window-system-unsupported: Emacs was compiled without X |
| 1798 | support. Try again on the terminal. */ | 1801 | support. Try again on the terminal. */ |
| 1799 | nowait = 0; | 1802 | nowait = 0; |
| 1800 | tty = 1; | 1803 | tty = 1; |
| 1801 | goto retry; | 1804 | goto retry; |
| 1802 | } | 1805 | } |
| 1803 | else if (strprefix ("-print ", string)) | 1806 | else if (strprefix ("-print ", p)) |
| 1804 | { | 1807 | { |
| 1805 | /* -print STRING: Print STRING on the terminal. */ | 1808 | /* -print STRING: Print STRING on the terminal. */ |
| 1806 | str = unquote_argument (string + strlen ("-print ")); | 1809 | str = unquote_argument (p + strlen ("-print ")); |
| 1807 | if (needlf) | 1810 | if (needlf) |
| 1808 | printf ("\n"); | 1811 | printf ("\n"); |
| 1809 | printf ("%s", str); | 1812 | printf ("%s", str); |
| 1810 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1813 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
| 1811 | } | 1814 | } |
| 1812 | else if (strprefix ("-error ", string)) | 1815 | else if (strprefix ("-error ", p)) |
| 1813 | { | 1816 | { |
| 1814 | /* -error DESCRIPTION: Signal an error on the terminal. */ | 1817 | /* -error DESCRIPTION: Signal an error on the terminal. */ |
| 1815 | str = unquote_argument (string + strlen ("-error ")); | 1818 | str = unquote_argument (p + strlen ("-error ")); |
| 1816 | if (needlf) | 1819 | if (needlf) |
| 1817 | printf ("\n"); | 1820 | printf ("\n"); |
| 1818 | fprintf (stderr, "*ERROR*: %s", str); | 1821 | fprintf (stderr, "*ERROR*: %s", str); |
| 1819 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1822 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
| 1820 | exit_status = EXIT_FAILURE; | 1823 | exit_status = EXIT_FAILURE; |
| 1821 | } | 1824 | } |
| 1822 | #ifdef SIGSTOP | 1825 | #ifdef SIGSTOP |
| 1823 | else if (strprefix ("-suspend ", string)) | 1826 | else if (strprefix ("-suspend ", p)) |
| 1824 | { | 1827 | { |
| 1825 | /* -suspend: Suspend this terminal, i.e., stop the process. */ | 1828 | /* -suspend: Suspend this terminal, i.e., stop the process. */ |
| 1826 | if (needlf) | 1829 | if (needlf) |
| 1827 | printf ("\n"); | 1830 | printf ("\n"); |
| 1828 | needlf = 0; | 1831 | needlf = 0; |
| 1829 | kill (0, SIGSTOP); | 1832 | kill (0, SIGSTOP); |
| 1830 | } | 1833 | } |
| 1831 | #endif | 1834 | #endif |
| 1832 | else | 1835 | else |
| 1833 | { | 1836 | { |
| 1834 | /* Unknown command. */ | 1837 | /* Unknown command. */ |
| 1835 | if (needlf) | 1838 | if (needlf) |
| 1836 | printf ("\n"); | 1839 | printf ("\n"); |
| 1837 | printf ("*ERROR*: Unknown message: %s", string); | 1840 | needlf = 0; |
| 1838 | needlf = string[0] | 1841 | printf ("*ERROR*: Unknown message: %s\n", p); |
| 1839 | == '\0' ? needlf : string[strlen (string) - 1] != '\n'; | 1842 | } |
| 1840 | } | 1843 | } |
| 1841 | } | 1844 | } |
| 1842 | 1845 | ||
| 1843 | if (needlf) | 1846 | if (needlf) |