| sic-lineprint-9bb34de.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| sic-lineprint-9bb34de.diff (1275B) | |
| --- | |
| 1 diff --git a/config.def.h b/config.def.h | |
| 2 index 6d720e9..a1308e6 100644 | |
| 3 --- a/config.def.h | |
| 4 +++ b/config.def.h | |
| 5 @@ -12,3 +12,6 @@ | |
| 6 | |
| 7 /* Parting message used when none is specified with ":l ..." command. */ | |
| 8 #define DEFAULT_PARTING_MESSAGE "sic - 250 LOC are too much!" | |
| 9 + | |
| 10 +/* Suffix character used to print the current inserting command */ | |
| 11 +#define LINEPRINT_SUFFIX_CHAR '\\' | |
| 12 diff --git a/sic.c b/sic.c | |
| 13 index 8a0301b..6401414 100644 | |
| 14 --- a/sic.c | |
| 15 +++ b/sic.c | |
| 16 @@ -18,6 +18,7 @@ static char *password; | |
| 17 static char nick[32]; | |
| 18 static char bufin[4096]; | |
| 19 static char bufout[4096]; | |
| 20 +static char bufln[4096]; | |
| 21 static char channel[256]; | |
| 22 static time_t trespond; | |
| 23 static FILE *srv; | |
| 24 @@ -60,11 +61,29 @@ privmsg(char *channel, char *msg) { | |
| 25 | |
| 26 static void | |
| 27 parsein(char *s) { | |
| 28 + int i, off; | |
| 29 char c, *p; | |
| 30 | |
| 31 if(s[0] == '\0') | |
| 32 return; | |
| 33 skip(s, '\n'); | |
| 34 + | |
| 35 + /* input reprint */ | |
| 36 + i = strlen(s) - 1; | |
| 37 + off = (*bufln ? strlen(bufln) : 0); | |
| 38 + if(s[i] == LINEPRINT_SUFFIX_CHAR) { | |
| 39 + s[i] = '\0'; | |
| 40 + if(i) | |
| 41 + snprintf(&bufln[off], (sizeof bufln - off), "%s… | |
| 42 + printf("%s", bufln); | |
| 43 + return; | |
| 44 + } | |
| 45 + else if(*bufln) { | |
| 46 + snprintf(&bufln[off], sizeof bufln, "%s", s); | |
| 47 + strlcpy(s, bufln, 4096); | |
| 48 + *bufln = '\0'; | |
| 49 + } | |
| 50 + | |
| 51 if(s[0] != COMMAND_PREFIX_CHARACTER) { | |
| 52 privmsg(channel, s); | |
| 53 return; |