xrpn 1.9.5 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 751d07df684dda975c02987fa4b1988a898e90ca38cee59c43599afa70839461
4
- data.tar.gz: 0b35a364703da952c89c3a4a4dd544437e838ec5806f4a60ad93702bce2a43c8
3
+ metadata.gz: 9b24dce24109f4a7222e21c8512f6d94abc5249627b5c5fcb3c445ad3f6fd6d4
4
+ data.tar.gz: c1f0dcc7aeb1b15e9f2301305069c8845b02da91fae7a955f39bf29c533835b0
5
5
  SHA512:
6
- metadata.gz: 4ac219252e205fb60271a60b5e5f9a8e6bb7f19c3dfe7e0ce8f2dce60ca1d1a8ffb83645ee664601a7a1a09ddd150c0c5275950ca1fd6bf5599443530023deae
7
- data.tar.gz: 9506c918f3173955a7112c45e5d19c194a58c0579f797f6cfef605fdf65a71321da052b828c77b3246da4efd9b9868d8d35af4b02b9d3bba17c29af03b9bcca8
6
+ metadata.gz: 6f900855140a10644b1a83bfa50de31e74c2ac1468e7fc2284f698187e69538515a19744893b0f4c1d7cb3fe88a9b749628386803be304d72a99538685ecb0ed
7
+ data.tar.gz: 25471831a90d05f1138baad38554922c3ef43efe7d7195313d521ed1e29665b459b67dbc94b99fa2d94360665204117684ca532836fbaed76a426d015826ac14
data/bin/xrpn CHANGED
@@ -23,12 +23,8 @@ require 'bigdecimal'
23
23
  require 'open-uri'
24
24
  require 'json'
25
25
  require 'tty-prompt'
26
+ require 'timeout'
26
27
 
27
- $gem = nil
28
- begin
29
- $gem = Gem.latest_spec_for("xrpn").gem_dir
30
- rescue
31
- end
32
28
 
33
29
  # ENSURE DIRs
34
30
  Dir.mkdir(Dir.home + "/.xrpn") unless File.exist?(Dir.home + "/.xrpn")
@@ -37,8 +33,11 @@ Dir.mkdir(Dir.home + "/.xrpn") unless File.exist?(Dir.home + "/.xrpn")
37
33
  end
38
34
 
39
35
  # READ LIBRARY AND COMMANDS
36
+ $gem = `VISUAL=echo gem open xrpn`.chomp
37
+ $gem = nil if $gem =~ /^Unable/
38
+ $cmd = []
40
39
  Dir[$gem+"/xlib/*"].each { |file| load file } if $gem # Read xlib directory from the Gem
41
- Dir[Dir.home+"/.xrpn/xlib/*"].each { |file| load file } # Read xlib directory from home dir
40
+ Dir[Dir.home+"/.xrpn/xlib/*"].each { |file| load file unless $cmd.include?(file) } # Read xlib directory from home dir
42
41
  read_xcmd # Read XRPN commands (both from Gem and home dir)
43
42
 
44
43
  # INITIALIZE VARIABLES
@@ -134,6 +133,8 @@ until @p.pc == @p.prg[@p.pg].length do
134
133
  puts "No such command: #{l1}"
135
134
  exit if $exe
136
135
  @p.stop
136
+ elsif l1.downcase == "reload"
137
+ read_xcmd
137
138
  elsif XRPN.method_defined?(l1.downcase) # Or execute the command with either 1 or 2 parts
138
139
  begin
139
140
  l2 ? ret = @p.send(l1.downcase, l2) : ret = @p.send(l1.downcase)
data/xcmd/cmds ADDED
@@ -0,0 +1,8 @@
1
+ class XRPN
2
+ # Print all available commands
3
+ def cmds
4
+ p $cmd
5
+ end
6
+ end
7
+
8
+ # vim:ft=ruby:
data/xlib/_xrpn_version CHANGED
@@ -1,5 +1,6 @@
1
1
  def xrpn_version
2
- puts "XRPN version: 1.9"
2
+ puts "XRPN version: 2.1"
3
+ puts "RubyGem version: " + Gem.latest_spec_for("xrpn").version.to_s
3
4
  end
4
5
 
5
6
  # vim:ft=ruby:
data/xlib/debug_mode CHANGED
@@ -9,8 +9,8 @@ def debug_mode
9
9
  @p.prstk
10
10
  @line = @debugprompt.ask(">")
11
11
  unless @line == nil or @line.length == 1
12
- @line = [@line]
13
- @line = hp_41(@line)[0]
12
+ @line = hp_41([@line])[0]
13
+ #@line = rxcmd(@line)
14
14
  end
15
15
  end
16
16
  case @line
@@ -87,6 +87,13 @@ def debug_mode
87
87
  @p.prg[@p.pg].insert(@p.pc + 1, @line.sub(/^\+\+ /, ''))
