Deleted Added
sdiff udiff text old ( 192856 ) new ( 192914 )
full compact
1/*
2 | ee (easy editor)
3 |
4 | An easy to use, simple screen oriented editor.
5 |
6 | written by Hugh Mahon
7 |
8 | THIS MATERIAL IS PROVIDED "AS IS". THERE ARE
9 | NO WARRANTIES OF ANY KIND WITH REGARD TO THIS
10 | MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE
11 | IMPLIED WARRANTIES OF MERCHANTABILITY AND
12 | FITNESS FOR A PARTICULAR PURPOSE. Neither
13 | Hewlett-Packard nor Hugh Mahon shall be liable
14 | for errors contained herein, nor for
15 | incidental or consequential damages in
16 | connection with the furnishing, performance or
17 | use of this material. Neither Hewlett-Packard
18 | nor Hugh Mahon assumes any responsibility for
19 | the use or reliability of this software or
20 | documentation. This software and
21 | documentation is totally UNSUPPORTED. There
22 | is no support contract available. Hewlett-
23 | Packard has done NO Quality Assurance on ANY
24 | of the program or documentation. You may find
25 | the quality of the materials inferior to
26 | supported materials.
27 |
28 | This software is not a product of Hewlett-Packard, Co., or any
29 | other company. No support is implied or offered with this software.
30 | You've got the source, and you're on your own.
31 |
32 | This software may be distributed under the terms of Larry Wall's
33 | Artistic license, a copy of which is included in this distribution.
34 |
35 | This notice must be included with this software and any derivatives.
36 |
37 | This editor was purposely developed to be simple, both in
38 | interface and implementation. This editor was developed to
39 | address a specific audience: the user who is new to computers
40 | (especially UNIX).
41 |
42 | ee is not aimed at technical users; for that reason more
43 | complex features were intentionally left out. In addition,
44 | ee is intended to be compiled by people with little computer
45 | experience, which means that it needs to be small, relatively
46 | simple in implementation, and portable.
47 |
48 | This software and documentation contains
49 | proprietary information which is protected by
50 | copyright. All rights are reserved.
51 |
52 | $Header: /home/hugh/sources/old_ae/RCS/ee.c,v 1.96 1998/07/14 05:02:30 hugh Exp $
53 |
54 */
55
56#include <sys/cdefs.h>
57__FBSDID("$FreeBSD: head/contrib/ee/ee.c 192856 2009-05-26 21:06:51Z ed $");
58
59char *ee_copyright_message =
60"Copyright (c) 1986, 1990, 1991, 1992, 1993, 1994, 1995, 1996 Hugh Mahon ";
61
62char *ee_long_notice[] = {
63 "This software and documentation contains",
64 "proprietary information which is protected by",
65 "copyright. All rights are reserved."
66 };
67
68char *version = "@(#) ee, version 1.4.1 $Revision: 1.96 $";
69
70#ifdef NCURSE
71#include "new_curse.h"
72#elif HAS_NCURSES
73#include <ncurses.h>
74#else
75#include <curses.h>
76#endif
77
78#ifdef HAS_CTYPE
79#include <ctype.h>
80#endif
81#include <err.h>
82#include <errno.h>
83#include <fcntl.h>
84#include <paths.h>
85#include <pwd.h>
86#include <signal.h>
87#include <sys/types.h>
88#include <sys/stat.h>
89#ifdef HAS_SYS_WAIT
90#include <sys/wait.h>
91#endif
92#ifdef HAS_STDARG
93#include <stdarg.h>
94#endif
95#ifdef HAS_STDLIB
96#include <stdlib.h>
97#endif
98#include <string.h>
99#ifdef HAS_UNISTD
100#include <unistd.h>
101#endif
102
103#ifndef NO_CATGETS
104#include <locale.h>
105#include <nl_types.h>
106
107nl_catd catalog;
108#else
109#define catgetlocal(a, b) (b)
110#endif /* NO_CATGETS */

--- 35 unchanged lines hidden (view full) ---

146
147struct files *top_of_stack = NULL;
148
149int d_wrd_len; /* length of deleted word */
150int position; /* offset in bytes from begin of line */
151int scr_pos; /* horizontal position */
152int scr_vert; /* vertical position on screen */
153int scr_horz; /* horizontal position on screen */
154int tmp_vert, tmp_horz;
155int input_file; /* indicate to read input file */
156int recv_file; /* indicate reading a file */
157int edit; /* continue executing while true */
158int gold; /* 'gold' function key pressed */
159int fildes; /* file descriptor */
160int case_sen; /* case sensitive search flag */
161int last_line; /* last line for text display */

--- 36 unchanged lines hidden (view full) ---

198unsigned char *srch_2; /* pointer to next character of string */
199unsigned char *srch_3;
200unsigned char *in_file_name = NULL; /* name of input file */
201char *tmp_file; /* temporary file name */
202unsigned char *d_char; /* deleted character */
203unsigned char *d_word; /* deleted word */
204unsigned char *d_line; /* deleted line */
205char in_string[513]; /* buffer for reading a file */
206unsigned char *print_command = "lpr"; /* string to use for the print command */
207unsigned char *start_at_line = NULL; /* move to this line at start of session*/
208const char count_text_default[] = "===============================================================================";
209int count_text_len = sizeof(count_text_default); /* length of the line above */
210char count_text[sizeof(count_text_default)]; /* buffer for current position display */
211int in; /* input character */
212
213FILE *temp_fp; /* temporary file pointer */
214FILE *bit_bucket; /* file pointer to /dev/null */
215
216char *table[] = {
217 "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "\t", "^J",
218 "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U",
219 "^V", "^W", "^X", "^Y", "^Z", "^[", "^\\", "^]", "^^", "^_"
220 };
221
222WINDOW *com_win;
223WINDOW *text_win;
224WINDOW *help_win;
225WINDOW *info_win;
226WINDOW *count_win;
227
228#if defined(__STDC__) || defined(__cplusplus)
229#define P_(s) s
230#else
231#define P_(s) ()
232#endif
233
234

--- 104 unchanged lines hidden (view full) ---

339void ispell_op P_((void));
340int first_word_len P_((struct text *test_line));
341void Auto_Format P_((void));
342void modes_op P_((void));
343char *is_in_string P_((char *string, char *substring));
344char *resolve_name P_((char *name));
345int restrict_mode P_((void));
346int unique_test P_((char *string, char *list[]));
347void renumber_lines P_((struct text *firstline, int startnumber));
348void strings_init P_((void));
349
350#undef P_
351/*
352 | allocate space here for the strings that will be in the menu
353 */
354
355struct menu_entries modes_menu[] = {

--- 177 unchanged lines hidden (view full) ---

533char *NOEMACS_string;
534char *conf_dump_err_msg;
535char *conf_dump_success_msg;
536char *conf_not_saved_msg;
537char *ree_no_file_msg;
538char *cancel_string;
539char *menu_too_lrg_msg;
540char *more_above_str, *more_below_str;
541
542char *chinese_cmd, *nochinese_cmd;
543
544
545int
546main(argc, argv) /* beginning of main program */
547int argc;
548char *argv[];
549{
550 /* Always read from (and write to) a terminal. */
551 if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)) {
552 fprintf(stderr, "ee's standard input and output must be a terminal\n");
553 exit(1);
554 }
555
556 signal(SIGCHLD, SIG_DFL);
557 signal(SIGSEGV, SIG_DFL);
558 signal(SIGINT, edit_abort);
559 signal(SIGHUP, edit_abort);
560
561 d_char = malloc(3); /* provide a buffer for multi-byte chars */
562 d_word = malloc(150);
563 *d_word = (char) NULL;
564 d_line = NULL;
565 dlt_line = txtalloc();
566 dlt_line->line = d_line;
567 dlt_line->line_length = 0;
568 curr_line = first_line = txtalloc();
569 curr_line->line = point = malloc(10);
570 curr_line->line_length = 1;
571 curr_line->max_length = 10;
572 curr_line->prev_line = NULL;
573 curr_line->next_line = NULL;
574 curr_line->line_number = 1;
575 srch_str = NULL;
576 u_srch_str = NULL;
577 position = 1;
578 scr_pos =0;
579 scr_vert = 0;
580 scr_horz = 0;
581 bit_bucket = fopen(_PATH_DEVNULL, "w");
582 edit = TRUE;
583 gold = case_sen = FALSE;
584 shell_fork = TRUE;
585 strings_init();
586 ee_init();
587 if (argc > 0 )
588 get_options(argc, argv);
589 set_up_term();

