]> andersk Git - moira.git/blame - lib/strs.c
make sure FixCase uppercases starting letters
[moira.git] / lib / strs.c
CommitLineData
68687902 1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
babbc197 7 * For copying and distribution information, please see the file
8 * <mit-copyright.h>.
68687902 9 *
10 * Miscellaneous string functions.
11 */
12
13#ifndef lint
14static char *rcsid_strs_c = "$Header$";
15#endif lint
16
babbc197 17#include <mit-copyright.h>
0fed7e9b 18#include <sys/types.h>
19#include <strings.h>
20#include <ctype.h>
21
22extern char *malloc(), *realloc();
68687902 23
24/*
25 * Random string functions which should be in the C library..
26 */
27
28/*
29 * Make a copy of a string.
30 */
31char *
32strsave(s)
33 char *s;
34{
0fed7e9b 35 register int len;
36 register char *p;
37 /* Kludge for sloppy string semantics */
38 if (!s) {
39 printf("NULL != \"\" !!!!\r\n");
40 p = malloc(1);
070955b9 41 *p = '\0';
0fed7e9b 42 return p;
43 }
44 len = strlen(s) + 1;
45 p = malloc((u_int)len);
68687902 46 if (p) bcopy(s, p, len);
47 return p;
48}
49/*
50 * Trim whitespace off both ends of a string.
51 */
9ca8ff13 52char *strtrim(save)
53 register char *save;
68687902 54{
9ca8ff13 55 register char *t, *s;
56
57 s = save;
68687902 58 while (isspace(*s)) s++;
59 /* skip to end of string */
9ca8ff13 60 if (*s == '\0') {
61 *save = '\0';
62 return(save);
63 }
68687902 64
65 for (t = s; *t; t++) continue;
66 while (t > s) {
67 --t;
68 if (!isspace(*t)) {
69 t++;
70 break;
71 }
72 }
73 *t = '\0';
74 return s;
75}
This page took 0.158311 seconds and 5 git commands to generate.