]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdc-catalog.cxx
Full sweep of all Clang warnings, plus some bug fixes for incorrect memcpy usage.
[thirdparty/cups.git] / ppdc / ppdc-catalog.cxx
index f709d75e17aefe1cfa32b1d182ed05ab5a961d5b..1bf46566f0d6f8895bd6b81392c91be23c4d2e86 100644 (file)
@@ -1,29 +1,16 @@
 //
 // "$Id$"
 //
-//   Shared message catalog class for the CUPS PPD Compiler.
+// Shared message catalog class for the CUPS PPD Compiler.
 //
-//   Copyright 2007-2012 by Apple Inc.
-//   Copyright 2002-2006 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2006 by Easy Software Products.
 //
-//   These coded instructions, statements, and computer programs are the
-//   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/".
-//
-// Contents:
-//
-//   ppdcCatalog::ppdcCatalog()   - Create a shared message catalog.
-//   ppdcCatalog::~ppdcCatalog()  - Destroy a shared message catalog.
-//   ppdcCatalog::add_message()   - Add a new message.
-//   ppdcCatalog::find_message()  - Find a message in a catalog...
-//   ppdcCatalog::load_messages() - Load messages from a .po file.
-//   ppdcCatalog::save_messages() - Save the messages to a .po file.
-//   get_utf8()                   - Get a UTF-8 character.
-//   get_utf16()                  - Get a UTF-16 character...
-//   put_utf8()                   - Add a UTF-8 character to a string.
-//   put_utf16()                  - Write a UTF-16 character to a file.
+// These coded instructions, statements, and computer programs are the
+// 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/".
 //
 
 //
@@ -817,7 +804,7 @@ put_utf8(int  ch,                   // I  - Unicode character
     if (ptr >= end)
       return (-1);
 
-    *ptr++ = ch;
+    *ptr++ = (char)ch;
   }
   else if (ch < 0x800)
   {
@@ -825,8 +812,8 @@ put_utf8(int  ch,                   // I  - Unicode character
     if ((ptr + 1) >= end)
       return (-1);
 
-    *ptr++ = 0xc0 | (ch >> 6);
-    *ptr++ = 0x80 | (ch & 0x3f);
+    *ptr++ = (char)(0xc0 | (ch >> 6));
+    *ptr++ = (char)(0x80 | (ch & 0x3f));
   }
   else if (ch < 0x10000)
   {
@@ -834,9 +821,9 @@ put_utf8(int  ch,                   // I  - Unicode character
     if ((ptr + 2) >= end)
       return (-1);
 
-    *ptr++ = 0xe0 | (ch >> 12);
-    *ptr++ = 0x80 | ((ch >> 6) & 0x3f);
-    *ptr++ = 0x80 | (ch & 0x3f);
+    *ptr++ = (char)(0xe0 | (ch >> 12));
+    *ptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+    *ptr++ = (char)(0x80 | (ch & 0x3f));
   }
   else
   {
@@ -844,10 +831,10 @@ put_utf8(int  ch,                 // I  - Unicode character
     if ((ptr + 3) >= end)
       return (-1);
 
-    *ptr++ = 0xf0 | (ch >> 18);
-    *ptr++ = 0x80 | ((ch >> 12) & 0x3f);
-    *ptr++ = 0x80 | ((ch >> 6) & 0x3f);
-    *ptr++ = 0x80 | (ch & 0x3f);
+    *ptr++ = (char)(0xf0 | (ch >> 18));
+    *ptr++ = (char)(0x80 | ((ch >> 12) & 0x3f));
+    *ptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+    *ptr++ = (char)(0x80 | (ch & 0x3f));
   }
 
   return (0);
@@ -868,8 +855,8 @@ put_utf16(cups_file_t *fp,          // I - File to write to
   if (ch < 0x10000)
   {
     // One-word UTF-16 big-endian...
-    buffer[0] = ch >> 8;
-    buffer[1] = ch;
+    buffer[0] = (unsigned char)(ch >> 8);
+    buffer[1] = (unsigned char)ch;
 
     if (cupsFileWrite(fp, (char *)buffer, 2) == 2)
       return (0);
@@ -879,10 +866,10 @@ put_utf16(cups_file_t *fp,                // I - File to write to
     // Two-word UTF-16 big-endian...
     ch -= 0x10000;
 
-    buffer[0] = 0xd8 | (ch >> 18);
-    buffer[1] = ch >> 10;
-    buffer[2] = 0xdc | ((ch >> 8) & 0x03);
-    buffer[3] = ch;
+    buffer[0] = (unsigned char)(0xd8 | (ch >> 18));
+    buffer[1] = (unsigned char)(ch >> 10);
+    buffer[2] = (unsigned char)(0xdc | ((ch >> 8) & 0x03));
+    buffer[3] = (unsigned char)ch;
 
     if (cupsFileWrite(fp, (char *)buffer, 4) == 4)
       return (0);