[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Three small MiNT-diffs (relative to 1.14.7)



Hi there!

I've included three small diffs for MiNT 1.14.7 in this mail:

1. Fix a problem in MiNT's Cconrs() which currently "swallows"
   characters, i.e. if you do Ccrons() with a buffer of 80 bytes, but
   the line actually only has 20 characters, the next Cconrs() won't
   ever see the remaining 60 characters.

   This patch is rather old ond was already posted here, but nobody
   seems to have noticed it.

2. A temporary workaround for those 'Ax' files you get when using VFAT
   disks with MiNT on top of certain TOS versions. That means, some
   versions of GEMDOS ignore files with attribute 0xf (this is OK), some
   don't, e.g. the Falcon's GEMDOS. Thus, the patch simply filters all
   files with this attribute.

3. A fix for a typo in the makefile, at least it seems like one to me.


Ciao

Thomas


-- 
Thomas Binder (Gryf @ IRCNet)  gryf@hrzpub.tu-darmstadt.de
PGP-key available on request!  binder@rbg.informatik.tu-darmstadt.de
--- console.c.orig	Thu Nov  2 22:39:00 1995
+++ console.c	Thu Jan 18 23:06:52 1996
@@ -171,29 +171,73 @@
 
 long ARGS_ON_STACK
 c_conrs(buf)
 	char *buf;
 {
-	long size, r;
-	char *s;
+	long size, count, r;
+	char dummy;
 
 	size = ((long)*buf) & 0xff;
-	r = f_read(0, size, buf+2);
-	if (r < 0) {
-		buf[1] = 0;
-		return r;
+	if (is_terminal(curproc->handle[0]))
+	{
+/*
+ * TB: When reading from a terminal, f_read is used which automatically
+ * breaks at the first newline
+ */
+		r = f_read(0, size, buf + 2);
+		if (r < 0)
+			buf[1] = 0;
+		else
+			buf[1] = (char)r;
+		return (r < 0) ? r : 0;
 	}
-/* if reading from a file, stop at first CR or LF encountered */
-	s = buf+2;
-	size = 0;
-	while(r-- > 0) {
-		if (*s == '\r' || *s == '\n')
-			break;
-		s++; size++;
+/*
+ * TB: In all other cases, we must read character by character, breaking
+ * at a newline or carriage return, or when the maximum number of
+ * characters has been read
+ */
+	for (count = 0L;; count++)
+	{
+		if (count == size)
+		{
+			buf[1] = (char)count;
+		  	buf[count + 2] = 0;
+			return 0;
+		}
+		r = c_conin();
+/* Also break on error... */
+		if (r < 0)
+		{
+			buf[count + 2] = 0;
+			buf[1] = (char)count;
+			return r;
+		}
+		dummy = (char)r;
+/* ... or at EOF */
+		if (dummy == MiNTEOF)
+		{
+			buf[count + 2] = 0;
+			buf[1] = (char)count;
+			return 0;
+		}
+		if ((dummy == '\r') || (dummy == '\n'))
+		{
+			buf[count + 2] = 0;
+			buf[1] = (char)count;
+/*
+ * When we've read a carriage return, the next char has to be skipped,
+ * because it usually is a linefeed (GEMDOS-style lines end with CR/LF).
+ * Problems may occur with files that have lines ending with CR only, but
+ * I have not seen many yet.
+ */
+			if (dummy == '\r')
+				return f_read(0, 1L, &dummy);
+			else
+				return 0;
+		}
+		buf[count + 2] = dummy;
 	}
-	buf[1] = (char)size;
-	return 0;
 }
 
 long ARGS_ON_STACK
 c_conis()
 {
--- tosfs.c.orig	Sun Jun 11 15:40:02 1995
+++ tosfs.c	Thu May 21 01:17:10 1998
@@ -942,6 +942,9 @@
 	do_setdta(DIR_DTA(dirh));
 
 	r = Fsfirst(tmpbuf, FILEORDIR);
+/* TB: Filter VFAT-Entries */
+	while ((r == 0) && (DIR_DTA(dirh)->dta_attrib == (char)0xf))
+		r = Fsnext();
 
 	if (r == 0) {
 		t->open++;
@@ -978,6 +981,9 @@
 		assert(DIR_FLAG(dirh) == INSEARCH);
 		do_setdta(dta);
 		ret = Fsnext();
+/* TB: Filter VFAT-entries */
+		while ((ret == 0) && (dta->dta_attrib == (char)0xf))
+			ret = Fsnext();
 		if (ret) {
 			DIR_FLAG(dirh) = NMFILE;
 			return ret;
@@ -1042,6 +1048,9 @@
 	(void)tfullpath(tmpbuf, ti, "*.*");
 	do_setdta(DIR_DTA(dirh));
 	r = Fsfirst(tmpbuf, FILEORDIR);
+/* TB: Filter VFAT entries */
+	while ((r == 0) && (DIR_DTA(dirh)->dta_attrib == (char)0xf))
+		r = Fsnext();
 	if (r == 0) {
 		DIR_FLAG(dirh) = STARTSEARCH;
 	} else {
--- makefile.orig	Wed May 20 23:24:44 1998
+++ makefile	Thu May 21 01:24:20 1998
@@ -85,7 +85,7 @@
 	filesys.o1 main.o1 mem.o1 proc.o1 signal.o1 timeout.o1 tty.o1 util.o1 \
 	biosfs.o1 pipefs2.o1 procfs.o1 tosfs.o1 debug.o1 rendez.o1 \
 	unifs.o1 shmfs.o1 fasttext.o1 welcome.o1 nalloc2.o1 memprot.o realloc.o1 \
-	update.o1 ssystem2.o0
+	update.o1 ssystem2.o1
 
 CFILES = bios.c xbios.c console.c dos.c dosdir.c dosfile.c dosmem.c dossig.c \
 	filesys.c main.c mem.c proc.c signal.c timeout.c tty.c util.c \

Attachment: pgpRyQtKYAww5.pgp
Description: PGP signature