comparison src/realpath.c @ 2421:ab71ad6ff3dd

[xemacs-hg @ 2004-12-06 03:50:53 by ben] (none) README.packages: Document use of --package-prefix. Fix error in specifying standard package location. make-docfile.c: Use QXE_PATH_MAX. info.el: Correct doc string giving example package path. menubar-items.el: Move Prefix Rectangle command up one level. xemacs/packages.texi: Add long form of Lisp Reference Manual to links. Add links pointing to Lisp Reference Manual for more detailed package discussion. lispref/range-tables.texi: Document range-table changes. internals/internals.texi: Update history section. elhash.c, elhash.h, profile.c: Create inchash_eq() to allow direct incrementing of hash-table entry. Use in profile.c to try to reduce profiling overhead. Increase initial size of profile hash tables to reduce profiling overhead. buffer.c, device-msw.c, dialog-msw.c, dired-msw.c, editfns.c, event-msw.c, events.c, glyphs-msw.c, keymap.c, objects-msw.c, process-nt.c, syswindows.h, text.c, text.h, unexnt.c: Rename xetcs* -> qxetcs* for consistency with qxestr*. Rename ei*_c(_*) -> ei*_ascii(_*) since they work with ASCII-only strings not "C strings", whatever those are. This is the last place where "c" was incorrectly being used for "ascii". dialog-msw.c, dumper.c, event-msw.c, fileio.c, glyphs-gtk.c, glyphs-x.c, nt.c, process-nt.c, realpath.c, sysdep.c, sysfile.h, unexcw.c, unexnext.c, unexnt.c: Try to avoid differences in systems that do or do not include final null byte in PATH_MAX. Create PATH_MAX_INTERNAL and PATH_MAX_EXTERNAL and use them everywhere. Rewrite code in dumper.c to avoid use of PATH_MAX. When necessary in nt.c, use _MAX_PATH instead of MAX_PATH to be consistent with other places. text.c: Code to short-circuit when binary or Unicode was not working due to EOL wrapping. Fix this code to work when either no EOL autodetection or no CR's or LF's in the text. lisp.h, rangetab.c, rangetab.h, regex.c, search.c: Implement different types of ranges (open/closed start and end). Change default to be start-closed, end-open.
author ben
date Mon, 06 Dec 2004 03:52:23 +0000
parents ecf1ebac70d8
children 902d5bd9b75c
comparison
equal deleted inserted replaced
2420:ad56e5a6d09f 2421:ab71ad6ff3dd
103 if (qxestrpbrk (name, "*?|<>\"")) 103 if (qxestrpbrk (name, "*?|<>\""))
104 { 104 {
105 errno = ENOENT; 105 errno = ENOENT;
106 return -1; 106 return -1;
107 } 107 }
108 else if (qxestrlen (name) >= PATH_MAX) 108 else if (qxestrlen (name) >= PATH_MAX_INTERNAL)
109 { 109 {
110 errno = ENAMETOOLONG; 110 errno = ENAMETOOLONG;
111 return -1; 111 return -1;
112 } 112 }
113 113
168 internally-formatted strings. */ 168 internally-formatted strings. */
169 169
170 Ibyte * 170 Ibyte *
171 qxe_realpath (const Ibyte *path, Ibyte *resolved_path) 171 qxe_realpath (const Ibyte *path, Ibyte *resolved_path)
172 { 172 {
173 Ibyte copy_path[PATH_MAX]; 173 Ibyte copy_path[PATH_MAX_INTERNAL];
174 Ibyte *new_path = resolved_path; 174 Ibyte *new_path = resolved_path;
175 Ibyte *max_path; 175 Ibyte *max_path;
176 #if defined (HAVE_READLINK) || defined (WIN32_ANY) 176 #if defined (HAVE_READLINK) || defined (WIN32_ANY)
177 int readlinks = 0; 177 int readlinks = 0;
178 Ibyte link_path[PATH_MAX]; 178 Ibyte link_path[PATH_MAX_INTERNAL];
179 int n; 179 int n;
180 int abslen = abs_start (path); 180 int abslen = abs_start (path);
181 #endif 181 #endif
182 182
183 restart: 183 restart:
184 184
185 /* Make a copy of the source path since we may need to modify it. */ 185 /* Make a copy of the source path since we may need to modify it. */
186 qxestrcpy (copy_path, path); 186 qxestrcpy (copy_path, path);
187 path = copy_path; 187 path = copy_path;
188 max_path = copy_path + PATH_MAX - 2; 188 max_path = copy_path + PATH_MAX_INTERNAL - 2;
189 189
190 if (0) 190 if (0)
191 ; 191 ;
192 #ifdef WIN32_ANY 192 #ifdef WIN32_ANY
193 /* Check for c:/... or //server/... */ 193 /* Check for c:/... or //server/... */
214 #endif 214 #endif
215 #ifdef WIN32_NATIVE 215 #ifdef WIN32_NATIVE
216 /* No drive letter, but a beginning slash? Prepend drive letter. */ 216 /* No drive letter, but a beginning slash? Prepend drive letter. */
217 else if (abslen == 1) 217 else if (abslen == 1)
218 { 218 {
219 get_initial_directory (new_path, PATH_MAX - 1); 219 get_initial_directory (new_path, PATH_MAX_INTERNAL - 1);
220 new_path += 3; 220 new_path += 3;
221 path++; 221 path++;
222 } 222 }
223 /* Just a path name, prepend the current directory */ 223 /* Just a path name, prepend the current directory */
224 else 224 else
225 { 225 {
226 get_initial_directory (new_path, PATH_MAX - 1); 226 get_initial_directory (new_path, PATH_MAX_INTERNAL - 1);
227 new_path += qxestrlen (new_path); 227 new_path += qxestrlen (new_path);
228 if (!IS_DIRECTORY_SEP (new_path[-1])) 228 if (!IS_DIRECTORY_SEP (new_path[-1]))
229 *new_path++ = DIRECTORY_SEP; 229 *new_path++ = DIRECTORY_SEP;
230 } 230 }
231 #else 231 #else
232 /* If it's a relative pathname use get_initial_directory for starters. */ 232 /* If it's a relative pathname use get_initial_directory for starters. */
233 else if (abslen == 0) 233 else if (abslen == 0)
234 { 234 {
235 get_initial_directory (new_path, PATH_MAX - 1); 235 get_initial_directory (new_path, PATH_MAX_INTERNAL - 1);
236 new_path += qxestrlen (new_path); 236 new_path += qxestrlen (new_path);
237 if (!IS_DIRECTORY_SEP (new_path[-1])) 237 if (!IS_DIRECTORY_SEP (new_path[-1]))
238 *new_path++ = DIRECTORY_SEP; 238 *new_path++ = DIRECTORY_SEP;
239 } 239 }
240 else 240 else
295 295
296 #if defined (HAVE_READLINK) || defined (WIN32_ANY) 296 #if defined (HAVE_READLINK) || defined (WIN32_ANY)
297 /* See if latest pathname component is a symlink or needs case 297 /* See if latest pathname component is a symlink or needs case
298 correction. */ 298 correction. */
299 *new_path = '\0'; 299 *new_path = '\0';
300 n = readlink_and_correct_case (resolved_path, link_path, PATH_MAX - 1); 300 n = readlink_and_correct_case (resolved_path, link_path, PATH_MAX_INTERNAL - 1);
301 301
302 if (n < 0) 302 if (n < 0)
303 { 303 {
304 /* EINVAL means the file exists but isn't a symlink or doesn't 304 /* EINVAL means the file exists but isn't a symlink or doesn't
305 need case correction. */ 305 need case correction. */
335 /* Otherwise back up over this component. */ 335 /* Otherwise back up over this component. */
336 for (--new_path; !IS_DIRECTORY_SEP (*new_path); --new_path) 336 for (--new_path; !IS_DIRECTORY_SEP (*new_path); --new_path)
337 assert (new_path > resolved_path); 337 assert (new_path > resolved_path);
338 338
339 /* Safe sex check. */ 339 /* Safe sex check. */
340 if (qxestrlen (path) + n >= PATH_MAX) 340 if (qxestrlen (path) + n >= PATH_MAX_INTERNAL)
341 { 341 {
342 errno = ENAMETOOLONG; 342 errno = ENAMETOOLONG;
343 return NULL; 343 return NULL;
344 } 344 }
345 345