/[hydra]/hydra/src/util.c
ViewVC logotype

Diff of /hydra/src/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by nmav, Sun Sep 22 09:07:57 2002 UTC revision 1.3 by nmav, Mon Sep 23 12:48:59 2002 UTC
# Line 385  void rfc822_time_buf(char *buf, time_t s Line 385  void rfc822_time_buf(char *buf, time_t s
385      memcpy(p, day_tab + t->tm_wday * 4, 4);      memcpy(p, day_tab + t->tm_wday * 4, 4);
386  }  }
387    
388  void simple_itoa(unsigned int i, char buf[22])  void simple_itoa(unsigned long int i, char buf[22])
389  {  {
390      /* 21 digits plus null terminator, good for 64-bit or smaller ints      /* 21 digits plus null terminator, good for 64-bit or smaller ints
391       * for bigger ints, use a bigger buffer!       * for bigger ints, use a bigger buffer!
# Line 393  void simple_itoa(unsigned int i, char bu Line 393  void simple_itoa(unsigned int i, char bu
393       * 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time)       * 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time)
394       * and is 10 bytes long       * and is 10 bytes long
395       */       */
     /* FIXME */  
396      char *p = &buf[21];      char *p = &buf[21];
397        int digits = 1; /* include null char */
398    
399      *p-- = '\0';      *p-- = '\0';
400      do {      do {
401            digits++;
402          *p-- = '0' + i % 10;          *p-- = '0' + i % 10;
403          i /= 10;          i /= 10;
404      } while (i > 0);      } while (i > 0);
405    
406        p++;
407        if (p!=buf) memmove( buf, p, digits);
408    
409      return;      return;
410  }  }
411    
# Line 408  void simple_itoa(unsigned int i, char bu Line 413  void simple_itoa(unsigned int i, char bu
413   * Therefore, -1 indicates error   * Therefore, -1 indicates error
414   */   */
415    
416  int boa_atoi(char *s)  int boa_atoi(const char *s)
417  {  {
418      int retval;      int retval;
419      char reconv[22];      char reconv[22];
# Line 416  int boa_atoi(char *s) Line 421  int boa_atoi(char *s)
421      if (!isdigit(*s))      if (!isdigit(*s))
422          return -1;          return -1;
423    
424      retval = atoi(s);      retval = atoi( s);
425      if (retval < 0)      if (retval < 0)
426          return -1;          return -1;
427    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26