Subversion Repositories SvarDOS

Rev

Rev 2222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2222 Rev 2223
Line 447... Line 447...
447
    dst[end] = 0;
447
    dst[end] = 0;
448
  }
448
  }
449
}
449
}
450
 
450
 
451
 
451
 
452
/* convert an unsigned short to ASCIZ, output set to fixlen chars if fixlen
452
/* convert an unsigned short to ASCIZ, output expanded to minlen chars
453
 * is non zero (prefixed with prefixchar if value too small, else truncated)
453
 * (prefixed with prefixchar if value too small, else truncated)
454
 * returns length of produced string */
454
 * returns length of produced string */
455
unsigned short ustoa(char *dst, unsigned short n, unsigned char fixlen, char prefixchar) {
455
unsigned short ustoa(char *dst, unsigned short n, unsigned char minlen, char prefixchar) {
456
  unsigned short r;
456
  unsigned short r;
457
  unsigned char i;
457
  unsigned char i, len;
458
  unsigned char nonzerocharat = 5;
458
  unsigned char nonzerocharat = 5;
459
 
459
 
460
  for (i = 4; i != 0xff; i--) {
460
  for (i = 4; i != 0xff; i--) {
461
    r = n % 10;
461
    r = n % 10;
462
    n /= 10;
462
    n /= 10;
Line 468... Line 468...
468
  for (i = 0; i < 4; i++) {
468
  for (i = 0; i < 4; i++) {
469
    if (dst[i] != '0') break;
469
    if (dst[i] != '0') break;
470
    dst[i] = prefixchar;
470
    dst[i] = prefixchar;
471
  }
471
  }
472
 
472
 
-
 
473
  len = 5 - nonzerocharat;
-
 
474
 
473
  /* apply fixlen, if set */
475
  /* apply minlen, if set */
474
  if ((fixlen > 0) && (fixlen < 6)) {
476
  if ((minlen > len) && (minlen < 6)) {
-
 
477
    len = minlen;
475
    nonzerocharat = 5 - fixlen;
478
    nonzerocharat = 5 - minlen;
476
  }
479
  }
477
 
480
 
478
  if (nonzerocharat != 0) {
481
  if (nonzerocharat != 0) {
479
    memcpy_ltr(dst, dst + nonzerocharat, 5 - nonzerocharat);
482
    memcpy_ltr(dst, dst + nonzerocharat, len);
480
  }
483
  }
481
 
484
 
482
  dst[5 - nonzerocharat] = 0;
485
  dst[len] = 0;
483
 
486
 
484
  return(5 - nonzerocharat);
487
  return(len);
485
}
488
}
486
 
489
 
487
 
490
 
488
/* converts an unsigned short to a four-byte ASCIZ hex string ("0ABC") */
491
/* converts an unsigned short to a four-byte ASCIZ hex string ("0ABC") */
489
void ustoh(char *dst, unsigned short n) {
492
void ustoh(char *dst, unsigned short n) {