OpenBSD CVS

CVS log for src/usr.bin/mg/fileio.c


[BACK] Up to [local] / src / usr.bin / mg

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.112 / (download) - annotate - [select for diffs], Fri Aug 11 04:45:05 2023 UTC (9 months, 1 week ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.111: +4 -4 lines
Diff to previous 1.111 (colored)

Replace use of the old BSD st_*timespec members in struct stat with
the POSIX-standard st_*tim members.

ok millert@

Revision 1.111 / (download) - annotate - [select for diffs], Thu Mar 30 19:00:02 2023 UTC (13 months, 2 weeks ago) by op
Branch: MAIN
Changes since 1.110: +23 -17 lines
Diff to previous 1.110 (colored)

don't access(conffile)

This removes a few access(2) calls in the configuration file handling.
startupfile() now opens and return the file and to avoid surprises it
also uses a caller-provided buffer to store the filename.  This also
removes the extra adjustpath() that load() did: it has been moved to
evalfile() only.

with help, fixes and ok tb@

Revision 1.110 / (download) - annotate - [select for diffs], Thu Mar 30 07:26:15 2023 UTC (13 months, 2 weeks ago) by op
Branch: MAIN
Changes since 1.109: +2 -2 lines
Diff to previous 1.109 (colored)

strncpy -> strlcpy to properly NUL-terminate the copy of the path

otherwise paths longer than NFILEN (1024) given with -u won't
NUL-terminate `file'.

Revision 1.109 / (download) - annotate - [select for diffs], Wed Mar 8 04:43:11 2023 UTC (14 months, 1 week ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.108: +1 -2 lines
Diff to previous 1.108 (colored)

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@

Revision 1.108 / (download) - annotate - [select for diffs], Mon Mar 1 10:51:14 2021 UTC (3 years, 2 months ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.107: +4 -4 lines
Diff to previous 1.107 (colored)

Put the hardcoded '\n' character which is found throughout mg into a
buffer specific variable. The diff should not produce any behavourial
changes in mg.

Revision 1.107 / (download) - annotate - [select for diffs], Tue Feb 23 08:10:51 2021 UTC (3 years, 2 months ago) by lum
Branch: MAIN
Changes since 1.106: +5 -3 lines
Diff to previous 1.106 (colored)

Allow the user to specify a path to the mg startup file on the command line.

Revision 1.106 / (download) - annotate - [select for diffs], Sat Jun 22 10:21:57 2019 UTC (4 years, 10 months ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.105: +7 -11 lines
Diff to previous 1.105 (colored)

This diff moves the check for a newline at the end of a buffer (when
saving it) earlier. This means data doesn't 'disappear' from the file
on disk while the user answers 'yes' or 'no'.

Revision 1.105 / (download) - annotate - [select for diffs], Fri Apr 13 14:11:37 2018 UTC (6 years, 1 month ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.104: +6 -9 lines
Diff to previous 1.104 (colored)

mg tries to write backups to the wrong directory when run under a
different effective user, i.e. when invoced via su and
backup-to-home-directory is enabled.

Problem pointed out and diff provied by Lucas Gabriel Vuotto
<lvuotto92 () gmail ! com>, thanks!

Subsequently slacked on for nearly a year by yours truly.

Then remembered when Han Boetes <hboetes () gmail ! com> came up with
a similar diff because of a problem report by Mark Willson where it
turned out that getlogin(2) is not very portable.

OK tb

Revision 1.104 / (download) - annotate - [select for diffs], Tue May 30 07:05:22 2017 UTC (6 years, 11 months ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.103: +2 -2 lines
Diff to previous 1.103 (colored)

fix -Wshadow warnings.
Found by bcallah, thanks!

Revision 1.103 / (download) - annotate - [select for diffs], Thu Jul 28 21:40:25 2016 UTC (7 years, 9 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.102: +2 -5 lines
Diff to previous 1.102 (colored)

strncmp is a more reasonable way to check the beginning of a string.

Revision 1.102 / (download) - annotate - [select for diffs], Thu Jul 28 21:37:45 2016 UTC (7 years, 9 months ago) by tedu
Branch: MAIN
Changes since 1.101: +3 -11 lines
Diff to previous 1.101 (colored)

these programs probably do not need to use TMPDIR. ok florian

Revision 1.101 / (download) - annotate - [select for diffs], Mon Jul 4 03:24:48 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.100: +2 -8 lines
Diff to previous 1.100 (colored)

Use fstatat() instead of crafting a filename to use with stat()

ok millert@

Revision 1.100 / (download) - annotate - [select for diffs], Tue Jan 26 18:02:51 2016 UTC (8 years, 3 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.99: +8 -1 lines
Diff to previous 1.99 (colored)

ensure the backup file has the same mtime as the original file, this is in line
with emacs' behaviour.

from Harald Dunkel via Han Boetes
ok lum@

Revision 1.99 / (download) - annotate - [select for diffs], Thu Mar 19 21:22:15 2015 UTC (9 years, 2 months ago) by bcallah
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.98: +10 -6 lines
Diff to previous 1.98 (colored)

Clean up the includes in mg.
This does the following:
Moves all POSIX headers from sysdef.h into the individual .c files so that
each file now only includes what it needs. All headers are properly sorted.
Moves the remainder of sysdef.h to other files (mostly def.h) and deletes
sysdef.h now that it's no longer contains anything.
Tweak a comment that references sysdef.h so that it no longer does that.
ok florian@

Revision 1.98 / (download) - annotate - [select for diffs], Sun Nov 16 04:16:41 2014 UTC (9 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.97: +2 -2 lines
Diff to previous 1.97 (colored)

Stop using <sys/param.h>; replace MAXPATHLEN with PATH_MAX, stop using MAX(),
and pull in <limits.h> for *_MAX constants.

inspired on a diff from Kamil Rytarowski (n54 (at) gmx.com)
ok bcallah@

Revision 1.97 / (download) - annotate - [select for diffs], Thu Mar 20 07:47:29 2014 UTC (10 years, 2 months ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.96: +11 -1 lines
Diff to previous 1.96 (colored)

Add some missing dobeeps.
ok florian@

Revision 1.96 / (download) - annotate - [select for diffs], Sat May 18 05:53:58 2013 UTC (11 years ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.95: +2 -2 lines
Diff to previous 1.95 (colored)

and and -> and

Revision 1.95 / (download) - annotate - [select for diffs], Tue Nov 27 19:45:01 2012 UTC (11 years, 5 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.94: +1 -2 lines
Diff to previous 1.94 (colored)

- move prototype of expandtilder() to def.h; needed by an upcoming diff.

Revision 1.94 / (download) - annotate - [select for diffs], Tue Jul 10 06:28:12 2012 UTC (11 years, 10 months ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.93: +9 -5 lines
Diff to previous 1.93 (colored)

Fix an outstanding debian bug: #658539

"looks good" kjell

Revision 1.93 / (download) - annotate - [select for diffs], Mon Jun 18 07:14:55 2012 UTC (11 years, 11 months ago) by jasper
Branch: MAIN
Changes since 1.92: +10 -9 lines
Diff to previous 1.92 (colored)

- add a pathnames.h
- some whitespace cleanup

ok lum@

Revision 1.92 / (download) - annotate - [select for diffs], Fri Jun 15 17:52:42 2012 UTC (11 years, 11 months ago) by lum
Branch: MAIN
Changes since 1.91: +65 -49 lines
Diff to previous 1.91 (colored)

Fixes a problem where if you try to open a file that doesn't exist and has
a name longer than LOGIN_NAME_MAX and also has a tilde at the front
e.g:

$ mg ~01234567890123456789012345678901

mg will give a "Login name too long" instead of opening a new buffer
named ~01234567890123456789012345678901

Revision 1.91 / (download) - annotate - [select for diffs], Thu Jun 14 17:21:22 2012 UTC (11 years, 11 months ago) by lum
Branch: MAIN
Changes since 1.90: +125 -5 lines
Diff to previous 1.90 (colored)

Allow mg to save backup files to a users home directory.
Suggestions from eric@ and Sunil Nimmagadda.
Remarks deraadt@.

Revision 1.90 / (download) - annotate - [select for diffs], Mon Jun 11 18:30:03 2012 UTC (11 years, 11 months ago) by lum
Branch: MAIN
Changes since 1.89: +2 -2 lines
Diff to previous 1.89 (colored)

Change error message to reflect the correct filename: nname is 'New
name' as opposed to tname 'Temp name'

Revision 1.89 / (download) - annotate - [select for diffs], Fri May 25 04:56:58 2012 UTC (11 years, 11 months ago) by lum
Branch: MAIN
Changes since 1.88: +14 -14 lines
Diff to previous 1.88 (colored)

Remove static FILE pointer used for handling files in fileio.c. Pass
by reference instead. This allows the mg startup file to open other
files without unexpected things happening.

Discussed with Sunil Nimmagadda.

Revision 1.88 / (download) - annotate - [select for diffs], Wed May 23 05:29:22 2012 UTC (11 years, 11 months ago) by lum
Branch: MAIN
Changes since 1.87: +21 -15 lines
Diff to previous 1.87 (colored)

Change how mg handles files beginning with a '~'.
Bring behaviour more into line with emacs.

Revision 1.87 / (download) - annotate - [select for diffs], Thu Apr 12 04:47:59 2012 UTC (12 years, 1 month ago) by lum
Branch: MAIN
Changes since 1.86: +1 -3 lines
Diff to previous 1.86 (colored)

Remove the conditional directives NO_MACRO and NO_STARTUP.
They have not compiled for numerous years.
ok kjell@ millert@

Revision 1.86 / (download) - annotate - [select for diffs], Wed Mar 28 17:16:53 2012 UTC (12 years, 1 month ago) by lum
Branch: MAIN
Changes since 1.85: +2 -1 lines
Diff to previous 1.85 (colored)

Close an opendir(). From Igor Zinovik.

Revision 1.85 / (download) - annotate - [select for diffs], Wed Aug 31 08:58:29 2011 UTC (12 years, 8 months ago) by lum
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.84: +5 -5 lines
Diff to previous 1.84 (colored)

On a file write fail:

1. return an error value
2. show an error message

From Loganaden Velvindron with suggestion from millert@

Revision 1.84 / (download) - annotate - [select for diffs], Fri Jan 21 19:10:13 2011 UTC (13 years, 4 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.83: +1 -2 lines
Diff to previous 1.83 (colored)

It volates style(9), but in mg, #include"def.h" goes first. 'twas the way it was built. no binary change here. confirmed by lum@, tested by Henri Kemppainen

Revision 1.83 / (download) - annotate - [select for diffs], Fri Jan 21 18:58:55 2011 UTC (13 years, 4 months ago) by kjell
Branch: MAIN
Changes since 1.82: +2 -4 lines
Diff to previous 1.82 (colored)

Change len+memcmp check to a strncmp for prefix testing on
filename completion. Avoids a recurring portability headache.
ok lum@
"concerns assuaged to the soothing sounds of Martin Denny blambert@"
(I worry about that guy...)

Revision 1.82 / (download) - annotate - [select for diffs], Mon Sep 15 16:11:35 2008 UTC (15 years, 8 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.81: +58 -8 lines
Diff to previous 1.81 (colored)

Enable dirty buffer detection in mg.
Emulate the emacs behavior: after suspend/resume, buffer switch,
or at save time, warn (prompt) the user if the file has been modified
on disk in the interim.
This has already saved my butt numerous times.
ok phessler

Revision 1.81 / (download) - annotate - [select for diffs], Tue Nov 27 16:22:14 2007 UTC (16 years, 5 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.80: +2 -2 lines
Diff to previous 1.80 (colored)

typos;  ok jmc@
sys/dev/pci/pciide.c from naddy@

Revision 1.80 / (download) - annotate - [select for diffs], Sun Dec 24 01:20:53 2006 UTC (17 years, 4 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.79: +2 -1 lines
Diff to previous 1.79 (colored)

Fix a bug where inserting a file resulted in an incorrect
line-number count for a buffer (M-X insert-file, M-> to reproduce).
While here, fix a number of bugs with incorrect line numbers
after swap point-and-mark

Originally reported via debian's bug tracking system. Fix tested by
Han Boetes and Deanna Phillips.

Revision 1.79 / (download) - annotate - [select for diffs], Sun Nov 19 16:51:19 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.78: +2 -2 lines
Diff to previous 1.78 (colored)

spacing

Revision 1.78 / (download) - annotate - [select for diffs], Tue Sep 19 05:52:23 2006 UTC (17 years, 8 months ago) by otto
Branch: MAIN
Changes since 1.77: +2 -2 lines
Diff to previous 1.77 (colored)

Use S_IS* macros insted of masking with S_IF* flags. The latter may
have multiple bits set, which lead to surprising results. Spotted by
Paul Stoeber, more to come. ok millert@ pedro@ jaredy@ djm@

Revision 1.77 / (download) - annotate - [select for diffs], Tue Jul 25 08:22:32 2006 UTC (17 years, 9 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.76: +2 -2 lines
Diff to previous 1.76 (colored)

Rename the header line of a buffer to b_headp, from the remarkably
unintuitive b_linep. No binary change.

Revision 1.76 / (download) - annotate - [select for diffs], Thu Jun 29 21:59:08 2006 UTC (17 years, 10 months ago) by jason
Branch: MAIN
Changes since 1.75: +3 -3 lines
Diff to previous 1.75 (colored)

- use <dirent.h> not <sys/dir.h> (this appeases FreeBSD's annoying #warning)
- grab <sys/time.h> before <sys/resource.h> like getrusage(2) says
ok kjell

Revision 1.75 / (download) - annotate - [select for diffs], Thu Jun 1 05:56:51 2006 UTC (17 years, 11 months ago) by kjell
Branch: MAIN
Changes since 1.74: +2 -2 lines
Diff to previous 1.74 (colored)

fix style

Revision 1.74 / (download) - annotate - [select for diffs], Thu Jun 1 05:34:52 2006 UTC (17 years, 11 months ago) by jason
Branch: MAIN
Changes since 1.73: +20 -5 lines
Diff to previous 1.73 (colored)

make // /~ path rewriting optional in adjustname() and use it everywhere
except for the command line specified files.  ok kjell,cloder

Revision 1.73 / (download) - annotate - [select for diffs], Wed May 3 22:25:34 2006 UTC (18 years ago) by kjell
Branch: MAIN
Changes since 1.72: +3 -3 lines
Diff to previous 1.72 (colored)

correct one more comment

Revision 1.72 / (download) - annotate - [select for diffs], Wed May 3 22:19:41 2006 UTC (18 years ago) by kjell
Branch: MAIN
Changes since 1.71: +17 -21 lines
Diff to previous 1.71 (colored)

Do some KNF, clean up some unused junk that has lying around for 40-odd
cvs revisions, and fix a few comments to match reality

Revision 1.71 / (download) - annotate - [select for diffs], Wed May 3 21:15:59 2006 UTC (18 years ago) by kjell
Branch: MAIN
Changes since 1.70: +7 -6 lines
Diff to previous 1.70 (colored)

len = strlen(foo); if foo[len - 1]... will do bad things if len == 0.
Avoid, and rearrange a test so it can't (hypothetically) overflow.

Revision 1.70 / (download) - annotate - [select for diffs], Mon Apr 3 00:40:56 2006 UTC (18 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.69: +7 -6 lines
Diff to previous 1.69 (colored)

lint love; ok kjell

Revision 1.69 / (download) - annotate - [select for diffs], Sun Apr 2 20:21:19 2006 UTC (18 years, 1 month ago) by kjell
Branch: MAIN
Changes since 1.68: +3 -3 lines
Diff to previous 1.68 (colored)

test char against '\0', not 0

Revision 1.68 / (download) - annotate - [select for diffs], Tue Dec 20 06:17:36 2005 UTC (18 years, 5 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.67: +12 -17 lines
Diff to previous 1.67 (colored)

Clean up the ugly casted frees. In one case, this meant eliminating a nasty
struct/union/casting nightmare when building the list of names for filename
completion. In particular, be consistent about strduping and freeing
the list data.

Revision 1.67 / (download) - annotate - [select for diffs], Tue Dec 20 05:04:28 2005 UTC (18 years, 5 months ago) by kjell
Branch: MAIN
Changes since 1.66: +5 -4 lines
Diff to previous 1.66 (colored)

Do some delinting of strl-type functions. Also, remove a superfluous
word in the undo-list.

Revision 1.66 / (download) - annotate - [select for diffs], Tue Dec 13 05:40:33 2005 UTC (18 years, 5 months ago) by kjell
Branch: MAIN
Changes since 1.65: +6 -6 lines
Diff to previous 1.65 (colored)

do some silly de-linting

Revision 1.65 / (download) - annotate - [select for diffs], Sun Nov 20 18:47:11 2005 UTC (18 years, 6 months ago) by kjell
Branch: MAIN
Changes since 1.64: +3 -6 lines
Diff to previous 1.64 (colored)

#ifdef NO_DIR can go too. From Han Boetes.

Revision 1.64 / (download) - annotate - [select for diffs], Sun Nov 20 04:16:34 2005 UTC (18 years, 6 months ago) by kjell
Branch: MAIN
Changes since 1.63: +1 -3 lines
Diff to previous 1.63 (colored)

Kill the NO_BACKUP #ifdef

Revision 1.63 / (download) - annotate - [select for diffs], Sun Nov 20 03:24:17 2005 UTC (18 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.62: +1 -11 lines
Diff to previous 1.62 (colored)

toast NO_DIRED #ifdef; ok kjell

Revision 1.62 / (download) - annotate - [select for diffs], Fri Nov 18 20:56:52 2005 UTC (18 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.61: +10 -10 lines
Diff to previous 1.61 (colored)

greedy use of typedef struct was making code harder to read; ok kjell cloder

Revision 1.61 / (download) - annotate - [select for diffs], Sun Nov 13 07:49:02 2005 UTC (18 years, 6 months ago) by kjell
Branch: MAIN
Changes since 1.60: +20 -18 lines
Diff to previous 1.60 (colored)

Better error checking of snprintfs. From Han Boetes.

Revision 1.60 / (download) - annotate - [select for diffs], Fri Nov 11 18:51:49 2005 UTC (18 years, 6 months ago) by kjell
Branch: MAIN
Changes since 1.59: +2 -15 lines
Diff to previous 1.59 (colored)

Now that we have an editable minibuffer, revert parsing of
"//" and "/~" as '/' and '~' respectively. I know emacs does it,
but it is weird, and breaks things that foolishly use filenames
like "/tmp//crontab.xxxx".
Proddings from matthieu and deraadt. Error report from Bernd Ahlers.

Revision 1.59 / (download) - annotate - [select for diffs], Fri Nov 11 18:40:51 2005 UTC (18 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.58: +2 -2 lines
Diff to previous 1.58 (colored)

spacing

Revision 1.58 / (download) - annotate - [select for diffs], Tue Oct 18 04:07:06 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.57: +15 -2 lines
Diff to previous 1.57 (colored)

When attempting to open a filename, walk backwards through minibuffer:
a> if you run into the beginning of the string, use the whole thing
b> if you run into a // combo, use everything starting from the second /
c> if you run into a /~ combo, use everything starting from the ~
i.e. do like emacs.
From (and for) Jason Wright

Revision 1.57 / (download) - annotate - [select for diffs], Mon Oct 17 14:54:03 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.56: +24 -18 lines
Diff to previous 1.56 (colored)

Fix string handling. LOGIN_NAME_MAX includes the NUL, so don't reserve extra
space. Fix usage of strlcpy. Correct test for terminating slash.

"looks good" deraadt@

Revision 1.56 / (download) - annotate - [select for diffs], Fri Oct 14 15:41:50 2005 UTC (18 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.55: +5 -3 lines
Diff to previous 1.55 (colored)

more headers to please lint

Revision 1.55 / (download) - annotate - [select for diffs], Fri Oct 14 06:41:47 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.54: +1 -86 lines
Diff to previous 1.54 (colored)

move the dired routines into dired.c where they belong.
ok cloder@

Revision 1.54 / (download) - annotate - [select for diffs], Thu Oct 13 20:23:01 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.53: +20 -2 lines
Diff to previous 1.53 (colored)

Make dired buffer read-only by default.
Noticed by Han Boetes

Revision 1.53 / (download) - annotate - [select for diffs], Thu Oct 13 19:46:45 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.52: +16 -3 lines
Diff to previous 1.52 (colored)

Use dired mode automatically if file specified for loading is
a directory. Modified version of patch from Han Boetes.
ok cloder@

Revision 1.52 / (download) - annotate - [select for diffs], Thu Oct 13 05:59:19 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.51: +3 -2 lines
Diff to previous 1.51 (colored)

check if current line is null. fixes a core in dired.

Revision 1.51 / (download) - annotate - [select for diffs], Thu Oct 13 05:47:45 2005 UTC (18 years, 7 months ago) by kjell
Branch: MAIN
Changes since 1.50: +2 -1 lines
Diff to previous 1.50 (colored)

Fix dired mode. Make deletions work, and keystrokes match emacs.
* dired-other-window should default to current buffer's path.
* Remove redundant code (from Han Boetes)
* Move initialization (and since we're here, fix mail-mode initialization
  too)
* Remove redundant keymap in dired.c, and replace it with
  the better one that was being ignored in keymap.c.

Revision 1.50 / (download) - annotate - [select for diffs], Tue Jun 14 18:14:40 2005 UTC (18 years, 11 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.49: +3 -1 lines
Diff to previous 1.49 (colored)

Add explicit public domain notices to all public domain files.
ok millert@, deraadt@

Revision 1.49 / (download) - annotate - [select for diffs], Sun Apr 3 02:09:28 2005 UTC (19 years, 1 month ago) by db
Branch: MAIN
Changes since 1.48: +48 -53 lines
Diff to previous 1.48 (colored)

This is a no binary change which does:

- spelling, punctuation fixes
- variable declaration lineup
- use parentheses for return and sizeof
- K&R function declarations -> ANSI
- other minor code beautification

ok henning@

Revision 1.48 / (download) - annotate - [select for diffs], Thu Mar 10 16:58:57 2005 UTC (19 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

spacing

Revision 1.47 / (download) - annotate - [select for diffs], Thu Mar 10 16:46:24 2005 UTC (19 years, 2 months ago) by henning
Branch: MAIN
Changes since 1.46: +7 -4 lines
Diff to previous 1.46 (colored)

the realpath() was needed to do do relative to absolute path
conversion. revert my diff that takes it out, and instead, on
realpath() failure (like when you have no perms on pwd) just return the
unexpanded path. everything still fine with that, just tab completeion
and the like does not work (obviously).
this was mainly for "sudo mg /etc/something" from ~ where ~ is
nfs-mounted with root mapped to -2
and now, that case works as well as tab completion on insert-file etc.

Revision 1.46 / (download) - annotate - [select for diffs], Wed Mar 9 16:20:48 2005 UTC (19 years, 2 months ago) by jfb
Branch: MAIN
Changes since 1.45: +6 -3 lines
Diff to previous 1.45 (colored)

fix mg's behaviour with regards to files on which we do not have
write access.  diff originally from vincent@ and forgotten for
a while.

ok rohee@, "toss it in, i'll bitch if it doesn't work" henning@

Revision 1.45 / (download) - annotate - [select for diffs], Tue Feb 1 16:04:15 2005 UTC (19 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.44: +2 -1 lines
Diff to previous 1.44 (colored)

make fbackupfile() return FALSE when the rename(2) from the
mkstemp()-derived name to the filename~ one fails
From: Han Boetes <han@mijncomputer.nl>

Revision 1.44 / (download) - annotate - [select for diffs], Mon Jan 31 15:48:00 2005 UTC (19 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.43: +20 -6 lines
Diff to previous 1.43 (colored)

Safer backup file generation using mkstemp(); henning@ OK

Revision 1.43 / (download) - annotate - [select for diffs], Tue Jan 11 17:19:16 2005 UTC (19 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.42: +4 -4 lines
Diff to previous 1.42 (colored)

no need to call realpath() in adjustname()
realpath returns an error if cwd is not writeable, and that is quite common
with NFS-mounted ~ and sudo mg /etc/something - annoying as hell. realpath
is not needed at all here, so zap it. vincent ok

Revision 1.42 / (download) - annotate - [select for diffs], Fri Jul 9 13:50:40 2004 UTC (19 years, 10 months ago) by vincent
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.41: +10 -1 lines
Diff to previous 1.41 (colored)

when saving a file, check whether it is newline terminated and if it is not,
prompt the user and add the newline if he agrees.

tested by a lot of helpful tech@ guys, approved by henning

Revision 1.41 / (download) - annotate - [select for diffs], Thu Jul 8 20:48:50 2004 UTC (19 years, 10 months ago) by vincent
Branch: MAIN
Changes since 1.40: +10 -26 lines
Diff to previous 1.40 (colored)

simplify the file writing loop

looked at by ian, tested on i386, macppc, sparc64

Revision 1.40 / (download) - annotate - [select for diffs], Fri Nov 14 22:41:33 2003 UTC (20 years, 6 months ago) by vincent
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.39: +4 -4 lines
Diff to previous 1.39 (colored)

read(2) returns ssize_t, not size_t.  spotted by Andrey Matveev.

Revision 1.39 / (download) - annotate - [select for diffs], Sat Nov 8 19:17:29 2003 UTC (20 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

typos from Jonathon Gray;

Revision 1.38 / (download) - annotate - [select for diffs], Fri Aug 15 23:23:18 2003 UTC (20 years, 9 months ago) by vincent
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.37: +8 -6 lines
Diff to previous 1.37 (colored)

make dired work more like emacs. (well, make it _work_, and then add a
bunch of missing commands)

Revision 1.37 / (download) - annotate - [select for diffs], Fri Aug 15 23:09:57 2003 UTC (20 years, 9 months ago) by vincent
Branch: MAIN
Changes since 1.36: +11 -7 lines
Diff to previous 1.36 (colored)

 actually extract the filename off the ls line. makes dired *slightly*
more useful.

Revision 1.36 / (download) - annotate - [select for diffs], Thu May 8 12:37:13 2003 UTC (21 years ago) by vincent
Branch: MAIN
Changes since 1.35: +4 -4 lines
Diff to previous 1.35 (colored)

use NULL to indicate failure in functions that return pointers, not FALSE.
typo in comment

from Patrick Latifi (patrick.l@hermes.usherb.ca)

Revision 1.35 / (download) - annotate - [select for diffs], Tue May 6 10:45:07 2003 UTC (21 years ago) by vincent
Branch: MAIN
Changes since 1.34: +6 -5 lines
Diff to previous 1.34 (colored)

fix a small memleak on errors. noticed by pat latifi.

ok millert, fgsch

Revision 1.34 / (download) - annotate - [select for diffs], Thu Aug 22 23:28:19 2002 UTC (21 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.33: +3 -3 lines
Diff to previous 1.33 (colored)

knf

Revision 1.33 / (download) - annotate - [select for diffs], Thu Jul 25 16:37:54 2002 UTC (21 years, 9 months ago) by vincent
Branch: MAIN
Changes since 1.32: +40 -118 lines
Diff to previous 1.32 (colored)

 replace the ugly and buggy adjustname function by a simple one using
simple APIs. makes mg not crash with 65k filenames...

 ok art@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Jul 1 17:20:04 2002 UTC (21 years, 10 months ago) by vincent
Branch: MAIN
Changes since 1.31: +13 -13 lines
Diff to previous 1.31 (colored)

KNF

Revision 1.31 / (download) - annotate - [select for diffs], Fri Jun 21 05:37:20 2002 UTC (21 years, 11 months ago) by vincent
Branch: MAIN
Changes since 1.30: +17 -6 lines
Diff to previous 1.30 (colored)

fix bad usage of strlcpy()'s return value. (made pointers point
beyond the boundaries of buffers)

ok deraadt@

Revision 1.30 / (download) - annotate - [select for diffs], Mon Apr 22 05:27:39 2002 UTC (22 years, 1 month ago) by vincent
Branch: MAIN
Changes since 1.29: +43 -14 lines
Diff to previous 1.29 (colored)

 don't use /bin/cp to copy files.

 ok deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Mon Apr 22 04:27:37 2002 UTC (22 years, 1 month ago) by vincent
Branch: MAIN
Changes since 1.28: +4 -3 lines
Diff to previous 1.28 (colored)

 fix mem leak

 ok deraadt@

Revision 1.28 / (download) - annotate - [select for diffs], Mon Apr 15 23:24:42 2002 UTC (22 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.27: +3 -3 lines
Diff to previous 1.27 (colored)

use fchmod and fchown instead; vincent

Revision 1.27 / (download) - annotate - [select for diffs], Wed Mar 27 17:42:37 2002 UTC (22 years, 1 month ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.26: +9 -13 lines
Diff to previous 1.26 (colored)

Fixes the the following problems (from zyrnix)
1) Mg crashes with column width of 1, rows > 2
2) Mg panics on resizing due to incomplete write
3) Mg doesn't compile with STARTUPFILE defined
deraadt@ OK

Revision 1.26 / (download) - annotate - [select for diffs], Sat Mar 16 19:30:29 2002 UTC (22 years, 2 months ago) by vincent
Branch: MAIN
Changes since 1.25: +5 -1 lines
Diff to previous 1.25 (colored)

 Make these special buffers readonly by default. ok art@

Revision 1.25 / (download) - annotate - [select for diffs], Mon Mar 11 13:02:56 2002 UTC (22 years, 2 months ago) by vincent
Branch: MAIN
Changes since 1.24: +9 -21 lines
Diff to previous 1.24 (colored)

  * Move to ANSI function definitions.
  * Add a whole lot of consts where I thought it made sense

   no ok, but no objections either...

Revision 1.24 / (download) - annotate - [select for diffs], Fri Feb 22 00:18:37 2002 UTC (22 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.23: +16 -3 lines
Diff to previous 1.23 (colored)

if file mode known, try to avoid a race.. i think.  millert spotted a bug in my first draft

Revision 1.23 / (download) - annotate - [select for diffs], Thu Feb 14 22:58:20 2002 UTC (22 years, 3 months ago) by vincent
Branch: MAIN
Changes since 1.22: +18 -13 lines
Diff to previous 1.22 (colored)

d_makename now takes a length parameter so we can remove the
strcpy call.

Revision 1.22 / (download) - annotate - [select for diffs], Thu Feb 14 14:24:21 2002 UTC (22 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

some KNF

Revision 1.21 / (download) - annotate - [select for diffs], Wed Feb 13 03:03:49 2002 UTC (22 years, 3 months ago) by vincent
Branch: MAIN
Changes since 1.20: +20 -17 lines
Diff to previous 1.20 (colored)

 * Replace unsafe strcpy and strcat calls to safe strlcpy and strlcat.
 * Be a little bit more verbose about some errors
 * Fix some memory leaks in fileio.c

ok deraadt@, art@

Revision 1.20 / (download) - annotate - [select for diffs], Fri Sep 21 15:08:16 2001 UTC (22 years, 8 months ago) by wilfried
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.19: +8 -6 lines
Diff to previous 1.19 (colored)

correct fork logic and rewrite for clarity, ok todd@

Revision 1.19 / (download) - annotate - [select for diffs], Mon Jul 9 07:04:49 2001 UTC (22 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

correct type on last arg to execl(); nordin@cse.ogi.edu

Revision 1.18 / (download) - annotate - [select for diffs], Fri Jul 6 13:32:45 2001 UTC (22 years, 10 months ago) by art
Branch: MAIN
Changes since 1.17: +26 -18 lines
Diff to previous 1.17 (colored)

Change the filename completion code to:
 - not use an unprotected strcat.
 - Append a '/' when a file is a symlink to a directory.
   (tab completion on '/sys' is now less annoying.)
 - actually make some more sense.

Revision 1.17 / (download) - annotate - [select for diffs], Thu May 24 10:19:51 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Don't assume that map_table[0] is the fundamental map.

Revision 1.16 / (download) - annotate - [select for diffs], Thu May 24 03:05:22 2001 UTC (23 years ago) by mickey
Branch: MAIN
Changes since 1.15: +45 -46 lines
Diff to previous 1.15 (colored)

spaces

Revision 1.15 / (download) - annotate - [select for diffs], Thu May 24 00:59:38 2001 UTC (23 years ago) by mickey
Branch: MAIN
Changes since 1.14: +20 -18 lines
Diff to previous 1.14 (colored)

use strlcpy vs cpy+len, some other fixes

Revision 1.14 / (download) - annotate - [select for diffs], Wed May 23 22:36:14 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

Get rid of unnecessary casts of NULL.

Revision 1.13 / (download) - annotate - [select for diffs], Wed May 23 22:20:35 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.12: +12 -12 lines
Diff to previous 1.12 (colored)

remove VOID. We're way beyond the point where this could build with an
ancient compiler.

Revision 1.12 / (download) - annotate - [select for diffs], Thu May 3 12:57:22 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.11: +48 -53 lines
Diff to previous 1.11 (colored)

 * Let make_file_list always append a '/' at the end of directories.
   This makes filename TAB-completion more useful, now you don't need to
   write that '/' manually.
 * random cleanups including using snprintf and memcmp where open-coded
   equivalents were used, waitpid instead of 'while (wait() != pid);', etc.

Revision 1.11 / (download) - annotate - [select for diffs], Tue May 1 13:26:59 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.10: +28 -35 lines
Diff to previous 1.10 (colored)

Use opendir/readdir instead of open/read when making a file list.
This makes filename tab-completion work and takes dired a step further.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Jan 29 01:58:07 2001 UTC (23 years, 3 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.9: +2 -0 lines
Diff to previous 1.9 (colored)

$OpenBSD$

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jan 24 20:24:15 2001 UTC (23 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.8: +44 -13 lines
Diff to previous 1.8 (colored)

Don't use rename to backup the file to a ~ file.  We need to make a
copy instead so the original is edited in place for things like
cron and vipw.

Revision 1.8 / (download) - annotate - [select for diffs], Wed Aug 2 04:10:48 2000 UTC (23 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.7: +4 -3 lines
Diff to previous 1.7 (colored)

$HOME paranoia: never use getenv("HOME") w/o checking for NULL and non-zero

Revision 1.7 / (download) - annotate - [select for diffs], Thu Apr 13 06:12:14 2000 UTC (24 years, 1 month ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.6: +387 -356 lines
Diff to previous 1.6 (colored)

The start of KNF + -Wall.  The code has been run through indent but
needs hand fixup.  I stopped at keymap.c...

Revision 1.6 / (download) - annotate - [select for diffs], Sun Feb 27 06:02:35 2000 UTC (24 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.5: +2 -16 lines
Diff to previous 1.5 (colored)

Remove a now-bogus comment
Use pid_t
Use vfork(), not fork() when sensible

Revision 1.5 / (download) - annotate - [select for diffs], Sun Feb 27 05:49:14 2000 UTC (24 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.4: +3 -23 lines
Diff to previous 1.4 (colored)

We don't have silly SYSV 14-character file name limits.  Taken from
the BSD fileio.c.  Note that this module is rife with PATH_MAX overflow
possibilities.

Revision 1.4 / (download) - annotate - [select for diffs], Sat Feb 26 23:22:44 2000 UTC (24 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.3: +2 -41 lines
Diff to previous 1.3 (colored)

Use uid_t, gid_t and mode_t where applicable.
Pull in changes from the BSD-specific sysdef.h and fileio.c:
kill bogus unlinkdir() and rename() kludges since we have rmdir(2) and rename(2)
define SYMBLINK since we have symlinks
TODO: merge BSD spawn.c and ttyio.c

Revision 1.3 / (download) - annotate - [select for diffs], Fri Feb 25 19:13:21 2000 UTC (24 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +0 -3 lines
Diff to previous 1.2 (colored)

further pruning

Revision 1.2 / (download) - annotate - [select for diffs], Fri Feb 25 19:09:48 2000 UTC (24 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.1: +5 -3 lines
Diff to previous 1.1 (colored)

make it minimally compile; millert

Revision 1.1 / (download) - annotate - [select for diffs], Fri Feb 25 19:08:47 2000 UTC (24 years, 2 months ago) by deraadt
Branch: MAIN

initial import of mg2a

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.