newline handling

In light of the recent 'bad options' feedback issue where \r messed
up message display, try to to make newline handling be more consistent.
I'm sure there are lots of places that still handle \n manually, but
it's a start.
This commit is contained in:
PatR
2015-12-25 21:54:01 -08:00
parent 1c80503938
commit c4a9d6a45c
5 changed files with 27 additions and 27 deletions

View File

@@ -18,6 +18,7 @@
char * ucase (char *)
char * upstart (char *)
char * mungspaces (char *)
char * strip_newline (char *)
char * eos (char *)
boolean str_end_is (const char *, const char *)
char * strkitten (char *,char)
@@ -158,6 +159,21 @@ char *bp;
return bp;
}
/* remove \n from end of line; remove \r too if one is there */
char *
strip_newline(str)
char *str;
{
char *p = index(str, '\n');
if (p) {
if (p > str && *(p - 1) == '\r')
--p;
*p = '\0';
}
return str;
}
/* return the end of a string (pointing at '\0') */
char *
eos(s)