88
88
  when "--"
89
89
  @p.prg[@p.pg].delete_at(@p.pc)
90
+ when /^:/
91
+ begin
92
+ eval @line[1..-1]
93
+ rescue StandardError => err
94
+ puts err
95
+ end
96
+ break
90
97
  when nil # A simple ENTER
91
98
  @line = "lift"
92
99
  break
data/xlib/numeric CHANGED
@@ -36,12 +36,16 @@ class Numeric
36
36
  s = x.to_i.to_s
37
37
  self < 0 ? m = "-" : m = ""
38
38
  s.sub!(/-/, '')
39
- f = x.frc.to_s[0..(i + 1)].to_f
40
- f = f.to_s.sub(/../, '')
39
+ f = (x.frc * 10 ** i).round.to_i.to_s
40
+ if f.length > i # Fix rounding overflow
41
+ s = (x + 1).to_i.to_s
42
+ f = f[1..-1]
43
+ end
44
+ f = f.to_s
41
45
  i > 0 ? s.sub!(/(\d*\.)(\d{,#{i}}).*/, '\1\2') : s.sub!(/(\d*).*/, '\1')
42
46
  if e.abs >= n # If exponent kicks in
43
47
  s += "." + f.ljust(i, "0")
44
- s += "e"
48
+ s += " e"
45
49
  if ge < 0
46
50
  s += "-"
47
51
  s.sub!(/0\.(\d)/, '\1.')
data/xrpn.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xrpn'
3
- s.version = '1.9.5'
3
+ s.version = '2.1'
4
4
  s.licenses = ['Unlicense']
5
5
  s.summary = "XRPN - The eXtended RPN (Reverse Polish Notation) programming language"
6
- s.description = "A full programming language and environment extending the features of the venerable HP calculator programmable calculators. With XRPN you can accomplish a wide range of modern programming tasks as well as running existing HP-41 FOCAL programs directly. XRPN gives modern life to tens of thousands of old HP calculator programs and opens the possibilities to many, many more. New in 1.9: Added functions 'lastpage' and 'load' and also added 'pprgtofile' in version 1.9.1 (see GitHub wiki). 1.9.5: Comments are now removed when loading programs (comments start with a tab and a semicolon and a space and whatever)"
6
+ s.description = "A full programming language and environment extending the features of the venerable HP calculator programmable calculators. With XRPN you can accomplish a wide range of modern programming tasks as well as running existing HP-41 FOCAL programs directly. XRPN gives modern life to tens of thousands of old HP calculator programs and opens the possibilities to many, many more. New in 2.0: Startup speed 4X. Added command 'cmds'. 2.1: Fixed rounding overflow bug. Added : commands to access underlying Ruby."
7
7
 
8
8
  s.authors = ["Geir Isene"]
9
9
  s.email = 'g@isene.com'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrpn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.5
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-21 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -28,10 +28,9 @@ description: 'A full programming language and environment extending the features
28
28
  the venerable HP calculator programmable calculators. With XRPN you can accomplish
29
29
  a wide range of modern programming tasks as well as running existing HP-41 FOCAL
30
30
  programs directly. XRPN gives modern life to tens of thousands of old HP calculator
31
- programs and opens the possibilities to many, many more. New in 1.9: Added functions
32
- ''lastpage'' and ''load'' and also added ''pprgtofile'' in version 1.9.1 (see GitHub
33
- wiki). 1.9.5: Comments are now removed when loading programs (comments start with
34
- a tab and a semicolon and a space and whatever)'
31
+ programs and opens the possibilities to many, many more. New in 2.0: Startup speed
32
+ 4X. Added command ''cmds''. 2.1: Fixed rounding overflow bug. Added : commands to
33
+ access underlying Ruby.'
35
34
  email: g@isene.com
36
35
  executables:
37
36
  - xrpn
@@ -97,6 +96,7 @@ files:
97
96
  - xcmd/cmdadd
98
97
  - xcmd/cmddel
99
98
  - xcmd/cmdhelp
99
+ - xcmd/cmds
100
100
  - xcmd/copy
101
101
  - xcmd/correct
102
102
  - xcmd/cos
@@ -342,7 +342,7 @@ homepage: https://github.com/isene/XRPN
342
342
  licenses:
343
343
  - Unlicense
344
344
  metadata: {}
345
- post_install_message:
345
+ post_install_message:
346
346
  rdoc_options: []
347
347
  require_paths:
348
348
  - lib
@@ -357,8 +357,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
357
357
  - !ruby/object:Gem::Version
358
358
  version: '0'
359
359
  requirements: []
360
- rubygems_version: 3.3.5
361
- signing_key:
360
+ rubygems_version: 3.4.20
361
+ signing_key:
362
362
  specification_version: 4
363
363
  summary: XRPN - The eXtended RPN (Reverse Polish Notation) programming language
364
364
  test_files: []