parameters: (lines)
docstring: Given a binary dump as given by GNU od -b, look for long double
      representation.
docstring_summary: Given a binary dump as given by GNU od -b, look for long double
      representation.
docstring_tokens: Given a binary dump as given by GNU od - b look for long double representation .
function: def long_double_representation(lines):
      """Given a binary dump as given by GNU od -b, look for long double
      representation."""
  
      # Read contains a list of 32 items, each item is a byte (in octal
      # representation, as a string). We 'slide' over the output until read is of
      # the form before_seq + content + after_sequence, where content is the long double
      # representation:
      #  - content is 12 bytes: 80 bits Intel representation
      #  - content is 16 bytes: 80 bits Intel representation (64 bits) or quad precision
      #  - content is 8 bytes: same as double (not implemented yet)
      read = [''] * 32
      saw = None
      for line in lines:
          # we skip the first word, as od -b output an index at the beginning of
          # each line
          for w in line.split()[1:]:
              read.pop(0)
              read.append(w)
  
              # If the end of read is equal to the after_sequence, read contains
              # the long double
              if read[-8:] == _AFTER_SEQ:
                  saw = copy.copy(read)
                  # if the content was 12 bytes, we only have 32 - 8 - 12 = 12
                  # "before" bytes. In other words the first 4 "before" bytes went
                  # past the sliding window.
                  if read[:12] == _BEFORE_SEQ[4:]:
                      if read[12:-8] == _INTEL_EXTENDED_12B:
                          return 'INTEL_EXTENDED_12_BYTES_LE'
                      if read[12:-8] == _MOTOROLA_EXTENDED_12B:
                          return 'MOTOROLA_EXTENDED_12_BYTES_BE'
                  # if the content was 16 bytes, we are left with 32-8-16 = 16
                  # "before" bytes, so 8 went past the sliding window.
                  elif read[:8] == _BEFORE_SEQ[8:]:
                      if read[8:-8] == _INTEL_EXTENDED_16B:
                          return 'INTEL_EXTENDED_16_BYTES_LE'
                      elif read[8:-8] == _IEEE_QUAD_PREC_BE:
                          return 'IEEE_QUAD_BE'
                      elif read[8:-8] == _IEEE_QUAD_PREC_LE:
                          return 'IEEE_QUAD_LE'
                      elif read[8:-8] == _IBM_DOUBLE_DOUBLE_LE:
                          return 'IBM_DOUBLE_DOUBLE_LE'
                      elif read[8:-8] == _IBM_DOUBLE_DOUBLE_BE:
                          return 'IBM_DOUBLE_DOUBLE_BE'
                  # if the content was 8 bytes, left with 32-8-8 = 16 bytes
                  elif read[:16] == _BEFORE_SEQ:
                      if read[16:-8] == _IEEE_DOUBLE_LE:
                          return 'IEEE_DOUBLE_LE'
                      elif read[16:-8] == _IEEE_DOUBLE_BE:
                          return 'IEEE_DOUBLE_BE'
  
      if saw is not None:
          raise ValueError("Unrecognized format (%s)" % saw)
      else:
          # We never detected the after_sequence
          raise ValueError("Could not lock sequences (%s)" % saw)
function_tokens: def long_double_representation ( lines ) : # Read contains a list of 32 items, each item is a byte (in octal # representation, as a string). We 'slide' over the output until read is of # the form before_seq + content + after_sequence, where content is the long double # representation: #  - content is 12 bytes: 80 bits Intel representation #  - content is 16 bytes: 80 bits Intel representation (64 bits) or quad precision #  - content is 8 bytes: same as double (not implemented yet) read = [ '' ] * 32 saw = None for line in lines : # we skip the first word, as od -b output an index at the beginning of # each line for w in line . split ( ) [ 1 : ] : read . pop ( 0 ) read . append ( w ) # If the end of read is equal to the after_sequence, read contains # the long double if read [ - 8 : ] == _AFTER_SEQ : saw = copy . copy ( read ) # if the content was 12 bytes, we only have 32 - 8 - 12 = 12 # "before" bytes. In other words the first 4 "before" bytes went # past the sliding window. if read [ : 12 ] == _BEFORE_SEQ [ 4 : ] : if read [ 12 : - 8 ] == _INTEL_EXTENDED_12B : return 'INTEL_EXTENDED_12_BYTES_LE' if read [ 12 : - 8 ] == _MOTOROLA_EXTENDED_12B : return 'MOTOROLA_EXTENDED_12_BYTES_BE' # if the content was 16 bytes, we are left with 32-8-16 = 16 # "before" bytes, so 8 went past the sliding window. elif read [ : 8 ] == _BEFORE_SEQ [ 8 : ] : if read [ 8 : - 8 ] == _INTEL_EXTENDED_16B : return 'INTEL_EXTENDED_16_BYTES_LE' elif read [ 8 : - 8 ] == _IEEE_QUAD_PREC_BE : return 'IEEE_QUAD_BE' elif read [ 8 : - 8 ] == _IEEE_QUAD_PREC_LE : return 'IEEE_QUAD_LE' elif read [ 8 : - 8 ] == _IBM_DOUBLE_DOUBLE_LE : return 'IBM_DOUBLE_DOUBLE_LE' elif read [ 8 : - 8 ] == _IBM_DOUBLE_DOUBLE_BE : return 'IBM_DOUBLE_DOUBLE_BE' # if the content was 8 bytes, left with 32-8-8 = 16 bytes elif read [ : 16 ] == _BEFORE_SEQ : if read [ 16 : - 8 ] == _IEEE_DOUBLE_LE : return 'IEEE_DOUBLE_LE' elif read [ 16 : - 8 ] == _IEEE_DOUBLE_BE : return 'IEEE_DOUBLE_BE' if saw is not None : raise ValueError ( "Unrecognized format (%s)" % saw ) else : # We never detected the after_sequence raise ValueError ( "Could not lock sequences (%s)" % saw )