]> git.cameronkatri.com Git - mandoc.git/blobdiff - term.c
Put mansearch.{h,c}, manpage.c, and compat_ohash.{h,c}
[mandoc.git] / term.c
diff --git a/term.c b/term.c
index 3420c70c4629105446ba2a532f0b02024faa4390..79a39ff2fdcdf384df2003ede8e0e08fe90bee2c 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/*     $Id: term.c,v 1.212 2013/12/23 02:20:09 schwarze Exp $ */
+/*     $Id: term.c,v 1.215 2013/12/31 18:07:42 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -407,6 +407,7 @@ term_fontpop(struct termp *p)
 void
 term_word(struct termp *p, const char *word)
 {
 void
 term_word(struct termp *p, const char *word)
 {
+       const char       nbrsp[2] = { ASCII_NBRSP, 0 };
        const char      *seq, *cp;
        char             c;
        int              sz, uc;
        const char      *seq, *cp;
        char             c;
        int              sz, uc;
@@ -429,7 +430,7 @@ term_word(struct termp *p, const char *word)
        else
                p->flags |= TERMP_NOSPACE;
 
        else
                p->flags |= TERMP_NOSPACE;
 
-       p->flags &= ~(TERMP_SENTENCE | TERMP_IGNDELIM);
+       p->flags &= ~TERMP_SENTENCE;
 
        while ('\0' != *word) {
                if ('\\' != *word) {
 
        while ('\0' != *word) {
                if ('\\' != *word) {
@@ -438,7 +439,15 @@ term_word(struct termp *p, const char *word)
                                word++;
                                continue;
                        }
                                word++;
                                continue;
                        }
-                       ssz = strcspn(word, "\\");
+                       if (TERMP_NBRWORD & p->flags) {
+                               if (' ' == *word) {
+                                       encode(p, nbrsp, 1);
+                                       word++;
+                                       continue;
+                               }
+                               ssz = strcspn(word, "\\ ");
+                       } else
+                               ssz = strcspn(word, "\\");
                        encode(p, word, ssz);
                        word += (int)ssz;
                        continue;
                        encode(p, word, ssz);
                        word += (int)ssz;
                        continue;
@@ -513,6 +522,7 @@ term_word(struct termp *p, const char *word)
                        break;
                }
        }
                        break;
                }
        }
+       p->flags &= ~TERMP_NBRWORD;
 }
 
 static void
 }
 
 static void
@@ -649,7 +659,6 @@ term_strlen(const struct termp *p, const char *cp)
                for (i = 0; i < rsz; i++)
                        sz += cond_width(p, *cp++, &skip);
 
                for (i = 0; i < rsz; i++)
                        sz += cond_width(p, *cp++, &skip);
 
-               c = 0;
                switch (*cp) {
                case ('\\'):
                        cp++;
                switch (*cp) {
                case ('\\'):
                        cp++;