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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user