Project

General

Profile

Actions

Bug #407

open

Serialization of instances of custom types broken in ksh93

Added by Guido Berhörster about 13 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
cmd - userland programs
Start date:
2010-11-10
Due date:
% Done:

0%

Estimated time:
Difficulty:
Tags:
Gerrit CR:
External Bug:

Description

The serialization of instances of custom types in ksh93 is broken, print -C/-v produce random byte garbage.

Example:

#!/usr/bin/ksh93

typeset -T ipv4_addr_t=(
    integer value

    function set
    {
        typeset oIFS="${IFS}" 
        IFS=.
        typeset -a -i inet_parts=( ${.sh.value} )
        IFS="${oIFS}" 
        _.value=$(( (inet_parts[0] << 24) + (inet_parts[1] << 16) + \
            (inet_parts[2] << 8) + inet_parts[3] ))
    }

    function get
    {
        .sh.value=${ printf "%d.%d.%d.%d\n" \
            $(( _.value >> 24 & 255 )) \
            $(( _.value >> 16 & 255 )) \
            $(( _.value >> 8 & 255 )) \
            $(( _.value & 255 )); }
    }
)

ipv4_addr_t ip="192.168.0.1" 

print -C ip
print -v ip

No data to display

Actions

Also available in: Atom PDF