Explorar o código

* Fixed $b still showing up with .color off

svn: 1514
Bryan Drewery %!s(int64=21) %!d(string=hai) anos
pai
achega
f5a01431cb
Modificáronse 1 ficheiros con 57 adicións e 49 borrados
  1. 57 49
      src/dccutil.c

+ 57 - 49
src/dccutil.c

@@ -71,56 +71,10 @@ char *add_cr(char *buf)
   return WBUF;
   return WBUF;
 }
 }
 
 
-void dprintf(int idx, const char *format, ...)
+static void colorbuf(char *buf, size_t len, int idx)
 {
 {
-  static char buf[1024] = "";
-  size_t len;
-  va_list va;
-
-  va_start(va, format);
-  egg_vsnprintf(buf, 1023, format, va);
-  va_end(va);
-
-  /* We can not use the return value vsnprintf() to determine where
-   * to null terminate. The C99 standard specifies that vsnprintf()
-   * shall return the number of bytes that would be written if the
-   * buffer had been large enough, rather then -1.
-   */
-  /* We actually can, since if it's < 0 or >= sizeof(buf), we know it wrote
-   * sizeof(buf) bytes. But we're not doing that anyway.
-  */
-  buf[sizeof(buf) - 1] = 0;
-  len = strlen(buf);
-
-/* this is for color on dcc :P */
-
-  if (idx < 0) {
-    tputs(-idx, buf, len);
-  } else if (idx > 0x7FF0) {
-    switch (idx) {
-    case DP_LOG:
-      putlog(LOG_MISC, "*", "%s", buf);
-      break;
-    case DP_STDOUT:
-      tputs(STDOUT, buf, len);
-      break;
-    case DP_STDERR:
-      tputs(STDERR, buf, len);
-      break;
-#ifdef LEAF
-    case DP_SERVER:
-    case DP_HELP:
-    case DP_MODE:
-    case DP_MODE_NEXT:
-    case DP_SERVER_NEXT:
-    case DP_HELP_NEXT:
-      queue_server(idx, buf, len);
-      break;
-#endif /* LEAF */
-    }
-    return;
-  } else { /* normal chat text */
-    if (coloridx(idx)) {
+//  char *buf = *bufp;
+  int cidx = coloridx(idx);
       static int cflags;
       static int cflags;
       int schar = 0;
       int schar = 0;
       char buf3[1024] = "", buf2[1024] = "", c = 0;
       char buf3[1024] = "", buf2[1024] = "", c = 0;
@@ -132,6 +86,7 @@ void dprintf(int idx, const char *format, ...)
         if (schar) {	/* These are for $X replacements */
         if (schar) {	/* These are for $X replacements */
           schar--;	/* Unset identifier int */
           schar--;	/* Unset identifier int */
 
 
+          if (cidx) {
           switch (c) {
           switch (c) {
             case 'b':
             case 'b':
               if (cflags & CFLGS_BOLD) {
               if (cflags & CFLGS_BOLD) {
@@ -164,6 +119,8 @@ void dprintf(int idx, const char *format, ...)
               sprintf(buf2, "$%c", c);		/* No identifier, put the '$' back in */
               sprintf(buf2, "$%c", c);		/* No identifier, put the '$' back in */
               break;
               break;
           }
           }
+          }
+          
         } else {    	/* These are character replacements */
         } else {    	/* These are character replacements */
           switch (c) {
           switch (c) {
             case '$':
             case '$':
@@ -191,7 +148,58 @@ void dprintf(int idx, const char *format, ...)
       }
       }
       buf3[strlen(buf3)] = 0;
       buf3[strlen(buf3)] = 0;
       strcpy(buf, buf3);
       strcpy(buf, buf3);
+}
+
+void dprintf(int idx, const char *format, ...)
+{
+  static char buf[1024] = "";
+  size_t len;
+  va_list va;
+
+  va_start(va, format);
+  egg_vsnprintf(buf, 1023, format, va);
+  va_end(va);
+
+  /* We can not use the return value vsnprintf() to determine where
+   * to null terminate. The C99 standard specifies that vsnprintf()
+   * shall return the number of bytes that would be written if the
+   * buffer had been large enough, rather then -1.
+   */
+  /* We actually can, since if it's < 0 or >= sizeof(buf), we know it wrote
+   * sizeof(buf) bytes. But we're not doing that anyway.
+  */
+  buf[sizeof(buf) - 1] = 0;
+  len = strlen(buf);
+
+/* this is for color on dcc :P */
+
+  if (idx < 0) {
+    tputs(-idx, buf, len);
+  } else if (idx > 0x7FF0) {
+    switch (idx) {
+    case DP_LOG:
+      putlog(LOG_MISC, "*", "%s", buf);
+      break;
+    case DP_STDOUT:
+      tputs(STDOUT, buf, len);
+      break;
+    case DP_STDERR:
+      tputs(STDERR, buf, len);
+      break;
+#ifdef LEAF
+    case DP_SERVER:
+    case DP_HELP:
+    case DP_MODE:
+    case DP_MODE_NEXT:
+    case DP_SERVER_NEXT:
+    case DP_HELP_NEXT:
+      queue_server(idx, buf, len);
+      break;
+#endif /* LEAF */
     }
     }
+    return;
+  } else { /* normal chat text */
+    colorbuf(buf, len, idx);
     buf[sizeof(buf) - 1] = 0;
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
     len = strlen(buf);