Fixed a crash caused by yadif deinterlacer on Windows XP
[vlc/solaris.git] / src / test / xmlent.c
blob6c04093a2fbe76ff84ebd80dd8d0dfee6ab272a3
1 /*****************************************************************************
2 * xmlent.c: Test for XML entities
3 *****************************************************************************
4 * Copyright (C) 2006, 2008 Rémi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
29 #include <vlc_common.h>
30 #include <vlc_strings.h>
32 static void decode (const char *in, const char *out)
34 char buf[strlen (in) + 1];
36 printf ("\"%s\" -> \"%s\" ?\n", in, out);
37 strcpy (buf, in);
38 resolve_xml_special_chars (buf);
40 if (strcmp (buf, out))
42 printf (" ERROR: got \"%s\"\n", buf);
43 exit (2);
47 static void encode (const char *in, const char *out)
49 char *buf;
51 printf ("\"%s\" -> \"%s\" ?\n", in, out);
52 buf = convert_xml_special_chars (in);
54 if (strcmp (buf, out))
56 printf (" ERROR: got \"%s\"\n", buf);
57 exit (2);
59 free (buf);
62 int main (void)
64 (void)setvbuf (stdout, NULL, _IONBF, 0);
65 decode ("This should not be modified 1234",
66 "This should not be modified 1234");
68 decode ("R&eacute;mi&nbsp;Fran&ccedil;ois&nbsp;&amp;&nbsp;&Eacute;mile",
69 "Rémi François & Émile");
71 decode ("", "");
73 /* tests with invalid input */
74 decode ("&<\"'", "&<\"'");
75 decode ("&oelig", "&oelig");
77 encode ("", "");
78 encode ("a'àc\"çe&én<ño>ö1:", "a&#39;àc&quot;çe&amp;én&lt;ño&gt;ö1:");
79 encode ("\x01\xC2\x81\xC2\x85", "&#1;&#129;\xC2\x85");
80 encode ("\r\n", "\r\n");
82 return 0;