--- 12 unchanged lines hidden (view full) ---

602 wprintw(com_win, no_file_string);
603 wrefresh(com_win);
604 }
605 else
606 check_fp();
607
608 clear_com_win = TRUE;
609
610 while(edit)
611 {
612 if (info_window)
613 {
614 snprintf(count_text, count_text_len, "L: %d C: %d %s", \
615 curr_line->line_number, scr_horz + 1, count_text_default);
616 wmove(count_win, 0, 0);
617 if (!nohighlight)
618 wstandout(count_win);
619 wprintw(count_win, count_text);
620 wstandend(count_win);
621 wnoutrefresh(count_win);
622 }
623
624 wnoutrefresh(text_win);
625 doupdate();
626 in = wgetch(text_win);
627 if (in == -1)
628 continue;
629
630 resize_check();
631
632 if (clear_com_win)
633 {
634 clear_com_win = FALSE;
635 wmove(com_win, 0, 0);
636 werase(com_win);

--- 158 unchanged lines hidden (view full) ---

795 {
796 if (del_width == 1)
797 *d_char = *point; /* save deleted character */
798 else
799 {
800 d_char[0] = *point;
801 d_char[1] = *(point + 1);
802 }
803 d_char[del_width] = (unsigned char) NULL;
804 }
805 while (temp_pos <= curr_line->line_length)
806 {
807 temp_pos++;
808 *tp = *temp2;
809 tp++;
810 temp2++;
811 }
812 if (scr_horz < horiz_offset)
813 {
814 horiz_offset -= 8;
815 midscreen(scr_vert, point);
816 }
817 }
818 else if (curr_line->prev_line != NULL)
819 {
820 text_changes = TRUE;
821 left(disp); /* go to previous line */
822 temp_buff = curr_line->next_line;
823 point = resiz_line(temp_buff->line_length, curr_line, position);
824 if (temp_buff->next_line != NULL)
825 temp_buff->next_line->prev_line = curr_line;
826 curr_line->next_line = temp_buff->next_line;
827 renumber_lines(curr_line->next_line, curr_line->line_number + 1);
828 temp2 = temp_buff->line;
829 if (in == 8)
830 {
831 d_char[0] = '\n';
832 d_char[1] = (unsigned char) NULL;
833 }
834 tp = point;
835 temp_pos = 1;
836 while (temp_pos < temp_buff->line_length)
837 {
838 curr_line->line_length++;
839 temp_pos++;
840 *tp = *temp2;
841 tp++;
842 temp2++;
843 }
844 *tp = (char) NULL;
845 free(temp_buff->line);
846 free(temp_buff);
847 temp_buff = curr_line;
848 temp_vert = scr_vert;
849 scr_pos = scr_horz;
850 if (scr_vert < last_line)
851 {
852 wmove(text_win, scr_vert + 1, 0);

--- 72 unchanged lines hidden (view full) ---

925
926int
927out_char(window, character, column) /* output non-printing character */
928WINDOW *window;
929char character;
930int column;
931{
932 int i1, i2;
933 unsigned char *string;
934 char string2[8];
935
936 if (character == TAB)
937 {
938 i1 = tabshift(column);
939 for (i2 = 0;
940 (i2 < i1) && (((column+i2+1)-horiz_offset) < last_col); i2++)
941 {

--- 11 unchanged lines hidden (view full) ---

953 string = "^?";
954 else if (!eightbit)
955 {
956 sprintf(string2, "<%d>", (character < 0) ? (character + 256) : character);
957 string = string2;
958 }
959 else
960 {
961 waddch(window, (unsigned char)character );
962 return(1);
963 }
964 }
965 else
966 {
967 waddch(window, (unsigned char)character);
968 return(1);
969 }
970 for (i2 = 0; (string[i2] != (char) NULL) && (((column+i2+1)-horiz_offset) < last_col); i2++)
971 waddch(window, string[i2]);
972 return(strlen(string));
973}
974
975int
976len_char(character, column) /* return the length of the character */
977char character;
978int column; /* the column must be known to provide spacing for tabs */

--- 85 unchanged lines hidden (view full) ---

1064
1065 text_changes = TRUE;
1066 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1067 wclrtoeol(text_win);
1068 temp_nod= txtalloc();
1069 temp_nod->line = extra= malloc(10);
1070 temp_nod->line_length = 1;
1071 temp_nod->max_length = 10;
1072 temp_nod->next_line = curr_line->next_line;
1073 renumber_lines(temp_nod, curr_line->line_number + 1);
1074 if (temp_nod->next_line != NULL)
1075 temp_nod->next_line->prev_line = temp_nod;
1076 temp_nod->prev_line = curr_line;
1077 curr_line->next_line = temp_nod;
1078 temp_pos2 = position;
1079 temp = point;
1080 if (temp_pos2 < curr_line->line_length)
1081 {

--- 5 unchanged lines hidden (view full) ---

1087 temp_nod->line_length++;
1088 temp_pos++;
1089 temp_pos2++;
1090 *extra= *temp;
1091 extra++;
1092 temp++;
1093 }
1094 temp=point;
1095 *temp = (char) NULL;
1096 temp = resiz_line((1 - temp_nod->line_length), curr_line, position);
1097 curr_line->line_length = 1 + temp - curr_line->line;
1098 }
1099 curr_line->line_length = position;
1100 curr_line = temp_nod;
1101 *extra = (char) NULL;
1102 position = 1;
1103 point= curr_line->line;
1104 if (disp)
1105 {
1106 if (scr_vert < last_line)
1107 {
1108 scr_vert++;
1109 wclrtoeol(text_win);

--- 26 unchanged lines hidden (view full) ---

1136struct files *name_alloc() /* allocate space for file name list node */
1137{
1138 return((struct files *) malloc(sizeof( struct files)));
1139}
1140
1141unsigned char *next_word(string) /* move to next word in string */
1142unsigned char *string;
1143{
1144 while ((*string != (char) NULL) && ((*string != 32) && (*string != 9)))
1145 string++;
1146 while ((*string != (char) NULL) && ((*string == 32) || (*string == 9)))
1147 string++;
1148 return(string);
1149}
1150
1151void
1152prev_word() /* move to start of previous word in text */
1153{
1154 if (position != 1)

--- 17 unchanged lines hidden (view full) ---

1172void
1173control() /* use control for commands */
1174{
1175 char *string;
1176
1177 if (in == 1) /* control a */
1178 {
1179 string = get_string(ascii_code_str, TRUE);
1180 if (*string != (char) NULL)
1181 {
1182 in = atoi(string);
1183 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1184 insert(in);
1185 }
1186 free(string);
1187 }
1188 else if (in == 2) /* control b */

--- 91 unchanged lines hidden (view full) ---

1280 undel_line();
1281 else if (in == 13) /* control m */
1282 insert_line(TRUE);
1283 else if (in == 14) /* control n */
1284 down();
1285 else if (in == 15) /* control o */
1286 {
1287 string = get_string(ascii_code_str, TRUE);
1288 if (*string != (char) NULL)
1289 {
1290 in = atoi(string);
1291 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1292 insert(in);
1293 }
1294 free(string);
1295 }
1296 else if (in == 16) /* control p */

--- 23 unchanged lines hidden (view full) ---

1320 menu_op(main_menu);
1321 }
1322}
1323
1324void
1325bottom() /* go to bottom of file */
1326{
1327 while (curr_line->next_line != NULL)
1328 curr_line = curr_line->next_line;
1329 point = curr_line->line;
1330 if (horiz_offset)
1331 horiz_offset = 0;
1332 position = 1;
1333 midscreen(last_line, point);
1334 scr_pos = scr_horz;
1335}
1336
1337void
1338top() /* go to top of file */
1339{
1340 while (curr_line->prev_line != NULL)
1341 curr_line = curr_line->prev_line;
1342 point = curr_line->line;
1343 if (horiz_offset)
1344 horiz_offset = 0;
1345 position = 1;
1346 midscreen(0, point);
1347 scr_pos = scr_horz;
1348}
1349
1350void
1351nextline() /* move pointers to start of next line */
1352{
1353 curr_line = curr_line->next_line;
1354 point = curr_line->line;
1355 position = 1;
1356 if (scr_vert == last_line)
1357 {
1358 wmove(text_win, 0,0);
1359 wdeleteln(text_win);
1360 wmove(text_win, last_line,0);
1361 wclrtobot(text_win);
1362 draw_line(last_line,0,point,1,curr_line->line_length);
1363 }
1364 else
1365 scr_vert++;
1366}
1367
1368void
1369prevline() /* move pointers to start of previous line*/
1370{
1371 curr_line = curr_line->prev_line;
1372 point = curr_line->line;
1373 position = 1;
1374 if (scr_vert == 0)
1375 {
1376 winsertln(text_win);
1377 draw_line(0,0,point,1,curr_line->line_length);
1378 }
1379 else

--- 21 unchanged lines hidden (view full) ---

1401 scanline(point);
1402 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1403 scr_pos = scr_horz;
1404 }
1405 else if (curr_line->prev_line != NULL)
1406 {
1407 if (!disp)
1408 {
1409 curr_line = curr_line->prev_line;
1410 point = curr_line->line + curr_line->line_length;
1411 position = curr_line->line_length;
1412 return;
1413 }
1414 position = 1;
1415 prevline();
1416 scanline(point);

--- 19 unchanged lines hidden (view full) ---

1436 scanline(point);
1437 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1438 scr_pos = scr_horz;
1439 }
1440 else if (curr_line->next_line != NULL)
1441 {
1442 if (!disp)
1443 {
1444 curr_line = curr_line->next_line;
1445 point = curr_line->line;
1446 position = 1;
1447 return;
1448 }
1449 nextline();
1450 scr_pos = scr_horz = 0;
1451 if (horiz_offset)

--- 69 unchanged lines hidden (view full) ---

1521 if (in == KEY_LEFT)
1522 left(TRUE);
1523 else if (in == KEY_RIGHT)
1524 right(TRUE);
1525 else if (in == KEY_HOME)
1526 bol();
1527 else if (in == KEY_END)
1528 eol();
1529 else if ( in == KEY_UP)
1530 up();
1531 else if (in == KEY_DOWN)
1532 down();
1533 else if (in == KEY_NPAGE)
1534 move_rel("d", max( 5, (last_line - 5)));
1535 else if (in == KEY_PPAGE)
1536 move_rel("u", max(5, (last_line - 5)));
1537 else if (in == KEY_DL)

--- 143 unchanged lines hidden (view full) ---

1681 help();
1682 else if (compare(cmd_str, WRITE, FALSE))
1683 {
1684 if (restrict_mode())
1685 {
1686 return;
1687 }
1688 cmd_str = next_word(cmd_str);
1689 if (*cmd_str == (char) NULL)
1690 {
1691 cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);
1692 }
1693 tmp_file = resolve_name(cmd_str);
1694 write_file(tmp_file, 1);
1695 if (tmp_file != cmd_str)
1696 free(tmp_file);
1697 }
1698 else if (compare(cmd_str, READ, FALSE))
1699 {
1700 if (restrict_mode())
1701 {
1702 return;
1703 }
1704 cmd_str = next_word(cmd_str);
1705 if (*cmd_str == (char) NULL)
1706 {
1707 cmd_str = cmd_str2 = get_string(file_read_prompt_str, TRUE);
1708 }
1709 tmp_file = cmd_str;
1710 recv_file = TRUE;
1711 tmp_file = resolve_name(cmd_str);
1712 check_fp();
1713 if (tmp_file != cmd_str)

--- 153 unchanged lines hidden (view full) ---

1867 clear_com_win = TRUE;
1868 g_horz = g_position = scan(prompt, strlen(prompt), 0);
1869 g_pos = 0;
1870 do
1871 {
1872 esc_flag = FALSE;
1873 in = wgetch(com_win);
1874 if (in == -1)
1875 continue;
1876 if (((in == 8) || (in == 127) || (in == KEY_BACKSPACE)) && (g_pos > 0))
1877 {
1878 tmp_int = g_horz;
1879 g_pos--;
1880 g_horz = scan(g_point, g_pos, g_position);
1881 tmp_int = tmp_int - g_horz;
1882 for (; 0 < tmp_int; tmp_int--)
1883 {

--- 8 unchanged lines hidden (view full) ---

1892 }
1893 else if ((in != 8) && (in != 127) && (in != '\n') && (in != '\r') && (in < 256))
1894 {
1895 if (in == '\026') /* control-v, accept next character verbatim */
1896 { /* allows entry of ^m, ^j, and ^h */
1897 esc_flag = TRUE;
1898 in = wgetch(com_win);
1899 if (in == -1)
1900 continue;
1901 }
1902 *nam_str = in;
1903 g_pos++;
1904 if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 1)))
1905 g_horz += out_char(com_win, in, g_horz);
1906 else
1907 {
1908 g_horz++;
1909 if (g_horz < (last_col - 1))
1910 waddch(com_win, in);
1911 }
1912 nam_str++;
1913 }
1914 wrefresh(com_win);
1915 if (esc_flag)
1916 in = (char) NULL;
1917 } while ((in != '\n') && (in != '\r'));
1918 *nam_str = (char) NULL;
1919 nam_str = tmp_string;
1920 if (((*nam_str == ' ') || (*nam_str == 9)) && (advance))
1921 nam_str = next_word(nam_str);
1922 string = malloc(strlen(nam_str) + 1);
1923 strcpy(string, nam_str);
1924 free(tmp_string);
1925 wrefresh(com_win);
1926 return(string);

--- 8 unchanged lines hidden (view full) ---

1935 char *strng1;
1936 char *strng2;
1937 int tmp;
1938 int equal;
1939
1940 strng1 = string1;
1941 strng2 = string2;
1942 tmp = 0;
1943 if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == (char) NULL) || (*strng2 == (char) NULL))
1944 return(FALSE);
1945 equal = TRUE;
1946 while (equal)
1947 {
1948 if (sensitive)
1949 {
1950 if (*strng1 != *strng2)
1951 equal = FALSE;
1952 }
1953 else
1954 {
1955 if (toupper(*strng1) != toupper(*strng2))
1956 equal = FALSE;
1957 }
1958 strng1++;
1959 strng2++;
1960 if ((*strng1 == (char) NULL) || (*strng2 == (char) NULL) || (*strng1 == ' ') || (*strng2 == ' '))
1961 break;
1962 tmp++;
1963 }
1964 return(equal);
1965}
1966
1967void
1968goto_line(cmd_str)

--- 28 unchanged lines hidden (view full) ---

1997 t_line = t_line->next_line;
1998 }
1999 if ((i < 30) && (i > 0))
2000 {
2001 move_rel(direction, i);
2002 }
2003 else
2004 {
2005 curr_line = t_line;
2006 point = curr_line->line;
2007 position = 1;
2008 midscreen((last_line / 2), point);
2009 scr_pos = scr_horz;
2010 }
2011 wmove(com_win, 0, 0);
2012 wclrtoeol(com_win);

