shithub: riscv

Download patch

ref: 66cc2fa96036398b10bc8def293bb5759bbbabe4
parent: a989f89f3e15bae969c764114a256237c3538672
author: cinap_lenrek <[email protected]>
date: Fri Dec 6 19:51:19 EST 2013

mothra: remove debug code, dont create $home/lib/mothra/mothra.err file

--- a/sys/man/1/mothra
+++ b/sys/man/1/mothra
@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B mothra
 [
-.B -dva
+.B -va
 ]
 [
 .B -m
@@ -52,10 +52,6 @@
 .PP
 There are a number of options:
 .TP
-.B -d
-Debug mode. Causes debug messages to appear in
-.B $home/lib/mothra/mothra.err.
-.TP
 .B -a
 Alt display. Starts in alt display mode, see menu
 commands table below.
@@ -70,8 +66,8 @@
 .B /mnt/web.
 .TP
 .B -v
-Verbose mode. Causes HTML errors to appear in
-.B $home/lib/mothra/mothra.err.
+Verbose mode. Causes HTML errors to be printed
+on file-descriptor 2.
 .PP
 The display contains the last message from
 .I mothra,
@@ -169,9 +165,6 @@
 .SH FILES
 .B $home/lib/mothra/hit.html 
 the hit list
-.br
-.B $home/lib/mothra/mothra.err
-log of debug and/or error messages, including HTML syntax errors
 .SH SOURCE
 .B /sys/src/cmd/mothra
 .SH "SEE ALSO"
--- a/sys/src/cmd/mothra/forms.c
+++ b/sys/src/cmd/mothra/forms.c
@@ -701,17 +701,8 @@
 			return;
 		}
 		buf[n] = 0;
-		if(debug)fprint(2, "GET %s\n", buf);
 		geturl(buf, -1, 0, 0);
 	} else {
-		if(debug){
-			fprint(2, "POST %s ->\n", form->action);
-			if(form->ctype)
-				mencodeform(form, 2);
-			else
-				uencodeform(form, 2);
-			fprint(2, "\n");
-		}
 		/* only set for multipart/form-data */
 		if(form->ctype)
 			mencodeform(form, fd);
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -11,8 +11,8 @@
 #include <panel.h>
 #include "mothra.h"
 #include "rtext.h"
-int debug=0;		/* -d flag causes debug messages to appear in mothra.err */
-int verbose=0;		/* -v flag causes html errors to appear in mothra.err */
+int debug=0;
+int verbose=0;		/* -v flag causes html errors to be written to file-descriptor 2 */
 int defdisplay=1;	/* is the default (initial) display visible? */
 Panel *root;	/* the whole display */
 Panel *alt;	/* the alternate display */
@@ -208,29 +208,29 @@
 void dienow(void*, char*){
 	noted(NDFLT);
 }
-int mkmfile(char *stem, int mode){
-	char *henv;
-	char filename[NNAME];
+
+char* mkhome(void){
+	static char *home;		/* where to put files */
+	char *henv, *tmp;
 	int f;
-	if(home[0]=='\0'){
+
+	if(home == nil){
 		henv=getenv("home");
 		if(henv){
-			sprint(home, "%s/lib", henv);
-			f=create(home, OREAD, DMDIR|0777);
+			tmp = smprint("%s/lib", henv);
+			f=create(tmp, OREAD, DMDIR|0777);
 			if(f!=-1) close(f);
-			sprint(home, "%s/lib/mothra", henv);
+			free(tmp);
+
+			home = smprint("%s/lib/mothra", henv);
 			f=create(home, OREAD, DMDIR|0777);
 			if(f!=-1) close(f);
 			free(henv);
 		}
 		else
-			strcpy(home, "/tmp");
+			home = strdup("/tmp");
 	}
-	snprint(filename, sizeof(filename), "%s/%s", home, stem);
-	f=create(filename, OWRITE, mode);
-	if(f==-1)
-		f=create(stem, OWRITE, mode);
-	return f;
+	return home;
 }
 
 void donecurs(void){
@@ -263,7 +263,6 @@
 	Www *new;
 	Action *a;
 	char *url;
-	int errfile;
 	int i;
 
 	quotefmtinstall();
@@ -302,11 +301,6 @@
 		break;
 	case 1: url=argv[0]; break;
 	}
-	errfile=mkmfile("mothra.err", 0666);
-	if(errfile!=-1){
-		dup(errfile, 2);
-		close(errfile);
-	}
 	if(initdraw(0, 0, mothra) < 0)
 		sysfatal("initdraw: %r");
 	display->locking = 1;
@@ -1129,7 +1123,7 @@
 			message("no url selected");
 			break;
 		}
-		snprint(name, sizeof(name), "%s/hit.html", home);
+		snprint(name, sizeof(name), "%s/hit.html", mkhome());
 		fd=open(name, OWRITE);
 		if(fd==-1){
 			fd=create(name, OWRITE, 0666);
@@ -1145,7 +1139,7 @@
 		close(fd);
 		break;
 	case 5:
-		snprint(name, sizeof(name), "file:%s/hit.html", home);
+		snprint(name, sizeof(name), "file:%s/hit.html", mkhome());
 		geturl(name, -1, 1, 0);
 		break;
 	case 6:
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -65,7 +65,6 @@
 };
 
 Image *hrule, *bullet, *linespace;
-char home[512];		/* where to put files */
 int chrwidth;		/* nominal width of characters in font */
 Panel *text;		/* Panel displaying the current www page */
 int debug;		/* command line flag */