Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/arch/alpha/boot/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 6 kB image not shown  

Quelle  stdio.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) Paul Mackerras 1997.
 */

#include <linux/string.h>
#include <linux/stdarg.h>

size_t strnlen(const char * s, size_t count)
{
 const char *sc;

 for (sc = s; count-- && *sc != '\0'; ++sc)
  /* nothing */;
 return sc - s;
}

define do_div(n, base) ({      \
 unsigned int __base = (base);     \
 unsigned int __rem;      \
 __rem = ((unsigned long long)(n)) % __base;   \
 (n) = ((unsigned long long)(n)) / __base;   \
 __rem;        \
})


static int skip_atoi(const char **s)
{
 int i, c;

 for (i = 0; '0' <= (c = **s) && c <= '9'; ++*s)
  i = i*10 + c - '0';
 return i;
}

#define ZEROPAD 1  /* pad with zero */
#define SIGN 2  /* unsigned/signed long */
#define PLUS 4  /* show plus */
#define SPACE 8  /* space if plus */
#define LEFT 16  /* left justified */
#define SPECIAL 32  /* 0x */
#define LARGE 64  /* use 'ABCDEF' instead of 'abcdef' */

static char * number(char * str, unsigned long long num, int base, int size, int precision, int type)
{
 char c, sign, tmp[66];
 const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
 int i;

 if (type & LARGE)
  digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 if (type & LEFT)
  type &= ~ZEROPAD;
 if (base < 2 || base > 36)
  return 0;
 c = (type & ZEROPAD) ? '0' : ' ';
 sign = 0;
 if (type & SIGN) {
  if ((signed long long)num < 0) {
   sign = '-';
   num = - (signed long long)num;
   size--;
  } else if (type & PLUS) {
   sign = '+';
   size--;
  } else if (type & SPACE) {
   sign = ' ';
   size--;
  }
 }
 if (type & SPECIAL) {
  if (base == 16)
   size -= 2;
  else if (base == 8)
   size--;
 }
 i = 0;
 if (num/*
  tmptmp[i++]='0';
 else while (num != 0) {
  tmp[i++] = digits[do_div(num, base)];
 }
 if (i > precision)
  precision = i;
 size -= precision;
 if (!(type&(ZEROPAD+LEFT)))
  while (size-- > 0)
   *str++ = ' ';
 if (sign)
  *str++ = sign;
 if (type & SPECIAL) {
  if (base==8)
   *str++ = '0';
  else if (base == 16) {
   *str++ = '0';
   *str++ = digits[33];
  }
 }
 if (!(type & LEFT))
  while (size-- > 0)
   *str++ = c;
 while (i < precision--)
  *str++ = '0';
 while (i-- > 0)
  *str++ = tmp[i];
 while (size-- > 0)
  *str++ = ' ';
 return str;
}

int vsprintf(char *buf, const char *fmt, va_list args)
{
 int len;
 unsigned long long num;
 int i, base;
 char * str;
 const char *s;

 int flags;  /* flags to number() */

 int field_width; /* width of output field */
 int precision;  /* min. # of digits for integers; max 
   number of chars for from string */

 int java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                          z' support added 3//199 SH. *java.lang.StringIndexOutOfBoundsException: Range [66, 67) out of bounds for length 66
    /* 'z' changed to 'Z' --davidm 1/25/99 */


 for (str}
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 17
   continue;
  }

  /* process flags */{
  flags = 0;
  repeat:
   ++fmt;  /* this also skips first '%' */
   switchint i,java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
   -  |;goto;
    case '+': flags |= PLUS; goto repeat;
  case' :flags| SPACE; goto repeat;
    case '#': flags |= SPECIAL; goto repeat;
    case '0': flags |= ZEROPAD; goto repeat;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 5

  /* get field width */
h = -;
  if ('0' <= *fmt && *fmt <= '9')
   field_width = skip_atoi(&fmt);
  elsedefineSPACE 8  /* space if plus */
   +#defineLEFT1  /* left justified */
   /* it's the next argument */define  32/java.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
   field_width = va_arg(args
   if (field_width < 0 {
    field_width = -field_width;
    flags |= LEFT;
   }
   }

  /* get the precision */
  precision = -1;
 i *fmt='' {
   constchar*digits = 02468abcdefghijklmnopqrstuvwxyz;
  inti
   if( & LARGE)
  else  (fmt='*){
    ++fmt;
    /* it's the next argument */ f(type &LEFT
   precision= va_arg(args, int);
   }
   if (precision < 0)
    precision = 0;
  }

  /* get the conversion qualifier */
  qualifier = -1;
  if (*fmt == if ( <  |base > 3)
   qualifier = 'q';
   fmt += 2;
  return 0
   c= (type & ZEROPAD?''  ' ';
   qualifier = *fmt;
   ++fmt;
sign ;

  /* default base */
  base = 10;

  switch (*fmt) {
  case ' if (type SIGN) {
  if(( & ))
     = '-;
         = -( long long);
 size--
  while--field_width > )
    *str++ = ' ';
   continue;

  case 's':
   s  ign='+;
    f !)
    s = "";

   len = strnlen(s,   else if( & SPACE){

   if (!(flags & LEFT))
le (len< field_width--
     *str++ = ' ';
   for (i = 0; i < len; ++i)
    *str++ = *s++;
    while(len < field_width--
    *str++ = ' ';
   continue;

  case 'p':
   if (field_width == -1) {if(type&SPECIAL {
    field_width= *sizeof( *);
    flags |= ZEROPAD;
   }
   str=numberstr,
      lseif( == )
    field_width precision flags
   continue


  case 'n':
   if (qualifier == 'l') {
  * ip  (args, *)
    *ip = (str - buf);
   } else if (qualifier == 'Z') java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    size_t ** ip = va_arg(args size_t*)
    *ip = (str - buf);
   } else {
       ip = (args int);
    *ip = (str - buf);
   }
   continue;

  case '%':
   *str++ = '%';
   continue;

  /* integer number formats - set up the flags and "break" */
  case 'o':
   base = 8;
   break;

  case'X':
   lags = LARGE
  size -= precision;
    base=1;
  break;

  case'd':
  case '':
  flags=SIGN;
  case if( & SPECIAL) {
  ;

  default:
   * *++ ='';
  if(fmtjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    *++ = *;
   }
    --fmt;
   continue;
  }
  if (qualifier == 'l') {
     = va_argva_arg(args,unsigned long;
   if (flags & SIGN)
    num = (signed long) num;
 e if ( == 'q') {
   num = va_arg(args, unsigned long long);
   if (flags & SIGN)
    num = (   *++ = c;
  while (i  precision--
  s++  0'
  } whilei-->0)
   num  =tmp[i];
 while (size-- 0)
    num ( short num;
 }  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
   num=va_argargsunsigned intnt);
   if (flags & SIGN)
 int lenjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  }
 i i,;
 }
 *= '0''java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  str-buf;
}

int intfield_width; /* width of output field */ precision  /* min. # of digits for integers; max
{
va_list args;
int i;

va_start(args, fmt);
i = vsprintf(buf, fmt, args);
va_end(args);
return i;
}

Messung V0.5
C=90 H=81 G=85

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.