rocky / elisp-decompile

Emacs Lisp Decompiler
GNU General Public License v3.0
29 stars 4 forks source link

Carriage return in constant throws off scanner #6

Open danmcmahill opened 4 years ago

danmcmahill commented 4 years ago

the carriage return in this LAP file throws off the scanner.

    262     constant  define-key
    263     varref    map
    264     constant  "^M"
    267     constant  il-electric-return
    270     call      3
    271     discard

This seems to fix that but probably isn't so DOS friendly:

diff --git a/lapdecompile/main.py b/lapdecompile/main.py
index de0cd58..a4c029a 100755
--- a/lapdecompile/main.py
+++ b/lapdecompile/main.py
@@ -54,7 +54,7 @@ def control_flow(name, instructions, show_assembly, write_cfg):

 def deparse(path, outstream, show_assembly, write_cfg, show_grammar, show_tree):
     # Scan...
-    with open(path, "r") as fp:
+    with open(path, "r", newline="\n") as fp:
         scanner = LapScanner(fp, show_assembly=show_assembly)
         pass

a similar change would go at the very bottom of scanner.py

danmcmahill commented 4 years ago

what's the best way for me to contribute little things like that? Fork, create branch with the patch, push, and then PR on your repo?

rocky commented 4 years ago

Yes - the standard process is is

  1. Fork code
  2. Create branch in your repository for the change. (This is called a "topic" branch).
  3. Commit code in your repository.
  4. Put in a PR for that fork.

As for the other problems, I'll write a detailed answer of what's up later.