Raymond Toy pushed to branch issue-266-b-tilde-pathname-support at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/code/exports.lisp
    ... ... @@ -2074,7 +2074,7 @@
    2074 2074
     	   "FD-STREAM-P" "FIND-IF-IN-CLOSURE" "FOREIGN-SYMBOL-ADDRESS"
    
    2075 2075
     	   "FOREIGN-SYMBOL-CODE-ADDRESS" "FOREIGN-SYMBOL-DATA-ADDRESS"
    
    2076 2076
     	   "GET-PAGE-SIZE" "GET-SYSTEM-INFO"
    
    2077
    -           "GET-USER-HOMEDIR-PATHNAME"
    
    2077
    +           "GET-USER-HOMEDIR-NAMESTRING"
    
    2078 2078
     	   "IGNORE-INTERRUPT"
    
    2079 2079
     	   "INT-SAP" "INVALIDATE-DESCRIPTOR" "IO-TIMEOUT"
    
    2080 2080
     	   "LISP-STREAM" "LONG-FLOAT-RADIX" "LONG-WORDS"
    

  • src/code/filesys.lisp
    ... ... @@ -305,10 +305,9 @@
    305 305
       (cond ((zerop (length name))
    
    306 306
              (let ((user (unix:unix-getpwuid (unix:unix-getuid))))
    
    307 307
                (concatenate 'simple-base-string
    
    308
    -                        (unix:user-info-dir user)
    
    309
    -                        "/")))
    
    308
    +                        (unix:user-info-dir user))))
    
    310 309
             (t
    
    311
    -         (let ((path (system:get-user-homedir-pathname name)))
    
    310
    +         (let ((path (system:get-user-homedir-namestring name)))
    
    312 311
                (unless path
    
    313 312
                  (error "Unknown user: ~S" name))
    
    314 313
                path))))
    
    ... ... @@ -326,22 +325,24 @@
    326 325
       (let ((end-user (position #\/ str :start start :end end)))
    
    327 326
         #+nil
    
    328 327
         (format t "user ~D:~D: ~A~%" (1+ start) end-user (subseq str (1+ start) end-user))
    
    329
    -    (cond (end-user
    
    330
    -           (let* ((user-name (subseq str (1+ start) end-user))
    
    331
    -                  (homedir (user-homedir-namestring user-name)))
    
    332
    -             #+nil
    
    333
    -             (format t "user-name: ~S; homedir: ~S~%"
    
    334
    -                     user-name homedir)
    
    335
    -             (values (concatenate 'simple-base-string
    
    336
    -                                  (subseq str 0 start)
    
    337
    -                                  homedir
    
    338
    -                                  (subseq str (1+ end-user)))
    
    339
    -                     start
    
    340
    -                     (+ end (- (length homedir)
    
    341
    -                               (length user-name)
    
    342
    -                               2)))))
    
    343
    -          (t
    
    344
    -           (values str start end)))))
    
    328
    +    ;; Quick exit if we can't find a "/" to terminate the user name.
    
    329
    +    (unless end-user
    
    330
    +      (return-from replace-tilde-user
    
    331
    +        (values str start end)))
    
    332
    +    (let* ((user-name (subseq str (1+ start) end-user))
    
    333
    +           (homedir (user-homedir-namestring user-name)))
    
    334
    +      #+nil
    
    335
    +      (format t "user-name: ~S; homedir: ~S~%"
    
    336
    +              user-name homedir)
    
    337
    +      ;; Replace the ~user part with the home directory, adjusting END because of the replacement.
    
    338
    +      (values (concatenate 'simple-base-string
    
    339
    +                           (subseq str 0 start)
    
    340
    +                           homedir
    
    341
    +                           (subseq str end-user))
    
    342
    +              start
    
    343
    +              (+ end (- (length homedir)
    
    344
    +                        (length user-name)
    
    345
    +                        1))))))
    
    345 346
         
    
    346 347
     (defun parse-unix-namestring (namestr start end)
    
    347 348
       (declare (type simple-base-string namestr)
    

  • src/code/os.lisp
    ... ... @@ -58,9 +58,9 @@
    58 58
     	       (unix:get-unix-error-msg utime)))
    
    59 59
           (values utime stime major-fault))))
    
    60 60
     
    
    61
    -;;; GET-USER-HOMEDIR-PATHNAME  -- Public
    
    61
    +;;; GET-USER-HOMEDIR-NAMESTRING  -- Public
    
    62 62
     ;;;
    
    63
    -(defun get-user-homedir-pathname (name)
    
    63
    +(defun get-user-homedir-namestring (name)
    
    64 64
       _N"Get the user home directory for user named NAME.  Two values are
    
    65 65
       returned: the pathname of the home directory and a status code.  If
    
    66 66
       the home directory does not exist NIL is returned.  The status is 0
    
    ... ... @@ -80,9 +80,7 @@
    80 80
                         (alien:addr status)))
    
    81 81
                  (if (and (zerop status)
    
    82 82
                           (not (alien:null-alien result)))
    
    83
    -                 (values (concatenate 'string
    
    84
    -                                       (alien:cast result c-call:c-string)
    
    85
    -                                       "/")
    
    83
    +                 (values (alien:cast result c-call:c-string)
    
    86 84
                              status)
    
    87 85
                      (values nil status)))
    
    88 86
             (alien:free-alien result)))))