(FILECREATED "10-Jun-87 17:40:13" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH047.;1 4912   

      changes to:  (VARS RGPATCH047COMS)
		   (FNS NC.RobustReadItemIdentifier))


(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT RGPATCH047COMS)

(RPAQQ RGPATCH047COMS ((* * rg 6/10/87 these fns are referenced from NC.ExpandIndexInPlace)
			 (* * the following FNS must be MOVED from NCREPAIR to NCDATABASE near 
			    NC.FindNextCardPart)
			 (FNS NC.SearchFor### NC.RobustReadItemIdentifier NC.RobustReadDate 
			      NC.RobustReadUID NC.RobustReadChar NC.RobustReadByte NC.RobustRead)))
(* * rg 6/10/87 these fns are referenced from NC.ExpandIndexInPlace)

(* * the following FNS must be MOVED from NCREPAIR to NCDATABASE near NC.FindNextCardPart)

(DEFINEQ

(NC.SearchFor###
  [LAMBDA (Stream Ptr)                                       (* rht: " 2-Dec-85 16:28")

          (* * Move the file ptr to next occurrence of either %# or NOBIND. The latter is for the stupid case of NOBIND 
	  instead of titles identifier. The choice of FFILEPOS rather than FILEPOS for the NOBIND search is based on 
	  empirical evidence from TIMEALL.)



          (* * rht 12/1/85: Now positions file 3 bytes in front of %###, to account for new length bytes.
	  Now doesn't fool with NOBIND litatoms.)


    (LET ((NewPtr (FILEPOS (QUOTE %###)
			     Stream Ptr)))
         (AND NewPtr (SETFILEPTR Stream (DIFFERENCE NewPtr 3])

(NC.RobustReadItemIdentifier
  [LAMBDA (Stream)                                           (* rht: " 1-Dec-85 22:24")

          (* * Look for an item identifier at the current position in Stream. If successful, return the part/item type.)



          (* * rht 12/1/85: Ripped out kludgy NOBIND litatom test.)


    (LET ((OldPtr (GETFILEPTR Stream))
	  Atom VersionNumber)
         (SETQ Atom (CAR (NC.RobustRead Stream)))
         (if [AND (FMEMB Atom NC.IdentifierAtoms)
		      (NC.RobustReadChar Stream)
		      (NUMBERP (SETQ VersionNumber (CAR (NC.RobustReadByte Stream]
	     then (CONS Atom VersionNumber)
	   else (SETFILEPTR Stream OldPtr)
		  NIL])

(NC.RobustReadDate
  [LAMBDA (Stream)                                           (* rht: " 1-Dec-85 22:32")

          (* * Try to read a date string or the litatom NIL. Return a list containing the date or NIL indicating failure.)



          (* * rht 12/1/85: Now skips past CR if successful.)


    (LET ((OldPtr (GETFILEPTR Stream))
	  Val)
         (if (OR [NULL (SETQ Val (CAR (NC.RobustRead Stream]
		     (AND (STRINGP Val)
			    (EQ (NCHARS Val)
				  NC.DateStringLength)))
	     then                                          (* Skip CR.)
		    (NC.RobustReadChar Stream)
		    (LIST Val)
	   else (SETFILEPTR Stream OldPtr)
		  NIL])

(NC.RobustReadUID
  [LAMBDA (Stream)                                           (* rht: " 1-Dec-85 23:03")

          (* * Try to read a Notecards ID from Stream. Return NIL if it's not a valid ID.)



          (* * rht 12/1/85: Updated to handle new card format.)


    (LET [(OldPtr (GETFILEPTR Stream))
	  (Val (CAR (RESETVAR HELPFLAG NIL (NLSETQ (NC.ReadUID Stream]
         (if (type? UID Val)
	     then Val
	   else (SETFILEPTR Stream OldPtr)
		  NIL])

(NC.RobustReadChar
  [LAMBDA (Stream)                                           (* rht: "22-Mar-86 16:01")

          (* * Try to read a character, In an NLSETQ so we won't see error messages. The RESETVAR is so that no breaks will 
	  occur. This returns list of the one element read or NIL if unsuccessful read.)


    (RESETVAR HELPFLAG NIL (NLSETQ (CHARACTER (BIN Stream])

(NC.RobustReadByte
  [LAMBDA (Stream)                                           (* rht: "10-Jul-85 23:07")

          (* * Try to read a byte, In an NLSETQ so we won't see error messages. The RESETVAR is so that no breaks will occur.
	  This returns list of the one element read or NIL if unsuccessful read.)


    (RESETVAR HELPFLAG NIL (NLSETQ (NC.GetPtr Stream 1])

(NC.RobustRead
  [LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:21")

          (* * Try to read an object, In an NLSETQ so we won't see error messages. The RESETVAR is so that no breaks will 
	  occur. This returns list of the one element read or NIL if unsuccessful read.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (RESETVAR HELPFLAG NIL (NLSETQ (READ Stream NC.OrigReadTable])
)
(PUTPROPS RGPATCH047 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (793 4831 (NC.SearchFor### 803 . 1504) (NC.RobustReadItemIdentifier 1506 . 2246) (
NC.RobustReadDate 2248 . 2977) (NC.RobustReadUID 2979 . 3494) (NC.RobustReadChar 3496 . 3904) (
NC.RobustReadByte 3906 . 4297) (NC.RobustRead 4299 . 4829)))))
STOP