aboutsummaryrefslogtreecommitdiff
path: root/ncurses/tinfo/trim_sgr0.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-02-28 19:18:07 +0000
committerXin LI <delphij@FreeBSD.org>2014-02-28 19:18:07 +0000
commita0044ffc69cfe39a3b0b2d208e0952254555afc6 (patch)
tree7b2d708d03277cdd2560e9ce6572bdafc2e58bab /ncurses/tinfo/trim_sgr0.c
parent4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a (diff)
downloadsrc-a0044ffc69cfe39a3b0b2d208e0952254555afc6.tar.gz
src-a0044ffc69cfe39a3b0b2d208e0952254555afc6.zip
Redo import of ncurses 5.9 (stripped).vendor/ncurses/5.9-20110404_stripped
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=262617 svn path=/vendor/ncurses/5.9-20110404_stripped/; revision=262631; tag=vendor/ncurses/5.9-20110404_stripped
Diffstat (limited to 'ncurses/tinfo/trim_sgr0.c')
-rw-r--r--ncurses/tinfo/trim_sgr0.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/ncurses/tinfo/trim_sgr0.c b/ncurses/tinfo/trim_sgr0.c
index 80c8f77fbebe..1f99208667ec 100644
--- a/ncurses/tinfo/trim_sgr0.c
+++ b/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2005-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2005-2007,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -35,9 +35,8 @@
#include <ctype.h>
#include <tic.h>
-#include <term_entry.h>
-MODULE_ID("$Id: trim_sgr0.c,v 1.8 2007/04/07 17:14:11 tom Exp $")
+MODULE_ID("$Id: trim_sgr0.c,v 1.12 2010/12/25 23:03:57 tom Exp $")
#undef CUR
#define CUR tp->
@@ -100,8 +99,8 @@ rewrite_sgr(char *s, char *attr)
{
if (PRESENT(s)) {
if (PRESENT(attr)) {
- unsigned len_s = strlen(s);
- unsigned len_a = strlen(attr);
+ size_t len_s = strlen(s);
+ size_t len_a = strlen(attr);
if (len_s > len_a && !strncmp(attr, s, len_a)) {
unsigned n;
@@ -124,8 +123,8 @@ similar_sgr(char *a, char *b)
bool result = FALSE;
int csi_a = is_csi(a);
int csi_b = is_csi(b);
- unsigned len_a;
- unsigned len_b;
+ size_t len_a;
+ size_t len_b;
TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
_nc_visbuf2(1, a),
@@ -170,13 +169,13 @@ chop_out(char *string, unsigned i, unsigned j)
* Returns the number of chars from 'full' that we matched. If any mismatch
* occurs, return zero.
*/
-static int
+static unsigned
compare_part(const char *part, const char *full)
{
const char *next_part;
const char *next_full;
- int used_full = 0;
- int used_delay = 0;
+ unsigned used_full = 0;
+ unsigned used_delay = 0;
while (*part != 0) {
if (*part != *full) {
@@ -199,7 +198,7 @@ compare_part(const char *part, const char *full)
next_part = skip_delay(part);
next_full = skip_delay(full);
if (next_part != part && next_full != full) {
- used_delay += (next_full - full);
+ used_delay += (unsigned) (next_full - full);
full = next_full;
part = next_part;
continue;
@@ -261,10 +260,11 @@ _nc_trim_sgr0(TERMTYPE *tp)
k = strlen(exit_alt_charset_mode);
if (j > k) {
for (i = 0; i <= (j - k); ++i) {
- int k2 = compare_part(exit_alt_charset_mode, off + i);
+ unsigned k2 = compare_part(exit_alt_charset_mode,
+ off + i);
if (k2 != 0) {
found = TRUE;
- chop_out(off, i, i + k2);
+ chop_out(off, (unsigned) i, (unsigned) (i + k2));
break;
}
}
@@ -274,18 +274,18 @@ _nc_trim_sgr0(TERMTYPE *tp)
* SGR 10 would reset to normal font.
*/
if (!found) {
- if ((i = is_csi(off)) != 0
+ if ((i = (size_t) is_csi(off)) != 0
&& off[strlen(off) - 1] == 'm') {
TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
_nc_visbuf(off)));
tmp = skip_zero(off + i);
if (tmp[0] == '1'
&& skip_zero(tmp + 1) != tmp + 1) {
- i = tmp - off;
+ i = (size_t) (tmp - off);
if (off[i - 1] == ';')
i--;
- j = skip_zero(tmp + 1) - off;
- i = chop_out(off, i, j);
+ j = (size_t) (skip_zero(tmp + 1) - off);
+ (void) chop_out(off, (unsigned) i, (unsigned) j);
found = TRUE;
}
}
@@ -293,10 +293,10 @@ _nc_trim_sgr0(TERMTYPE *tp)
if (!found
&& (tmp = strstr(end, off)) != 0
&& strcmp(end, off) != 0) {
- i = tmp - end;
+ i = (size_t) (tmp - end);
j = strlen(off);
tmp = strdup(end);
- chop_out(tmp, i, j);
+ chop_out(tmp, (unsigned) i, (unsigned) j);
free(off);
result = tmp;
}