     chp++;
   } while(    //Serial.available()
            buf[chp-1] != '\n'
+           && buf[chp-1] != '\r'
            && chp < maxbuf );
 
   // terminate the buffer
   buf[chp] = '\0';
 
   // strip newline
-  if( chp > 0 && buf[ chp-1 ] == '\n' ) buf[chp-1] = '\0';
+  if( chp > 0 && ( buf[ chp-1 ] == '\n' || buf[ chp-1 ] == '\r') ) { buf[chp-1] = '\0'; chp--; }
+  if( chp > 0 && ( buf[ chp-1 ] == '\n' || buf[ chp-1 ] == '\r') ) buf[chp-1] = '\0';
 
   if( echoback ) Serialprint( "\n" );
 }

char * gosubStack[ kNGosubs ];

// Return values for the opcode handlers
#define kJRGosubStack	(-6)	/* Stack error for CAll */
#define kJRDBZError	(-5)	/* Divide by Zero error */
#define kJRSyntaxError	(-4)	/* general syntax erorr */

	Serial.print( ":) " );
	
	// get a line of input
#ifdef kLocalEcho
	getSerialLine( linebuf, kLineLen, true );
#else
	getSerialLine( linebuf, kLineLen, false );
#endif

	bptr = linebuf;
