# File lib/Dnsruby/zone_reader.rb, line 202
    def normalise_line(line, do_prefix_hack = false)
      # Note that a freestanding "@" is used to denote the current origin - we can simply replace that straight away
      # Remove the ( and )
      # Note that no domain name may be specified in the RR - in that case, last_name should be used. How do we tell? Tab or space at start of line.
      if ((line[0,1] == " ") || (line[0,1] == "\t"))
        line = @last_name + " " + line
      end
      line.chomp!
      line.sub!(/\s+@$/, " #{@origin}") # IN CNAME @
      line.sub!(/^@\s+/, "#{@origin} ") # IN CNAME @
      line.sub!(/\s+@\s+/, " #{@origin} ")
      line.strip!


      # o We need to identify the domain name in the record, and then
      split = line.split(' ') # split on whitespace
      name = split[0].strip
      if (name.index"\\")
        old_name = name

        ls =[]
        Name.create(name).labels.each {|el| ls.push(Name.decode(RR::TXT.display(el.to_s, false)))}
        name = ls.join('.')


        if (/\.\z/ =~ old_name)
          name += "."
        end
        line = name + " "
        (split.length - 1).times {|i| line += "#{split[i+1]} "}
        line += "\n"
        split = line.split
      end
      # o add $ORIGIN to it if it is not absolute
      if !(/\.\z/ =~ name)
        new_name = name + "." + @origin
        line.sub!(name, new_name)
        name = new_name
        split = line.split
      end

      # If the second field is not a number, then we should add the TTL to the line
      # Remember we can get "m" "w" "y" here! So need to check for appropriate regexp...
      found_ttl_regexp = (split[1]=~/^[0-9]+[smhdwSMHDW]/)
      if (found_ttl_regexp == 0)
        # Replace the formatted ttl with an actual number
        ttl = get_ttl(split[1])
        line = name + " #{ttl} "
        @last_explicit_ttl = ttl
        (split.length - 2).times {|i| line += "#{split[i+2]} "}
        line += "\n"
        split = line.split
      elsif (((split[1]).to_i == 0) && (split[1] != "0"))
        # Add the TTL
        if (!@last_explicit_ttl)
          # If this is the SOA record, and no @last_explicit_ttl is defined,
          # then we need to try the SOA TTL element from the config. Otherwise,
          # find the SOA Minimum field, and use that.
          # We should also generate a warning to that effect
          # How do we know if it is an SOA record at this stage? It must be, or
          # else @last_explicit_ttl should be defined
          # We could put a marker in the RR for now - and replace it once we know
          # the actual type. If the type is not SOA then, then we can raise an error
          line = name + " %MISSING_TTL% "
        else
          line = name + " #{@last_explicit_ttl} "
        end
        (split.length - 1).times {|i| line += "#{split[i+1]} "}
        line += "\n"
        split = line.split
      else
        @last_explicit_ttl = split[1].to_i
      end

      # Now see if the clas is included. If not, then we should default to the last class used.
      begin
        klass = Classes.new(split[2])
        @last_explicit_class = klass
      rescue ArgumentError
        # Wasn't a CLASS
        # So add the last explicit class in
        line = ""
        (2).times {|i| line += "#{split[i]} "}
        line += " #{@last_explicit_class} "
        (split.length - 2).times {|i| line += "#{split[i+2]} "}
        line += "\n"
        split = line.split
      rescue Error => e
      end

      # Add the type so we can load the zone one RRSet at a time.
      type = Types.new(split[3].strip)
      is_soa = (type == Types::SOA)
      type_was = type
      if (type == Types.RRSIG)
        # If this is an RRSIG record, then add the TYPE COVERED rather than the type - this allows us to load a complete RRSet at a time
        type = Types.new(split[4].strip)
      end

      type_string=prefix_for_rrset_order(type, type_was)
      @last_name = name

      if !([Types::NAPTR, Types::TXT].include?type_was)
        line.sub!("(", "")
        line.sub!(")", "")
      end

      if (is_soa)
        if (@soa_ttl)
          # Replace the %MISSING_TTL% text with the SOA TTL from the config
          line.sub!(" %MISSING_TTL% ", " #{@soa_ttl} ")
        else
          # Can we try the @last_explicit_ttl?
          if (@last_explicit_ttl)
            line.sub!(" %MISSING_TTL% ", " #{@last_explicit_ttl} ")
          end
        end
        line = replace_soa_ttl_fields(line)
        if (!@last_explicit_ttl)
          soa_rr = Dnsruby::RR.create(line)
          @last_explicit_ttl = soa_rr.minimum
        end
      end

      line = line.split.join(' ').strip
      # We need to fix up any non-absolute names in the RR
      # Some RRs have a single name, at the end of the string -
      #   to do these, we can just check the last character for "." and add the
      #   "." + origin string if necessary
      if ([Types::MX, Types::NS, Types::AFSDB, Types::NAPTR, Types::RT,
            Types::SRV, Types::CNAME, Types::MB, Types::MG, Types::MR,
            Types::PTR].include?type_was)
        if (line[line.length-1, 1] != ".")
          line = line + "." + @origin.to_s
        end
      end
      # Other RRs have several names. These should be parsed by Dnsruby,
      #   and the names adjusted there.
      if ([Types::MINFO, Types::PX, Types::RP].include?type_was)
        parsed_rr = Dnsruby::RR.create(line)
        case parsed_rr.type
        when Types::MINFO
          if (!parsed_rr.rmailbx.absolute?)
            parsed_rr.rmailbx = parsed_rr.rmailbx.to_s + "." + @origin.to_s
          end
          if (!parsed_rr.emailbx.absolute?)
            parsed_rr.emailbx = parsed_rr.emailbx.to_s + "." + @origin.to_s
          end
        when Types::PX
          if (!parsed_rr.map822.absolute?)
            parsed_rr.map822 = parsed_rr.map822.to_s + "." + @origin.to_s
          end
          if (!parsed_rr.mapx400.absolute?)
            parsed_rr.mapx400 = parsed_rr.mapx400.to_s + "." + @origin.to_s
          end
        when Types::RP
          if (!parsed_rr.mailbox.absolute?)
            parsed_rr.mailbox = parsed_rr.mailbox.to_s + "." + @origin.to_s
            if (!parsed_rr.txtdomain.absolute?)
              parsed_rr.txtdomain = parsed_rr.txtdomain.to_s + "." + @origin.to_s
            end
          end
        end
        line = parsed_rr.to_s
      end

      if (do_prefix_hack)
        return line + "\n", type_string, @last_name
      end
      return line+"\n"
    end