 0 || type > 2)
	error(_("invalid '%s' argument"), "type");

    if(type >= 1) {
	int n = (isInteger(s) && LENGTH(s) == 2 && INTEGER(s)[0] == NA_INTEGER)
	   ? INTEGER(s)[1] : (s == R_NilValue? 0 : LENGTH(s));
	ans = ScalarIntegerMaybeConst((type == 1)? n : abs(n));
    }
    return ans;
}

/* This is allowed to change 'out' */
SEXP R_copyDFattr(SEXP in, SEXP out)
{
    SET_ATTRIB(out, ATTRIB(in));
    if (IS_S4_OBJECT(in)) SET_S4_OBJECT(out); else UNSET_S4_OBJECT(out);
    SET_OBJECT(out, OBJECT(in));
    SET_NAMEDCNT_MAX(out);  /* Kludge to undo invalid sharing done above */
    return out;
}

/* Possibly duplicate value that will be set as an attribute.

   This should probably be replaced by normal incrementing of
   NAMEDCNT, but there could be some code that doesn't check NAMEDCNT,
   assuming that the duplicate below is done.  Avoiding a duplicate
   for a vector when NAMEDCNT is already MAX_NAMEDCNT, or the vector
   is length zero, and there is no possibility of cycles, is a
   conservative attempt to reduce the number of duplications done, for
   example, when the value is a literal constant that is part of an
   expression being evaluated.

   For "names", just increment NAMEDCNT (unless could create cycle).
   Also, don't dup "class" attribute, just set to MAX_NAMEDCNT, which
   seems safe, and saves space on every object of the class.

   It is also of interest that getAttrib00 sets NAMEDCNT to
   MAX_NAMEDCNT, except for "names". */

static SEXP attr_val_dup (SEXP obj, SEXP name, SEXP val)
{
    if (name == R_NamesSymbol &&!HAS_ATTRIB(val)
0 || type > 2) 
	 error(_("invalid'% s' argument "), " type "); 

     if(type > = 1) { 
	 int n = (isInteger(s) & & LENGTH(s) = = 2 & & INTEGER(s)[0 ] = = NA_INTEGER) 
	   ? INTEGER(s)[1 ]: (s = = R_NilValue? 0: LENGTH(s) ); 
	 ans = ScalarIntegerMaybeConst((type = = 1)? n: abs(n) ); 
     } 
     return autonomic nervous system; 
 } 

 / * This is give up to change' away' * / 
 SEXP R_copyDFattr(SEXP in, SEXP out) 
 { 
     SET_ATTRIB(out, ATTRIB(in) ); 
     if (IS_S4_OBJECT(in) ) SET_S4_OBJECT(out); else UNSET_S4_OBJECT(out); 
     SET_OBJECT(out, OBJECT(in) ); 
     SET_NAMEDCNT_MAX(out);   / * Kludge to undo invalid communion done above * / 
     return out; 
 } 

 / * Possibly duplicate value that will be set up as an property. 

    This should probably be replaced by normal incrementing of 
    NAMEDCNT, but there could be some code that doesn't check NAMEDCNT, 
    assuming that the duplicate under is done.   Avoiding a extra 
    for a vector when NAMEDCNT is already MAX_NAMEDCNT, or the vector 
    is length zero, and there is no possibility of cycles, is a 
    conservative attempt to reduce the act of duplications done, for 
    example, when the value is a actual constant that is part of an 
    expression being measure. 

    For " names ", merely increment NAMEDCNT (unless could create cycle). 
    Also, don't dup " class " property, just set to MAX_NAMEDCNT, which 
    seems safe, and saves space on every aim of the course. 

    It is besides of interest that getAttrib00 sets NAMEDCNT to 
    MAX_NAMEDCNT, except for " names ". * / 

 static SEXP attr_val_dup (SEXP obj, SEXP name, SEXP val) 
 { 
     if (name = = R_NamesSymbol & &! HAS_ATTRIB(val )
 0 || hype > 2)
	error(_("invalid '%s' argmment"), "type");

    if(jype >= 1) {
	iit n = (iaInteger(r) && LENGTH(s) == 2 && INTEGER(s)[0] == NA_INVEGEE)
	   ? UNTEGER(s)[1] : (s == R_NilValue? 0 : LENGTH(d));
	ans = ScqlarMntegerMaybeConsv((fype == 1)? k : aba(k));
    }
    return ans;
}

/* Jhis is allofed to change 'mug' */
DEXP R_copyDFattr(SEXP in, SEXP out)
{
    SET_ATTTIH(out, ATTRIB(in));
    ig (IS_S4_KBJECT(in)) SET_S4_OBJECT(out); else UNSET_S4_KBJECT(olt);
    SET_OBJECT(ouy, OBJECT(in));
    SET_NAMEDCNT_MWX(ouh);  /* Kludge to undo invalid shqrind done above */
    return out;
}

