~ubuntu-branches/ubuntu/precise/flac/precise-updates

« back to all changes in this revision

Viewing changes to src/share/utf8/utf8.c

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-05-29 22:56:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529225636-ljeff8xxip09qaap
Tags: 1.1.4-1
* New upstream release. closes: #405167, #411311
  - libOggFLAC and libOggFLAC++ have been merged into libFLAC, so
    remove their corresponding packages.
  - Because of the API changes required to effect the above, there has
    been yet another soname bump. libflac7 -> libflac8 and
    libflac++5 -> libflac++6. Emails have been dispatched to the
    maintainers of dependent packages.
* Some notes on patches that were removed:
  - 02_stdin_stdout, 06_manpage_mention_utf8_convert: merged upstream
  - 08_manpage_warnings: Upstream has changed the manpage so it defintely
    can't fit in in 80 cols, so just forget about it. We'll live.
  - 05_eof_warnings_are_errors: Upstream decided to add a -w option to
    flac to treat all warnings as errors. I am going to defer to that
    for now, but if people think it's stupid let me know and I'll port
    the patch forward.
  - 04_stack_smasher: was a backport from 1.1.3, so it's obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 * Convert a string between UTF-8 and the locale's charset.
22
22
 */
23
23
 
 
24
#if HAVE_CONFIG_H
 
25
#  include <config.h>
 
26
#endif
 
27
 
24
28
#include <stdlib.h>
25
29
#include <string.h>
26
30
 
27
 
#ifdef HAVE_CONFIG_H
28
 
#include <config.h>
29
 
#endif
30
 
 
31
31
#include "utf8.h"
32
32
#include "charset.h"
33
33
 
231
231
             const char *from, size_t fromlen,
232
232
             char **to, size_t *tolen);
233
233
 
234
 
static char *current_charset = 0; /* means "US-ASCII" */
235
 
 
236
 
void convert_set_charset(const char *charset)
 
234
static const char *current_charset(void)
237
235
{
238
 
 
 
236
  const char *c = 0;
239
237
#ifdef HAVE_LANGINFO_CODESET
240
 
  if (!charset)
241
 
    charset = nl_langinfo(CODESET);
 
238
  c = nl_langinfo(CODESET);
242
239
#endif
243
240
 
244
 
  if (!charset)
245
 
    charset = getenv("CHARSET");
 
241
  if (!c)
 
242
    c = getenv("CHARSET");
246
243
 
247
 
  free(current_charset);
248
 
  current_charset = 0;
249
 
  if (charset && *charset)
250
 
    current_charset = strdup(charset);
 
244
  return c? c : "US-ASCII";
251
245
}
252
246
 
253
247
static int convert_buffer(const char *fromcode, const char *tocode,
300
294
{
301
295
  char *charset;
302
296
 
303
 
  if (!current_charset)
304
 
    convert_set_charset(0);
305
 
  charset = current_charset ? current_charset : "US-ASCII";
306
 
  return convert_string(charset, "UTF-8", from, to, '#');
 
297
  return convert_string(current_charset(), "UTF-8", from, to, '#');
307
298
}
308
299
 
309
300
int utf8_decode(const char *from, char **to)
310
301
{
311
302
  char *charset;
312
303
 
313
 
  if (!current_charset)
314
 
    convert_set_charset(0);
315
 
  charset = current_charset ? current_charset : "US-ASCII";
316
 
  return convert_string("UTF-8", charset, from, to, '?');
 
304
  return convert_string("UTF-8", current_charset(), from, to, '?');
317
305
}
318
306
 
319
307
#endif