diff options
| author | Richard M. Stallman | 1993-06-07 05:30:29 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-07 05:30:29 +0000 |
| commit | e31fbc7a000930036c42f6b05aaf423fdb128690 (patch) | |
| tree | 220c9c77722e25072790f915eaae524c1198d976 /src | |
| parent | c9ca4659ed223b4e94f686a20f3a6cbc4ccfeecf (diff) | |
| download | emacs-e31fbc7a000930036c42f6b05aaf423fdb128690.tar.gz emacs-e31fbc7a000930036c42f6b05aaf423fdb128690.zip | |
(MAKE_LOCK_PATH): If SHORT_FILE_NAMES allocates
different space and calls fill_in_lock_short_file_name.
(fill_in_lock_short_file_name): New function for 14-chars hashed
file names. Replaces fill_in_lock_file_name if SHORT_FILE_NAMES.
Diffstat (limited to 'src')
| -rw-r--r-- | src/filelock.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/filelock.c b/src/filelock.c index fad8dd15171..5b31acbcb16 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -66,10 +66,54 @@ char *superlock_path; | |||
| 66 | 66 | ||
| 67 | /* Set LOCK to the name of the lock file for the filename FILE. | 67 | /* Set LOCK to the name of the lock file for the filename FILE. |
| 68 | char *LOCK; Lisp_Object FILE; */ | 68 | char *LOCK; Lisp_Object FILE; */ |
| 69 | |||
| 70 | #ifdef SHORT_FILE_NAMES | ||
| 71 | |||
| 72 | #define MAKE_LOCK_PATH(lock, file) \ | ||
| 73 | (lock = (char *) alloca (14 + strlen (lock_path) + 1), \ | ||
| 74 | fill_in_lock_short_file_name (lock, (file))) | ||
| 75 | |||
| 76 | |||
| 77 | fill_in_lock_short_file_name (lockfile, fn) | ||
| 78 | register char *lockfile; | ||
| 79 | register Lisp_Object fn; | ||
| 80 | { | ||
| 81 | register union | ||
| 82 | { | ||
| 83 | unsigned int word [2]; | ||
| 84 | unsigned char byte [8]; | ||
| 85 | } crc; | ||
| 86 | register unsigned char *p, new; | ||
| 87 | |||
| 88 | /* 7-bytes cyclic code for burst correction on byte-by-byte basis. | ||
| 89 | the used polynomial is D^7 + D^6 + D^3 +1. pot@cnuce.cnr.it */ | ||
| 90 | |||
| 91 | crc.word[0] = crc.word[1] = 0; | ||
| 92 | |||
| 93 | for (p = XSTRING (fn)->data; new = *p++; ) | ||
| 94 | { | ||
| 95 | new += crc.byte[7]; | ||
| 96 | crc.byte[7] = crc.byte[6]; | ||
| 97 | crc.byte[6] = crc.byte[5] + new; | ||
| 98 | crc.byte[5] = crc.byte[4]; | ||
| 99 | crc.byte[4] = crc.byte[3]; | ||
| 100 | crc.byte[3] = crc.byte[2] + new; | ||
| 101 | crc.byte[2] = crc.byte[1]; | ||
| 102 | crc.byte[1] = crc.byte[0]; | ||
| 103 | crc.byte[0] = new; | ||
| 104 | } | ||
| 105 | sprintf (lockfile, "%s%.2x%.2x%.2x%.2x%.2x%.2x%.2x", lock_path, | ||
| 106 | crc.byte[0], crc.byte[1], crc.byte[2], crc.byte[3], | ||
| 107 | crc.byte[4], crc.byte[5], crc.byte[6]); | ||
| 108 | } | ||
| 109 | |||
| 110 | #else /* !defined SHORT_FILE_NAMES */ | ||
| 111 | |||
| 69 | #define MAKE_LOCK_PATH(lock, file) \ | 112 | #define MAKE_LOCK_PATH(lock, file) \ |
| 70 | (lock = (char *) alloca (XSTRING (file)->size + strlen (lock_path) + 1), \ | 113 | (lock = (char *) alloca (XSTRING (file)->size + strlen (lock_path) + 1), \ |
| 71 | fill_in_lock_file_name (lock, (file))) | 114 | fill_in_lock_file_name (lock, (file))) |
| 72 | 115 | ||
| 116 | |||
| 73 | fill_in_lock_file_name (lockfile, fn) | 117 | fill_in_lock_file_name (lockfile, fn) |
| 74 | register char *lockfile; | 118 | register char *lockfile; |
| 75 | register Lisp_Object fn; | 119 | register Lisp_Object fn; |
| @@ -88,6 +132,7 @@ fill_in_lock_file_name (lockfile, fn) | |||
| 88 | *p = '!'; | 132 | *p = '!'; |
| 89 | } | 133 | } |
| 90 | } | 134 | } |
| 135 | #endif /* SHORT_FILE_NAMES */ | ||
| 91 | 136 | ||
| 92 | static Lisp_Object | 137 | static Lisp_Object |
| 93 | lock_file_owner_name (lfname) | 138 | lock_file_owner_name (lfname) |
| @@ -124,6 +169,11 @@ lock_file_owner_name (lfname) | |||
| 124 | and put in the Emacs lock directory. */ | 169 | and put in the Emacs lock directory. */ |
| 125 | /* (ie., /ka/king/junk.tex -> /!/!ka!king!junk.tex). */ | 170 | /* (ie., /ka/king/junk.tex -> /!/!ka!king!junk.tex). */ |
| 126 | 171 | ||
| 172 | /* If SHORT_FILE_NAMES is defined, the lock file name is the hex | ||
| 173 | representation of a 14-bytes CRC generated from the file name | ||
| 174 | and put in the Emacs lock directory (not very nice, but it works). | ||
| 175 | (ie., /ka/king/junk.tex -> /!/ec92d3ed24a8f0). */ | ||
| 176 | |||
| 127 | void | 177 | void |
| 128 | lock_file (fn) | 178 | lock_file (fn) |
| 129 | register Lisp_Object fn; | 179 | register Lisp_Object fn; |