[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: |
Fri, 11 Mar 2005 20:08:35 -0500 |
Index: pspp/src/str.c
diff -u pspp/src/str.c:1.9 pspp/src/str.c:1.10
--- pspp/src/str.c:1.9 Tue Mar 1 08:16:16 2005
+++ pspp/src/str.c Sat Mar 12 01:08:33 2005
@@ -194,6 +194,31 @@
dest[n - 1] = 0;
}
}
+
+/* Copies SRC to DST, truncating DST to N-1 characters if
+ necessary. Always appends a null character. */
+void
+st_trim_copy (char *dst, const char *src, size_t n)
+{
+ size_t len = strlen (src);
+ assert (n > 0);
+ if (len + 1 < n)
+ memcpy (dst, src, len + 1);
+ else
+ {
+ memcpy (dst, src, n - 1);
+ dst[n - 1] = '\0';
+ }
+}
+
+
+/* Converts each character in S to uppercase. */
+void
+st_uppercase (char *s)
+{
+ for (; *s != '\0'; s++)
+ *s = toupper ((unsigned char) *s);
+}
/* Initializes ST with initial contents S. */
void