File: trimchar.c

package info (click to toggle)
di 4.18-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 368 kB
  • ctags: 394
  • sloc: ansic: 4,933; sh: 1,352; perl: 1,004; makefile: 174
file content (44 lines) | stat: -rw-r--r-- 736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * $Id: trimchar.c,v 1.2 2009-11-23 11:24:06-08 bll Exp $
 * $Source: /home/bll/DI/RCS/trimchar.c,v $
 * Copyright 1994-2009 Brad Lanam, Walnut Creek, CA
 */

#include "config.h"
#include "di.h"

#include <stdio.h>
#if _hdr_stdlib
# include <stdlib.h>
#endif
#if _hdr_string
# include <string.h>
#endif
#if _hdr_strings && ((! defined (_hdr_string)) || (_include_string))
# include <strings.h>
#endif

void
#if _proto_stdc
trimChar (char *str, int ch)
#else
trimChar (str, ch)
    char         *str;
    int          ch;
#endif
{
    unsigned int  len;

    len = strlen (str);
    if (len > 0)
    {
        --len;
    }
    if (len >= 0)
    {
        if (str [len] == ch)
        {
            str [len] = '\0';
        }
    }
}