Your message dated Fri, 08 Apr 2016 08:00:31 +0000
with message-id <[email protected]>
and subject line Bug#813338: fixed in icu 57.1-1
has caused the Debian Bug report #813338,
regarding Please add minimal autopkgtest
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
813338: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813338
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: icu
Severity: wishlist

Hi,
when doing security fixes on the package (e.g. during LTS work) its
always nice to know one didn't break the package completely (e.g. by an
error in the build environment). The time is better spent on testing
the specific results of the security change.

The attached autopkgtest aims to provide that certainty by building a
small example program and by executing some of the toos.

Please consider it for the next version.
Cheers,
 -- Guido

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'stable-updates'), (500, 'unstable'), 
(500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.1.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
>From 6baef176a37a8d0d35bcc2b732221120529d467c Mon Sep 17 00:00:00 2001
Message-Id: <6baef176a37a8d0d35bcc2b732221120529d467c.1454268283.git....@sigxcpu.org>
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <[email protected]>
Date: Sun, 31 Jan 2016 12:01:16 +0100
Subject: [PATCH] Add build and smoke autopkgtest

When working on security updates besides looking for specific
regressions one wants to also check basic functionality. To not have to
do this by hand add some very basic autopkgtests.
---
 debian/tests/build-test  |  10 +
 debian/tests/control     |   7 +
 debian/tests/smoke       |  11 +
 debian/tests/ustring.cpp | 600 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 628 insertions(+)
 create mode 100755 debian/tests/build-test
 create mode 100644 debian/tests/control
 create mode 100755 debian/tests/smoke
 create mode 100644 debian/tests/ustring.cpp

diff --git a/debian/tests/build-test b/debian/tests/build-test
new file mode 100755
index 0000000..1de6ecb
--- /dev/null
+++ b/debian/tests/build-test
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+
+CFLAGS=$(shell pkg-config --cflags icu-io)
+LIBS=$(shell pkg-config --libs icu-io)
+
+a.out: debian/tests/ustring.cpp
+	g++ $(CFLAGS) $< $(LIBS)
+	@echo "Build test of $< succeeded"
+	./a.out
+	@rm -f a.out
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..ce2c1e5
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,7 @@
+Tests: smoke
+Depends: @
+Restrictions: allow-stderr
+
+Tests: build-test
+Depends: libicu-dev, pkg-config
+Restrictions: allow-stderr
diff --git a/debian/tests/smoke b/debian/tests/smoke
new file mode 100755
index 0000000..88c2f1f
--- /dev/null
+++ b/debian/tests/smoke
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+set -x
+
+# Smoke test some of the tools
+uconv -f utf8 -t latin1 /etc/hostname
+icu-config --unicode-version
+
+echo 'Smoke test of test driver succesful'
+exit 0
diff --git a/debian/tests/ustring.cpp b/debian/tests/ustring.cpp
new file mode 100644
index 0000000..43254d8
--- /dev/null
+++ b/debian/tests/ustring.cpp
@@ -0,0 +1,600 @@
+/*
+ * Simple compile test, based on samples/ustring which is:
+*******************************************************************************
+*
+*   Copyright (C) 2000-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#include <stdio.h>
+#include <unicode/utypes.h>
+#include <unicode/uchar.h>
+#include <unicode/locid.h>
+#include <unicode/ustring.h>
+#include <unicode/ucnv.h>
+#include <unicode/unistr.h>
+
+#define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
+// helper functions -------------------------------------------------------- ***
+
+// default converter for the platform encoding
+static UConverter *cnv=NULL;
+
+static void
+printUString(const char *announce, const UChar *s, int32_t length) {
+    static char out[200];
+    UChar32 c;
+    int32_t i;
+    UErrorCode errorCode=U_ZERO_ERROR;
+
+    /*
+     * Convert to the "platform encoding". See notes in printUnicodeString().
+     * ucnv_fromUChars(), like most ICU APIs understands length==-1
+     * to mean that the string is NUL-terminated.
+     */
+    ucnv_fromUChars(cnv, out, sizeof(out), s, length, &errorCode);
+    if(U_FAILURE(errorCode) || errorCode==U_STRING_NOT_TERMINATED_WARNING) {
+        printf("%sproblem converting string from Unicode: %s\n", announce, u_errorName(errorCode));
+        return;
+    }
+
+    printf("%s%s {", announce, out);
+
+    /* output the code points (not code units) */
+    if(length>=0) {
+        /* s is not NUL-terminated */
+        for(i=0; i<length; /* U16_NEXT post-increments */) {
+            U16_NEXT(s, i, length, c);
+            printf(" %04x", c);
+        }
+    } else {
+        /* s is NUL-terminated */
+        for(i=0; /* condition in loop body */; /* U16_NEXT post-increments */) {
+            U16_NEXT(s, i, length, c);
+            if(c==0) {
+                break;
+            }
+            printf(" %04x", c);
+        }
+    }
+    printf(" }\n");
+}
+
+static void
+printUnicodeString(const char *announce, const UnicodeString &s) {
+    static char out[200];
+    int32_t i, length;
+
+    // output the string, converted to the platform encoding
+
+    // Note for Windows: The "platform encoding" defaults to the "ANSI codepage",
+    // which is different from the "OEM codepage" in the console window.
+    // However, if you pipe the output into a file and look at it with Notepad
+    // or similar, then "ANSI" characters will show correctly.
+    // Production code should be aware of what encoding is required,
+    // and use a UConverter or at least a charset name explicitly.
+    out[s.extract(0, 99, out)]=0;
+    printf("%s%s {", announce, out);
+
+    // output the code units (not code points)
+    length=s.length();
+    for(i=0; i<length; ++i) {
+        printf(" %04x", s.charAt(i));
+    }
+    printf(" }\n");
+}
+
+// sample code for utf.h macros -------------------------------------------- ***
+
+static void
+demo_utf_h_macros() {
+    static UChar input[]={ 0x0061, 0xd800, 0xdc00, 0xdbff, 0xdfff, 0x0062 };
+    UChar32 c;
+    int32_t i;
+    UBool isError;
+
+    printf("\n* demo_utf_h_macros() -------------- ***\n\n");
+
+    printUString("iterate forward through: ", input, UPRV_LENGTHOF(input));
+    for(i=0; i<UPRV_LENGTHOF(input); /* U16_NEXT post-increments */) {
+        /* Iterating forwards 
+           Codepoint at offset 0: U+0061
+           Codepoint at offset 1: U+10000
+           Codepoint at offset 3: U+10ffff
+           Codepoint at offset 5: U+0062
+        */
+        printf("Codepoint at offset %d: U+", i);
+        U16_NEXT(input, i, UPRV_LENGTHOF(input), c);
+        printf("%04x\n", c); 
+    }
+
+    puts("");
+
+    isError=FALSE;
+    i=1; /* write position, gets post-incremented so needs to be in an l-value */
+    U16_APPEND(input, i, UPRV_LENGTHOF(input), 0x0062, isError);
+
+    printUString("iterate backward through: ", input, UPRV_LENGTHOF(input));
+    for(i=UPRV_LENGTHOF(input); i>0; /* U16_PREV pre-decrements */) {
+        U16_PREV(input, 0, i, c);
+        /* Iterating backwards
+           Codepoint at offset 5: U+0062
+           Codepoint at offset 3: U+10ffff
+           Codepoint at offset 2: U+dc00 -- unpaired surrogate because lead surr. overwritten
+           Codepoint at offset 1: U+0062 -- by this BMP code point
+           Codepoint at offset 0: U+0061
+        */
+        printf("Codepoint at offset %d: U+%04x\n", i, c);
+    }
+}
+
+// sample code for Unicode strings in C ------------------------------------ ***
+
+static void demo_C_Unicode_strings() {
+    printf("\n* demo_C_Unicode_strings() --------- ***\n\n");
+
+    static const UChar text[]={ 0x41, 0x42, 0x43, 0 };          /* "ABC" */
+    static const UChar appendText[]={ 0x61, 0x62, 0x63, 0 };    /* "abc" */
+    static const UChar cmpText[]={ 0x61, 0x53, 0x73, 0x43, 0 }; /* "aSsC" */
+    UChar buffer[32];
+    int32_t compare;
+    int32_t length=u_strlen(text); /* length=3 */
+
+    /* simple ANSI C-style functions */
+    buffer[0]=0;                    /* empty, NUL-terminated string */
+    u_strncat(buffer, text, 1);     /* append just n=1 character ('A') */
+    u_strcat(buffer, appendText);   /* buffer=="Aabc" */
+    length=u_strlen(buffer);        /* length=4 */
+    printUString("should be \"Aabc\": ", buffer, -1);
+
+    /* bitwise comparing buffer with text */
+    compare=u_strcmp(buffer, text);
+    if(compare<=0) {
+        printf("String comparison error, expected \"Aabc\" > \"ABC\"\n");
+    }
+
+    /* Build "A<sharp s>C" in the buffer... */
+    u_strcpy(buffer, text);
+    buffer[1]=0xdf; /* sharp s, case-compares equal to "ss" */
+    printUString("should be \"A<sharp s>C\": ", buffer, -1);
+
+    /* Compare two strings case-insensitively using full case folding */
+    compare=u_strcasecmp(buffer, cmpText, U_FOLD_CASE_DEFAULT);
+    if(compare!=0) {
+        printf("String case insensitive comparison error, expected \"AbC\" to be equal to \"ABC\"\n");
+    }
+}
+
+// sample code for case mappings with C APIs -------------------------------- ***
+
+static void demoCaseMapInC() {
+    /*
+     * input=
+     *   "aB<capital sigma>"
+     *   "iI<small dotless i><capital dotted I> "
+     *   "<sharp s> <small lig. ffi>"
+     *   "<small final sigma><small sigma><capital sigma>"
+     */
+    static const UChar input[]={
+        0x61, 0x42, 0x3a3,
+        0x69, 0x49, 0x131, 0x130, 0x20,
+        0xdf, 0x20, 0xfb03,
+        0x3c2, 0x3c3, 0x3a3, 0
+    };
+    UChar buffer[32];
+
+    UErrorCode errorCode;
+    UChar32 c;
+    int32_t i, j, length;
+    UBool isError;
+
+    printf("\n* demoCaseMapInC() ----------------- ***\n\n");
+
+    /*
+     * First, use simple case mapping functions which provide
+     * 1:1 code point mappings without context/locale ID.
+     *
+     * Note that some mappings will not be "right" because some "real"
+     * case mappings require context, depend on the locale ID,
+     * and/or result in a change in the number of code points.
+     */
+    printUString("input string: ", input, -1);
+
+    /* uppercase */
+    isError=FALSE;
+    for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+        U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
+        if(c==0) {
+            break; /* stop at terminating NUL, no need to terminate buffer */
+        }
+        c=u_toupper(c);
+        U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError);
+    }
+    printUString("simple-uppercased: ", buffer, j);
+    /* lowercase */
+    isError=FALSE;
+    for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+        U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
+        if(c==0) {
+            break; /* stop at terminating NUL, no need to terminate buffer */
+        }
+        c=u_tolower(c);
+        U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError);
+    }
+    printUString("simple-lowercased: ", buffer, j);
+    /* titlecase */
+    isError=FALSE;
+    for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+        U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
+        if(c==0) {
+            break; /* stop at terminating NUL, no need to terminate buffer */
+        }
+        c=u_totitle(c);
+        U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError);
+    }
+    printUString("simple-titlecased: ", buffer, j);
+    /* case-fold/default */
+    isError=FALSE;
+    for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+        U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
+        if(c==0) {
+            break; /* stop at terminating NUL, no need to terminate buffer */
+        }
+        c=u_foldCase(c, U_FOLD_CASE_DEFAULT);
+        U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError);
+    }
+    printUString("simple-case-folded/default: ", buffer, j);
+    /* case-fold/Turkic */
+    isError=FALSE;
+    for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+        U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
+        if(c==0) {
+            break; /* stop at terminating NUL, no need to terminate buffer */
+        }
+        c=u_foldCase(c, U_FOLD_CASE_EXCLUDE_SPECIAL_I);
+        U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError);
+    }
+    printUString("simple-case-folded/Turkic: ", buffer, j);
+
+    /*
+     * Second, use full case mapping functions which provide
+     * 1:n code point mappings (n can be 0!) and are sensitive to context and locale ID.
+     *
+     * Note that lower/upper/titlecasing take a locale ID while case-folding
+     * has bit flag options instead, by design of the Unicode SpecialCasing.txt UCD file.
+     *
+     * Also, string titlecasing requires a BreakIterator to find starts of words.
+     * The sample code here passes in a NULL pointer; u_strToTitle() will open and close a default
+     * titlecasing BreakIterator automatically.
+     * For production code where many strings are titlecased it would be more efficient
+     * to open a BreakIterator externally and pass it in.
+     */
+    printUString("\ninput string: ", input, -1);
+
+    /* lowercase/English */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToLower(buffer, UPRV_LENGTHOF(buffer), input, -1, "en", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-lowercased/en: ", buffer, length);
+    } else {
+        printf("error in u_strToLower(en)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* lowercase/Turkish */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToLower(buffer, UPRV_LENGTHOF(buffer), input, -1, "tr", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-lowercased/tr: ", buffer, length);
+    } else {
+        printf("error in u_strToLower(tr)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* uppercase/English */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToUpper(buffer, UPRV_LENGTHOF(buffer), input, -1, "en", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-uppercased/en: ", buffer, length);
+    } else {
+        printf("error in u_strToUpper(en)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* uppercase/Turkish */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToUpper(buffer, UPRV_LENGTHOF(buffer), input, -1, "tr", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-uppercased/tr: ", buffer, length);
+    } else {
+        printf("error in u_strToUpper(tr)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* titlecase/English */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToTitle(buffer, UPRV_LENGTHOF(buffer), input, -1, NULL, "en", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-titlecased/en: ", buffer, length);
+    } else {
+        printf("error in u_strToTitle(en)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* titlecase/Turkish */
+    errorCode=U_ZERO_ERROR;
+    length=u_strToTitle(buffer, UPRV_LENGTHOF(buffer), input, -1, NULL, "tr", &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-titlecased/tr: ", buffer, length);
+    } else {
+        printf("error in u_strToTitle(tr)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* case-fold/default */
+    errorCode=U_ZERO_ERROR;
+    length=u_strFoldCase(buffer, UPRV_LENGTHOF(buffer), input, -1, U_FOLD_CASE_DEFAULT, &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-case-folded/default: ", buffer, length);
+    } else {
+        printf("error in u_strFoldCase(default)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+    /* case-fold/Turkic */
+    errorCode=U_ZERO_ERROR;
+    length=u_strFoldCase(buffer, UPRV_LENGTHOF(buffer), input, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode);
+    if(U_SUCCESS(errorCode)) {
+        printUString("full-case-folded/Turkic: ", buffer, length);
+    } else {
+        printf("error in u_strFoldCase(Turkic)=%ld error=%s\n", length, u_errorName(errorCode));
+    }
+}
+
+// sample code for case mappings with C++ APIs ------------------------------ ***
+
+static void demoCaseMapInCPlusPlus() {
+    /*
+     * input=
+     *   "aB<capital sigma>"
+     *   "iI<small dotless i><capital dotted I> "
+     *   "<sharp s> <small lig. ffi>"
+     *   "<small final sigma><small sigma><capital sigma>"
+     */
+    static const UChar input[]={
+        0x61, 0x42, 0x3a3,
+        0x69, 0x49, 0x131, 0x130, 0x20,
+        0xdf, 0x20, 0xfb03,
+        0x3c2, 0x3c3, 0x3a3, 0
+    };
+
+    printf("\n* demoCaseMapInCPlusPlus() --------- ***\n\n");
+
+    UnicodeString s(input), t;
+    const Locale &en=Locale::getEnglish();
+    Locale tr("tr");
+
+    /*
+     * Full case mappings as in demoCaseMapInC(), using UnicodeString functions.
+     * These functions modify the string object itself.
+     * Since we want to keep the input string around, we copy it each time
+     * and case-map the copy.
+     */
+    printUnicodeString("input string: ", s);
+
+    /* lowercase/English */
+    printUnicodeString("full-lowercased/en: ", (t=s).toLower(en));
+    /* lowercase/Turkish */
+    printUnicodeString("full-lowercased/tr: ", (t=s).toLower(tr));
+    /* uppercase/English */
+    printUnicodeString("full-uppercased/en: ", (t=s).toUpper(en));
+    /* uppercase/Turkish */
+    printUnicodeString("full-uppercased/tr: ", (t=s).toUpper(tr));
+    /* titlecase/English */
+    printUnicodeString("full-titlecased/en: ", (t=s).toTitle(NULL, en));
+    /* titlecase/Turkish */
+    printUnicodeString("full-titlecased/tr: ", (t=s).toTitle(NULL, tr));
+    /* case-folde/default */
+    printUnicodeString("full-case-folded/default: ", (t=s).foldCase(U_FOLD_CASE_DEFAULT));
+    /* case-folde/Turkic */
+    printUnicodeString("full-case-folded/Turkic: ", (t=s).foldCase(U_FOLD_CASE_EXCLUDE_SPECIAL_I));
+}
+
+// sample code for UnicodeString storage models ----------------------------- ***
+
+static const UChar readonly[]={
+    0x61, 0x31, 0x20ac
+};
+static UChar writeable[]={
+    0x62, 0x32, 0xdbc0, 0xdc01 // includes a surrogate pair for a supplementary code point
+};
+static char out[100];
+
+static void
+demoUnicodeStringStorage() {
+    // These sample code lines illustrate how to use UnicodeString, and the
+    // comments tell what happens internally. There are no APIs to observe
+    // most of this programmatically, except for stepping into the code
+    // with a debugger.
+    // This is by design to hide such details from the user.
+    int32_t i;
+
+    printf("\n* demoUnicodeStringStorage() ------- ***\n\n");
+
+    // * UnicodeString with internally stored contents
+    // instantiate a UnicodeString from a single code point
+    // the few (2) UChars will be stored in the object itself
+    UnicodeString one((UChar32)0x24001);
+    // this copies the few UChars into the "two" object
+    UnicodeString two=one;
+    printf("length of short string copy: %d\n", two.length());
+    // set "one" to contain the 3 UChars from readonly
+    // this setTo() variant copies the characters
+    one.setTo(readonly, UPRV_LENGTHOF(readonly));
+
+    // * UnicodeString with allocated contents
+    // build a longer string that will not fit into the object's buffer
+    one+=UnicodeString(writeable, UPRV_LENGTHOF(writeable));
+    one+=one;
+    one+=one;
+    printf("length of longer string: %d\n", one.length());
+    // copying will use the same allocated buffer and increment the reference
+    // counter
+    two=one;
+    printf("length of longer string copy: %d\n", two.length());
+
+    // * UnicodeString using readonly-alias to a const UChar array
+    // construct a string that aliases a readonly buffer
+    UnicodeString three(FALSE, readonly, UPRV_LENGTHOF(readonly));
+    printUnicodeString("readonly-alias string: ", three);
+    // copy-on-write: any modification to the string results in
+    // a copy to either the internal buffer or to a newly allocated one
+    three.setCharAt(1, 0x39);
+    printUnicodeString("readonly-aliasing string after modification: ", three);
+    // the aliased array is not modified
+    for(i=0; i<three.length(); ++i) {
+        printf("readonly buffer[%d] after modifying its string: 0x%lx\n",
+               i, readonly[i]);
+    }
+    // setTo() readonly alias
+    one.setTo(FALSE, writeable, UPRV_LENGTHOF(writeable));
+    // copying the readonly-alias object with fastCopyFrom() (new in ICU 2.4)
+    // will readonly-alias the same buffer
+    two.fastCopyFrom(one);
+    printUnicodeString("fastCopyFrom(readonly alias of \"writeable\" array): ", two);
+    printf("verify that a fastCopyFrom(readonly alias) uses the same buffer pointer: %d (should be 1)\n",
+        one.getBuffer()==two.getBuffer());
+    // a normal assignment will clone the contents (new in ICU 2.4)
+    two=one;
+    printf("verify that a regular copy of a readonly alias uses a different buffer pointer: %d (should be 0)\n",
+        one.getBuffer()==two.getBuffer());
+
+    // * UnicodeString using writeable-alias to a non-const UChar array
+    UnicodeString four(writeable, UPRV_LENGTHOF(writeable), UPRV_LENGTHOF(writeable));
+    printUnicodeString("writeable-alias string: ", four);
+    // a modification writes through to the buffer
+    four.setCharAt(1, 0x39);
+    for(i=0; i<four.length(); ++i) {
+        printf("writeable-alias backing buffer[%d]=0x%lx "
+               "after modification\n", i, writeable[i]);
+    }
+    // a copy will not alias any more;
+    // instead, it will get a copy of the contents into allocated memory
+    two=four;
+    two.setCharAt(1, 0x21);
+    for(i=0; i<two.length(); ++i) {
+        printf("writeable-alias backing buffer[%d]=0x%lx after "
+               "modification of string copy\n", i, writeable[i]);
+    }
+    // setTo() writeable alias, capacity==length
+    one.setTo(writeable, UPRV_LENGTHOF(writeable), UPRV_LENGTHOF(writeable));
+    // grow the string - it will not fit into the backing buffer any more
+    // and will get copied before modification
+    one.append((UChar)0x40);
+    // shrink it back so it would fit
+    one.truncate(one.length()-1);
+    // we still operate on the copy
+    one.setCharAt(1, 0x25);
+    printf("string after growing too much and then shrinking[1]=0x%lx\n"
+           "                          backing store for this[1]=0x%lx\n",
+           one.charAt(1), writeable[1]);
+    // if we need it in the original buffer, then extract() to it
+    // extract() does not do anything if the string aliases that same buffer
+    // i=min(one.length(), length of array)
+    if(one.length()<UPRV_LENGTHOF(writeable)) {
+        i=one.length();
+    } else {
+        i=UPRV_LENGTHOF(writeable);
+    }
+    one.extract(0, i, writeable);
+    for(i=0; i<UPRV_LENGTHOF(writeable); ++i) {
+        printf("writeable-alias backing buffer[%d]=0x%lx after re-extract\n",
+               i, writeable[i]);
+    }
+}
+
+// sample code for UnicodeString instantiations ----------------------------- ***
+
+static void
+demoUnicodeStringInit() {
+    // *** Make sure to read about invariant characters in utypes.h! ***
+    // Initialization of Unicode strings from C literals works _only_ for
+    // invariant characters!
+
+    printf("\n* demoUnicodeStringInit() ---------- ***\n\n");
+
+    // the string literal is 32 chars long - this must be counted for the macro
+    UnicodeString invariantOnly=UNICODE_STRING("such characters are safe 123 %-.", 32);
+
+    /*
+     * In C, we need two macros: one to declare the UChar[] array, and
+     * one to populate it; the second one is a noop on platforms where
+     * wchar_t is compatible with UChar and ASCII-based.
+     * The length of the string literal must be counted for both macros.
+     */
+    /* declare the invString array for the string */
+    U_STRING_DECL(invString, "such characters are safe 123 %-.", 32);
+    /* populate it with the characters */
+    U_STRING_INIT(invString, "such characters are safe 123 %-.", 32);
+
+    // compare the C and C++ strings
+    printf("C and C++ Unicode strings are equal: %d\n", invariantOnly==UnicodeString(TRUE, invString, 32));
+
+    /*
+     * convert between char * and UChar * strings that
+     * contain only invariant characters
+     */
+    static const char *cs1="such characters are safe 123 %-.";
+    static UChar us1[40];
+    static char cs2[40];
+    u_charsToUChars(cs1, us1, 33); /* include the terminating NUL */
+    u_UCharsToChars(us1, cs2, 33);
+    printf("char * -> UChar * -> char * with only "
+           "invariant characters: \"%s\"\n",
+           cs2);
+
+    // initialize a UnicodeString from a string literal that contains
+    // escape sequences written with invariant characters
+    // do not forget to duplicate the backslashes for ICU to see them
+    // then, count each double backslash only once!
+    UnicodeString german=UNICODE_STRING(
+        "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n", 64).
+        unescape();
+    printUnicodeString("german UnicodeString from unescaping:\n    ", german);
+
+    /*
+     * C: convert and unescape a char * string with only invariant
+     * characters to fill a UChar * string
+     */
+    UChar buffer[200];
+    int32_t length;
+    length=u_unescape(
+        "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n",
+        buffer, UPRV_LENGTHOF(buffer));
+    printf("german C Unicode string from char * unescaping: (length %d)\n    ", length);
+    printUnicodeString("", UnicodeString(buffer));
+}
+
+extern int
+main(int argc, const char *argv[]) {
+    UErrorCode errorCode=U_ZERO_ERROR;
+
+    // Note: Using a global variable for any object is not exactly thread-safe...
+
+    // You can change this call to e.g. ucnv_open("UTF-8", &errorCode) if you pipe
+    // the output to a file and look at it with a Unicode-capable editor.
+    // This will currently affect only the printUString() function, see the code above.
+    // printUnicodeString() could use this, too, by changing to an extract() overload
+    // that takes a UConverter argument.
+    cnv=ucnv_open(NULL, &errorCode);
+    if(U_FAILURE(errorCode)) {
+        fprintf(stderr, "error %s opening the default converter\n", u_errorName(errorCode));
+        return errorCode;
+    }
+
+    ucnv_setFromUCallBack(cnv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C, NULL, NULL, &errorCode);
+    if(U_FAILURE(errorCode)) {
+        fprintf(stderr, "error %s setting the escape callback in the default converter\n", u_errorName(errorCode));
+        ucnv_close(cnv);
+        return errorCode;
+    }
+
+    demo_utf_h_macros();
+    demo_C_Unicode_strings();
+    demoCaseMapInC();
+    demoCaseMapInCPlusPlus();
+    demoUnicodeStringStorage();
+    demoUnicodeStringInit();
+
+    ucnv_close(cnv);
+    return 0;
+}
-- 
2.7.0.rc3


--- End Message ---
--- Begin Message ---
Source: icu
Source-Version: 57.1-1

We believe that the bug you reported is fixed in the latest version of
icu, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Laszlo Boszormenyi (GCS) <[email protected]> (supplier of updated icu package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sun, 27 Mar 2016 10:46:16 +0000
Source: icu
Binary: libicu57 libicu57-dbg libicu-dev icu-devtools icu-devtools-dbg icu-doc
Architecture: source amd64 all
Version: 57.1-1
Distribution: experimental
Urgency: low
Maintainer: Laszlo Boszormenyi (GCS) <[email protected]>
Changed-By: Laszlo Boszormenyi (GCS) <[email protected]>
Description:
 icu-devtools - Development utilities for International Components for Unicode
 icu-devtools-dbg - Development utilities for International Components for 
Unicode (d
 icu-doc    - API documentation for ICU classes and functions
 libicu-dev - Development files for International Components for Unicode
 libicu57   - International Components for Unicode
 libicu57-dbg - International Components for Unicode (debug symbols)
Closes: 776821 804026 813338
Changes:
 icu (57.1-1) experimental; urgency=low
 .
   * New major upstream release (closes: #804026).
   * Update package names due to soname bump.
   * Add icu-devtools debug package.
   * Drop CVE-2015-2632.patch as this release contains it.
   * Update patches.
   * Keep rebuildable.
   * Update Standars-Version to 3.9.7 .
 .
   [ Helmut Grohne <[email protected]> ]
   * Move icu-config to a M-A:no package (closes: #776821).
     + Move icu-config from icu-devtools to libicu-dev.
     + Declare relevant Breaks and Replaces.
     + Remove Multi-Arch:same from libicu-dev.
 .
   [ Guido Günther <[email protected]> ]
   * Add build and smoke autopkgtest (closes: #813338).
Checksums-Sha1:
 d3a06aaeb9e2a00cff5e4e119676161c42e7be8e 2097 icu_57.1-1.dsc
 ca5f5cc584f45e87bf56bf8b7f9244d12a5ada67 22360664 icu_57.1.orig.tar.gz
 cde09418e396cdead3e9f2bd549df27212afaadc 26464 icu_57.1-1.debian.tar.xz
 51d9735e4b04c33aafb98e7e8b730b4a51ac329e 615970 
icu-devtools-dbg_57.1-1_amd64.deb
 8b93dbe5451515ce4fa6451ac810558e48fe86d7 172356 icu-devtools_57.1-1_amd64.deb
 0fc819c9d317dba5069941970d00aa6ab3e4646a 2311784 icu-doc_57.1-1_all.deb
 f5e56c161ecf51b51635268802d4185ea37d17bf 16137672 libicu-dev_57.1-1_amd64.deb
 3c59b2b18aafb75085bf8a6127bc926dec2a2607 7159580 libicu57-dbg_57.1-1_amd64.deb
 76402c5b9aafd3d880233a05f5e35e706eb88f2f 7685806 libicu57_57.1-1_amd64.deb
Checksums-Sha256:
 1a1345d6922e8ed6d2a4875833dabbc6e0d021425af35683a9ca0e3d396653e5 2097 
icu_57.1-1.dsc
 ff8c67cb65949b1e7808f2359f2b80f722697048e90e7cfc382ec1fe229e9581 22360664 
icu_57.1.orig.tar.gz
 cbb5a11bb69298f89b24af2b0f64a580b874754b7c8fab0778e5f84a42d587ff 26464 
icu_57.1-1.debian.tar.xz
 9204f5ec317d310e4ba61ae80f7ee46e200e805b543f540152a029b498ba9c43 615970 
icu-devtools-dbg_57.1-1_amd64.deb
 eeb7aa262fe10ee9d557ba892b014a05d1254f76694881d490da32e3c45c41d5 172356 
icu-devtools_57.1-1_amd64.deb
 d2efc1777fca3922c1932477734e9cd81c2641e489c3368e00cca68981cfd053 2311784 
icu-doc_57.1-1_all.deb
 17039c5f3c9b103abf6621654682ea2a4b89cd86a2ff237805ec0dcb1d7b6b58 16137672 
libicu-dev_57.1-1_amd64.deb
 4e20f8e0830405a1c52a1528628f7624be66c04073743fd92b1185042d887c78 7159580 
libicu57-dbg_57.1-1_amd64.deb
 5e3dc8e0a732aac90cb6819f95b45d7254c31652cbb1052a861819a470d541a3 7685806 
libicu57_57.1-1_amd64.deb
Files:
 aa31b7973051ae3cba2c85c61a275413 2097 libs optional icu_57.1-1.dsc
 976734806026a4ef8bdd17937c8898b9 22360664 libs optional icu_57.1.orig.tar.gz
 7373a2c6e94f60f8ba4f5d33354a8f2a 26464 libs optional icu_57.1-1.debian.tar.xz
 1adaaba07bc4976163dd4b54020b8fee 615970 debug extra 
icu-devtools-dbg_57.1-1_amd64.deb
 d8626dd1ac65839fa674464d58564f6d 172356 libdevel optional 
icu-devtools_57.1-1_amd64.deb
 31d1995666c5bde871822f7e2160f476 2311784 doc optional icu-doc_57.1-1_all.deb
 5b78c165d8cf83643fe814c55abdf383 16137672 libdevel optional 
libicu-dev_57.1-1_amd64.deb
 c6b7ebc4ecf6ce517249cfcf88ce3073 7159580 debug extra 
libicu57-dbg_57.1-1_amd64.deb
 646480904e4478e488cdef844e49702c 7685806 libs optional 
libicu57_57.1-1_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJXAQ+JAAoJENzjEOeGTMi/jd8P/j2ThIeatR3DaI6+sxgl03p0
BPLu6yQIp/EHr73cU7NQpJ9UCjXSDawprqcqBipViqm5V2yil7vOZerplaW6COZQ
U61cnJBYQMMF7gq39tXotFPhsG9MggyN1tkWUyY6fUjqTgJ4WBoOQfe/vFn1iadY
N/wZlVn5vwhWCDeyjC84iz343KW0NNbaN7q1wTffv5JxVcXoktBbdVXF4E1HlSrD
D4muCAlbdKz8YAwMed30pw5FdWOZo2nOduoAP5Cc0yLEib4eybk1vGyNznqu1ZHw
VShBKaNHgGgh1+2lKT9OQVky4WQicQIhrzh7Fvse2NzcIM68eyNNsaRpPyND2Dun
bR7VuBlh/J/Kczc3fOQCuqOIqROvEZ+ZqImT9A+AWFGGIzWL2pNuzXEhYTeMB1Zg
sY8ndYkxN0o3BeXKfGFfHd1/PdJxNsyNpfcOkq1D5Al2MiJ5pP5eUxTVyxdfMurc
mARMjXAyNMUNRRcryKHEp8bN6dcnb/zE+tModspBzYMXLzxU6CugY8iQMWRVb9Zt
NxyOGFpnvVCPwyahL/GuuTQ/gatoES2gkWCHH9eOldjbWt35x/jLYSV+lcUwPyuP
ixlHgS084DAZbX5UzK9GNe0u6EKFaebB0UGTcH61LteaN4DyEVX1aIOnlwId31B0
gWy42AUMJR+FjxIvnqar
=5oSa
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to