--- 44 unchanged lines hidden (view full) ---

2057 name++;
2058 if (!strcmp(name, "ree"))
2059 restricted = TRUE;
2060
2061 top_of_stack = NULL;
2062 input_file = FALSE;
2063 recv_file = FALSE;
2064 count = 1;
2065 while ((count < numargs) && (!no_more_opts))
2066 {
2067 buff = arguments[count];
2068 if (!strcmp("-i", buff))
2069 {
2070 info_window = FALSE;
2071 }
2072 else if (!strcmp("-e", buff))
2073 {

--- 7 unchanged lines hidden (view full) ---

2081 {
2082 fprintf(stderr, usage0, arguments[0]);
2083 fprintf(stderr, usage1);
2084 fprintf(stderr, usage2);
2085 fprintf(stderr, usage3);
2086 fprintf(stderr, usage4);
2087 exit(1);
2088 }
2089 else if (*buff == '+')
2090 {
2091 buff++;
2092 start_at_line = buff;
2093 }
2094 else if (!(strcmp("--", buff)))
2095 no_more_opts = TRUE;
2096 else
2097 {

--- 10 unchanged lines hidden (view full) ---

2108 temp_names = top_of_stack = name_alloc();
2109 }
2110 else
2111 {
2112 temp_names->next_name = name_alloc();
2113 temp_names = temp_names->next_name;
2114 }
2115 ptr = temp_names->name = malloc(strlen(buff) + 1);
2116 while (*buff != (char) NULL)
2117 {
2118 *ptr = *buff;
2119 buff++;
2120 ptr++;
2121 }
2122 *ptr = (char) NULL;
2123 temp_names->next_name = NULL;
2124 input_file = TRUE;
2125 recv_file = TRUE;
2126 count++;
2127 }
2128}
2129
2130void

