#include "portab.h"
-static char UNUSED id[] = "$Id: tool.c,v 1.4 2006/03/22 08:05:10 alex Exp $";
+static char UNUSED id[] = "$Id: tool.c,v 1.9 2008/02/26 22:04:18 fw Exp $";
#include "imp.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#include <netinet/in.h>
+
#include "exp.h"
#include "tool.h"
start = String;
/* Remove whitespaces at the beginning of the string ... */
- while (*start == ' ' || *start == '\t')
+ while (*start == ' ' || *start == '\t' ||
+ *start == '\n' || *start == '\r')
start++;
+ if (!*start) {
+ *String = '\0';
+ return;
+ }
+
/* ... and at the end: */
end = strchr(start, '\0');
+ end--;
while ((*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')
&& end >= start)
end--;
/* New trailing NULL byte */
*(++end) = '\0';
- memmove(String, start, (size_t)(end - start));
+ memmove(String, start, (size_t)(end - start)+1);
} /* ngt_TrimStr */
if( String[len] == Chr ) String[len] = '\0';
} /* ngt_TrimLastChr */
-
/* -eof- */