Re: Patch removed from CVS

Nikos Balkanas <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Sure thing. Here it goes...

BR,

Nikos

On Thu, Jan 29, 2009 at 10:25 AM, Alexander Malysh <[email protected]>wrote:

> looks ok to me but could you please fix coding style. e.g.
>
> if (bla) {
>    ggg
> } else {
>    xxx
> }
>
> the same for:
>
> switch(bla) {
> case x:
>    lll
> case y:
>   bbb
> }
>
> Thanks,
> Alex
>
> Am 29.01.2009 um 01:59 schrieb Nikos Balkanas:
>
>  You are absolutely right. Couldn't figure out the logic behind the
>> existing type casting. I believe that now it is OK.
>>
>> BR,
>> Nikos
>> ----- Original Message ----- From: "Martin Conte Mac Donell" <
>> [email protected]>
>> To: "Nikos Balkanas" <[email protected]>
>> Cc: "Alexander Malysh" <[email protected]>; <[email protected]>
>> Sent: Thursday, January 29, 2009 2:00 AM
>> Subject: Re: Patch removed from CVS
>>
>>
>>  On Wed, Jan 28, 2009 at 8:58 PM, Nikos Balkanas <[email protected]>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> Attached patch to gwlib/octstr.c provides support for %ll and %llu in
>>>> octstr_format. To do that I introduced a new format->type: 'L' for long
>>>> long
>>>> variables. This is a prerequisite patch for #460.
>>>>
>>>> Please vote, and if possible test (I have tested it only with my demo
>>>> program, not kannel).
>>>>
>>>> BR,
>>>> Nikos
>>>>
>>>
>>> Why default cases are casted to (short) and (unsigned short)
>>> respectively?
>>>
>>> Also format->prec is already long, so you don't need:
>>>
>>> +            n = (long) format->prec;
>>>
>>> M
>>>
>> <patch.diff>
>>
>
>
patch.diff (application/octet-stream, 2 KB)
Index: gwlib/octstr.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/octstr.c,v
retrieving revision 1.182
diff -u -r1.182 octstr.c
--- gwlib/octstr.c	12 Jan 2009 16:46:53 -0000	1.182
+++ gwlib/octstr.c	29 Jan 2009 10:51:53 -0000
@@ -2218,13 +2218,18 @@
 
 static void format_type(struct format *format, const char **fmt)
 {
-    switch (**fmt)
-    {
+    switch (**fmt) {
     case 'h':
-    case 'l':
         format->type = **fmt;
         ++(*fmt);
         break;
+    case 'l':
+        if (*(*fmt + 1) == 'l'){
+           format->type = 'L';
+           ++(*fmt);
+        } else format->type = **fmt;
+        ++(*fmt);
+        break;
     }
 }
 
@@ -2234,8 +2239,8 @@
 {
     Octstr *new;
     char *s, *pad;
-    long n;
-    unsigned long u;
+    long long n;
+    unsigned long long u;
     char tmpfmt[1024];
     char tmpbuf[1024];
     char c;
@@ -2253,6 +2258,9 @@
     case 'd':
     case 'i':
         switch (format->type) {
+        case 'L':
+            n = va_arg(VALST(args), long long);
+            break;
         case 'l':
             n = va_arg(VALST(args), long);
             break;
@@ -2271,18 +2279,21 @@
     case 'u':
     case 'x':
     case 'X':
-	switch (format->type) {
-	case 'l':
-	    u = va_arg(VALST(args), unsigned long);
-	    break;
-        case 'h':
-            u = (unsigned short) va_arg(VALST(args), unsigned int);
-            break;
-        default:
-            u = va_arg(VALST(args), unsigned int);
-            break;
-        }
-        tmpfmt[0] = '%';
+   switch (format->type) {
+   case 'l':
+      u = va_arg(VALST(args), unsigned long);
+      break;
+   case 'L':
+      u = va_arg(VALST(args), unsigned long long);
+      break;
+   case 'h':
+      u = (unsigned short) va_arg(VALST(args), unsigned int);
+      break;
+   default:
+      u = va_arg(VALST(args), unsigned int);
+      break;
+   }
+   tmpfmt[0] = '%';
 	tmpfmt[1] = 'l';
 	tmpfmt[2] = **fmt;
 	tmpfmt[3] = '\0';
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.