]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/snprintf.c
Remove obsolete files and ignore Xcode files.
[thirdparty/cups.git] / cups / snprintf.c
index 313102b86c67e461523cd3a04b41f318ecfbf760..9af6b90f8544640f36e658015bbd6ee1e24afe87 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: snprintf.c 6188 2007-01-10 16:23:06Z mike $"
+ * "$Id$"
  *
- *   snprintf functions for the Common UNIX Printing System (CUPS).
+ *   snprintf functions for CUPS.
  *
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  *
@@ -33,9 +24,7 @@
  * Include necessary headers...
  */
 
-#include <stdio.h>
-#include <ctype.h>
-#include "string.h"
+#include "string-private.h"
 
 
 #ifndef HAVE_VSNPRINTF
@@ -59,6 +48,7 @@ _cups_vsnprintf(char       *buffer,   /* O - Output buffer */
   char         tformat[100],           /* Temporary format string for sprintf() */
                *tptr,                  /* Pointer into temporary format */
                temp[1024];             /* Buffer for formatted numbers */
+  size_t       templen;                /* Length of "temp" */
   char         *s;                     /* Pointer to string */
   int          slen;                   /* Length of string */
   int          bytes;                  /* Total number of bytes needed */
@@ -194,20 +184,21 @@ _cups_vsnprintf(char       *buffer,       /* O - Output buffer */
              break;
 
            sprintf(temp, tformat, va_arg(ap, double));
+           templen = strlen(temp):
 
-            bytes += (int)strlen(temp);
+            bytes += (int)templen;
 
             if (bufptr)
            {
-             if ((bufptr + strlen(temp)) > bufend)
+             if ((bufptr + templen) > bufend)
              {
-               strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+               strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
                bufptr = bufend;
              }
              else
              {
-               strcpy(bufptr, temp);
-               bufptr += strlen(temp);
+               memcpy(bufptr, temp, templen + 1);
+               bufptr += templen;
              }
            }
            break;
@@ -224,20 +215,21 @@ _cups_vsnprintf(char       *buffer,       /* O - Output buffer */
              break;
 
            sprintf(temp, tformat, va_arg(ap, int));
+           templen = strlen(temp):
 
-            bytes += (int)strlen(temp);
+            bytes += (int)templen;
 
            if (bufptr)
            {
-             if ((bufptr + strlen(temp)) > bufend)
+             if ((bufptr + templen) > bufend)
              {
-               strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+               strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
                bufptr = bufend;
              }
              else
              {
-               strcpy(bufptr, temp);
-               bufptr += strlen(temp);
+               memcpy(bufptr, temp, templen + 1);
+               bufptr += templen;
              }
            }
            break;
@@ -247,20 +239,21 @@ _cups_vsnprintf(char       *buffer,       /* O - Output buffer */
              break;
 
            sprintf(temp, tformat, va_arg(ap, void *));
+           templen = strlen(temp):
 
-            bytes += (int)strlen(temp);
+            bytes += (int)templen;
 
            if (bufptr)
            {
-             if ((bufptr + strlen(temp)) > bufend)
+             if ((bufptr + templen) > bufend)
              {
-               strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+               strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
                bufptr = bufend;
              }
              else
              {
-               strcpy(bufptr, temp);
-               bufptr += strlen(temp);
+               memcpy(bufptr, temp, templen + 1);
+               bufptr += templen;
              }
            }
            break;
@@ -303,13 +296,13 @@ _cups_vsnprintf(char       *buffer,       /* O - Output buffer */
 
              if (sign == '-')
              {
-               strncpy(bufptr, s, (size_t)slen);
+               memcpy(bufptr, s, (size_t)slen);
                memset(bufptr + slen, ' ', (size_t)(width - slen));
              }
              else
              {
                memset(bufptr, ' ', (size_t)(width - slen));
-               strncpy(bufptr + width - slen, s, (size_t)slen);
+               memcpy(bufptr + width - slen, s, (size_t)slen);
              }
 
              bufptr += width;
@@ -368,6 +361,6 @@ _cups_snprintf(char       *buffer,  /* O - Output buffer */
 
 
 /*
- * End of "$Id: snprintf.c 6188 2007-01-10 16:23:06Z mike $".
+ * End of "$Id$".
  */