Changeset 10601


Ignore:
Timestamp:
Sep 2, 2008, 11:58:11 AM (11 years ago)
Author:
gb
Message:

Fix a few problems with %OS-GETCWD and CURRENT-DIRECTORY-NAME, mostly
related to the interpretation of "bufsize".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/level-1/linux-files.lisp

    r10033 r10601  
    194194  (%signal-semaphore-ptr (semaphore-value s)))
    195195
    196 (defun %os-getcwd (buf bufsize)
     196(defun %os-getcwd (buf noctets)
    197197  ;; Return N < 0, if error
    198   ;;        N < bufsize: success, string is of length n
    199   ;;        N > bufsize: buffer needs to be larger.
    200   (let* ((p (#+windows-target #__wgetcwd #-windows-target #_getcwd buf bufsize)))
     198  ;;        N < noctets: success, string is of length N (octets).
     199  ;;        N >= noctets: buffer needs to be larger.
     200  (let* ((p #+windows-target
     201           (#__wgetcwd buf (ash noctets -1))
     202           #-windows-target
     203           (#_getcwd buf noctets)))
    201204    (declare (dynamic-extent p))
    202205    (if (%null-ptr-p p)
    203206      (let* ((err (%get-errno)))
    204207        (if (eql err (- #$ERANGE))
    205           (+ bufsize bufsize)
     208          (+ noctets noctets)
    206209          err))
    207210      #+windows-target
    208211      (do* ((i 0 (+ i 2)))
    209            ((= i bufsize) (+ bufsize))
     212           ((= i noctets) (+ noctets noctets))
    210213        (when (eql (%get-unsigned-word buf i) 0)
    211           (return (ash i -1))))
     214          (return i)))
    212215      #-windows-target
    213       (dotimes (i bufsize (+ bufsize bufsize))
     216      (dotimes (i noctets (+ noctets noctets))
    214217        (when (eql 0 (%get-byte buf i))
    215218          (return i))))))
     
    222225           (%stack-block ((buf bufsize))
    223226             (let* ((len (%os-getcwd buf bufsize)))
    224                (cond ((< len 0) (%errno-disp len bufsize))
     227               (cond ((< len 0) (%errno-disp len))
    225228                     ((< len bufsize)
    226                       #+windows-target
    227                       (setf (%get-unsigned-word buf (+ len len)) 0)
    228                       #-windows-target
    229                       (setf (%get-unsigned-byte buf len) 0)
    230229                      (values (get-foreign-namestring buf) len))
    231230                     (t (values nil len)))))))
    232231    (do* ((string nil)
    233           (len 64)
     232          (len #+windows-target 128 #-windows-target 64)
    234233          (bufsize len len))
    235234         ((multiple-value-setq (string len) (try-getting-dirname bufsize))
     
    646645      (+ date unix-to-universal-time))))
    647646
    648 #-windows-target
    649647(defun %file-author (namestring)
     648  #+windows-target (declare (ignore namestring))
     649  #-windows-target
    650650  (let* ((uid (nth-value 5 (%stat namestring))))
    651651    (if uid
Note: See TracChangeset for help on using the changeset viewer.