Branch: Tag:

2003-03-28

2003-03-28 22:27:30 by Martin Stjernholm <mast@lysator.liu.se>

Fixed bugs with sprintf("%c"...) on negative numbers which were due to
the cleanup to adhere to the gmp api.

Rev: src/modules/Gmp/mpz_glue.c:1.132

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: mpz_glue.c,v 1.131 2003/03/28 22:15:47 mast Exp $ + || $Id: mpz_glue.c,v 1.132 2003/03/28 22:27:30 mast Exp $   */      #include "global.h" - RCSID("$Id: mpz_glue.c,v 1.131 2003/03/28 22:15:47 mast Exp $"); + RCSID("$Id: mpz_glue.c,v 1.132 2003/03/28 22:27:30 mast Exp $");   #include "gmp_machine.h"   #include "module.h"   
647:       case 'c':    { -  INT_TYPE length, neg = 0; +  INT_TYPE neg = mpz_sgn (THIS) < 0;    unsigned char *dst; -  size_t pos; +  size_t pos, length = mpz_size (THIS);    mpz_t tmp;    MP_INT *n;    INT_TYPE i;    -  length = mpz_size (THIS); -  +     if(width_undecided)    {    p_wchar2 ch = mpz_get_ui(THIS); -  if(length<0) +  if(neg)    ch = (~ch)+1;    s = make_shared_binary_string2(&ch, 1);    break;    }    -  if(length < 0) +  if (neg)    {    mpz_init_set(tmp, THIS);    mpz_add_ui(tmp, tmp, 1); -  length = -mpz_size (tmp); +  length = mpz_size (tmp);    n = tmp; -  neg = 1; +     }    else    n = THIS;