Skip to content
Snippets Groups Projects
Commit c7363587 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

BOOL->bool conversion

parent e4764fdb
No related branches found
No related tags found
No related merge requests found
...@@ -223,7 +223,7 @@ static struct section_len get_ws_len(char *buf, int col) ...@@ -223,7 +223,7 @@ static struct section_len get_ws_len(char *buf, int col)
* maxlen cols (used to find the number of bytes to fill a specific * maxlen cols (used to find the number of bytes to fill a specific
* number of columns). * number of columns).
*/ */
static struct section_len get_word_len(char *buf, int maxlen, BOOL is_utf8) static struct section_len get_word_len(char *buf, int maxlen, bool is_utf8)
{ {
struct section_len ret = {0,0}; struct section_len ret = {0,0};
...@@ -295,21 +295,21 @@ static void free_paragraphs(struct paragraph *paragraph, int count) ...@@ -295,21 +295,21 @@ static void free_paragraphs(struct paragraph *paragraph, int count)
/* /*
* Appends bytes to a paragraph, realloc()ing space if needed. * Appends bytes to a paragraph, realloc()ing space if needed.
*/ */
static BOOL paragraph_append(struct paragraph *paragraph, const char *bytes, size_t count) static bool paragraph_append(struct paragraph *paragraph, const char *bytes, size_t count)
{ {
char *new_text; char *new_text;
while (paragraph->len + count + 1 > paragraph->alloc_size) { while (paragraph->len + count + 1 > paragraph->alloc_size) {
new_text = realloc(paragraph->text, paragraph->alloc_size * 2); new_text = realloc(paragraph->text, paragraph->alloc_size * 2);
if (new_text == NULL) if (new_text == NULL)
return FALSE; return false;
paragraph->text = new_text; paragraph->text = new_text;
paragraph->alloc_size *= 2; paragraph->alloc_size *= 2;
} }
memcpy(paragraph->text + paragraph->len, bytes, count); memcpy(paragraph->text + paragraph->len, bytes, count);
paragraph->text[paragraph->len+count] = 0; paragraph->text[paragraph->len+count] = 0;
paragraph->len += count; paragraph->len += count;
return TRUE; return true;
} }
/* /*
...@@ -319,7 +319,7 @@ static BOOL paragraph_append(struct paragraph *paragraph, const char *bytes, siz ...@@ -319,7 +319,7 @@ static BOOL paragraph_append(struct paragraph *paragraph, const char *bytes, siz
* The returned malloc()ed array will have the text member of the last * The returned malloc()ed array will have the text member of the last
* paragraph set to NULL. * paragraph set to NULL.
*/ */
static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes, BOOL *has_crs, BOOL is_utf8) static struct paragraph *word_unwrap(char *inbuf, int oldlen, bool handle_quotes, bool *has_crs, bool is_utf8)
{ {
unsigned inpos=0; unsigned inpos=0;
struct prefix new_prefix; struct prefix new_prefix;
...@@ -327,7 +327,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -327,7 +327,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
int paragraph = 0; int paragraph = 0;
struct paragraph *ret = NULL; struct paragraph *ret = NULL;
struct paragraph *newret = NULL; struct paragraph *newret = NULL;
BOOL paragraph_done; bool paragraph_done;
int next_word_len; int next_word_len;
size_t new_prefix_len; size_t new_prefix_len;
size_t alloc_len = oldlen+1; size_t alloc_len = oldlen+1;
...@@ -335,7 +335,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -335,7 +335,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
if (alloc_len > 4096) if (alloc_len > 4096)
alloc_len = 4096; alloc_len = 4096;
if(has_crs) if(has_crs)
*has_crs = FALSE; *has_crs = false;
while(inbuf[inpos]) { while(inbuf[inpos]) {
incol = 0; incol = 0;
/* Start of a new paragraph (ie: after a hard CR) */ /* Start of a new paragraph (ie: after a hard CR) */
...@@ -357,12 +357,12 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -357,12 +357,12 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
} }
else else
memset(&ret[paragraph].prefix, 0, sizeof(ret[paragraph].prefix)); memset(&ret[paragraph].prefix, 0, sizeof(ret[paragraph].prefix));
paragraph_done = FALSE; paragraph_done = false;
while(!paragraph_done) { while(!paragraph_done) {
switch(inbuf[inpos]) { switch(inbuf[inpos]) {
case '\r': // Strip CRs and add them in later. case '\r': // Strip CRs and add them in later.
if (has_crs) if (has_crs)
*has_crs = TRUE; *has_crs = true;
// Fall-through to strip // Fall-through to strip
case '\b': // Strip backspaces. case '\b': // Strip backspaces.
case DEL: // Strip delete chars. case DEL: // Strip delete chars.
...@@ -378,7 +378,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -378,7 +378,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
break; break;
// If the original line was overly long, it's hard. // If the original line was overly long, it's hard.
if (incol > oldlen) { if (incol > oldlen) {
paragraph_done = TRUE; paragraph_done = true;
break; break;
} }
// Now, if the prefix changes, it's hard. // Now, if the prefix changes, it's hard.
...@@ -391,7 +391,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -391,7 +391,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
new_prefix_len = 0; new_prefix_len = 0;
} }
if (cmp_prefix(&new_prefix, &ret[paragraph].prefix) != 0) { if (cmp_prefix(&new_prefix, &ret[paragraph].prefix) != 0) {
paragraph_done = TRUE; paragraph_done = true;
FREE_AND_NULL(new_prefix.bytes); FREE_AND_NULL(new_prefix.bytes);
break; break;
} }
...@@ -403,18 +403,18 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -403,18 +403,18 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
case '\r': case '\r':
case '\n': case '\n':
FREE_AND_NULL(new_prefix.bytes); FREE_AND_NULL(new_prefix.bytes);
paragraph_done = TRUE; paragraph_done = true;
break; break;
} }
if (paragraph_done) { if (paragraph_done) {
FREE_AND_NULL(new_prefix.bytes); FREE_AND_NULL(new_prefix.bytes);
paragraph_done = TRUE; paragraph_done = true;
break; break;
} }
// If this paragraph was only whitespace, it's hard. // If this paragraph was only whitespace, it's hard.
if(strspn(ret[paragraph].text, " \t\r") == strlen(ret[paragraph].text)) { if(strspn(ret[paragraph].text, " \t\r") == strlen(ret[paragraph].text)) {
FREE_AND_NULL(new_prefix.bytes); FREE_AND_NULL(new_prefix.bytes);
paragraph_done = TRUE; paragraph_done = true;
break; break;
} }
...@@ -422,7 +422,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -422,7 +422,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
next_word_len = get_word_len(inbuf+inpos+1+new_prefix_len, -1, is_utf8).len; next_word_len = get_word_len(inbuf+inpos+1+new_prefix_len, -1, is_utf8).len;
if ((incol + next_word_len + 1 - 1) < oldlen) { if ((incol + next_word_len + 1 - 1) < oldlen) {
FREE_AND_NULL(new_prefix.bytes); FREE_AND_NULL(new_prefix.bytes);
paragraph_done = TRUE; paragraph_done = true;
break; break;
} }
// Skip the new prefix... // Skip the new prefix...
...@@ -447,7 +447,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes ...@@ -447,7 +447,7 @@ static struct paragraph *word_unwrap(char *inbuf, int oldlen, BOOL handle_quotes
} }
inpos++; inpos++;
if (inbuf[inpos] == 0) if (inbuf[inpos] == 0)
paragraph_done = TRUE; paragraph_done = true;
} }
paragraph++; paragraph++;
} }
...@@ -472,7 +472,7 @@ fail_return: ...@@ -472,7 +472,7 @@ fail_return:
* *
* Returns a malloc()ed string. * Returns a malloc()ed string.
*/ */
static char *wrap_paragraphs(struct paragraph *paragraph, size_t outlen, BOOL handle_quotes, BOOL has_crs, BOOL is_utf8) static char *wrap_paragraphs(struct paragraph *paragraph, size_t outlen, bool handle_quotes, bool has_crs, bool is_utf8)
{ {
int outcol; int outcol;
char *outbuf = NULL; char *outbuf = NULL;
...@@ -551,11 +551,11 @@ static char *wrap_paragraphs(struct paragraph *paragraph, size_t outlen, BOOL ha ...@@ -551,11 +551,11 @@ static char *wrap_paragraphs(struct paragraph *paragraph, size_t outlen, BOOL ha
return outbuf; return outbuf;
} }
char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes, BOOL is_utf8) char* wordwrap(char* inbuf, int len, int oldlen, bool handle_quotes, bool is_utf8)
{ {
char* outbuf; char* outbuf;
struct paragraph *paragraphs; struct paragraph *paragraphs;
BOOL has_crs; bool has_crs;
if (oldlen < 1) if (oldlen < 1)
oldlen = 79; oldlen = 79;
......
/* $Id: wordwrap.h,v 1.8 2019/07/08 07:08:01 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -13,21 +11,9 @@ ...@@ -13,21 +11,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -38,7 +24,7 @@ ...@@ -38,7 +24,7 @@
extern "C" { extern "C" {
#endif #endif
char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes, BOOL is_utf8); char* wordwrap(char* inbuf, int len, int oldlen, bool handle_quotes, bool is_utf8);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment