*input_buffer == LF)
*input_buffer == nsCRT::LF)
mime_decode_uue_buffer (MimeDecoderData *data,						const char *input_buffer, PRInt32 input_length){  /* First, copy input_buffer into state->uue_line_buffer until we have	 a complete line.	 Then decode that line in place (in the uue_line_buffer) and write	 it out.	 Then pull the next line into uue_line_buffer and continue.   */  int status = 0;  char *line = data->uue_line_buffer;  char *line_end = data->uue_line_buffer + sizeof (data->uue_line_buffer) - 1;  PR_ASSERT(data->encoding == mime_uuencode);  if (data->encoding != mime_uuencode) return -1;  if (data->uue_state == UUE_END)	{	  status = 0;	  goto DONE;	}  while (input_length > 0)	{	  /* Copy data from input_buffer to `line' until we have a complete line,		 or until we've run out of input.		 (line may have data in it already if the last time we were called,		 we weren't called with a buffer that ended on a line boundary.)	   */	  {		char *out = line + nsCRT::strlen(line);		while (input_length > 0 &&			   out < line_end)		  {			*out++ = *input_buffer++;			input_length--;			if (out[-1] == CR || out[-1] == LF)			  {				/* If we just copied a CR, and an LF is waiting, grab it too.				 */				if (out[-1] == CR &&					input_length > 0 &&					*input_buffer == LF)				  input_buffer++, input_length--;				/* We have a line. */				break;			  }		  }		*out = 0;		/* Ignore blank lines.		 */		if (*line == CR || *line == LF)		  {			*line = 0;			continue;		  }		/* If this line was bigger than our buffer, truncate it.		   (This means the data was way corrupted, and there's basically		   no chance of decoding it properly, but give it a shot anyway.)		 */		if (out == line_end)		  {			out--;			out[-1] = CR;			out[0] = 0;		  }		/* If we didn't get a complete line, simply return; we'll be called		   with the rest of this line next time.		 */		if (out[-1] != CR && out[-1] != LF)		  {			PR_ASSERT (input_length == 0);			break;		  }	  }	  /* Now we have a complete line.  Deal with it.	   */	  if (data->uue_state == UUE_BODY &&		  line[0] == 'e' &&		  line[1] == 'n' &&		  line[2] == 'd' &&		  (line[3] == CR ||		   line[3] == LF))		{		  /* done! */		  data->uue_state = UUE_END;		  *line = 0;		  break;		}	  else if (data->uue_state == UUE_BEGIN)		{		  if (!nsCRT::strncmp (line, "begin ", 6))			data->uue_state = UUE_BODY;		  *line = 0;		  continue;		}	  else		{		  /* We're in UUE_BODY.  Decode the line. */		  char *in, *out;		  PRInt32 i;		  long lost;		  PR_ASSERT (data->uue_state == UUE_BODY);		  /* We map down `line', reading four bytes and writing three.			 That means that `out' always stays safely behind `in'.		   */		  in = line;		  out = line;# undef DEC# define DEC(c) (((c) - ' ') & 077)		  i = DEC (*in); /* get length */		  /* all the parens and casts are because gcc was doing something evil.		   */		  lost = ((long) i) - (((((long) nsCRT::strlen (in)) - 2L) * 3L) / 4L);		  if (lost > 0) /* Short line!! */			{			  /* If we get here, then the line is shorter than the length byte				 at the beginning says it should be.  However, the case where				 the line is short because it was at the end of the buffer and				 we didn't get the whole line was handled earlier (up by the				 "didn't get a complete line" comment.)  So if we've gotten				 here, then this is a complete line which is internally				 inconsistent.  We will parse from it what we can...				 This probably happened because some gateway stripped trailing				 whitespace from the end of the line -- so pretend the line				 was padded with spaces (which map to \000.)			   */			  i -= lost;			}		  for (++in; i > 0; in += 4, i -= 3)			{			  char ch;			  PR_ASSERT(out <= in);			  if (i >= 3)				{				  /* We read four; write three. */				  ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4;				  *out++ = ch;				  PR_ASSERT(out <= in+1);				  ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2;				  *out++ = ch;				  PR_ASSERT(out <= in+2);				  ch = DEC (in[2]) << 6 | DEC (in[3]);				  *out++ = ch;				  PR_ASSERT(out <= in+3);				}			  else				{				  /* Handle a line that isn't a multiple of 4 long.					 (We read 1, 2, or 3, and will write 1 or 2.)				   */				  PR_ASSERT (i > 0 && i < 3);				  ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4;				  *out++ = ch;				  PR_ASSERT(out <= in+1);				  if (i == 2)					{					  ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2;					  *out++ = ch;					  PR_ASSERT(out <= in+2);					}				}			}		  /* If the line was truncated, pad the missing bytes with 0 (SPC). */		  while (lost > 0)			{			  *out++ = 0;			  lost--;			  in = out+1; /* just to prevent the assert, below. */			}# undef DEC		  /* Now write out what we decoded for this line.		   */		  PR_ASSERT(out >= line && out < in);		  if (out > line)			status = data->write_buffer (line, (out - line), data->closure);		  /* Reset the line so that we don't think it's partial next time. */		  *line = 0;		  if (status < 0) /* abort */			goto DONE;		}	}  status = 1; DONE:  return status;}