miscellaneous: clean up trailing whitespace throughout
The entire tree's polluted with inappropriate trailing whitespace. This commit rids our environment of all of those useless keystrokes. Unfortunately, it sure ain't a permanent solution and requires every contributor to instruct their editor(s) to prevent or eliminate them. Plus it's strongly recommended we all insert something like what's shown below to our '.gitconfig' file so as to provide at least some warnings when we try to apply any patches (git am) that do contain the #@!%& things! References(s): ~/.gitconfig excerpt --------------------------------- [core] whitespace = trailing-space, space-before-tab, blank-at-eof [apply] whitespace = warn --------------------------------- ~/.gitconfig excerpt Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
committed by
Jaromir Capik
parent
7b708ca334
commit
fe75e26ab6
@ -37,26 +37,26 @@ static int escape_str_utf8(char *restrict dst, const char *restrict src, int buf
|
||||
int my_cells = 0;
|
||||
int my_bytes = 0;
|
||||
mbstate_t s;
|
||||
|
||||
|
||||
memset(&s, 0, sizeof (s));
|
||||
|
||||
|
||||
for(;;) {
|
||||
wchar_t wc;
|
||||
int len = 0;
|
||||
|
||||
if(my_cells >= *maxcells || my_bytes+1 >= bufsize)
|
||||
|
||||
if(my_cells >= *maxcells || my_bytes+1 >= bufsize)
|
||||
break;
|
||||
|
||||
|
||||
if (!(len = mbrtowc (&wc, src, MB_CUR_MAX, &s)))
|
||||
/* 'str' contains \0 */
|
||||
break;
|
||||
|
||||
|
||||
if (len < 0) {
|
||||
/* invalid multibyte sequence -- zeroize state */
|
||||
memset (&s, 0, sizeof (s));
|
||||
*(dst++) = '?';
|
||||
src++;
|
||||
my_cells++;
|
||||
my_cells++;
|
||||
my_bytes++;
|
||||
|
||||
} else if (!iswprint(wc)) {
|
||||
@ -64,14 +64,14 @@ static int escape_str_utf8(char *restrict dst, const char *restrict src, int buf
|
||||
*(dst++) = '?';
|
||||
src+=len;
|
||||
my_cells++;
|
||||
my_bytes++;
|
||||
|
||||
my_bytes++;
|
||||
|
||||
} else {
|
||||
/* multibyte - printable */
|
||||
/* multibyte - printable */
|
||||
int wlen = wcwidth(wc);
|
||||
|
||||
if (wlen==0) {
|
||||
// invisible multibyte -- we don't ignore it, because some terminal
|
||||
// invisible multibyte -- we don't ignore it, because some terminal
|
||||
// interpret it wrong and more safe is replace it with '?'
|
||||
*(dst++) = '?';
|
||||
src+=len;
|
||||
@ -103,7 +103,7 @@ static int escape_str_utf8(char *restrict dst, const char *restrict src, int buf
|
||||
*dst = '\0';
|
||||
|
||||
// fprintf(stderr, "maxcells: %d, my_cells; %d\n", *maxcells, my_cells);
|
||||
|
||||
|
||||
*maxcells -= my_cells;
|
||||
return my_bytes; // bytes of text, excluding the NUL
|
||||
}
|
||||
@ -124,10 +124,10 @@ int escape_str(char *restrict dst, const char *restrict src, int bufsize, int *m
|
||||
"????????????????????????????????"
|
||||
"????????????????????????????????"
|
||||
"????????????????????????????????";
|
||||
|
||||
|
||||
#if (__GNU_LIBRARY__ >= 6) && (!defined(__UCLIBC__) || defined(__UCLIBC_HAS_WCHAR__))
|
||||
static int utf_init=0;
|
||||
|
||||
|
||||
if(utf_init==0){
|
||||
/* first call -- check if UTF stuff is usable */
|
||||
char *enc = nl_langinfo(CODESET);
|
||||
@ -138,11 +138,11 @@ int escape_str(char *restrict dst, const char *restrict src, int bufsize, int *m
|
||||
return escape_str_utf8(dst, src, bufsize, maxcells);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if(bufsize > *maxcells+1) bufsize=*maxcells+1; // FIXME: assumes 8-bit locale
|
||||
|
||||
for(;;){
|
||||
if(my_cells >= *maxcells || my_bytes+1 >= bufsize)
|
||||
if(my_cells >= *maxcells || my_bytes+1 >= bufsize)
|
||||
break;
|
||||
c = (unsigned char) *(src++);
|
||||
if(!c) break;
|
||||
@ -152,7 +152,7 @@ int escape_str(char *restrict dst, const char *restrict src, int bufsize, int *m
|
||||
*(dst++) = c;
|
||||
}
|
||||
*dst = '\0';
|
||||
|
||||
|
||||
*maxcells -= my_cells;
|
||||
return my_bytes; // bytes of text, excluding the NUL
|
||||
}
|
||||
|
Reference in New Issue
Block a user