]> mj.ucw.cz Git - checkmail.git/commitdiff
Compress spaces and avoid printing unprintable characters.
authorMartin Mares <mj@ucw.cz>
Sat, 3 Jun 2006 11:08:31 +0000 (11:08 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 3 Jun 2006 11:08:31 +0000 (11:08 +0000)
ChangeLog
Makefile
cm.c

index c577a418e0ce844eac508401d953d1c8e9fb0f37..98a275b28e3be6ee23c67d14c90a081801f42546 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-06-03  Martin Mares  <mj@ucw.cz>
+
+       * cm.c (add_snippet): Compress spaces and avoid printing unprintable
+       characters.
+
+       * Released as 0.4.
+
 2005-05-25  Martin Mares  <mj@ucw.cz>
 
        * cm.c (add_snippet): Don't forget to terminate the string. Gets rid of
index 2d3c5b1fb8aad1112218bc5c74c23c56955bea1f..bf1f5a954d30475d1400254ba9d29e963e3a0039 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,8 @@
 CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline $(DEBUG) -std=gnu99 -DVERSION=$(VERSION) -DYEAR=$(YEAR)
 LDFLAGS=-lncurses
 
-VERSION=0.3
-YEAR=2005
+VERSION=0.4
+YEAR=2006
 
 all: cm
 
diff --git a/cm.c b/cm.c
index 53635efec1e1065e747275c0bec44d56771bbbf4..f04618b69a656d7a424b0702269063bde250cd12 100644 (file)
--- a/cm.c
+++ b/cm.c
@@ -200,11 +200,30 @@ mbox_visible_p(struct mbox *b)
 }
 
 static void
-add_snippet(char **ppos, char *term, char *add)
+add_snippet(char **ppos, char *term, unsigned char *add)
 {
   char *pos = *ppos;
+  int space = 1;
   while (*add && pos < term)
-    *pos++ = *add++;
+    {
+      if (*add <= ' ')
+       {
+         if (!space)
+           *pos++ = ' ';
+         space = 1;
+       }
+      else if (*add >= 0x7f)
+       {
+         *pos++ = '?';
+         space = 0;
+       }
+      else
+       {
+         *pos++ = *add;
+         space = 0;
+       }
+      add++;
+    }
   *ppos = pos;
   *pos = 0;
 }
@@ -240,7 +259,7 @@ mb_reset(int pos)
   mb_pos = pos;
 }
 
-static int
+static void
 mb_seek(uns pos)
 {
   lseek(mb_fd, pos, SEEK_SET);