[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] Changes to pspp/src/str.c
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] Changes to pspp/src/str.c |
Date: |
Tue, 25 Oct 2005 00:28:22 -0400 |
Index: pspp/src/str.c
diff -u pspp/src/str.c:1.16 pspp/src/str.c:1.17
--- pspp/src/str.c:1.16 Mon Sep 12 11:33:55 2005
+++ pspp/src/str.c Tue Oct 25 04:28:17 2005
@@ -79,8 +79,8 @@
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--)
@@ -247,6 +247,21 @@
memcpy (dst, src, dst_size - 1);
dst[dst_size - 1] = '\0';
}
+}
+
+/* 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. */
- [Pspp-cvs] Changes to pspp/src/str.c,
Ben Pfaff <=