[svn:parrot] r47349 - trunk/tools/util

gerd at svn.parrot.org gerd at svn.parrot.org
Fri Jun 4 08:59:43 UTC 2010


Author: gerd
Date: Fri Jun  4 08:59:42 2010
New Revision: 47349
URL: https://trac.parrot.org/parrot/changeset/47349

Log:
rewritten with I/O in method style

Modified:
   trunk/tools/util/inc_ver.pir

Modified: trunk/tools/util/inc_ver.pir
==============================================================================
--- trunk/tools/util/inc_ver.pir	Fri Jun  4 02:46:29 2010	(r47348)
+++ trunk/tools/util/inc_ver.pir	Fri Jun  4 08:59:42 2010	(r47349)
@@ -5,37 +5,40 @@
 .sub 'main' :main
     .local string version_file_name
     version_file_name = 'VERSION'
+
     # read the version
-    $P0 = open version_file_name, 'r'
-    $S0 = readline $P0
-    close $P0
+    $P0 = new 'FileHandle'
+    $P0.'open'( version_file_name, 'r' )
+    $S0 = $P0.'readline'()
+    $P0.'close'()
 
     print 'version: '
     print $S0
 
     # split the version
-    $P0 = split '.', $S0
+    $P1 = split '.', $S0
 
     # increment version
-    $I0 = $P0[1]
+    $I0 = $P1[1]
     inc $I0
     if $I0 != 12 goto NOT_NILL
-    $I0 = $P0[0]
+    $I0 = $P1[0]
     inc $I0
-    $P0[0] = $I0
+    $P1[0] = $I0
     $I0 = 0
 NOT_NILL:
-    $P0[1] = $I0
+    $P1[1] = $I0
 
-    # join the version
-    $S0 = join '.', $P0
+    # join the incremented version
+    $S0 = join '.', $P1
 
     print 'new version: '
     print $S0
 
-    $P0 = open version_file_name, 'w'
-    print $P0, $S0
-    close $P0
+    # write the new version to the version_file
+    $P0.'open'( version_file_name, 'w' )
+    $P0.'print'( $S0 )
+    $P0.'close'() 
 .end
 
 # Local Variables:


More information about the parrot-commits mailing list