/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
#include <stdlib.h>
#include "alloc.h"
#include "error.h"
-#include "pool.h"
\f
/* sprintf() wrapper functions for convenience. */
void
buf_reverse (char *p, size_t nbytes)
{
- unsigned char *h = p, *t = &h[nbytes - 1];
- unsigned char temp;
+ char *h = p, *t = &h[nbytes - 1];
+ char temp;
nbytes /= 2;
while (nbytes--)
}
}
+/* Copies buffer SRC, of SRC_LEN bytes,
+ to DST, which is in a buffer DST_SIZE bytes long.
+ Truncates DST to DST_SIZE - 1 characters, if necessary. */
+void
+str_copy_buf_trunc (char *dst, size_t dst_size,
+ const char *src, size_t src_size)
+{
+ size_t dst_len;
+ assert (dst_size > 0);
+
+ dst_len = src_size < dst_size ? src_size : dst_size - 1;
+ memcpy (dst, src, dst_len);
+ dst[dst_len] = '\0';
+}
+
/* Converts each character in S to uppercase. */
void
str_uppercase (char *s)
for (; *s != '\0'; s++)
*s = toupper ((unsigned char) *s);
}
+
+/* Converts each character in S to lowercase. */
+void
+str_lowercase (char *s)
+{
+ for (; *s != '\0'; s++)
+ *s = tolower ((unsigned char) *s);
+}
\f
/* Initializes ST with initial contents S. */
void