--- 65 unchanged lines hidden (view full) ---

2196 start_at_line = NULL;
2197 }
2198 }
2199 else
2200 {
2201 wmove(com_win, 0, 0);
2202 wclrtoeol(com_win);
2203 text_changes = TRUE;
2204 if ((tmp_file != NULL) && (*tmp_file != (char) NULL))
2205 wprintw(com_win, file_read_fin_msg, tmp_file);
2206 }
2207 wrefresh(com_win);
2208 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2209 wrefresh(text_win);
2210}
2211
2212void

--- 100 unchanged lines hidden (view full) ---

2313 {
2314 str2++;
2315 num++;
2316 char_count++;
2317 }
2318 if (!(*append)) /* if not append to current line, insert new one */
2319 {
2320 tline = txtalloc(); /* allocate data structure for next line */
2321 tline->next_line = curr_line->next_line;
2322 renumber_lines(tline, curr_line->line_number + 1);
2323 tline->prev_line = curr_line;
2324 curr_line->next_line = tline;
2325 if (tline->next_line != NULL)
2326 tline->next_line->prev_line = tline;
2327 curr_line = tline;
2328 curr_line->line = point = (unsigned char *) malloc(char_count);
2329 curr_line->line_length = char_count;
2330 curr_line->max_length = char_count;

--- 4 unchanged lines hidden (view full) ---

2335 curr_line->line_length += (char_count - 1);
2336 }
2337 for (temp_counter = 1; temp_counter < char_count; temp_counter++)
2338 {
2339 *point = *str1;
2340 point++;
2341 str1++;
2342 }
2343 *point = (char) NULL;
2344 *append = FALSE;
2345 if ((num == length) && (*str2 != '\n'))
2346 *append = TRUE;
2347 }
2348}
2349
2350void
2351draw_screen() /* redraw the screen from current postion */

--- 21 unchanged lines hidden (view full) ---

