~rdoering/ubuntu/intrepid/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/erl_interface/src/misc/ei_printterm.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-05-01 16:57:10 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070501165710-2sapk0hp2gf3o0ip
Tags: 1:11.b.4-2ubuntu1
* Merge with Debian Unstable. Remaining changes:
  - Add -fno-stack-protector to fix broken crypto_drv.
* DebianMaintainerField update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 * PRINT out a binary term (hacked from 'erl'_print_term)
47
47
 */
48
48
 
49
 
static int print_string(FILE* fp, ei_x_buff* x, char* s);
 
49
static int print_string(FILE* fp, ei_x_buff* x, char* s, int len);
50
50
static int print_term(FILE* fp, ei_x_buff* x,
51
51
                               const char* buf, int* index);
52
52
 
190
190
            ei_free(p);
191
191
            goto err;
192
192
        }
193
 
        ch_written += print_string(fp, x, p);
 
193
        ch_written += print_string(fp, x, p, n);
194
194
        ei_free(p);
195
195
        break;
196
196
    case ERL_SMALL_TUPLE_EXT:
267
267
    return -1;
268
268
}
269
269
 
270
 
static int print_string(FILE* fp, ei_x_buff* x, char* s)
 
270
static int print_string(FILE* fp, ei_x_buff* x, char* s, int len)
271
271
{
272
272
    int ch_written = 0;         /* counter of written chars */
273
 
  
 
273
 
274
274
    xputc('"', fp, x);
275
275
    ++ch_written;
276
 
    for (; *s != '\0'; ++s) {
 
276
    for (; len > 0; ++s, --len) {
277
277
        int c = *s;
278
278
        if (c >= ' ') {
279
279
            xputc((char)c, fp, x); ++ch_written; }
296
296
    return ch_written;
297
297
}
298
298
 
299
 
 
300
299
/* ------------------------------------------ */
301
300
 
302
301
/*