summaryrefslogtreecommitdiff
path: root/editors/em/files/patch-ag
blob: d94a2dac738a0afd0b4ec7f8b4369ee7c71ae20b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--- main.c.orig	Fri Jan 26 21:31:22 2001
+++ main.c	Fri Dec 15 01:11:42 2006
@@ -49,11 +49,17 @@
  *
  * 4.0	Petri Kutvonen, 1-Sep-91
  *
- * 4.0  convert from Linux source code to FreeBSD.
- *      Added tabmask change option. (-T) tabsize 8 to 4.
- *	Added automatic .c file setup cmode. like OS-9 uEMacs.
- *      Tadashi Yumoto, 27-Jan-01
+ * 4.0      convert from Linux source code to FreeBSD.
+ *          Added tabmask change option. (-T) tabsize 8 to 4.
+ *          Added automatic .c file setup cmode. like OS-9 uEMacs.
+ *          Tadashi Yumoto, 27-Jan-01
+ * 4.0.17   added file access permission test in file.c.
+ *          Tadashi Yumoto, 14-Apr-01
  *
+ *          modified -t option for -t4 or -t or -t8 supported.
+ *			fixed bug in eval.c not set "tabsize".
+ *			added help message.
+ *			Tadashi Yumoto 30-Dec-01
  */
 
 #include        <stdio.h>
@@ -89,6 +95,19 @@
 #include <signal.h>
 #endif
 
+static int prtuse(char*);
+
+#if UNIX
+static void emergencyexit();
+#ifdef SIGWINCH
+extern void sizesignal();
+#endif
+#endif
+
+#if	defined(TOYCODE) && defined(BSD)
+#include	<sys/unistd.h>
+#include	<errno.h>
+#endif
 #if	CALLED
 emacs(argc, argv)
 #else
@@ -131,13 +150,6 @@
 	int sink;			/* for file name scan */
 #endif
 
-#if UNIX
-	static void emergencyexit();
-#ifdef SIGWINCH
-	extern void sizesignal();
-#endif
-#endif
-
 #if	PKCODE & VMS
 	(void) umask(-1);	/* use old protection (this is at wrong place) */
 #endif
@@ -225,9 +237,21 @@
 #if	TOYCODE
 				case 't':	/* -t for tabmask change */
 				case 'T':
-					tabmask = 0x03;
-					tabsize = 4;
-					break;
+				case 'x':
+				case 'X':
+					if ( argv[carg][2] == '4' || argv[carg][2] == NULL ) {
+						tabsize = 4;
+						tabmask = 0x03;
+					} else if ( argv[carg][2] == '8' ) {
+						tabmask = 0x07;
+					}
+					break;
+				case 'h': case 'H': case '?':
+					TTclose();
+					TTkclose();
+					vttidy();
+					prtuse(argv[0]);
+					exit(0);
 #endif
 				default:	/* unknown switch */
 					/* ignore this for now */
@@ -273,7 +297,11 @@
 			sink = strlen(argv[carg]);
 			if (sink >= 2 && (argv[carg][sink-2] == '.' &&
 				 (argv[carg][sink-1] == 'c' || argv[carg][sink-1] == 'h')))
-				bp->b_mode |= MDCMOD;
+				bp->b_mode |= gmode | MDCMOD;
+			/* for C++ */
+			if (sink >= 3 && (argv[carg][sink-3] == '.' &&
+				 (argv[carg][sink-2] == 'c' && argv[carg][sink-1] == 'c')))
+				bp->b_mode |= gmode | MDCMOD;
 #endif
 		}
 	}
@@ -769,7 +797,7 @@
 			ALWAYS null terminate
 */
 
-char *strncpy(dst, src, maxlen)
+char *mystrncpy(dst, src, maxlen)
 
 char *dst;	/* destination of copied string */
 char *src;	/* source */
@@ -913,5 +941,44 @@
 #undef	exit
 	exit(status);
 #endif
+}
+#endif
+
+#if TOYCODE
+static char	*helpmsg[] = {
+	"Description:\n",
+	"   Light-weight full screen editor.\n",
+#if PKCODE
+	"   use termcap but,\n",
+	"   em recognizes the size of the screen dynamically.\n",
+#endif
+	"\n",
+	"Options: upper/lower case handling same way.\n",
+	"   -a      ... process error file.\n",
+	"   -e      ... edit file.\n",
+	"   -g<n>   ... initial goto line <n>.\n",
+#if PKCODE
+	"   +g<n>   ... initial goto line <n>.\n",
+#endif
+#if CRYPT
+	"   -k<key> ... cryption.\n",
+#endif
+#if PKCODE
+	"   -n      ... accept null chars.\n",
+#endif
+    "   -r      ... restrictive use.\n",
+    "   -s<str> ... initial serarch string.\n",
+    "   -v      ... view file.\n",
+	"   -t<4/8> ... force tab width change to 4/8.\n",
+};
+
+static int prtuse(pname)
+char	*pname;
+{
+	char	**p = helpmsg,
+			**e = helpmsg + (sizeof (helpmsg) / (sizeof (char **)));
+
+	fprintf(stderr,"Syntax: %s {[<opt>] file ...}\n",pname);
+	while ( p < e ) fputs(*p++,stderr);
 }
 #endif