Quellcode durchsuchen

a more generic way to avoid empty commands in a shell

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7095 8c9fc860-2736-0410-a75d-ab315db34111
eth.morozova vor 8 Jahren
Ursprung
Commit
ce5f08d41d
1 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 9 1
      source/Shell.Mod

+ 9 - 1
source/Shell.Mod

@@ -218,7 +218,15 @@ TYPE
 
 					IF IsControlCharacter(ch) OR (ch = Delete) THEN
 
-						IF (* (ch = CR) OR*)  (ch = LF) OR (ch = Streams.EOT) OR (context.in.res # Streams.Ok) THEN
+						IF (ch = CR) OR (ch = LF) OR (ch = Streams.EOT) OR (context.in.res # Streams.Ok) THEN
+							
+							(* skip redundant CR and LF to avoid generation of empty commands *)
+							WHILE (context.in.res = Streams.Ok) & (context.in.Available() # 0) & ((context.in.Peek() = CR) OR (context.in.Peek() = LF)) DO
+								context.in.SkipBytes(1);
+							END;
+							
+							ch := LF;
+
 							EXIT
 
 						ELSIF (ch = Backspace) OR (ch = Delete)THEN