gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some minor fixes for gnokii


From: Jan de Cuveland
Subject: Re: Some minor fixes for gnokii
Date: Wed, 30 Oct 2002 21:27:04 +0100
User-agent: Mutt/1.3.22.1i

On Tue, Oct 29, 2002, Pawel Kot wrote:
> Thanks for your interest and work on gnokii. You'll find the comments
> below.

Thanks for your kind response. You'll find some more comments below.

> > What do the patches do?
> > * The first corrects an obvious mistake (?) in gnooki.c.
> 
>     if (argc && (strcmp("-i", args[0])) && (strcmp("-v", args[0])))
>         usage(stderr);
> -   if (!strcmp("-v", args[0]))
> +   if (argc && !strcmp("-v", args[0]))
> 
> That's not needed. usage() does exit program. I think I'll add an argument
> int retval to this function as `gnokii --help` exits with -1.
> The other part (memory_type_string) is certainly OK.

I think the modification is indeed needed, since if no argument is
provided (argc==0), usage() will not be called, but strcmp("-v", args[0])
tries to access memory which is not allocated, which causes gnokii
to crash.

By the way, as you probably noticed, the other part was not mainly about
setting memory_type_string correctly, but inverting the if-condition from
(decodephonebook()!=NULL) to (decodephonebook()==NULL). It should now
work perfectly.
 
> > * The second increases the size of a struct. This is necessary because
> >   otherwise gnokii segfaults with some large entries. (There is no range
> >   checking, so gnokii overwrites the return address -> bad!)
> 
> I'll try to do this "more correct". We definitely need range checking
> there. Thanks for spotting.

My suggestion was just a quick hack I had used to get it working. Thanks
for the (more sophisticated) solution!

> > * The third is a patch to /common/gsm-encoding.c. The problem is, that
> >   mbtowc and wctomb do not work as desired with the special characters of
> >   a latin1 charset.
> 
> Could you put more light on this? Some example?

I'll try to.
This is my understanding of what is going on when writing to the phone:

I have my locale set to "de_DE.ISO-8859-1", which means I am using an
iso-8859-1 single-byte charset, which is of course also used by the
phonebook data which I provide on stdin. This data is now pushed through
mbtowc(), which converts a multibyte sequence to a wide character. The
problem now is, that the input string is NOT a multibyte character, but
a single-byte character string. So mbtowc() should always fail... but it
does not, since the first 128 characters of iso-8859-1 are identical to
their multibyte sequence representation. Now our language uses certain
special characters, which in iso-8859-1 are encoded with representations
above 128. For these values, mbtowc() actually fails with an error code.

If I (other way round) enter a name into my 6510 that includes some
special characters, and then try to read the data, gnokii calls wctomb()
for each character, which again fails for special characters.

If, on the other hand, I forget about these two routines and just do a
typecast from (char) to (unsigned short) and vice versa, everything works
like charm.

Now this is my unprofessional suspicion:
- The phone does not understand unicode after all. They are just using
  shorts instead of chars for transmission for some reason.
- Because the current procedure works for most characters, nobody has yet
  reported this misapprehension.

But I could be totally wrong with this. Knowing that, I just suggested
the small change of the returned character in case of error, so that
things now work for me (and probably would for many others), but the rest
stays the same, in case anybody needs the mbtowc()/wctomb()
functionality.

I understand that my suggested patch is no solution to the underlying
charset problem. My understanding of the matter is just not sufficient to
suggest anything more elaborate.
 
> >   Returning -1 is anyway a bad idea, since it
> >   effectively deletes the previous character of the string as well.
> >   Since I only changed the behaviour in case of error, I think these
> >   modifications will not break anything.
> 
> Yeah, good point. I'd prefer though to set '?' as the returned character.
> So, I'll just modify the return value there with the option to modify
> *dest as well when you convince me to do it.

If there is no other solution to the problem in sight, I would appreciate
it if you could modify *dest as well. Otherwise I'll have question marks
all over my phonebook...

Thanks again for your response and the great work on gnokii.

Jan de Cuveland




reply via email to

[Prev in Thread] Current Thread [Next in Thread]