Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\boot\printf.c Create Date:2022-07-28 07:26:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:vsprintf

Proto:int vsprintf(char *buf, const char *fmt, va_list args)

Type:int

Parameter:

TypeParameterName
char *buf
const char *fmt
va_listargs
128  When fmt cycle
129  If fmt != '%' Then
130  str++ = fmt
131  Continue
135  flags = 0
136  repeat :
137  ++fmt
139  Case fmt == '-'
141  Go to repeat
142  Case fmt == '+'
143  flags |= show plus
144  Go to repeat
145  Case fmt == ' '
147  Go to repeat
148  Case fmt == '#'
149  flags |= 0x
150  Go to repeat
151  Case fmt == '0'
153  Go to repeat
157  field_width = -1
158  If isdigit( * fmt) Then field_width = -*- linux-c -*- ------------------------------------------------------- ** Copyright (C) 1991, 1992 Linus Torvalds* Copyright 2007 rPath, Inc. - All Rights Reserved* -----------------------------------------------------------------------
160  Else if fmt == '*' Then
161  ++fmt
163  field_width = va_arg(args, int)
164  If field_width < 0 Then
171  precision = -1
172  If fmt == '.' Then
173  ++fmt
176  Else if fmt == '*' Then
177  ++fmt
179  precision = va_arg(args, int)
181  If precision < 0 Then precision = 0
186  qualifier = -1
187  If fmt == 'h' || fmt == 'l' || fmt == 'L' Then
188  qualifier = fmt
189  ++fmt
193  base = 10
196  Case fmt == 'c'
197  If Not (flags & left justified ) Then When --field_width > 0 cycle
199  str++ = ' '
200  str++ = va_arg(args, int)
201  When --field_width > 0 cycle
202  str++ = ' '
203  Continue
205  Case fmt == 's'
206  s = va_arg(args, char * )
207  len = strnlen(s, precision)
209  If Not (flags & left justified ) Then When len < field_width-- cycle
211  str++ = ' '
212  When i < len cycle str++ = s++
214  When len < field_width-- cycle
215  str++ = ' '
216  Continue
218  Case fmt == 'p'
219  If field_width == -1 Then
220  field_width = 2 * size of *
223  str = number(str, (unsignedlong)va_arg(args, void * ), 16, field_width, precision, flags)
226  Continue
228  Case fmt == 'n'
229  If qualifier == 'l' Then
230  ip = va_arg(args, long * )
231  ip = str - buf
232  Else
233  ip = va_arg(args, int * )
234  ip = str - buf
236  Continue
238  Case fmt == '%'
239  str++ = '%'
240  Continue
243  Case fmt == 'o'
244  base = 8
245  Break
247  Case fmt == 'x'
249  Case fmt == 'X'
250  base = 16
251  Break
253  Case fmt == 'd'
254  Case fmt == 'i'
256  Case fmt == 'u'
257  Break
259  Default
260  str++ = '%'
261  If fmt Then str++ = fmt
263  Else --fmt
265  Continue
267  If qualifier == 'l' Then num = va_arg(args, unsignedlong)
269  Else if qualifier == 'h' Then
270  num = va_arg(args, int)
271  If flags & unsigned/signed long Then num = num
273  Else if flags & unsigned/signed long Then num = va_arg(args, int)
275  Else num = va_arg(args, unsignedint)
277  str = number(str, num, base, field_width, precision, flags)
279  str = '\0'
280  Return str - buf
Caller
NameDescribe
sprintf
printf