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