~ubuntu-branches/ubuntu/oneiric/bc/oneiric

« back to all changes in this revision

Viewing changes to dc/misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-05 12:24:03 UTC
  • mfrom: (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20071205122403-rv1a7x90ktu1wl95
Tags: 1.06.94-3ubuntu1
* Merge with Debian; remaining changes:
  - Make bc/dc notice read and write errors on its input and output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
2
 * misc. functions for the "dc" Desk Calculator language.
3
3
 *
4
 
 * Copyright (C) 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
 
4
 * Copyright (C) 1994, 1997, 1998, 2000, 2006 Free Software Foundation, Inc.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
17
17
 * along with this program; if not, you can either send email to this
18
18
 * program's author (see below) or write to:
19
19
 *   The Free Software Foundation, Inc.
20
 
 *   59 Temple Place, Suite 330
21
 
 *   Boston, MA 02111 USA
 
20
 *   51 Franklin Street, Fifth Floor
 
21
 *   Boston, MA 02110-1301  USA
22
22
 */
23
23
 
24
 
/* This module contains miscelaneous functions that have no
 
24
/* This module contains miscellaneous functions that have no
25
25
 * special knowledge of any private data structures.
26
 
 * They could all be moved to their own separate modules, but
27
 
 * are agglomerated here for convenience.
 
26
 * They could each be moved to their own separate modules,
 
27
 * but are aggregated here as a matter of convenience.
28
28
 */
29
29
 
30
30
#include "config.h"
70
70
{
71
71
        void *result = malloc(len);
72
72
 
73
 
        if (!result)
 
73
        if (result == NULL)
74
74
                dc_memfail();
75
75
        return result;
76
76
}
88
88
        const char *suffix DC_DECLEND
89
89
{
90
90
        if (isgraph(id))
91
 
                fprintf(fp, "'%c' (%#o)%s", id, id, suffix);
 
91
                fprintf(fp, "'%c' (%#o)%s", (unsigned int) id, id, suffix);
92
92
        else
93
 
                fprintf(fp, "%#o%s", id, suffix);
 
93
                fprintf(fp, "%#o%s", (unsigned int) id, suffix);
94
94
        checkferror_output(fp);
95
95
}
96
96
 
135
135
        size_t len;
136
136
 
137
137
        p = strchr(s, '\n');
138
 
        if (p) {
139
 
                len = p - s;
 
138
        if (p != NULL) {
 
139
                len = (size_t) (p - s);
140
140
                tmpstr = dc_malloc(len + 1);
141
141
                strncpy(tmpstr, s, len);
142
142
                tmpstr[len] = '\0';
178
178
        /*else*/
179
179
        return dc_dup_str(value.v.string);
180
180
}
 
181
 
 
182
 
 
183
/*
 
184
 * Local Variables:
 
185
 * mode: C
 
186
 * tab-width: 4
 
187
 * End:
 
188
 * vi: set ts=4 :
 
189
 */