Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v4 2/3] smsutil: <CR> is not necessarily a CBS padding character
Date: Mon, 17 Sep 2012 11:58:10 -0500	[thread overview]
Message-ID: <505756A2.6040102@gmail.com> (raw)
In-Reply-To: <1346425438-12220-2-git-send-email-philippe.nunes@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]

Hi Philippe,

On 08/31/2012 10:03 AM, Philippe Nunes wrote:
> ---
>   src/smsutil.c |   36 +++++++++++++++++++++++++++++-------
>   1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/src/smsutil.c b/src/smsutil.c
> index b4d129f..7569c63 100644
> --- a/src/smsutil.c
> +++ b/src/smsutil.c
> @@ -4090,7 +4090,7 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
>   			unsigned char unpacked[CBS_MAX_GSM_CHARS];
>   			long written;
>   			int max_chars;
> -			int i;
> +			int i, j;
>
>   			max_chars =
>   				sms_text_capacity_gsm(CBS_MAX_GSM_CHARS, taken);
> @@ -4102,12 +4102,24 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
>   			i = iso639 ? 3 : 0;
>
>   			/*
> -			 * CR is a padding character, which means we can
> -			 * safely discard everything afterwards
> +			 * CR can be used as a padding character, which means
> +			 * we can safely discard everything afterwards
>   			 */
> +
>   			for (; i<  written; i++, bufsize++) {
> -				if (unpacked[i] == '\r')
> -					break;
> +				if (unpacked[i] == '\r') {
> +					/*
> +					 * check if this is a padding character
> +					 * or if it is a wanted<CR>
> +					 */
> +					for (j = i + 1; j<  written; j++)
> +						if (unpacked[j] != '\r')
> +							break;
> +
> +					if (j == written)
> +						break;
> +				}
> +
>
>   				buf[bufsize] = unpacked[i];
>   			}

I skipped the first two chunks and fixed this slightly differently.

> @@ -4135,8 +4147,18 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
>   			}
>
>   			while (i<  max_offset) {
> -				if (ud[i] == 0x00&&  ud[i+1] == '\r')
> -					break;
> +				if (ud[i] == 0x00&&  ud[i+1] == '\r') {
> +					int j = i + 2;
> +
> +					for (; j<  max_offset; j = j + 2)
> +						if (ud[j] != 0x00 ||
> +								ud[j + 1] !=
> +									'\r')
> +							break;
> +
> +					if (j == max_offset)
> +						break;
> +				}
>
>   				buf[bufsize] = ud[i];
>   				buf[bufsize + 1] = ud[i + 1];

The last chunk has been applied, thanks.

Regards,
-Denis

  reply	other threads:[~2012-09-17 16:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-31 15:03 [PATCH v4 1/3] smsutil: Fix style issues Philippe Nunes
2012-08-31 15:03 ` [PATCH v4 2/3] smsutil: <CR> is not necessarily a CBS padding character Philippe Nunes
2012-09-17 16:58   ` Denis Kenzior [this message]
2012-08-31 15:03 ` [PATCH v4 3/3] unit: Add test to check " Philippe Nunes
2012-09-17 16:58   ` Denis Kenzior
2012-09-17 16:57 ` [PATCH v4 1/3] smsutil: Fix style issues Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505756A2.6040102@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox