* fix another possible hickup situation in the linebuffered reader.
int CtdlDecodeBase64(char *dest, const char *source, size_t length);
unsigned int decode_hex(char *Source);
int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
+void StripSlashes(char *Dir, int TrailingSlash);
size_t striplt(char *);
int haschar(const char *st, int ch);
void remove_token(char *source, int parmnum, char separator);
{
pche = buf->buf + buf->BufUsed;
pch = pos;
- while ((pch <= pche) && (*pch != '\n'))
+ while ((pch < pche) && (*pch != '\n'))
pch ++;
- if (*pch == 0)
+ if ((pch >= pche) || (*pch == '\0'))
pch = NULL;
if ((pch != NULL) &&
(pch <= pche))
return result;
}
+/*
+ * removes double slashes from pathnames
+ * allows / disallows trailing slashes
+ */
+void StripSlashes(char *Dir, int TrailingSlash)
+{
+ char *a, *b;
+
+ a = b = Dir;
+
+ while (!IsEmptyStr(a)) {
+ if (*a == '/') {
+ while (*a == '/')
+ a++;
+ *b = '/';
+ b++;
+ }
+ else {
+ *b = *a;
+ b++; a++;
+ }
+ }
+ if ((TrailingSlash) && (*(b - 1) != '/')){
+ *b = '/';
+ b++;
+ }
+ *b = '\0';
+
+}
/*
* Strip leading and trailing spaces from a string