# New Ticket Created by  Nick Glencross 
# Please include the string:  [perl #34637]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34637 >


A small patch to:

  * Give Jens credit for yesterday's enhancements (I think that I'm 
right in attributing them to you)

  * A small fix to the autoload function

  * Remove duplicate code between _md5_hex and _md5_print

  * A couple of internal function renames (more for consistency than 
anything)

All tests still pass.

Thanks,

Nick
Index: runtime/parrot/library/Digest/MD5.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Digest/MD5.imc,v
retrieving revision 1.3
diff -c -r1.3 MD5.imc
*** runtime/parrot/library/Digest/MD5.imc       31 Mar 2005 12:20:39 -0000      
1.3
--- runtime/parrot/library/Digest/MD5.imc       1 Apr 2005 12:09:05 -0000
***************
*** 1,5 ****
  # Parrot md5sum; Nick Glencross <[EMAIL PROTECTED]>
! #                Improvements from Leo
  #
  # Based on md5.c, from md5sum
  #           written by Ulrich Drepper <[EMAIL PROTECTED]>, 1995.
--- 1,5 ----
  # Parrot md5sum; Nick Glencross <[EMAIL PROTECTED]>
! #                Improvements from Leo and Jens Rieks
  #
  # Based on md5.c, from md5sum
  #           written by Ulrich Drepper <[EMAIL PROTECTED]>, 1995.
***************
*** 14,19 ****
--- 14,25 ----
    $P0 = _md5sum("foo")
    _md5_print($P0)
  
+ or
+ 
+   load_bytecode "library/Digest/MD5.imc"
+   $P0 = _md5sum("bar")
+   $S0 = _md5_hex($P0)
+ 
  =head1 DESCRIPTION
  
  This is a pure Parrot MD5 hash routine. Therefore you should run it
***************
*** 25,38 ****
  
  Pass in a string, returns an Integer array with the result
  
- =head2 _md5_print
- 
- Pass it the Integer array to print the checksum.
- 
  =head2 _md5_hex
  
  Pass it the Integer array to get the checksum as string.
  
  =head1 BUGS
  
  Only tested so far on i386.
--- 31,44 ----
  
  Pass in a string, returns an Integer array with the result
  
  =head2 _md5_hex
  
  Pass it the Integer array to get the checksum as string.
  
+ =head2 _md5_print
+ 
+ Pass it the Integer array to print the checksum.
+ 
  =head1 BUGS
  
  Only tested so far on i386.
***************
*** 47,60 ****
  
  =cut
  
! ####################################
! # export function entries to globals
  
  .sub onload @LOAD
      .local pmc endian
      endian = new Integer
      endian = 0
-     store_global "Digest", "_md5_swap_endian", endian
      
      $P0 = _config()
  
--- 53,65 ----
  
  =cut
  
! ###########################################################################
! # Export function entries to globals
  
  .sub onload @LOAD
      .local pmc endian
      endian = new Integer
      endian = 0
      
      $P0 = _config()
  
***************
*** 74,86 ****
  
  is_little_endian:
  
      .local pmc f
      f = find_global "Digest", "_md5sum"
      global "_md5sum" = f
-     f = find_global "Digest", "_md5_print"
-     global "_md5_print" = f
      f = find_global "Digest", "_md5_hex"
      global "_md5_hex" = f
  .end
  
  .include "library/config.imc"
--- 79,93 ----
  
  is_little_endian:
  
+     store_global "Digest", "_md5_swap_endian", endian
+ 
      .local pmc f
      f = find_global "Digest", "_md5sum"
      global "_md5sum" = f
      f = find_global "Digest", "_md5_hex"
      global "_md5_hex" = f
+     f = find_global "Digest", "_md5_print"
+     global "_md5_print" = f
  .end
  
  .include "library/config.imc"
***************
*** 103,110 ****
      $I0 = $P0
      _md5_create_buffer (str, buffer, $I0)
  
-     # _print_buffer (buffer, 8)
- 
      _md5_init (context)
      _md5_process_buffer (context, buffer)
  
--- 110,115 ----
***************
*** 132,138 ****
  .endm
  
  .macro FH (b,c,d)