2373{
2374 char *file_name = in_file_name;
2375
2376 /*
2377 | changes made here should be reflected in the 'save'
2378 | portion of file_op()
2379 */
2380
2381 if ((file_name == NULL) || (*file_name == (char) NULL))
2382 file_name = get_string(save_file_name_prompt, TRUE);
2383
2384 if ((file_name == NULL) || (*file_name == (char) NULL))
2385 {
2386 wmove(com_win, 0, 0);
2387 wprintw(com_win, file_not_saved_msg);
2388 wclrtoeol(com_win);
2389 wrefresh(com_win);
2390 clear_com_win = TRUE;
2391 return;
2392 }

--- 40 unchanged lines hidden (view full) ---

2433 exit(0);
2434 }
2435 else
2436 {
2437 delete_text();
2438 recv_file = TRUE;
2439 input_file = TRUE;
2440 check_fp();
2441 text_changes = FALSE;
2442 }
2443 return(0);
2444}
2445
2446void
2447edit_abort(arg)
2448int arg;
2449{

--- 8 unchanged lines hidden (view full) ---

2458delete_text()
2459{
2460 while (curr_line->next_line != NULL)
2461 curr_line = curr_line->next_line;
2462 while (curr_line != first_line)
2463 {
2464 free(curr_line->line);
2465 curr_line = curr_line->prev_line;
2466 free(curr_line->next_line);
2467 }
2468 curr_line->next_line = NULL;
2469 *curr_line->line = (char) NULL;
2470 curr_line->line_length = 1;
2471 curr_line->line_number = 1;
2472 point = curr_line->line;
2473 scr_pos = scr_vert = scr_horz = 0;
2474 position = 1;
2475}
2476
2477int

--- 75 unchanged lines hidden (view full) ---

2553int
2554search(display_message) /* search for string in srch_str */
2555int display_message;
2556{
2557 int lines_moved;
2558 int iter;
2559 int found;
2560
2561 if ((srch_str == NULL) || (*srch_str == (char) NULL))
2562 return(FALSE);
2563 if (display_message)
2564 {
2565 wmove(com_win, 0, 0);
2566 wclrtoeol(com_win);
2567 wprintw(com_win, searching_msg);
2568 wrefresh(com_win);
2569 clear_com_win = TRUE;

--- 8 unchanged lines hidden (view full) ---

2578 while ((!found) && (srch_line != NULL))
2579 {
2580 while ((iter < srch_line->line_length) && (!found))
2581 {
2582 srch_2 = srch_1;
2583 if (case_sen) /* if case sensitive */
2584 {
2585 srch_3 = srch_str;
2586 while ((*srch_2 == *srch_3) && (*srch_3 != (char) NULL))
2587 {
2588 found = TRUE;
2589 srch_2++;
2590 srch_3++;
2591 } /* end while */
2592 }
2593 else /* if not case sensitive */
2594 {
2595 srch_3 = u_srch_str;
2596 while ((toupper(*srch_2) == *srch_3) && (*srch_3 != (char) NULL))
2597 {
2598 found = TRUE;
2599 srch_2++;
2600 srch_3++;
2601 }
2602 } /* end else */
2603 if (!((*srch_3 == (char) NULL) && (found)))
2604 {
2605 found = FALSE;
2606 if (iter < srch_line->line_length)
2607 srch_1++;
2608 iter++;
2609 }
2610 }
2611 if (!found)

--- 23 unchanged lines hidden (view full) ---

2635 if (lines_moved < 30)
2636 {
2637 move_rel("d", lines_moved);
2638 while (position < iter)
2639 right(TRUE);
2640 }
2641 else
2642 {
2643 curr_line = srch_line;
2644 point = srch_1;
2645 position = iter;
2646 scanline(point);
2647 scr_pos = scr_horz;
2648 midscreen((last_line / 2), point);
2649 }
2650 }

--- 12 unchanged lines hidden (view full) ---

2663 return(found);
2664}
2665
2666void
2667search_prompt() /* prompt and read search string (srch_str) */
2668{
2669 if (srch_str != NULL)
2670 free(srch_str);
2671 if ((u_srch_str != NULL) && (*u_srch_str != (char) NULL))
2672 free(u_srch_str);
2673 srch_str = get_string(search_prompt_str, FALSE);
2674 gold = FALSE;
2675 srch_3 = srch_str;
2676 srch_1 = u_srch_str = malloc(strlen(srch_str) + 1);
2677 while (*srch_3 != (char) NULL)
2678 {
2679 *srch_1 = toupper(*srch_3);
2680 srch_1++;
2681 srch_3++;
2682 }
2683 *srch_1 = (char) NULL;
2684 search(TRUE);
2685}
2686
2687void
2688del_char() /* delete current character */
2689{
2690 in = 8; /* backspace */
2691 if (position < curr_line->line_length) /* if not end of line */

--- 20 unchanged lines hidden (view full) ---

2712undel_char() /* undelete last deleted character */
2713{
2714 if (d_char[0] == '\n') /* insert line if last del_char deleted eol */
2715 insert_line(TRUE);
2716 else
2717 {
2718 in = d_char[0];
2719 insert(in);
2720 if (d_char[1] != (unsigned char) NULL)
2721 {
2722 in = d_char[1];
2723 insert(in);
2724 }
2725 }
2726}
2727
2728void

--- 25 unchanged lines hidden (view full) ---

2754 while ((tposit < curr_line->line_length) &&
2755 ((*d_word3 == ' ') || (*d_word3 == '\t')))
2756 {
2757 tposit++;
2758 *d_word2 = *d_word3;
2759 d_word2++;
2760 d_word3++;
2761 }
2762 *d_word2 = (char) NULL;
2763 d_wrd_len = difference = d_word2 - d_word;
2764 d_word2 = point;
2765 while (tposit < curr_line->line_length)
2766 {
2767 tposit++;
2768 *d_word2 = *d_word3;
2769 d_word2++;
2770 d_word3++;
2771 }
2772 curr_line->line_length -= difference;
2773 *d_word2 = (char) NULL;
2774 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
2775 d_char[0] = tmp_char[0];
2776 d_char[1] = tmp_char[1];
2777 d_char[2] = tmp_char[2];
2778 text_changes = TRUE;
2779 formatted = FALSE;
2780}
2781

--- 36 unchanged lines hidden (view full) ---

2818 temp++;
2819 tposit++;
2820 *tmp_ptr = *tmp_old_ptr;
2821 tmp_ptr++;
2822 tmp_old_ptr++;
2823 }
2824 curr_line->line_length += d_wrd_len;
2825 tmp_old_ptr = point;
2826 *tmp_ptr = (char) NULL;
2827 tmp_ptr = tmp_space;
2828 tposit = 1;
2829 /*
2830 | now copy contents from temp space back to original line
2831 */
2832 while (tposit < temp)
2833 {
2834 tposit++;
2835 *tmp_old_ptr = *tmp_ptr;
2836 tmp_ptr++;
2837 tmp_old_ptr++;
2838 }
2839 *tmp_old_ptr = (char) NULL;
2840 free(tmp_space);
2841 draw_line(scr_vert, scr_horz, point, position, curr_line->line_length);
2842}
2843
2844void
2845del_line() /* delete from cursor to end of line */
2846{
2847 unsigned char *dl1;

--- 9 unchanged lines hidden (view full) ---

2857 while (tposit < curr_line->line_length)
2858 {
2859 *dl1 = *dl2;
2860 dl1++;
2861 dl2++;
2862 tposit++;
2863 }
2864 dlt_line->line_length = 1 + tposit - position;
2865 *dl1 = (char) NULL;
2866 *point = (char) NULL;
2867 curr_line->line_length = position;
2868 wclrtoeol(text_win);
2869 if (curr_line->next_line != NULL)
2870 {
2871 right(FALSE);
2872 delete(FALSE);
2873 }
2874 text_changes = TRUE;

--- 18 unchanged lines hidden (view full) ---

2893 tposit = 1;
2894 while (tposit < dlt_line->line_length)
2895 {
2896 tposit++;
2897 *ud1 = *ud2;
2898 ud1++;
2899 ud2++;
2900 }
2901 *ud1 = (char) NULL;
2902 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
2903}
2904
2905void
2906adv_word() /* advance to next word */
2907{
2908while ((position < curr_line->line_length) && ((*point != 32) && (*point != 9)))
2909 right(TRUE);

--- 23 unchanged lines hidden (view full) ---

2933 tmp = point;
2934 tmp_line = curr_line;
2935 for (i= 0;(i<5)&&(curr_line->prev_line != NULL); i++)
2936 {
2937 up();
2938 }
2939 scr_vert = scr_vert + i;
2940 curr_line = tmp_line;
2941 point = tmp;
2942 scanline(point);
2943 }
2944 }
2945 else
2946 {
2947 if ((position != 1) && (curr_line->next_line != NULL))
2948 {

--- 14 unchanged lines hidden (view full) ---

2963 if ((last_line > 10) && (scr_vert > (last_line - 5)))
2964 {
2965 tmp = point;
2966 tmp_line = curr_line;
2967 for (i=0; (i<5) && (curr_line->next_line != NULL); i++)
2968 {
2969 down();
2970 }
2971 scr_vert = scr_vert - i;
2972 curr_line = tmp_line;
2973 point = tmp;
2974 scanline(point);
2975 }
2976 }
2977 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2978}

--- 41 unchanged lines hidden (view full) ---

