~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to copy_doubles.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                copy_doubles.c
 
6
 
 
7
Purpose:
 
8
        Copy digits, signs and decimal points. Replace anything else with
 
9
        space.
 
10
 
 
11
Input:
 
12
        (1) Output string pointer.
 
13
        (2) Input string pointer.
 
14
        (3) The number of characters to be copied.
 
15
 
 
16
Output:
 
17
        (1) Output string.
 
18
 
 
19
Return value:
 
20
        No return value.
 
21
 
 
22
========includes:============================================================*/
 
23
 
 
24
#include <stdio.h>
 
25
 
 
26
#include <ctype.h>
 
27
 
 
28
/*======copy digits, signs and decimal points:===============================*/
 
29
 
 
30
void CopyDoubles_ (char *output_stringP, char *input_stringP, int charsN)
 
31
{
 
32
int             i, n;
 
33
 
 
34
/* Fill the output string with zeros (the number of zeros is charsN): */
 
35
for (i = 0; i < charsN; i++) *(output_stringP + i) = '\0';
 
36
 
 
37
/* Copy digits, signs and decimal points: */
 
38
for (i = 0; i < charsN; i++)
 
39
        {
 
40
        n = *(input_stringP + i);
 
41
        if (n == '\0')
 
42
                {
 
43
                *(output_stringP + i) = '\0';
 
44
                break;
 
45
                }
 
46
        if (isdigit (n) || (n == '-') || (n == '+') || (n == '.'))
 
47
                {
 
48
                *(output_stringP + i) = n;
 
49
                }
 
50
        else
 
51
                {
 
52
                *(output_stringP + i) = ' ';
 
53
                }
 
54
        }
 
55
 
 
56
}
 
57
 
 
58
/*===========================================================================*/
 
59
 
 
60