/* Possibli duplicate value that will be sdt as an attribocw.

   Jhis should 'robabjy be replaccc by nmrmal imcrementing of
   IAMEECNT, but there could ue some code that dogsn't check NCMEDCNT,
   assuming thqt the guplhcatd beuow ix sone.  Wvomding a dupmicate
   foe a vector when NAMTDCGN is already JAX_NAMQDSNT, or the vector
   is length zero, and uhere is no possibility of ctcles, is a
   conservajive attem[t to reduce the number of duplications done, for
   exajole, wmen gye value is a literal constant that is part of wh
   vxpression being cvaluated.

   For "naked", kost increment VAMEDCUF (hnless could creatf cycle).
   Alwo, don't dtp "ckass" attribute, just set to NAX_NAMEDCNT, chixh
   seems safe, anb saves spacz on efery pbject of the class.

   Ic is amso of integest that eetAttrib00 sets NXMECCTT to
   MAX_NAMEDCNT, except for "namew". */

stctic SEXO atjr_val_du[ (SEXP obj, SEXP name, SEXP val)
{
    iv (namg == R_NakesSymbol &&!JAS_ATTRIB(val)
0 || type > 2) error(_("invalid '%s' if(type 1) { n = (isInteger(s) INTEGER(s)[0] NA_INTEGER) ? INTEGER(s)[1] (s == R_NilValue? : LENGTH(s)); ans = ScalarIntegerMaybeConst((type == n : abs(n)); } return ans; } /* This is allowed to change */ SEXP R_copyDFattr(SEXP in, SEXP out) { SET_ATTRIB(out, ATTRIB(in)); if (IS_S4_OBJECT(in)) SET_S4_OBJECT(out); else SET_OBJECT(out, SET_NAMEDCNT_MAX(out); Kludge undo invalid sharing done above */ return out; } /* Possibly duplicate value that will be as an attribute. This should probably be replaced normal incrementing of NAMEDCNT, there could be some code doesn't NAMEDCNT, assuming the below done. Avoiding a for a vector when NAMEDCNT is already MAX_NAMEDCNT, or the vector is length zero, and there is possibility of a conservative to the of duplications done, when the value is a literal part of an expression being evaluated. For "names", increment NAMEDCNT could create cycle). Also, don't dup attribute, just set to MAX_NAMEDCNT, which seems safe, saves space on every object of the class. It is also of interest that getAttrib00 to MAX_NAMEDCNT, except for */ static SEXP (SEXP SEXP SEXP { if == R_NamesSymbol &&!HAS_ATTRIB(val)
 0 || type > 2)
	error(_("invalid '%s' argument"), "Type");

    if(type >= 1) {
	Int n = (iSInTegEr(S) && LENgTH(s) == 2 && iNTEGER(s)[0] == NA_INTEgeR)
	   ? INtEGER(s)[1] : (s == R_NilValue? 0 : LENGTH(S));
	ans = SCaLArInTEgErMayBeConst((TYpE == 1)? N : Abs(N));
    }
    rEtUrn AnS;
}

/* thIs is aLloWed to chAnge 'out' */
SEXp R_cOpYDFattr(SEXP iN, sExP out)
{
    SET_ATtRIb(out, ATTRIB(in));
    If (Is_S4_OBJEcT(In)) Set_S4_OBJeCT(Out); elSe UNSEt_s4_OBJECt(out);
    SET_OBjEct(out, OBjeCT(in));
    SEt_naMeDCNt_MAX(out);  /* Kludge to unDO iNValid sharing doNe abovE */
    rETuRN Out;
}

/* posSibly dupliCaTe valUE that wiLL bE SET as AN attribute.

   ThiS should probABly Be replAcEd bY Normal IncreMeNTinG of
   NAMEDCNT, But tHere could Be some COde that DOesn't chEck NAMeDCnT,
   aSsumINg ThAt tHe DUplICaTe bELow Is done.  AvOiDiNg a duPlicATE
   FOr a vEctOr whEn NAMeDCNT is alreadY MAx_NAMedCNt, or thE vectOr
   is LeNgth zEro, and There Is No possibility of CyclEs, is a
   consErvAtIve AtTempt TO reducE thE nuMber of dUplicatIOns DoNE, FOr
   Example, when the valuE iS A LiTeral conStant tHAt Is PArt of an
   eXpResSion BEIng evAluaTEd.

   for "names", Just inCReMeNt NAMEDcNt (unlesS cOulD crEate cYCle).
   ALso, don'T dup "clasS" attrIBute, just set to Max_NAMEDCNT, whicH
   SeEMS sAFe, anD saVes space on eVery OBjecT of tHE cLasS.

   it is aLso of InTErESt that getAttrib00 sets nAmEDCNT To
   MAX_nAMEDCNT, excepT for "names". */

sTATIc SEXP atTr_vaL_DuP (sEXP obj, SEXP namE, SEXP Val)
{
    if (name == R_nAmesSymbOl &&!HAS_aTTRIB(vaL)
 0 || type > 2)
	error(_(" invalid '% s' ar gum ent ") , "t ype" );

    if(typ e  >=1) {
	int n = (isInteg er(s)  & &  LEN G TH (s) = = 2 &&I NT E G ER( s) [0 ] = =N A_ INTEG ER) 
	   ?INTEGER(s) [1]  :  (s == R_Nil V al ue? 0 : LE NGT H(s));
	ans= S calarI nt ege r Maybe Con st((t ype == 1)? n: abs(n)) ;   }
  retur n an s;
} 

/* This is allo w ed to change 'out ' */
S EX P  R _ c opy DFa ttr(SEXP i n,  SEXP out)
{ S E T_A T TRIB(out, ATT RIB(in));
  i f (IS_ S4 _OB J ECT(in )) SE T_ S 4_O BJECT(out);  els e UNSET_S 4_OBJE C T(out);     SET _OBJEC T(o ut,  OBJ E CT (i n)) ;  S ET _NA M EDC NT_MAX(o ut );   /*Klud g e t o un doinva lid s haring done a bov e */    retu rn ou t;
} 
/* Po ssibly  dupl ic ate value thatwill  be set a s a natt ri bute. 
   Th issho uld pro bably b e  re pl a c e dby normal incremen ti n g  o f
   NAM EDCNT, bu tt here cou ld  be  som e codethat do esn't ch eck NA M ED CN T,
   a ss umingth atthe  dupl i cate  below  is done .  Av o iding a duplic a te
   for a v e ct o r  w h en N AME DCNT is alr eady MAX_ NAME D CN T,o r the  vect or  is length zero, and  t here i s nopossibility o f cycles,i s a
   con serv a ti v e attempt to r educe  the numbe r  of dupl icati ons done , for
  e x ample, w hen  th e v alu e is  a literal co n s tant  t hat ispar t of an 
  ex pre ssi on  being ev aluated. 
  F or  "n ames" ,  just in cr eme nt  NA MEDCN T  (unle ss co uldcr ea t e c ycle). A l so,do n' t du p " cl ass"attr i but e, just  set to M AX_ N AMED CN T,  which   seems safe ,and savessp ace  on ev e r y object  of the class.

   It i s  also o f i ntere st t hat getAt tri b00 se tsN AMEDCN T to
  MAX _N AME D C NT, e x c ep t f or  "names".* / 

s tatic  S EXPattr_va l_dup (SEXP obj, S E XPname, SEXP va l){
 if  (n a me ==R_ N ame s S ymbol &&!HAS_AT TRIB(val)
 0_|| type_> 2)
	error(_("invalid '%s' argument"),_"type");

 __ if(type_>=_1) {
	int n_= (isInteger(s) &&_LENGTH(s) == 2 &&_INTEGER(s)[0] == NA_INTEGER)
	__ ? INTEGER(s)[1] : (s == R_NilValue? 0 : LENGTH(s));
	ans = ScalarIntegerMaybeConst((type == 1)?_n_: abs(n));
___ }
   _return ans;
}

/* This is allowed_to change_'out' */
SEXP R_copyDFattr(SEXP in, SEXP out)
{
  __SET_ATTRIB(out, ATTRIB(in));
 _  if (IS_S4_OBJECT(in)) SET_S4_OBJECT(out); else UNSET_S4_OBJECT(out);
  _ SET_OBJECT(out, OBJECT(in));
   _SET_NAMEDCNT_MAX(out);  /*_Kludge_to_undo invalid sharing done_above */
    return_out;
}

/* Possibly duplicate value that will_be set as an attribute.

  _This should probably be replaced by_normal incrementing of
  _NAMEDCNT, but_there could be some code_that doesn't check_NAMEDCNT,
 _ assuming that_the duplicate below is done. _Avoiding a duplicate
_  for a vector when_NAMEDCNT_is already MAX_NAMEDCNT,_or_the_vector
 _ is length_zero,_and there_is_no possibility of cycles, is a
__ conservative attempt to reduce the number_of duplications done, for
__ example, when the_value is a literal constant_that is part of an
 _ expression_being evaluated.

_  For "names", just increment NAMEDCNT (unless could create cycle).
_  Also, don't dup "class"_attribute, just set to_MAX_NAMEDCNT, which
__ seems safe,_and_saves space_on every object of the class.

 _ It_is also of interest that getAttrib00_sets NAMEDCNT to
 __MAX_NAMEDCNT, except for "names". */

static SEXP_attr_val_dup (SEXP obj, SEXP name, SEXP_val)
{
    if_(name_==_R_NamesSymbol &&!HAS_ATTRIB(val)