3020 else if (curr_line->next_line != NULL)
3021 {
3022 scr_pos = 0;
3023 down();
3024 }
3025}
3026
3027void
3028sh_command(string) /* execute shell command */
3029char *string; /* string containing user command */
3030{
3031 char *temp_point;
3032 char *last_slash;
3033 char *path; /* directory path to executable */
3034 int parent; /* zero if child, child's pid if parent */
3035 int value;
3036 int return_val;
3037 struct text *line_holder;
3038
3039 if (restrict_mode())
3040 {
3041 return;
3042 }
3043
3044 if (!(path = getenv("SHELL")))
3045 path = "/bin/sh";
3046 last_slash = temp_point = path;
3047 while (*temp_point != (char) NULL)
3048 {
3049 if (*temp_point == '/')
3050 last_slash = ++temp_point;
3051 else
3052 temp_point++;
3053 }
3054
3055 /*

--- 55 unchanged lines hidden (view full) ---

3111 close(pipe_in[1]);
3112 get_fd = pipe_in[0];
3113 get_file("");
3114 close(pipe_in[0]);
3115 scr_vert = tmp_vert;
3116 scr_horz = scr_pos = 0;
3117 position = 1;
3118 curr_line = line_holder;
3119 point = curr_line->line;
3120 out_pipe = FALSE;
3121 signal(SIGCHLD, SIG_DFL);
3122/*
3123 | since flag "in_pipe" is still TRUE, the path which waits for the child
3124 | process to die will be avoided.
3125 | (the pipe is closed, no more output can be expected)
3126 */

--- 22 unchanged lines hidden (view full) ---

3149 */
3150 close(0);
3151 dup(pipe_out[0]);
3152 close(pipe_out[0]);
3153 close(pipe_out[1]);
3154 }
3155 for (value = 1; value < 24; value++)
3156 signal(value, SIG_DFL);
3157 execl(path, last_slash, "-c", string, (char *)NULL);
3158 errx(1, exec_err_msg, path);
3159 }
3160 else /* if the parent */
3161 {
3162 if (out_pipe)
3163 {
3164/*
3165 | output the contents of the buffer to the pipe (to be read by the
3166 | process forked and exec'd above as stdin)

--- 26 unchanged lines hidden (view full) ---

3193 */
3194 if (!shell_fork)
3195 exit(0);
3196 }
3197 signal(SIGINT, edit_abort);
3198 }
3199 if (shell_fork)
3200 {
3201 printf("%s", continue_msg);
3202 fflush(stdout);
3203 while ((in = getchar()) != '\n')
3204 ;
3205 }
3206
3207 if (!in_pipe)
3208 {
3209 fixterm();

--- 43 unchanged lines hidden (view full) ---

3253 idlok(text_win, TRUE);
3254 wrefresh(text_win);
3255 help_win = newwin((LINES - 1), COLS, 0, 0);
3256 keypad(help_win, TRUE);
3257 idlok(help_win, TRUE);
3258 if (info_window)
3259 {
3260 info_type = CONTROL_KEYS;
3261 info_win = newwin(5, COLS, 0, 0);
3262 werase(info_win);
3263 paint_info_win();
3264 count_win = newwin(1, COLS, 5, 0);
3265 leaveok(count_win, TRUE);
3266 wrefresh(count_win);
3267 }
3268
3269 last_col = COLS - 1;
3270 local_LINES = LINES;
3271 local_COLS = COLS;
3272
3273#ifdef NCURSE
3274 if (ee_chinese)

--- 8 unchanged lines hidden (view full) ---

3283 if ((LINES == local_LINES) && (COLS == local_COLS))
3284 return;
3285
3286 if (info_window)
3287 delwin(info_win);
3288 delwin(text_win);
3289 delwin(com_win);
3290 delwin(help_win);
3291 delwin(count_win);
3292 set_up_term();
3293 redraw();
3294 wrefresh(text_win);
3295}
3296
3297static char item_alpha[] = "abcdefghijklmnopqrstuvwxyz0123456789 ";
3298
3299int
3300menu_op(menu_list)
3301struct menu_entries menu_list[];
3302{
3303 WINDOW *temp_win;
3304 int max_width, max_height;
3305 int x_off, y_off;
3306 int counter;
3307 int length;
3308 int input;
3309 int temp = 0;
3310 int list_size;
3311 int top_offset; /* offset from top where menu items start */
3312 int vert_pos; /* vertical position */
3313 int vert_size; /* vertical size for menu list item display */
3314 int off_start = 1; /* offset from start of menu items to start display */
3315
3316
3317 /*

--- 65 unchanged lines hidden (view full) ---

3383 do
3384 {
3385 if (off_start > 2)
3386 wmove(temp_win, (1 + counter + top_offset - off_start), 3);
3387 else
3388 wmove(temp_win, (counter + top_offset - off_start), 3);
3389
3390 wrefresh(temp_win);
3391 input = wgetch(temp_win);
3392
3393 if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) ||
3394 ((input >= '0') && (input <= '9')))
3395 {
3396 if ((tolower(input) >= 'a') && (tolower(input) <= 'z'))
3397 {
3398 temp = 1 + tolower(input) - 'a';
3399 }

--- 226 unchanged lines hidden (view full) ---

3626 emacs_help_text[counter] : help_text[counter]);
3627 }
3628 wrefresh(help_win);
3629 werase(com_win);
3630 wmove(com_win, 0, 0);
3631 wprintw(com_win, press_any_key_msg);
3632 wrefresh(com_win);
3633 counter = wgetch(com_win);
3634 werase(com_win);
3635 wmove(com_win, 0, 0);
3636 werase(help_win);
3637 wrefresh(help_win);
3638 wrefresh(com_win);
3639 redraw();
3640}
3641

--- 11 unchanged lines hidden (view full) ---

3653 wmove(info_win, counter, 0);
3654 wclrtoeol(info_win);
3655 if (info_type == CONTROL_KEYS)
3656 waddstr(info_win, (emacs_keys_mode) ?
3657 emacs_control_keys[counter] : control_keys[counter]);
3658 else if (info_type == COMMANDS)
3659 waddstr(info_win, command_strings[counter]);
3660 }
3661 wrefresh(info_win);
3662}
3663
3664void
3665no_info_window()
3666{
3667 if (!info_window)
3668 return;

--- 17 unchanged lines hidden (view full) ---

3686 return;
3687 last_line = LINES - 8;
3688 delwin(text_win);
3689 text_win = newwin((LINES - 7), COLS, 6, 0);
3690 keypad(text_win, TRUE);
3691 idlok(text_win, TRUE);
3692 werase(text_win);
3693 info_window = TRUE;
3694 info_win = newwin(5, COLS, 0, 0);
3695 werase(info_win);
3696 info_type = CONTROL_KEYS;
3697 midscreen(min(scr_vert, last_line), point);
3698 clearok(info_win, TRUE);
3699 paint_info_win();
3700 count_win = newwin(1, COLS, 5, 0);
3701 leaveok(count_win, TRUE);
3702 wrefresh(count_win);
3703 wrefresh(text_win);
3704 clear_com_win = TRUE;
3705}
3706
3707int
3708file_op(arg)
3709int arg;
3710{

--- 31 unchanged lines hidden (view full) ---

3742 */
3743
3744 if (in_file_name)
3745 flag = TRUE;
3746 else
3747 flag = FALSE;
3748
3749 string = in_file_name;
3750 if ((string == NULL) || (*string == (char) NULL))
3751 string = get_string(save_file_name_prompt, TRUE);
3752 if ((string == NULL) || (*string == (char) NULL))
3753 {
3754 wmove(com_win, 0, 0);
3755 wprintw(com_win, file_not_saved_msg);
3756 wclrtoeol(com_win);
3757 wrefresh(com_win);
3758 clear_com_win = TRUE;
3759 return(0);
3760 }

--- 18 unchanged lines hidden (view full) ---

3779}
3780
3781void
3782shell_op()
3783{
3784 char *string;
3785
3786 if (((string = get_string(shell_prompt, TRUE)) != NULL) &&
3787 (*string != (char) NULL))
3788 {
3789 sh_command(string);
3790 free(string);
3791 }
3792}
3793
3794void
3795leave_op()

--- 109 unchanged lines hidden (view full) ---

