~ubuntu-branches/ubuntu/saucy/di/saucy

« back to all changes in this revision

Viewing changes to C/trimchar.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2011-02-23 21:52:32 UTC
  • mfrom: (1.1.12 upstream) (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110223215232-01vg7m0try2on4cy
Tags: 4.27-2
Do not ship "mi" (Closes: #614745)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: trimchar.c,v 1.7 2010-07-14 01:55:09-07 bll Exp $
 
3
 * $Source: /home/bll/DI/di/RCS/trimchar.c,v $
 
4
 * Copyright 1994-2010 Brad Lanam, Walnut Creek, CA
 
5
 */
 
6
 
 
7
#include "config.h"
 
8
#include "di.h"
 
9
 
 
10
#if _hdr_stdio
 
11
# include <stdio.h>
 
12
#endif
 
13
#if _hdr_stdlib
 
14
# include <stdlib.h>
 
15
#endif
 
16
#if _hdr_string
 
17
# include <string.h>
 
18
#endif
 
19
#if _hdr_strings
 
20
# include <strings.h>
 
21
#endif
 
22
 
 
23
void
 
24
#if _proto_stdc
 
25
trimChar (char *str, int ch)
 
26
#else
 
27
trimChar (str, ch)
 
28
    char         *str;
 
29
    int          ch;
 
30
#endif
 
31
{
 
32
    Size_t       len;
 
33
 
 
34
    len = strlen (str);
 
35
    if (len > 0)
 
36
    {
 
37
        --len;
 
38
    }
 
39
    if (len >= 0)
 
40
    {
 
41
        if (str [len] == ch)
 
42
        {
 
43
            str [len] = '\0';
 
44
        }
 
45
    }
 
46
}