]> andersk Git - moira.git/blame_incremental - lib/strs.c
fix prototyping problems
[moira.git] / lib / strs.c
... / ...
CommitLineData
1/* $Id $
2 *
3 * Miscellaneous string functions.
4 *
5 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
7 * <mit-copyright.h>.
8 */
9
10#include <mit-copyright.h>
11#include <moira.h>
12
13#include <ctype.h>
14
15RCSID("$Header$");
16
17/*
18 * Trim whitespace off both ends of a string.
19 */
20char *strtrim(char *save)
21{
22 char *t, *s;
23
24 s = save;
25 while (isspace(*s))
26 s++;
27 /* skip to end of string */
28 if (*s == '\0')
29 {
30 *save = '\0';
31 return save;
32 }
33
34 for (t = s; *t; t++)
35 continue;
36 while (t > s)
37 {
38 --t;
39 if (!isspace(*t))
40 {
41 t++;
42 break;
43 }
44 }
45 if (*t)
46 *t = '\0';
47 return s;
48}
49
50
51/* Modify a string for all of the letters to be uppercase. */
52
53char *uppercase(char *s)
54{
55 char *p;
56
57 for (p = s; *p; p++)
58 {
59 if (islower(*p))
60 *p = toupper(*p);
61 }
62 return s;
63}
64
65
66char *lowercase(char *s)
67{
68 char *p;
69
70 for (p = s; *p; p++)
71 {
72 if (isupper(*p))
73 *p = tolower(*p);
74 }
75 return s;
76}
This page took 0.035613 seconds and 5 git commands to generate.