To curse or not to curse

brian at bradley.UUCP brian at bradley.UUCP
Tue Jun 13 03:43:00 AEST 1989


> /* Written  8:56 am  Jun  9, 1989 by mhoffman at infocenter.UUCP */
> This works OK on every system I've worked on, but I understand that
> some unfortunate souls must work without the benefits of structure
> assignment. To make the code more portable for those systems
> without, a #define statement could indicate this capability:
> 
>           . . . 
> 
> #ifdef STRUCTURE_ASST
>         t = o;                   /* copy structure in one swell foop */
> #else
>         t.c_iflag  = o.c_iflag;  /* copy element by element. . . */
>         t.c_oflag  = o.c_oflag;
>         t.c_cflag  = o.c_cflag;
>         t.c_lflag  = 0;          /* inserting the desired changes */
>         t.c_line   = o.c_line;
>         *t.cc      = *o.cc;
>         t.cc[VEOF] = 1;
> #endif
>           . . . [rest of code]

  Wouldn't this work just as well:

#ifdef STRUCTURE_ASST
	t = o;
#else
	(void) memcpy((char *) &t, (char *) &o, sizeof(t));
#endif


  Brian Michael Wendt       UUCP: {cepu,uiucdcs,noao}!bradley!brian
  Bradley University        ARPA: cepu!bradley!brian at seas.ucla.edu
  (309) 677-2335            ICBM: 40 40' N  89 34' W
  "Down, down in the basement, we hear the sound of machines..."



More information about the Comp.unix.questions mailing list