New upstream version 20170828
Harald Dunkel
6 years ago
0 | 0 | /ttyio.c/1.37/Wed Mar 25 18:47:22 2015// |
1 | 1 | /def.h/1.155/Result of merge// |
2 | /fileio.c/1.103/Result of merge// | |
3 | /tags.c/1.14/Result of merge// | |
4 | 2 | /region.c/1.37/Result of merge// |
5 | 3 | /main.c/1.84/Result of merge// |
6 | 4 | /Makefile/1.33/Wed Oct 5 11:37:09 2016// |
12 | 10 | /cinfo.c/1.18/Thu Sep 1 15:28:17 2016// |
13 | 11 | /cmode.c/1.16/Thu Sep 1 15:28:17 2016// |
14 | 12 | /cscope.c/1.16/Thu Sep 1 15:28:17 2016// |
15 | /dir.c/1.29/Wed Oct 5 11:37:09 2016// | |
16 | 13 | /dired.c/1.83/Sat Nov 26 10:20:10 2016// |
17 | /display.c/1.47/Thu Sep 1 15:28:17 2016// | |
18 | 14 | /echo.c/1.66/Sat Nov 26 10:20:10 2016// |
19 | 15 | /extend.c/1.64/Mon Sep 12 16:36:26 2016// |
20 | 16 | /file.c/1.100/Thu Sep 1 15:28:17 2016// |
31 | 27 | /macro.h/1.7/Thu Sep 1 15:28:17 2016// |
32 | 28 | /match.c/1.19/Thu Sep 1 15:28:17 2016// |
33 | 29 | /mg.1/1.105/Thu Sep 1 15:30:59 2016// |
34 | /modes.c/1.20/Thu Sep 1 15:28:17 2016// | |
35 | 30 | /paragraph.c/1.45/Mon Sep 12 16:36:26 2016// |
36 | 31 | /pathnames.h/1.1/Thu Sep 1 15:28:17 2016// |
37 | /re_search.c/1.31/Thu Sep 1 15:28:17 2016// | |
38 | /search.c/1.44/Thu Sep 1 15:28:17 2016// | |
39 | 32 | /spawn.c/1.12/Thu Sep 1 15:28:17 2016// |
40 | 33 | /tty.c/1.36/Thu Sep 1 15:28:17 2016// |
41 | 34 | /ttykbd.c/1.18/Thu Sep 1 15:28:17 2016// |
42 | /tutorial/1.16/Thu Sep 1 15:28:17 2016// | |
43 | 35 | /undo.c/1.58/Mon Sep 12 16:36:26 2016// |
44 | 36 | /util.c/1.38/Thu Sep 1 15:28:17 2016// |
45 | 37 | /version.c/1.10/Thu Sep 1 15:28:17 2016// |
46 | 38 | /window.c/1.36/Thu Sep 1 15:28:17 2016// |
47 | 39 | /word.c/1.19/Thu Sep 1 15:28:17 2016// |
48 | 40 | /yank.c/1.14/Thu Sep 1 15:28:17 2016// |
49 | /buffer.c/1.103/Sat Apr 1 06:51:57 2017// | |
41 | /buffer.c/1.104/Mon Aug 28 07:58:35 2017// | |
42 | /dir.c/1.30/Mon Aug 28 07:58:35 2017// | |
43 | /display.c/1.48/Mon Aug 28 07:58:35 2017// | |
44 | /fileio.c/1.104/Result of merge// | |
45 | /modes.c/1.21/Mon Aug 28 07:58:36 2017// | |
46 | /re_search.c/1.33/Mon Aug 28 07:58:36 2017// | |
47 | /search.c/1.46/Mon Aug 28 07:58:36 2017// | |
48 | /tags.c/1.16/Result of merge// | |
49 | /tutorial/1.17/Mon Aug 28 07:58:36 2017// | |
50 | 50 | D |
0 | /* $OpenBSD: buffer.c,v 1.103 2017/03/13 20:32:58 florian Exp $ */ | |
0 | /* $OpenBSD: buffer.c,v 1.104 2017/08/06 04:39:45 bcallah Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
85 | 85 | if (curbp->b_altb == NULL) |
86 | 86 | bufp = eread("Switch to buffer: ", bufn, NBUFN, EFNEW | EFBUF); |
87 | 87 | else |
88 | bufp = eread("Switch to buffer: (default %s) ", bufn, NBUFN, | |
88 | bufp = eread("Switch to buffer (default %s): ", bufn, NBUFN, | |
89 | 89 | EFNUL | EFNEW | EFBUF, curbp->b_altb->b_bname); |
90 | 90 | |
91 | 91 | if (bufp == NULL) |
111 | 111 | bufp = eread("Switch to buffer in other window: ", bufn, NBUFN, |
112 | 112 | EFNEW | EFBUF); |
113 | 113 | else |
114 | bufp = eread("Switch to buffer in other window: (default %s) ", | |
114 | bufp = eread("Switch to buffer in other window (default %s): ", | |
115 | 115 | bufn, NBUFN, EFNUL | EFNEW | EFBUF, curbp->b_altb->b_bname); |
116 | 116 | if (bufp == NULL) |
117 | 117 | return (ABORT); |
145 | 145 | |
146 | 146 | if (f & FFRAND) /* dired mode 'q' */ |
147 | 147 | bp = curbp; |
148 | else if ((bufp = eread("Kill buffer: (default %s) ", bufn, NBUFN, | |
148 | else if ((bufp = eread("Kill buffer (default %s): ", bufn, NBUFN, | |
149 | 149 | EFNUL | EFNEW | EFBUF, curbp->b_bname)) == NULL) |
150 | 150 | return (ABORT); |
151 | 151 | else if (bufp[0] == '\0') |
745 | 745 | |
746 | 746 | /* Get buffer to use from user */ |
747 | 747 | if (curbp->b_altb != NULL) |
748 | bufp = eread("Insert buffer: (default %s) ", bufn, NBUFN, | |
748 | bufp = eread("Insert buffer (default %s): ", bufn, NBUFN, | |
749 | 749 | EFNUL | EFNEW | EFBUF, curbp->b_altb->b_bname); |
750 | 750 | else |
751 | 751 | bufp = eread("Insert buffer: ", bufn, NBUFN, EFNEW | EFBUF); |
0 | /* $OpenBSD: dir.c,v 1.29 2016/09/12 18:32:54 millert Exp $ */ | |
0 | /* $OpenBSD: dir.c,v 1.30 2017/05/30 07:05:22 florian Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
116 | 116 | { |
117 | 117 | struct stat sb; |
118 | 118 | int finished, ishere; |
119 | mode_t dir_mode, mode, oumask; | |
119 | mode_t dir_mode, f_mode, oumask; | |
120 | 120 | char *slash; |
121 | 121 | |
122 | 122 | if ((path = adjustname(path, TRUE)) == NULL) |
130 | 130 | slash = path; |
131 | 131 | |
132 | 132 | oumask = umask(0); |
133 | mode = 0777 & ~oumask; | |
134 | dir_mode = mode | S_IWUSR | S_IXUSR; | |
133 | f_mode = 0777 & ~oumask; | |
134 | dir_mode = f_mode | S_IWUSR | S_IXUSR; | |
135 | 135 | |
136 | 136 | for (;;) { |
137 | 137 | slash += strspn(slash, "/"); |
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | if (mkdir(path, finished ? mode : dir_mode) == 0) { | |
155 | if (mode > 0777 && chmod(path, mode) < 0) { | |
154 | if (mkdir(path, finished ? f_mode : dir_mode) == 0) { | |
155 | if (f_mode > 0777 && chmod(path, f_mode) < 0) { | |
156 | 156 | umask(oumask); |
157 | 157 | return (ABORT); |
158 | 158 | } |
0 | /* $OpenBSD: display.c,v 1.47 2015/04/03 22:10:29 bcallah Exp $ */ | |
0 | /* $OpenBSD: display.c,v 1.48 2017/07/06 19:27:37 schwarze Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
365 | 365 | } else if (ISCTRL(c) != FALSE) { |
366 | 366 | vtpute('^'); |
367 | 367 | vtpute(CCHR(c)); |
368 | } else { | |
368 | } else if (isprint(c)) { | |
369 | 369 | if (vtcol >= 0) |
370 | 370 | vp->v_text[vtcol] = c; |
371 | 371 | ++vtcol; |
372 | } else { | |
373 | char bf[5], *cp; | |
374 | ||
375 | snprintf(bf, sizeof(bf), "\\%o", c); | |
376 | for (cp = bf; *cp != '\0'; cp++) | |
377 | vtpute(*cp); | |
372 | 378 | } |
373 | 379 | } |
374 | 380 |
0 | /* $OpenBSD: fileio.c,v 1.103 2016/07/28 21:40:25 tedu Exp $ */ | |
0 | /* $OpenBSD: fileio.c,v 1.104 2017/05/30 07:05:22 florian Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
216 | 216 | fbackupfile(const char *fn) |
217 | 217 | { |
218 | 218 | struct stat sb; |
219 | struct timespec new_times[2]; | |
219 | 220 | int from, to, serrno; |
220 | 221 | ssize_t nread; |
221 | 222 | char buf[BUFSIZ]; |
269 | 270 | (void) fchmod(to, (sb.st_mode & 0777)); |
270 | 271 | |
271 | 272 | /* copy the mtime to the backupfile */ |
272 | struct timespec new_times[2]; | |
273 | 273 | new_times[0] = sb.st_atim; |
274 | 274 | new_times[1] = sb.st_mtim; |
275 | 275 | futimens(to, new_times); |
0 | /* $OpenBSD: modes.c,v 1.20 2015/03/19 21:22:15 bcallah Exp $ */ | |
0 | /* $OpenBSD: modes.c,v 1.21 2017/05/30 07:05:22 florian Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
22 | 22 | int defb_flag = 0; |
23 | 23 | |
24 | 24 | int |
25 | changemode(int f, int n, char *mode) | |
25 | changemode(int f, int n, char *newmode) | |
26 | 26 | { |
27 | 27 | int i; |
28 | 28 | struct maps_s *m; |
29 | 29 | |
30 | if ((m = name_mode(mode)) == NULL) { | |
30 | if ((m = name_mode(newmode)) == NULL) { | |
31 | 31 | dobeep(); |
32 | ewprintf("Can't find mode %s", mode); | |
32 | ewprintf("Can't find mode %s", newmode); | |
33 | 33 | return (FALSE); |
34 | 34 | } |
35 | 35 | if (!(f & FFARG)) { |
0 | /* $OpenBSD: re_search.c,v 1.31 2015/03/19 21:22:15 bcallah Exp $ */ | |
0 | /* $OpenBSD: re_search.c,v 1.33 2017/08/06 04:39:45 bcallah Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
419 | 419 | * some do-it-yourself control expansion. |
420 | 420 | */ |
421 | 421 | static int |
422 | re_readpattern(char *prompt) | |
422 | re_readpattern(char *re_prompt) | |
423 | 423 | { |
424 | 424 | static int dofree = 0; |
425 | 425 | int flags, error, s; |
426 | 426 | char tpat[NPAT], *rep; |
427 | 427 | |
428 | 428 | if (re_pat[0] == '\0') |
429 | rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, prompt); | |
429 | rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, re_prompt); | |
430 | 430 | else |
431 | rep = eread("%s: (default %s) ", tpat, NPAT, | |
432 | EFNUL | EFNEW | EFCR, prompt, re_pat); | |
431 | rep = eread("%s (default %s): ", tpat, NPAT, | |
432 | EFNUL | EFNEW | EFCR, re_prompt, re_pat); | |
433 | 433 | if (rep == NULL) |
434 | 434 | return (ABORT); |
435 | 435 | if (rep[0] != '\0') { |
0 | /* $OpenBSD: search.c,v 1.44 2015/03/19 21:22:15 bcallah Exp $ */ | |
0 | /* $OpenBSD: search.c,v 1.46 2017/08/06 04:39:45 bcallah Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
541 | 541 | } |
542 | 542 | |
543 | 543 | /* |
544 | * Prompt writing routine for the incremental search. The "prompt" is just | |
544 | * Prompt writing routine for the incremental search. The "i_prompt" is just | |
545 | 545 | * a string. The "flag" determines whether pat should be printed. |
546 | 546 | */ |
547 | 547 | static void |
548 | is_dspl(char *prompt, int flag) | |
548 | is_dspl(char *i_prompt, int flag) | |
549 | 549 | { |
550 | 550 | if (flag != FALSE) |
551 | ewprintf("%s: ", prompt); | |
551 | ewprintf("%s: ", i_prompt); | |
552 | 552 | else |
553 | ewprintf("%s: %s", prompt, pat); | |
553 | ewprintf("%s: %s", i_prompt, pat); | |
554 | 554 | } |
555 | 555 | |
556 | 556 | /* |
829 | 829 | * expansion. |
830 | 830 | */ |
831 | 831 | int |
832 | readpattern(char *prompt) | |
832 | readpattern(char *r_prompt) | |
833 | 833 | { |
834 | 834 | char tpat[NPAT], *rep; |
835 | 835 | int retval; |
836 | 836 | |
837 | 837 | if (pat[0] == '\0') |
838 | rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, prompt); | |
838 | rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, r_prompt); | |
839 | 839 | else |
840 | rep = eread("%s: (default %s) ", tpat, NPAT, | |
841 | EFNUL | EFNEW | EFCR, prompt, pat); | |
840 | rep = eread("%s (default %s): ", tpat, NPAT, | |
841 | EFNUL | EFNEW | EFCR, r_prompt, pat); | |
842 | 842 | |
843 | 843 | /* specified */ |
844 | 844 | if (rep == NULL) { |
0 | /* $OpenBSD: tags.c,v 1.14 2016/09/01 10:01:53 sunil Exp $ */ | |
0 | /* $OpenBSD: tags.c,v 1.16 2017/08/06 04:39:45 bcallah Exp $ */ | |
1 | 1 | |
2 | 2 | /* |
3 | 3 | * This file is in the public domain. |
89 | 89 | return (FALSE); |
90 | 90 | } |
91 | 91 | |
92 | bufp = eread("visit tags table (default %s): ", fname, | |
92 | bufp = eread("Visit tags table (default %s): ", fname, | |
93 | 93 | NFILEN, EFFILE | EFCR | EFNEW | EFDEF, DEFAULTFN); |
94 | 94 | if (bufp == NULL) |
95 | 95 | return (ABORT); |
153 | 153 | |
154 | 154 | if (curtoken(f, n, dtok) == FALSE) { |
155 | 155 | dtok[0] = '\0'; |
156 | bufp = eread("Find tag:", utok, MAX_TOKEN, EFNUL | EFNEW); | |
156 | bufp = eread("Find tag: ", utok, MAX_TOKEN, EFNUL | EFNEW); | |
157 | 157 | } else |
158 | bufp = eread("Find tag (default %s):", utok, MAX_TOKEN, | |
158 | bufp = eread("Find tag (default %s): ", utok, MAX_TOKEN, | |
159 | 159 | EFNUL | EFNEW, dtok); |
160 | 160 | |
161 | 161 | if (bufp == NULL) |
405 | 405 | * Search through each line of buffer for pattern. |
406 | 406 | */ |
407 | 407 | int |
408 | searchpat(char *pat) | |
408 | searchpat(char *s_pat) | |
409 | 409 | { |
410 | 410 | struct line *lp; |
411 | 411 | int dotline; |
412 | 412 | size_t plen; |
413 | 413 | |
414 | plen = strlen(pat); | |
414 | plen = strlen(s_pat); | |
415 | 415 | dotline = 1; |
416 | 416 | lp = lforw(curbp->b_headp); |
417 | 417 | while (lp != curbp->b_headp) { |
418 | 418 | if (ltext(lp) != NULL && plen <= llength(lp) && |
419 | (strncmp(pat, ltext(lp), plen) == 0)) { | |
419 | (strncmp(s_pat, ltext(lp), plen) == 0)) { | |
420 | 420 | curwp->w_doto = 0; |
421 | 421 | curwp->w_dotp = lp; |
422 | 422 | curwp->w_dotline = dotline; |
313 | 313 | |
314 | 314 | You've already seen C-x C-f and C-x C-s to open and save a file. There are |
315 | 315 | other longer commands. For instance, you can also open a file by typing |
316 | M-x open-file Enter. When you type a command using M-x, mg prompts you for | |
316 | M-x find-file Enter. When you type a command using M-x, mg prompts you for | |
317 | 317 | the command at the bottom of the screen. You can type out the whole command |
318 | 318 | if you wish, or you can type out part of the command and then use the TAB key |
319 | 319 | for autocompleting the command. |