projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4998edc
)
StrBufStripAllBut() now returns the LEFTMOST qualifying substring. This allows mail...
author
Art Cancro
<ajc@uncensored.citadel.org>
Thu, 11 Jul 2013 01:07:43 +0000
(21:07 -0400)
committer
Art Cancro
<ajc@uncensored.citadel.org>
Thu, 11 Jul 2013 01:07:43 +0000
(21:07 -0400)
libcitadel/lib/stringbuf.c
patch
|
blob
|
history
diff --git
a/libcitadel/lib/stringbuf.c
b/libcitadel/lib/stringbuf.c
index 103377bba0fef110b7e1da6915820e5f6907cfd8..bd67e0d48a93ad19eee581390e115d970de3ce0b 100644
(file)
--- a/
libcitadel/lib/stringbuf.c
+++ b/
libcitadel/lib/stringbuf.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 1987-201
1
by the citadel.org team
+ * Copyright (c) 1987-201
3
by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-1173,29
+1173,31
@@
void StrBufSpaceToBlank(StrBuf *Buf)
void StrBufStripAllBut(StrBuf *Buf, char leftboundary, char rightboundary)
{
void StrBufStripAllBut(StrBuf *Buf, char leftboundary, char rightboundary)
{
- const char *pBuff;
const char *pLeft;
const char *pRight;
const char *pLeft;
const char *pRight;
- if ((Buf == NULL) || (Buf->buf == NULL))
+ if ((Buf == NULL) || (Buf->buf == NULL)) {
+ StrBufCutAt(Buf, 0, Buf->buf);
return;
return;
- pLeft = pBuff = Buf->buf;
- while (pBuff != NULL) {
- pLeft = pBuff;
- pBuff = strchr(pBuff, leftboundary);
- if (pBuff != NULL)
- pBuff++;
}
}
-
- if (pLeft != NULL)
- pBuff = pLeft;
- else
- pBuff = Buf->buf;
- pRight = strchr(pBuff, rightboundary);
- if (pRight != NULL)
+
+ pRight = strchr(Buf->buf, rightboundary);
+ if (pRight != NULL) {
StrBufCutAt(Buf, 0, pRight);
StrBufCutAt(Buf, 0, pRight);
- if (pLeft != NULL)
- StrBufCutLeft(Buf, pLeft - Buf->buf);
+ }
+ else {
+ StrBufCutAt(Buf, 0, Buf->buf);
+ return;
+ }
+
+ pLeft = strrchr(ChrPtr(Buf), leftboundary);
+ if (pLeft != NULL) {
+ StrBufCutLeft(Buf, pLeft - Buf->buf + 1);
+ }
+ else {
+ StrBufCutAt(Buf, 0, Buf->buf);
+ return;
+ }
}
}