]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdc-catalog.cxx
Merge changes from CUPS 1.5svn-r8849.
[thirdparty/cups.git] / ppdc / ppdc-catalog.cxx
index 4961851718759d4d8e5129d26a9b47773fac5532..22a2828afda4ee7a8b4e1ce5b80556e2a2b2122e 100644 (file)
@@ -3,7 +3,7 @@
 //
 //   Shared message catalog class for the CUPS PPD Compiler.
 //
-//   Copyright 2007-2008 by Apple Inc.
+//   Copyright 2007-2009 by Apple Inc.
 //   Copyright 2002-2006 by Easy Software Products.
 //
 //   These coded instructions, statements, and computer programs are the
 //
 // 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.
 //
 
 //
 // Include necessary headers...
 //
 
-#include "ppdc.h"
-#include <cups/globals.h>
+#include "ppdc-private.h"
 
 
 //
@@ -59,6 +68,8 @@ ppdcCatalog::ppdcCatalog(const char *l,       // I - Locale
                                        // Global information
 
 
+  PPDC_NEW;
+
   locale   = new ppdcString(l);
   filename = new ppdcString(f);
   messages = new ppdcArray();
@@ -96,9 +107,11 @@ ppdcCatalog::ppdcCatalog(const char *l,     // I - Locale
 
 ppdcCatalog::~ppdcCatalog()
 {
-  delete locale;
-  delete filename;
-  delete messages;
+  PPDC_DELETE;
+
+  locale->release();
+  filename->release();
+  messages->release();
 }
 
 
@@ -140,7 +153,7 @@ ppdcCatalog::add_message(
     string = text;
   }
 
-  messages->add(new ppdcMessage(id, text));
+  messages->add(new ppdcMessage(id, string));
 }
 
 
@@ -276,6 +289,7 @@ ppdcCatalog::load_messages(
       {
         // Add string...
        add_message(id, str);
+       id[0] = '\0';
       }
     }
   }
@@ -321,7 +335,7 @@ ppdcCatalog::load_messages(
       if ((ptr = (char *)strrchr(line, '\"')) == NULL)
       {
        _cupsLangPrintf(stderr,
-                       _("ERROR: Expected quoted string on line %d of %s!\n"),
+                       _("ERROR: Expected quoted string on line %d of %s\n"),
                        linenum, f);
        cupsFileClose(fp);
        return (-1);
@@ -333,7 +347,7 @@ ppdcCatalog::load_messages(
       if ((ptr = strchr(line, '\"')) == NULL)
       {
        _cupsLangPrintf(stderr,
-                       _("ERROR: Expected quoted string on line %d of %s!\n"),
+                       _("ERROR: Expected quoted string on line %d of %s\n"),
                        linenum, f);
        cupsFileClose(fp);
        return (-1);
@@ -399,7 +413,7 @@ ppdcCatalog::load_messages(
        {
          _cupsLangPrintf(stderr,
                          _("ERROR: Need a msgid line before any "
-                           "translation strings on line %d of %s!\n"),
+                           "translation strings on line %d of %s\n"),
                          linenum, f);
          cupsFileClose(fp);
          return (-1);
@@ -415,7 +429,7 @@ ppdcCatalog::load_messages(
        strlcat(id, ptr, sizeof(id));
       else
       {
-       _cupsLangPrintf(stderr, _("ERROR: Unexpected text on line %d of %s!\n"),
+       _cupsLangPrintf(stderr, _("ERROR: Unexpected text on line %d of %s\n"),
                        linenum, f);
        cupsFileClose(fp);
        return (-1);
@@ -443,7 +457,7 @@ ppdcCatalog::load_messages(
   unknown_load_format:
 
   _cupsLangPrintf(stderr,
-                  _("ERROR: Unknown message catalog format for \"%s\"!\n"), f);
+                  _("ERROR: Unknown message catalog format for \"%s\"\n"), f);
   cupsFileClose(fp);
   return (-1);
 }