http://qs321.pair.com?node_id=1133681


in reply to Re^2: Looking for ideas: Converting a binary 'flags' field into something human readable
in thread Looking for ideas: Converting a binary 'flags' field into something human readable

I'd like to see the code that determines how to compress those together :)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re^4: Looking for ideas: Converting a binary 'flags' field into something human readable
by choroba (Cardinal) on Jul 08, 2015 at 10:29 UTC
    Not optimal and missing the "icycles" on the first line, but seems to work:
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Touché!

      (Removed the "Almost :)" which was added in the light of Monk::Thomas' post; before he added the bit about downloading it wrong.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
      % perl flag_compress.pl sideways |ompressed up |lse | deleted down | bar | | that
      Hmm. Looks quite strange. But I like the idea to try to keep all annotations on the same line and if that is not possible create a new line:
          flags1 => 0b0100110000100000101000000000100000000000000101000000000000001111;
      #                | compressed   | other     | and another  |foo             | up
      #                   | deleted                                | bar           | down 
      #                    | this       | something else                            | charm
      #                         | that                                               | strange
      
      Thanks!

      Update

      Downloaded the code via wget using the download link. Output looks a lot better after converting from DOS to UNIX file format.

Re^4: Looking for ideas: Converting a binary 'flags' field into something human readable
by GotToBTru (Prior) on Jul 08, 2015 at 15:17 UTC
    use strict; use warnings; my @labels = ({label=>'compressed',start=>3}, {label=>'deleted',start= +>6}, {label=>'this',start=>7}, {label=>'that',start=>12}, {label=>'other',start=>18}, {label=>'something else',sta +rt=>20}, {label=>'and another',start=>30}, {label=>'foo',start=>4 +5}, {label=>'bar',start=>47}, {label=>'up',start=>63}, {label=>'down',start=>64}, {label=>'sideways',start=>65} +); print "0b0x00xx0000x00000x0x000000000x00000000000000x0x000000000000000 +xxx\n"; my (@lines); # for each label LOOP: foreach my $lab (@labels) { # look thru the available lines foreach my $line (@lines) { my $delta = $lab->{start} - length($line); # for a line shorter than start if ($delta >= 0) { # and tack the label on there $line .= ' ' x $delta . '|' . $lab->{label}; next LOOP; } # or fit into empty space on existing line my $len = length($lab->{label}) + 1; if (substr($line, $lab->{start}, $len) eq ' ' x $len) { substr($line, $lab->{start}, $len,'|' . $lab->{label}); next LOOP; } } # or create a new line if needed push @lines, ' ' x $lab->{start} . '|' . $lab->{label}; } print "$_\n" for @lines;

    UPDATE: added comments, added fitting new label into blank space, improved flow

    Dum Spiro Spero