From e92e107a25b155e4006fee09be47c3886dfdb548 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 3 Jun 2006 11:08:31 +0000 Subject: [PATCH] Compress spaces and avoid printing unprintable characters. --- ChangeLog | 7 +++++++ Makefile | 4 ++-- cm.c | 25 ++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c577a41..98a275b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-06-03 Martin Mares + + * cm.c (add_snippet): Compress spaces and avoid printing unprintable + characters. + + * Released as 0.4. + 2005-05-25 Martin Mares * cm.c (add_snippet): Don't forget to terminate the string. Gets rid of diff --git a/Makefile b/Makefile index 2d3c5b1..bf1f5a9 100644 --- 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 53635ef..f04618b 100644 --- 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); -- 2.39.2