Introduction
Introduction Statistics Contact Development Disclaimer Help
fix empty line option and behavior - lchat - A line oriented chat front end for…
git clone git://git.suckless.org/lchat
Log
Files
Refs
README
---
commit a6e5a69166f668898bfc0731b634322bb277fe5a
parent e00ac3d799536cee5a7facf4fd5b39109377193d
Author: Jan Klemkow <[email protected]>
Date: Sat, 7 Nov 2015 05:16:21 +0100
fix empty line option and behavior
Diffstat:
M lchat.1 | 4 ++--
M lchat.c | 14 +++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/lchat.1 b/lchat.1
@@ -6,7 +6,7 @@
.Nd line chat
.Sh SYNOPSIS
.Nm
-.Op Fl nh
+.Op Fl eh
.Op Fl H Ar lines
.Op Fl p Ar prompt
.Op Fl t Ar title
@@ -24,7 +24,7 @@ in the background to get output lines from
The options are as follows:
.Bl -tag -width Ds
-.It Fl n
+.It Fl e
Allow to enter empty lines.
.It Fl h
Shows usage text.
diff --git a/lchat.c b/lchat.c
@@ -57,7 +57,7 @@ line_output(struct slackline *sl, char *file)
static void
usage(void)
{
- fprintf(stderr, "lchar [-nh] [-H lines] [-p prompt] [-t title] [-i in]"
+ fprintf(stderr, "lchar [-eh] [-H lines] [-p prompt] [-t title] [-i in]"
" [-o out] [directory]\n");
exit(EXIT_FAILURE);
}
@@ -72,7 +72,7 @@ main(int argc, char *argv[])
int fd = STDIN_FILENO;
int c;
int ch;
- bool empty_line = true;
+ bool empty_line = false;
size_t history_len = 5;
char *prompt = ">";
size_t prompt_len = strlen(prompt);
@@ -81,7 +81,7 @@ main(int argc, char *argv[])
char *out_file = NULL;
FILE *tail_fh;
- while ((ch = getopt(argc, argv, "H:i:no:p:t:h")) != -1) {
+ while ((ch = getopt(argc, argv, "H:i:eo:p:t:h")) != -1) {
switch (ch) {
case 'H':
errno = 0;
@@ -93,8 +93,8 @@ main(int argc, char *argv[])
if ((in_file = strdup(optarg)) == NULL)
err(EXIT_FAILURE, "strdup");
break;
- case 'n':
- empty_line = false;
+ case 'e':
+ empty_line = true;
break;
case 'o':
if ((out_file = strdup(optarg)) == NULL)
@@ -190,7 +190,7 @@ main(int argc, char *argv[])
c = getchar();
if (c == 13) { /* return */
if (sl->len == 0 && empty_line == false)
- continue;
+ goto out;
line_output(sl, in_file);
sl_reset(sl);
}
@@ -214,7 +214,7 @@ main(int argc, char *argv[])
err(EXIT_FAILURE, "write");
putchar('\a'); /* ring the bell on external inp…
}
-
+ out:
/* show current input line */
fputs(prompt, stdout);
fputs(sl->buf, stdout);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.