Explorar o código

Merge branch 'maint'

* maint:
  Fix bolds being backwards due to race between DCC and STDOUT.
  Fix HQ user not getting color
  Fix HQ user having all console flags.
Bryan Drewery %!s(int64=11) %!d(string=hai) anos
pai
achega
4745938a95
Modificáronse 5 ficheiros con 26 adicións e 14 borrados
  1. 4 0
      doc/UPDATES
  2. 2 2
      src/chanprog.cc
  3. 1 0
      src/dcc.h
  4. 17 10
      src/dccutil.cc
  5. 2 2
      src/misc.cc

+ 4 - 0
doc/UPDATES

@@ -7,6 +7,10 @@ maint
   * Allow 'set trace ignore' again. Undoes a change from 2005.
   * Fix ptrace detection on Linux
   * Fix broken startup with GCC from ports on FreeBSD.
+  * Fix simulated terminal mode (-nt) defaulting to all console flags.
+  * Fix simulated terminal mode (-nt) not having color supported.
+  * Fix race between DCC and terminal output which could result in
+    bolds being backwards (#86).
 
 1.4.5
   * Remove ahbl as it now positively identifies all hosts as abusive

+ 2 - 2
src/chanprog.cc

@@ -697,9 +697,9 @@ void setup_HQ(int n) {
     dcc[n].addr = iptolong(getmyip());
     dcc[n].sock = STDOUT;
     dcc[n].timeval = now;
-    dcc[n].u.chat->con_flags = conmask | LOG_ALL;
+    dcc[n].u.chat->con_flags = conmask;
     dcc[n].u.chat->strip_flags = STRIP_ALL;
-    dcc[n].status = STAT_ECHO;
+    dcc[n].status = STAT_ECHO|STAT_COLOR;
     strlcpy(dcc[n].nick, STR("HQ"), sizeof(dcc[n].nick));
     strlcpy(dcc[n].host, STR("llama@console"), sizeof(dcc[n].host));
     dcc[n].user = get_user_by_handle(userlist, dcc[n].nick);

+ 1 - 0
src/dcc.h

@@ -71,6 +71,7 @@ struct dcc_t {
 #ifdef USE_IPV6
   char host6[121];              /* easier.. ipv6 address in regular notation (3ffe:80c0:225::) */
 #endif /* USE_IPV6 */
+  int8_t cflags;	 	/* Color status flags. */
 };
 
 struct dns_info {

+ 17 - 10
src/dccutil.cc

@@ -96,9 +96,16 @@ colorbuf(char *buf, size_t len, int idx, size_t bufsiz)
 {
 //  char *buf = *bufp;
   int cidx = coloridx(idx);
-  static int cflags;
   int schar = 0;
   char buf3[1024] = "", buf2[15] = "", c = 0;
+  static int8_t stdout_cflags = 0;
+  int8_t *cflags;
+
+  if (idx == -1) {
+    cflags = &stdout_cflags;
+  } else {
+    cflags = &dcc[idx].cflags;
+  }
 
   for (size_t i = 0; i < len; i++) {
     c = buf[i];
@@ -120,30 +127,30 @@ colorbuf(char *buf, size_t len, int idx, size_t bufsiz)
         schar--;                  /* Unset identifier int */
         switch (c) {
           case 'b':
-            if (cflags & CFLGS_BOLD) {
+            if (*cflags & CFLGS_BOLD) {
               strlcpy(buf2, BOLD_END(idx), sizeof(buf2));
-              cflags &= ~CFLGS_BOLD;
+              *cflags &= ~CFLGS_BOLD;
             } else {
-              cflags |= CFLGS_BOLD;
+              *cflags |= CFLGS_BOLD;
               strlcpy(buf2, BOLD(idx), sizeof(buf2));
             }
             break;
           case 'u':
-            if (cflags & CFLGS_UNDERLINE) {
+            if (*cflags & CFLGS_UNDERLINE) {
               strlcpy(buf2, UNDERLINE_END(idx), sizeof(buf2));
-              cflags &= ~CFLGS_UNDERLINE;
+              *cflags &= ~CFLGS_UNDERLINE;
             } else {
               strlcpy(buf2, UNDERLINE(idx), sizeof(buf2));
-              cflags |= CFLGS_UNDERLINE;
+              *cflags |= CFLGS_UNDERLINE;
             }
             break;
           case 'f':
-            if (cflags & CFLGS_FLASH) {
+            if (*cflags & CFLGS_FLASH) {
               strlcpy(buf2, FLASH_END(idx), sizeof(buf2));
-              cflags &= ~CFLGS_FLASH;
+              *cflags &= ~CFLGS_FLASH;
             } else {
               strlcpy(buf2, FLASH(idx), sizeof(buf2));
-              cflags |= CFLGS_FLASH;
+              *cflags |= CFLGS_FLASH;
             }
             break;
           default:

+ 2 - 2
src/misc.cc

@@ -1288,8 +1288,8 @@ coloridx(int idx)
     if (dcc[idx].irc || dcc[idx].bot) {
       return 0;
     } else if ((dcc[idx].status & STAT_COLOR) && (dcc[idx].type && dcc[idx].type != &DCC_RELAYING)) {
-      /* telnet probably wants ANSI, even though it might be a relay from an mIRC client; fuck`em */
-      if (dcc[idx].status & STAT_TELNET)
+      /* telnet probably wants ANSI, even though it might be a relay from an mIRC client */
+      if (dcc[idx].status & STAT_TELNET || dcc[idx].sock == STDOUT)
         return 1;
       /* non-telnet is probably a /dcc-chat, most irc clients support mIRC codes... */
       else