Wolfgang Thallergcc16 merge934c3885 months agoHistory
61 lines · 2.2 KB · C
RawDownload
/* Implement the snprintf function.   Copyright (C) 2003-2026 Free Software Foundation, Inc.   Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. This file is part of the libiberty library.  This library is freesoftware; you can redistribute it and/or modify it under theterms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option)any later version. This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details. You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, if you link this library with filescompiled with a GNU compiler to produce an executable, this does not causethe resulting executable to be covered by the GNU General Public License.This exception does not however invalidate any other reasons whythe executable file might be covered by the GNU General Public License. */ /* @deftypefn Supplemental int snprintf (char *@var{buf}, size_t @var{n}, @  const char *@var{format}, ...) This function is similar to @code{sprintf}, but it will write to@var{buf} at most @code{@var{n}-1} bytes of text, followed by aterminating null byte, for a total of @var{n} bytes.On error the return value is -1, otherwise it returns the number ofbytes, not including the terminating null byte, that would have beenwritten had @var{n} been sufficiently large, regardless of the actualvalue of @var{n}.  Note some pre-C99 system libraries do not implementthis correctly so users cannot generally rely on the return value ifthe system version of this function is used. @end deftypefn */ #include "ansidecl.h" #include <stdarg.h>#include <stddef.h> int vsnprintf (char *, size_t, const char *, va_list); intsnprintf (char *s, size_t n, const char *format, ...){  int result;  va_list ap;  va_start (ap, format);  result = vsnprintf (s, n, format, ap);  va_end (ap);  return result;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t