Returning a string stored in a local BMessage doesn't work.

Instead use a BString object as return type that copies the string
so that it stays valid after return.
This commit is contained in:
Michael Lotz 2011-12-07 00:26:07 +01:00
parent f28e19f5be
commit 674e76845d

View File

@ -11,6 +11,7 @@
#include <Locale.h>
#include <LocaleRoster.h>
#include <Message.h>
#include <String.h>
#include <getopt.h>
#include <stdio.h>
@ -21,7 +22,7 @@ extern const char *__progname;
static const char *kProgramName = __progname;
const char*
BString
preferred_language()
{
BMessage preferredLanguages;
@ -75,10 +76,10 @@ main(int argc, char **argv)
while ((c = getopt_long(argc, argv, "lcfh", longopts, NULL)) != -1) {
switch (c) {
case 'l':
printf("%s\n", preferred_language());
printf("%s\n", preferred_language().String());
break;
case 'c':
printf("%s.UTF-8\n", preferred_language());
printf("%s.UTF-8\n", preferred_language().String());
break;
case 'f':
print_formatting_conventions();