Changeset 4673


Ignore:
Timestamp:
10/06/10 23:31:40 (3 years ago)
Author:
sam
Message:

Fix a bug in the %i formatting and implement %S.

Location:
zzuf/trunk/src/libzzuf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf/debug.c

    r4671 r4673  
    4747        char buf[128], *b = buf + 127; \ 
    4848        if (i <= 0) \ 
    49             append((i = -i) ? "-" : "0", 1); /* XXX: hack here */ \ 
    50         if (i <= 0) \ 
     49            append((i = 1 + ~i) ? "-" : "0", 1); /* XXX: hack here */ \ 
     50        if (i < 0) \ 
    5151        { \ 
    52             i = -(i + base); /* XXX: special case for INT_MIN */ \ 
     52            i = 1 + ~(i + base); /* XXX: special case for INT_MIN */ \ 
    5353            *b-- = hex2char[i % base]; \ 
    5454            i = i / base + 1; \ 
     
    212212            } 
    213213        } 
     214        else if(f[0] == 'S') 
     215        { 
     216            uint16_t *s = va_arg(args, uint16_t *); 
     217            if(!s) 
     218                append("(nil)", 5); 
     219            else 
     220            { 
     221                int l = 0; 
     222                while(s[l]) 
     223                { 
     224                    if (s[l] < 128) 
     225                    { 
     226                        char tmp = (char)s[l]; 
     227                        append(&tmp, 1); 
     228                    } 
     229                    else 
     230                    { 
     231                        append("\\u", 2); 
     232                        append(hex2char + ((s[l] & 0xf000) >> 12), 1); 
     233                        append(hex2char + ((s[l] & 0xf00) >> 8), 1); 
     234                        append(hex2char + ((s[l] & 0xf0) >> 4), 1); 
     235                        append(hex2char + (s[l] & 0xf), 1); 
     236                    } 
     237                    l++; 
     238                } 
     239            } 
     240        } 
    214241        else if(f[0] == '0' && f[1] == '2' && f[2] == 'x') 
    215242        { 
  • zzuf/trunk/src/libzzuf/lib-win32.c

    r4672 r4673  
    8686                            lpSecurityAttributes, dwCreationDisposition, 
    8787                            dwFlagsAndAttributes, hTemplateFile); 
    88     debug("CreateFileW(\"%s\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]", 
     88    debug("CreateFileW(\"%S\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]", 
    8989          lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, 
    9090          dwFlagsAndAttributes, (int)ret); 
Note: See TracChangeset for help on using the changeset viewer.