!     tmp = .b ~ .c
      tmp = tmp ~ .d
  .endm
  
--- 137,143 ----
  .endm
  
  .macro FH (b,c,d)
!     tmp = .b  ~ .c
      tmp = tmp ~ .d
  .endm
  
***************
*** 215,221 ****
  .end
  
  ###########################################################################
- 
  # Create a buffer from the requested buffer
  
  .sub _md5_create_buffer
--- 220,225 ----
***************
*** 267,273 ****
       inc subcounter
       if subcounter != 4 goto md5_create_buffer_loop
       if endian goto endian_ok
!        .swap (word)
  endian_ok:
  
  
--- 271,277 ----
       inc subcounter
       if subcounter != 4 goto md5_create_buffer_loop
       if endian goto endian_ok
!      .swap (word)
  endian_ok:
  
  
***************
*** 421,427 ****
      context[2] = C
      context[3] = D
  
!     # $S0 = _format_vals (A,B,C,D)
      # print $S0
      # print "\n"
  
--- 425,431 ----
      context[2] = C
      context[3] = D
  
!     # $S0 = _md5_format_vals (A,B,C,D)
      # print $S0
      # print "\n"
  
***************
*** 429,437 ****
  
  ###########################################################################
  
! # format four hex values
  
! .sub _format_vals
      .param int A
      .param int B
      .param int C
--- 433,441 ----
  
  ###########################################################################
  
! # Format four hex values
  
! .sub _md5_format_vals
      .param int A
      .param int B
      .param int C
***************
*** 450,464 ****
  
  ###########################################################################
  
! # Print the final checksum
  
! .sub _md5_print
      .param pmc context
  
!     .local int A
!     .local int B
!     .local int C
!     .local int D
  
      A = context[0]
      B = context[1]
--- 454,465 ----
  
  ###########################################################################
  
! # Retrieve the final checksum
  
! .sub _md5_hex
      .param pmc context
  
!     .local int A, B, C, D
  
      A = context[0]
      B = context[1]
***************
*** 475,516 ****
  
  dont_swap:
  
!     $S0 = _format_vals (A,B,C,D)
!     print $S0
  .end
  
! .sub _md5_hex
!     .param pmc context
! 
!     .local int A
!     .local int B
!     .local int C
!     .local int D
! 
!     A = context[0]
!     B = context[1]
!     C = context[2]
!     D = context[3]
! 
!     $P0 = find_global "Digest", "_md5_swap_endian"
!     if $P0 goto dont_swap
! 
!     .swap (A)
!     .swap (B)
!     .swap (C)
!     .swap (D)
  
! dont_swap:
  
!     $S0 = _format_vals (A,B,C,D)
!     .return($S0)
  .end
  
  ###########################################################################
  
  # For debugging
  
! .sub _print_buffer
      .param pmc buffer
      .param int word_size
  
--- 476,499 ----
  
  dont_swap:
  
!     $S0 = _md5_format_vals (A,B,C,D)
!     .return($S0)
  .end
  
! # Convenience subroutine
  
! .sub _md5_print
!     .param pmc context
  
!     $S0 = _md5_hex (context)
!     print $S0
  .end
  
  ###########################################################################
  
  # For debugging
  
! .sub _md5_print_buffer
      .param pmc buffer
      .param int word_size
  
***************
*** 526,532 ****
  print_buffer_loop:
      if counter >= size goto print_buffer_done
      value = buffer[counter]
!     $S0 = _number_as_hex (value, word_size)
      print $S0
      print " | "
      counter = counter + 1
--- 509,515 ----
  print_buffer_loop:
      if counter >= size goto print_buffer_done
      value = buffer[counter]
!     $S0 = _md5_number_as_hex (value, word_size)
      print $S0
      print " | "
      counter = counter + 1
***************
*** 542,548 ****
  
  # Also for debugging
  
! .sub _number_as_hex
      .param int number
      .param int word_size
  
--- 525,531 ----
  
  # Also for debugging
  
! .sub _md5_number_as_hex
      .param int number
      .param int word_size
  

Reply via email to