From 7d2f5a0a3de6181c0e06941d967213f3d2c7912c Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Wed, 9 Aug 2006 18:17:34 +0000
Subject: [PATCH] Fix formatting. Allow <?xjs to be at the end of a line
 without a trailing space. Allow short tags ala PHP... ie: <? some code here
 ?>

---
 exec/xjs_handler.js | 91 ++++++++++++++++++++++++---------------------
 1 file changed, 48 insertions(+), 43 deletions(-)

diff --git a/exec/xjs_handler.js b/exec/xjs_handler.js
index f8a3cd802b..69ca7f2793 100644
--- a/exec/xjs_handler.js
+++ b/exec/xjs_handler.js
@@ -19,51 +19,56 @@ if(file_exists(ssjs_filename)) {
 }
 
 if(!file_exists(ssjs_filename)) {
-   var file = new File(filename);
-   if(!file.open("r",true,8192)) {
-	   writeln("!ERROR " + file.error + " opening " + filename);
-	   exit();
-   }
-   var text = file.readAll(8192);
-   file.close();
+	var file = new File(filename);
+	if(!file.open("r",true,8192)) {
+		writeln("!ERROR " + file.error + " opening " + filename);
+		exit();
+	}
+	var text = file.readAll(8192);
+	file.close();
 
-   var script="";
+	var script="";
 
-   var in_xjs=false;
-   for (line in text) {
-	   var str=text[line];
-	   while(str != '') {
-		   if(!in_xjs) {
-			   if(str.search(/<\?xjs\s+/)==-1) {
-				   script += "writeln("+escape_quotes(str)+");\r\n";
-				   str='';
-			   }
-			   else {
-				   str=str.replace(/^(.*?)<\?xjs\s+/,
-					   function (str, p1, offset, s) {
-						   script += "write("+escape_quotes(p1)+");\r\n";
-						   in_xjs=true;
-						   return '';
-					   }
-				   );
-			   }
-		   }
-		   else {
-			   if(str.search(/\?>/)==-1) {
-				   script += str;
-				   str='';
-			   }
-			   else {
-				   str=str.replace(/^(.*?)\?>/,
-					   function (str, p1, offset, s) {
-						   script += p1+";\r\n";
-						   in_xjs=false;
-						   return '';
-					   }
-				   );
-			   }
-		   }
-	   }
+	var in_xjs=false;
+	for (line in text) {
+		var str=text[line];
+		while(str != '') {
+			if(!in_xjs) {
+				if(str=='<?xjs' || str=='<?') {
+					in_xjs=true;
+					str='';
+				}
+				else {
+					if(str.search(/<\?(xjs)?\s+/)==-1) {
+						script += "writeln("+escape_quotes(str)+");\r\n";
+						str='';
+					}
+					else {
+						str=str.replace(/^(.*?)<\?(xjs)?\s+/,
+						function (str, p1, p2, offset, s) {
+							script += "write("+escape_quotes(p1)+");\r\n";
+							in_xjs=true;
+							return '';
+						}
+					);
+				}
+			}
+			else {
+				if(str.search(/\?>/)==-1) {
+					script += str;
+					str='';
+				}
+				else {
+					str=str.replace(/^(.*?)\?>/,
+						function (str, p1, offset, s) {
+							script += p1+";\r\n";
+							in_xjs=false;
+							return '';
+						}
+					);
+				}
+			}
+		}
 	}
 
 	var f=new File(ssjs_filename);
-- 
GitLab