3905 case_sen = TRUE;
3906 tmp_srchstr = srch_str;
3907 temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position);
3908 if ((*point == ' ') || (*point == '\t'))
3909 adv_word();
3910 offset -= position;
3911 counter = position;
3912 line = temp1 = point;
3913 while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
3914 {
3915 *temp2 = *temp1;
3916 temp2++;
3917 temp1++;
3918 counter++;
3919 }
3920 *temp2 = (char) NULL;
3921 if (position != 1)
3922 bol();
3923 while (!Blank_Line(curr_line->prev_line))
3924 bol();
3925 string_count = 0;
3926 status = TRUE;
3927 while ((line != point) && (status))
3928 {

--- 159 unchanged lines hidden (view full) ---

4088 unsigned char *string;
4089 unsigned char *str1;
4090 unsigned char *str2;
4091 char *home;
4092 int counter;
4093 int temp_int;
4094
4095 string = getenv("HOME");
4096 if (!string)
4097 string = "/root"; /* Set to reasonable default so we don't crash */
4098 str1 = home = malloc(strlen(string)+10);
4099 strcpy(home, string);
4100 strcat(home, "/.init.ee");
4101 init_name[1] = home;
4102 string = malloc(512);
4103
4104 for (counter = 0; counter < 3; counter++)
4105 {
4106 if (!(access(init_name[counter], 4)))
4107 {
4108 init_file = fopen(init_name[counter], "r");
4109 while ((str2 = fgets(string, 512, init_file)) != NULL)
4110 {
4111 str1 = str2 = string;
4112 while (*str2 != '\n')
4113 str2++;
4114 *str2 = (char) NULL;
4115
4116 if (unique_test(string, init_strings) != 1)
4117 continue;
4118
4119 if (compare(str1, CASE, FALSE))
4120 case_sen = TRUE;
4121 else if (compare(str1, NOCASE, FALSE))
4122 case_sen = FALSE;

--- 14 unchanged lines hidden (view full) ---

4137 auto_format = TRUE;
4138 observ_margins = TRUE;
4139 }
4140 else if (compare(str1, NOAUTOFORMAT, FALSE))
4141 auto_format = FALSE;
4142 else if (compare(str1, Echo, FALSE))
4143 {
4144 str1 = next_word(str1);
4145 if (*str1 != (char) NULL)
4146 echo_string(str1);
4147 }
4148 else if (compare(str1, PRINTCOMMAND, FALSE))
4149 {
4150 str1 = next_word(str1);
4151 print_command = malloc(strlen(str1)+1);
4152 strcpy(print_command, str1);
4153 }

--- 107 unchanged lines hidden (view full) ---

4261 if (old_init_file != NULL)
4262 {
4263 /*
4264 | Copy non-configuration info into new .init.ee file.
4265 */
4266 while ((string = fgets(buffer, 512, old_init_file)) != NULL)
4267 {
4268 length = strlen(string);
4269 string[length - 1] = (char) NULL;
4270
4271 if (unique_test(string, init_strings) == 1)
4272 {
4273 if (compare(string, Echo, FALSE))
4274 {
4275 fprintf(init_file, "%s\n", string);
4276 }
4277 }

--- 30 unchanged lines hidden (view full) ---

4308void
4309echo_string(string) /* echo the given string */
4310char *string;
4311{
4312 char *temp;
4313 int Counter;
4314
4315 temp = string;
4316 while (*temp != (char) NULL)
4317 {
4318 if (*temp == '\\')
4319 {
4320 temp++;
4321 if (*temp == 'n')
4322 putchar('\n');
4323 else if (*temp == 't')
4324 putchar('\t');

--- 59 unchanged lines hidden (view full) ---

4384 char string[256];
4385 int fd;
4386
4387 if (restrict_mode())
4388 {
4389 return;
4390 }
4391 (void)sprintf(template, "/tmp/ee.XXXXXXXX");
4392 name = mktemp(&template[0]);
4393 fd = open(name, O_CREAT | O_EXCL | O_RDWR, 0600);
4394 if (fd < 0) {
4395 wmove(com_win, 0, 0);
4396 wprintw(com_win, create_file_fail_msg, name);
4397 wrefresh(com_win);
4398 return;
4399 }
4400 close(fd);
4401 if (write_file(name, 0))

--- 14 unchanged lines hidden (view full) ---

4416{
4417 int counter;
4418 unsigned char *pnt;
4419
4420 if (test_line == NULL)
4421 return(0);
4422
4423 pnt = test_line->line;
4424 if ((pnt == NULL) || (*pnt == (char) NULL) ||
4425 (*pnt == '.') || (*pnt == '>'))
4426 return(0);
4427
4428 if ((*pnt == ' ') || (*pnt == '\t'))
4429 {
4430 pnt = next_word(pnt);
4431 }
4432
4433 if (*pnt == (char) NULL)
4434 return(0);
4435
4436 counter = 0;
4437 while ((*pnt != (char) NULL) && ((*pnt != ' ') && (*pnt != '\t')))
4438 {
4439 pnt++;
4440 counter++;
4441 }
4442 while ((*pnt != (char) NULL) && ((*pnt == ' ') || (*pnt == '\t')))
4443 {
4444 pnt++;
4445 counter++;
4446 }
4447 return(counter);
4448}
4449
4450void

--- 34 unchanged lines hidden (view full) ---

4485 | will be in the same relative position
4486 */
4487
4488 tmp_d_line = d_line;
4489 tmp_d_line_length = dlt_line->line_length;
4490 d_line = NULL;
4491 auto_format = FALSE;
4492 offset = position;
4493 if ((position != 1) && ((*point == ' ') || (*point == '\t') || (position == curr_line->line_length) || (*point == (char) NULL)))
4494 prev_word();
4495 temp_dword = d_word;
4496 temp_dwl = d_wrd_len;
4497 d_wrd_len = 0;
4498 d_word = NULL;
4499 temp_case = case_sen;
4500 case_sen = TRUE;
4501 tmp_srchstr = srch_str;
4502 temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position);
4503 if ((*point == ' ') || (*point == '\t'))
4504 adv_word();
4505 offset -= position;
4506 counter = position;
4507 line = temp1 = point;
4508 while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
4509 {
4510 *temp2 = *temp1;
4511 temp2++;
4512 temp1++;
4513 counter++;
4514 }
4515 *temp2 = (char) NULL;
4516 if (position != 1)
4517 bol();
4518 while (!Blank_Line(curr_line->prev_line))
4519 bol();
4520 string_count = 0;
4521 status = TRUE;
4522 while ((line != point) && (status))
4523 {

--- 285 unchanged lines hidden (view full) ---

4809
4810char *
4811is_in_string(string, substring) /* a strchr() look-alike for systems without
4812 strchr() */
4813char * string, *substring;
4814{
4815 char *full, *sub;
4816
4817 for (sub = substring; (sub != NULL) && (*sub != (char)NULL); sub++)
4818 {
4819 for (full = string; (full != NULL) && (*full != (char)NULL);
4820 full++)
4821 {
4822 if (*sub == *full)
4823 return(full);
4824 }
4825 }
4826 return(NULL);
4827}

--- 26 unchanged lines hidden (view full) ---

4854 user = (struct passwd *) getpwuid(index);
4855 slash = name + 1;
4856 }
4857 else
4858 {
4859 slash = strchr(name, '/');
4860 if (slash == NULL)
4861 return(name);
4862 *slash = (char) NULL;
4863 user = (struct passwd *) getpwnam((name + 1));
4864 *slash = '/';
4865 }
4866 if (user == NULL)
4867 {
4868 return(name);
4869 }
4870 buffer = malloc(strlen(user->pw_dir) + strlen(slash) + 1);
4871 strcpy(buffer, user->pw_dir);
4872 strcat(buffer, slash);
4873 }
4874 else
4875 buffer = name;
4876
4877 if (is_in_string(buffer, "$"))
4878 {
4879 tmp = buffer;
4880 index = 0;
4881
4882 while ((*tmp != (char) NULL) && (index < 1024))
4883 {
4884
4885 while ((*tmp != (char) NULL) && (*tmp != '$') &&
4886 (index < 1024))
4887 {
4888 long_buffer[index] = *tmp;
4889 tmp++;
4890 index++;
4891 }
4892
4893 if ((*tmp == '$') && (index < 1024))
4894 {
4895 counter = 0;
4896 start_of_var = tmp;
4897 tmp++;
4898 if (*tmp == '{') /* } */ /* bracketed variable name */
4899 {
4900 tmp++; /* { */
4901 while ((*tmp != (char) NULL) &&
4902 (*tmp != '}') &&
4903 (counter < 128))
4904 {
4905 short_buffer[counter] = *tmp;
4906 counter++;
4907 tmp++;
4908 } /* { */
4909 if (*tmp == '}')
4910 tmp++;
4911 }
4912 else
4913 {
4914 while ((*tmp != (char) NULL) &&
4915 (*tmp != '/') &&
4916 (*tmp != '$') &&
4917 (counter < 128))
4918 {
4919 short_buffer[counter] = *tmp;
4920 counter++;
4921 tmp++;
4922 }
4923 }
4924 short_buffer[counter] = (char) NULL;
4925 if ((slash = getenv(short_buffer)) != NULL)
4926 {
4927 offset = strlen(slash);
4928 if ((offset + index) < 1024)
4929 strcpy(&long_buffer[index], slash);
4930 index += offset;
4931 }
4932 else

--- 6 unchanged lines hidden (view full) ---

4939 }
4940 }
4941 }
4942 }
4943
4944 if (index == 1024)
4945 return(buffer);
4946 else
4947 long_buffer[index] = (char) NULL;
4948
4949 if (name != buffer)
4950 free(buffer);
4951 buffer = malloc(index + 1);
4952 strcpy(buffer, long_buffer);
4953 }
4954
4955 return(buffer);

--- 35 unchanged lines hidden (view full) ---

4991 result = compare(string, list[counter], FALSE);
4992 if (result)
4993 num_match++;
4994 counter++;
4995 }
4996 return(num_match);
4997}
4998
4999void
5000renumber_lines(firstline, startnumber)
5001struct text *firstline;
5002int startnumber;
5003{
5004 struct text *lineptr;
5005 int i;
5006
5007 i = startnumber;
5008 for (lineptr = firstline; lineptr != NULL; lineptr = lineptr->next_line)
5009 lineptr->line_number = i++;
5010}
5011
5012#ifndef NO_CATGETS
5013/*
5014 | Get the catalog entry, and if it got it from the catalog,
5015 | make a copy, since the buffer will be overwritten by the
5016 | next call to catgets().
5017 */
5018
5019char *

--- 129 unchanged lines hidden (view full) ---

5149 yes_char = catgetlocal( 95, "y");
5150 file_exists_prompt = catgetlocal( 96, "file already exists, overwrite? (y/n) [n] ");
5151 create_file_fail_msg = catgetlocal( 97, "unable to create file \"%s\"");
5152 writing_file_msg = catgetlocal( 98, "writing file \"%s\"");
5153 file_written_msg = catgetlocal( 99, "\"%s\" %d lines, %d characters");
5154 searching_msg = catgetlocal( 100, " ...searching");
5155 str_not_found_msg = catgetlocal( 101, "string \"%s\" not found");
5156 search_prompt_str = catgetlocal( 102, "search for: ");
5157 exec_err_msg = catgetlocal( 103, "could not exec %s");
5158 continue_msg = catgetlocal( 104, "press return to continue ");
5159 menu_cancel_msg = catgetlocal( 105, "press Esc to cancel");
5160 menu_size_err_msg = catgetlocal( 106, "menu too large for window");
5161 press_any_key_msg = catgetlocal( 107, "press any key to continue ");
5162 shell_prompt = catgetlocal( 108, "shell command: ");
5163 formatting_msg = catgetlocal( 109, "...formatting paragraph...");
5164 shell_echo_msg = catgetlocal( 110, "<!echo 'list of unrecognized words'; echo -=-=-=-=-=-");
5165 spell_in_prog_msg = catgetlocal( 111, "sending contents of edit buffer to 'spell'");

--- 31 unchanged lines hidden (view full) ---

5197 EIGHTBIT = catgetlocal( 143, "EIGHTBIT");
5198 NOEIGHTBIT = catgetlocal( 144, "NOEIGHTBIT");
5199 /*
5200 | additions
5201 */
5202 mode_strings[7] = catgetlocal( 145, "emacs key bindings ");
5203 emacs_help_text[0] = help_text[0];
5204 emacs_help_text[1] = catgetlocal( 146, "^a beginning of line ^i tab ^r restore word ");
5205 emacs_help_text[2] = catgetlocal( 147, "^b back 1 char ^j undel char ^t begin of file ");
5206 emacs_help_text[3] = catgetlocal( 148, "^c command ^k delete line ^u end of file ");
5207 emacs_help_text[4] = catgetlocal( 149, "^d delete char ^l undelete line ^v next page ");
5208 emacs_help_text[5] = catgetlocal( 150, "^e end of line ^m newline ^w delete word ");
5209 emacs_help_text[6] = catgetlocal( 151, "^f forward 1 char ^n next line ^x search ");
5210 emacs_help_text[7] = catgetlocal( 152, "^g go back 1 page ^o ascii char insert ^y search prompt ");
5211 emacs_help_text[8] = catgetlocal( 153, "^h backspace ^p prev line ^z next word ");
5212 emacs_help_text[9] = help_text[9];
5213 emacs_help_text[10] = help_text[10];
5214 emacs_help_text[11] = help_text[11];
5215 emacs_help_text[12] = help_text[12];
5216 emacs_help_text[13] = help_text[13];
5217 emacs_help_text[14] = help_text[14];
5218 emacs_help_text[15] = help_text[15];
5219 emacs_help_text[16] = help_text[16];
5220 emacs_help_text[17] = help_text[17];
5221 emacs_help_text[18] = help_text[18];
5222 emacs_help_text[19] = help_text[19];
5223 emacs_help_text[20] = help_text[20];
5224 emacs_help_text[21] = help_text[21];
5225 emacs_control_keys[0] = catgetlocal( 154, "^[ (escape) menu ^y search prompt ^k delete line ^p prev line ^g prev page");
5226 emacs_control_keys[1] = catgetlocal( 155, "^o ascii code ^x search ^l undelete line ^n next line ^v next page");
5227 emacs_control_keys[2] = catgetlocal( 156, "^u end of file ^a begin of line ^w delete word ^b back char ^z next word");
5228 emacs_control_keys[3] = catgetlocal( 157, "^t begin of file ^e end of line ^r restore word ^f forward char ");
5229 emacs_control_keys[4] = catgetlocal( 158, "^c command ^d delete char ^j undelete char ESC-Enter: exit");
5230 EMACS_string = catgetlocal( 159, "EMACS");
5231 NOEMACS_string = catgetlocal( 160, "NOEMACS");
5232 usage4 = catgetlocal( 161, " +# put cursor at line #\n");
5233 conf_dump_err_msg = catgetlocal( 162, "unable to open .init.ee for writing, no configuration saved!");
5234 conf_dump_success_msg = catgetlocal( 163, "ee configuration saved in file %s");
5235 modes_menu[10].item_string = catgetlocal( 164, "save editor configuration");
5236 config_dump_menu[0].item_string = catgetlocal( 165, "save ee configuration");

--- 80 unchanged lines hidden ---